:root {
  --navy-950: #031d42;
  --navy-900: #05295c;
  --navy-850: #07336f;
  --navy-800: #0a3f82;
  --line: rgba(109, 174, 237, 0.42);
  --line-soft: rgba(109, 174, 237, 0.2);
  --yellow: #ffd414;
  --yellow-deep: #ffc500;
  --white: #ffffff;
  --text-soft: #b8d2f3;
  --green: #27b66a;
  --green-dark: #128a4b;
  --orange: #f47b20;
  --red: #c63838;
  --slate: #354b66;
  --panel: linear-gradient(180deg, rgba(8, 49, 103, 0.98), rgba(3, 35, 77, 0.98));
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(20, 91, 170, 0.45), transparent 40%),
    #020f24;
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 440px);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: linear-gradient(180deg, #083673 0%, #042557 62%, #031d42 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), var(--shadow);
  overflow: hidden;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: max(14px, env(safe-area-inset-top)) 24px 12px;
  background: linear-gradient(180deg, rgba(8,54,115,1) 0%, rgba(8,54,115,.95) 75%, rgba(8,54,115,0) 100%);
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 13px;
}

.status-icons { letter-spacing: 3px; font-size: 11px; }

.brand-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
}

.brand-block { text-align: center; }
.brand {
  font-weight: 1000;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -1.7px;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.brand span:last-child { color: var(--yellow); }
.screen-title { margin-top: 7px; color: var(--text-soft); font-weight: 700; }

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.04);
  font-size: 22px;
}
.icon-button.ghost { border-color: transparent; background: transparent; }

.screen-container {
  overflow-y: auto;
  padding: 8px 30px 24px;
  scroll-behavior: smooth;
}

