/* SmartLife Lite — Safari iOS 9 friendly (no Grid, limited modern CSS) */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0f1419;
  color: #e8eef4;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  box-sizing: border-box;
  min-height: 100%;
  background: -webkit-linear-gradient(top, #1a2430 0%, #0f1419 40%);
  background: linear-gradient(to bottom, #1a2430 0%, #0f1419 40%);
}

.top {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 18px;
}

.brand {
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8fb3d1;
  font-weight: 600;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 500;
  color: #f4f7fa;
}

.hint {
  margin: 0 0 12px;
  color: #9aabbc;
  font-size: 14px;
  line-height: 1.4;
}

.edit-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: #d7e6f3;
  background: rgba(60, 90, 120, 0.35);
  border-radius: 8px;
}

.view {
  padding-top: 4px;
}

.pin-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 36px;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 18px 12px;
  margin: 0 0 16px;
  border: 1px solid #3a4d61;
  border-radius: 10px;
  background: #162029;
  color: #fff;
  -webkit-appearance: none;
  appearance: none;
}

.pin-input:focus {
  outline: none;
  border-color: #5a9fd4;
}

.primary-btn,
.secondary-btn,
.toggle-btn,
.link-btn,
.icon-btn,
.home-chip,
.sheet-item,
.edit-btn {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  border: none;
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  color: #0b1218;
  background: #6eb6e8;
  border-radius: 10px;
}

.primary-btn:active {
  background: #4f9ad0;
}

.link-btn {
  background: transparent;
  color: #8fb3d1;
  font-size: 14px;
  padding: 6px 0;
}

.toolbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 10px;
}

.home-chip {
  max-width: 70%;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 600;
  color: #e8eef4;
  background: #243442;
  border: 1px solid #3a4d61;
  border-radius: 999px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-chip-caret {
  margin-left: 6px;
  color: #8fb3d1;
  font-size: 12px;
}

.toolbar-actions {
  white-space: nowrap;
}

.icon-btn {
  display: inline-block;
  width: 40px;
  height: 40px;
  margin-left: 6px;
  padding: 0;
  font-size: 20px;
  line-height: 40px;
  color: #d5e4f0;
  background: #243442;
  border: 1px solid #3a4d61;
  border-radius: 10px;
  text-align: center;
  vertical-align: middle;
}

.icon-btn:active {
  background: #2f4254;
}

.error {
  color: #f0a0a0;
  margin-top: 14px;
  font-size: 14px;
}

.device-list {
  list-style: none;
  margin: 0 -4px;
  padding: 0;
  overflow: hidden;
}

.device-item {
  float: left;
  width: 33.333%;
  box-sizing: border-box;
  padding: 4px;
}

.device-item.is-full {
  float: none;
  width: 100%;
  clear: both;
}

.device-tile {
  position: relative;
  box-sizing: border-box;
  height: 0;
  padding-bottom: 100%;
  background: rgba(30, 42, 54, 0.92);
  border: 1px solid #2c3d4e;
  border-radius: 12px;
  overflow: hidden;
}

.device-tile.is-on {
  border-color: #3d7a58;
  background: rgba(28, 48, 40, 0.95);
}

.device-tile.is-edit {
  border-color: #5a7d9a;
}

.device-tile .device-name,
.device-tile .tile-main,
.device-tile .tile-foot {
  position: absolute;
  left: 8px;
  right: 8px;
}

.device-name {
  top: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #f2f6fa;
  max-height: 2.5em;
  overflow: hidden;
}

.device-tile.is-edit .device-name {
  right: 34px;
}

.tile-main {
  top: 42%;
  margin-top: -14px;
  text-align: center;
}

.tile-foot {
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  line-height: 1.3;
  color: #8a9bab;
}

.tile-foot.has-toggle {
  right: 58px;
}

.device-tile.is-edit .tile-foot.has-toggle {
  right: 8px;
}

.tile-status,
.tile-updated {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-updated {
  margin-top: 2px;
  color: #7f9eb8;
}

.temp-value {
  font-size: 26px;
  font-weight: 600;
  color: #9fd0f0;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.temp-value.temp-compact {
  font-size: 22px;
}

.temp-value.muted {
  color: #5c6b7a;
  font-size: 20px;
  font-weight: 500;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  background: #666;
  vertical-align: middle;
}

.dot.on {
  background: #4caf78;
}

.dot.off {
  background: #c45c5c;
}

.toggle-btn {
  min-width: 56px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  color: #fff;
  background: #3a4d61;
}

.toggle-btn.tile-toggle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  min-width: 44px;
  padding: 7px 10px;
  font-size: 12px;
}

.device-tile.is-edit .tile-toggle {
  display: none;
}

.toggle-btn.is-on {
  background: #2f8f5b;
}

.toggle-btn.is-off {
  background: #4a5560;
}

.toggle-btn:disabled {
  opacity: 0.45;
}

.toggle-btn.busy {
  opacity: 0.6;
}

.edit-controls {
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 3;
  text-align: right;
}

.edit-btn {
  display: block;
  width: 28px;
  height: 28px;
  margin-bottom: 3px;
  padding: 0;
  font-size: 14px;
  line-height: 28px;
  color: #e8eef4;
  background: rgba(20, 30, 40, 0.85);
  border: 1px solid #3a4d61;
  border-radius: 6px;
  text-align: center;
}

.edit-btn.hide-btn {
  color: #f0a0a0;
}

.edit-btn:disabled {
  opacity: 0.35;
}

.empty {
  padding: 24px 8px;
  color: #9aabbc;
  text-align: center;
}

.chart-item {
  clear: both;
}

.chart-tile {
  position: relative;
  box-sizing: border-box;
  padding: 10px 10px 8px;
  background: rgba(30, 42, 54, 0.92);
  border: 1px solid #2c3d4e;
  border-radius: 12px;
}

.chart-tile.is-edit {
  border-color: #5a7d9a;
}

.chart-head {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 6px;
  padding-right: 0;
}

.chart-tile.is-edit .chart-head {
  padding-right: 34px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: #d7e6f3;
}

.chart-meta {
  font-size: 11px;
  color: #7f9eb8;
}

.chart-periods {
  margin: 0 0 8px;
  overflow: hidden;
}

.period-btn {
  display: inline-block;
  margin: 0 6px 0 0;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #9aabbc;
  background: #243442;
  border: 1px solid #3a4d61;
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.period-btn.is-active {
  color: #0b1218;
  background: #6eb6e8;
  border-color: #6eb6e8;
}

.period-btn-relay.is-active {
  color: #0b1218;
  background: #e0a35c;
  border-color: #e0a35c;
}

.sheet-hint {
  margin: 0;
  padding: 8px 16px 4px;
  font-size: 13px;
  color: #8a9bab;
  line-height: 1.35;
}

.legend-relay {
  font-weight: 600;
}

.temp-chart {
  display: block;
  width: 100%;
  height: 160px;
  background: #121a22;
  border-radius: 8px;
}

.chart-legend {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: #9aabbc;
}

.legend-item {
  display: inline-block;
  margin: 0 10px 4px 0;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
}

.chart-empty {
  margin-top: 8px;
  font-size: 12px;
  color: #8a9bab;
  text-align: center;
}

/* Sheets / menus */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.sheet-backdrop {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #162029;
  border-radius: 16px 16px 0 0;
  border-top: 1px solid #2c3d4e;
  box-sizing: border-box;
  padding: 0 0 20px;
}

.sheet-head {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  padding: 14px 16px 8px;
  border-bottom: 1px solid #243442;
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #f2f6fa;
}

.sheet-section-title {
  padding: 14px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7f9eb8;
}

.sheet-list {
  padding: 4px 0;
}

.sheet-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  font-size: 16px;
  color: #e8eef4;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid #1f2c38;
}

.sheet-item:active {
  background: #1e2a36;
}

.sheet-item.is-active {
  color: #9fd0f0;
}

.sheet-item-value,
.check {
  float: right;
  color: #8fb3d1;
  font-size: 14px;
}

.check.is-on:after {
  content: "✓";
  color: #6eb6e8;
  font-weight: 700;
}

.sheet-item .restore-btn {
  float: right;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0b1218;
  background: #6eb6e8;
  border-radius: 8px;
  border: none;
  font-family: inherit;
}