.stack { display: grid; gap: 14px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.no-pad { padding: 0; }

.eyebrow, .section-label {
  color: #d7e7fa;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .45px;
}
.section-label { margin: 0 2px 8px; }
.section-label.inside { margin: 0 0 12px; }

.status-card { text-align: center; }
.state-word {
  font-size: 31px;
  line-height: 1;
  font-weight: 1000;
  margin: 10px 0 7px;
}
.state-open { color: #39de82; }
.state-away { color: var(--yellow); }
.state-closing { color: #ff972d; }
.state-closed { color: #ff5b5b; }
.state-opening { color: #82b8ff; }
.state-offline { color: #a4b2c4; }
.status-message { font-size: 17px; font-weight: 750; }
.muted { color: var(--text-soft); }
.center { text-align: center; }
.no-top { margin-top: 0; }

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.quick-action {
  min-height: 92px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius-md);
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 8px 18px rgba(0,0,0,.14);
}
.quick-action strong { font-size: 17px; letter-spacing: .25px; }
.quick-action small { font-size: 12px; opacity: .92; }
.quick-action.green { background: linear-gradient(145deg, #2fc777, #138a4c); }
.quick-action.yellow { background: linear-gradient(145deg, #ffe35b, #ffc70d); color: #05244f; }
.quick-action.blue { background: linear-gradient(145deg, #1e69ad, #104778); }
.quick-action.slate { background: linear-gradient(145deg, #4a6079, #2e4259); }
.quick-action.orange { background: linear-gradient(145deg, #ff9c39, #cf5b13); }

.next-event-card .event-row { display: flex; gap: 14px; align-items: center; }
.event-icon { font-size: 32px; color: white; }
.event-row strong { font-size: 15px; }
.event-row .muted { margin-top: 4px; font-size: 13px; }

.display-preview-panel { padding-bottom: 15px; }
.mini-display {
  min-height: 160px;
  border-radius: 14px;
  padding: 16px;
  display: grid;
  align-content: center;
  text-align: center;
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: inset 0 0 25px rgba(0,0,0,.2);
}
.state-open-preview { background: linear-gradient(145deg, #087548, #0ba75f); }
.state-away-preview { background: linear-gradient(145deg, #5f5111, #2b2a17); }
.state-opening-preview { background: linear-gradient(145deg, #164c83, #082e5c); }
.state-closing-preview { background: linear-gradient(145deg, #85410c, #4b2304); }
.state-closed-preview { background: linear-gradient(145deg, #9d2929, #571313); }
.state-offline-preview { background: linear-gradient(145deg, #4e5e70, #263342); }
.mini-brand { font-size: 11px; font-weight: 900; opacity: .72; }
.mini-main { font-size: 26px; font-weight: 1000; margin-top: 7px; }
.mini-sub { color: #e9f3ff; margin-top: 7px; font-size: 13px; }

.hero-time {
  text-align: center;
  color: var(--yellow);
  font-size: clamp(64px, 18vw, 88px);
  line-height: .98;
  font-weight: 900;
  letter-spacing: -4px;
  text-shadow: 0 5px 20px rgba(0,0,0,.22);
}
.hero-time.compact { font-size: 70px; }

.three-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.outline-button, .secondary-button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(8,55,116,.8), rgba(3,36,79,.8));
  font-weight: 900;
}
.outline-button.active { border-color: var(--yellow); color: var(--yellow); }

.adjust-grid { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; }
.adjust-button {
  height: 56px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  font-weight: 1000;
  font-size: 18px;
}
.adjust-button:last-child { border-right: 0; }

.reason-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.reason-card {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 10px 5px;
}
.reason-card.selected { background: var(--yellow); color: #062654; border-color: var(--yellow); }
.reason-icon { font-size: 34px; }
.reason-card strong { font-size: 14px; }
.reason-card small { color: var(--text-soft); font-weight: 800; }
.reason-card.selected small { color: rgba(6,38,84,.55); }

.field-label { font-weight: 900; font-size: 13px; margin: 0 2px -4px; }
.text-field, select.text-field {
  width: 100%;
  min-height: 62px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #031e45;
  color: white;
  padding: 0 17px;
  outline: none;
}
.text-field:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,212,20,.12); }

.toggle-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.toggle-row span { display: grid; gap: 3px; }
.toggle-row small { color: var(--text-soft); }
.toggle-row input { width: 46px; height: 24px; accent-color: var(--yellow); }

.primary-button {
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffdc2c, #ffc408);
  color: #062654;
  font-weight: 1000;
  font-size: 19px;
  letter-spacing: .4px;
  box-shadow: 0 10px 20px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.55);
}
.secondary-button { padding: 0 18px; }
.secondary-button.full { width: 100%; margin-top: 12px; }

.away-active-card { text-align: center; }
.active-reason { font-size: 22px; font-weight: 900; margin: 10px 0 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segment {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  font-size: 12px;
  font-weight: 850;
}
.segment.active { background: var(--yellow); color: #062654; border-color: var(--yellow); }

.option-list { display: grid; gap: 9px; }
.option-card {
  min-height: 66px;
  display: grid;
  grid-template-columns: 36px 1fr 26px;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel);
  padding: 10px 13px;
}
.option-card span:nth-child(2) { display: grid; gap: 4px; }
.option-card small { color: var(--text-soft); }
.option-card .check { opacity: 0; font-weight: 1000; }
.option-card.selected { background: var(--yellow); color: #062654; border-color: var(--yellow); }
.option-card.selected small { color: rgba(6,38,84,.7); }
.option-card.selected .check { opacity: 1; }
.option-icon { font-size: 24px; }

.config-grid { display: grid; gap: 12px; }
.config-grid label { display: grid; gap: 7px; font-size: 12px; font-weight: 850; color: var(--text-soft); }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line-soft); }
.tab {
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-size: 11px;
  font-weight: 900;
}
.tab.active { color: var(--yellow); border-bottom-color: var(--yellow); }

.hours-list { overflow: hidden; padding: 0; }
.hours-row {
  min-height: 55px;
  padding: 0 15px;
  display: grid;
  grid-template-columns: 1fr auto 18px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  gap: 8px;
}
.hours-row:last-child { border-bottom: 0; }
.hours-row strong, .hours-row span { font-size: 13px; }
.hours-row button { background: transparent; border: 0; color: var(--text-soft); font-size: 20px; }
.next-opening { display: grid; gap: 5px; }

.automation-list { display: grid; gap: 10px; }
.automation-rule {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.rule-time { color: var(--yellow); font-weight: 1000; }
.rule-copy { display: grid; gap: 4px; }
.rule-copy small { color: var(--text-soft); }
.rule-toggle { width: 42px; accent-color: var(--yellow); }

.special-date-card { display: grid; gap: 4px; }
.special-date-card strong { font-size: 15px; }

.state-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.state-list button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px var(--safe-bottom);
  background: rgba(2, 24, 54, .98);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}
.nav-item {
  min-height: 54px;
  border: 0;
  background: transparent;
  color: #8daed4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 850;
}
.nav-icon { font-size: 21px; line-height: 1; }
.nav-item.active { color: var(--yellow); }

.modal {
  width: min(92%, 420px);
  border: 0;
  padding: 0;
  border-radius: 20px;
  color: white;
  background: #03214b;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal::backdrop { background: rgba(0,8,20,.72); backdrop-filter: blur(4px); }
.modal-card { padding: 18px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%) translateY(15px);
  width: min(calc(100% - 40px), 390px);
  background: #fff;
  color: #062654;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(0,0,0,.32);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 700px) {
  body { padding: 22px; }
  .app-shell { min-height: calc(100dvh - 44px); border-radius: 38px; border: 8px solid #4b5664; }
}

@media (max-width: 360px) {
  .screen-container { padding-left: 18px; padding-right: 18px; }
  .app-header { padding-left: 18px; padding-right: 18px; }
  .brand { font-size: 27px; }
  .hero-time { font-size: 64px; }
}


/* Phase 3 connection and pairing */
.panel-heading-row{display:flex;align-items:center;justify-content:space-between;gap:12px}
.connection-badge{display:inline-flex;align-items:center;justify-content:center;min-width:66px;padding:6px 9px;border-radius:999px;font-size:10px;font-weight:900;letter-spacing:.08em;background:rgba(255,255,255,.08);border:1px solid var(--line)}
.connection-badge.online{color:#62df9a;border-color:rgba(98,223,154,.5);background:rgba(39,182,106,.13)}
.connection-badge.connecting,.connection-badge.waiting{color:var(--yellow)}
.connection-badge.offline{color:#ff8a8a;border-color:rgba(255,80,80,.4);background:rgba(198,56,56,.14)}
.connection-details{display:grid;gap:8px;margin:8px 0 14px}.connection-details>div{display:flex;justify-content:space-between;gap:16px;padding:10px 0;border-bottom:1px solid var(--line-soft)}.connection-details span{color:var(--text-soft);font-size:12px}.connection-details strong{font-size:12px;max-width:62%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.two-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.two-grid .secondary-button{padding-inline:10px;font-size:12px}
.firebase-help{margin:0 0 12px;line-height:1.45}.code-area{width:100%;min-height:180px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.4}.pair-code-input{text-transform:uppercase;text-align:center;letter-spacing:.25em;font-size:28px;font-weight:900}
.status-dot{width:8px;height:8px;border-radius:50%;display:inline-block;margin-right:6px;background:currentColor;box-shadow:0 0 10px currentColor}
.action-alert-panel{border-color:rgba(255,212,20,.55);background:linear-gradient(180deg,rgba(100,75,0,.33),rgba(3,35,77,.98))}.action-alert-panel h3{margin:0 0 6px}.alert-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.alert-actions button{flex:1;min-width:100px;padding:11px;border-radius:12px;border:1px solid var(--line);background:#07336f;font-weight:800}.alert-actions button.primary{background:var(--yellow);color:#041d42;border-color:var(--yellow)}
.preview-button{margin-top:12px}.display-preview-panel{padding-bottom:15px}
@media(max-width:360px){.two-grid{grid-template-columns:1fr}}
.platform-details strong{overflow-wrap:anywhere;white-space:normal;text-align:right}.developer-config{border-top:1px solid var(--line-soft);padding-top:14px}.developer-config summary{cursor:pointer;color:var(--yellow);font-weight:850}.developer-config code{color:#dcecff}
