/* Gastronaut AI — app chrome tokens + shared components.
   Colour values come from the handoff v1.1 token table / prototype THEMES.
   Screens use only var(--…) — this file is the single place hex lives. */

[data-theme="light"] {
  --bg: #FFFFFF;
  --panel: #F6F5F4;
  --ink: #2C2A29;
  --ink2: rgba(44, 42, 41, .66);
  --ink3: rgba(44, 42, 41, .42);
  --line: rgba(44, 42, 41, .13);
  --accent: #6D4AA8;
  --up: #3E7A5E;
  --down: #A8453C;
  --hero-scrim-a: rgba(23, 21, 26, .42);
  --hero-scrim-b: rgba(23, 21, 26, .62);
  --hero-scrim-c: rgba(44, 42, 41, .9);
  --hero-base: #17151A;
  --nebula-a: rgba(168, 140, 232, .38);
  --nebula-b: rgba(109, 74, 168, .22);
  --nebula-c: rgba(60, 40, 96, .1);
  --ring: rgba(214, 198, 246, .3);
  --ring2: rgba(214, 198, 246, .18);
  --ring3: rgba(214, 198, 246, .1);
  --on-hero: rgba(255, 255, 255, .62);
  --on-accent: #FFFFFF;
  --down-tint: rgba(168, 69, 60, .1);
}

[data-theme="dark"] {
  --bg: #2C2A29;
  --panel: #3A3836;
  --ink: #FFFFFF;
  --ink2: rgba(255, 255, 255, .68);
  --ink3: rgba(255, 255, 255, .44);
  --line: rgba(255, 255, 255, .14);
  --accent: #A88CE8;
  --up: #7BB89A;
  --down: #D98A82;
  --hero-scrim-a: rgba(23, 21, 26, .42);
  --hero-scrim-b: rgba(23, 21, 26, .62);
  --hero-scrim-c: rgba(44, 42, 41, .9);
  --hero-base: #17151A;
  --nebula-a: rgba(168, 140, 232, .38);
  --nebula-b: rgba(109, 74, 168, .22);
  --nebula-c: rgba(60, 40, 96, .1);
  --ring: rgba(214, 198, 246, .3);
  --ring2: rgba(214, 198, 246, .18);
  --ring3: rgba(214, 198, 246, .1);
  --on-hero: rgba(255, 255, 255, .62);
  --on-accent: #FFFFFF;
  --down-tint: rgba(217, 138, 130, .12);
}

/* ── base ── */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: Poppins, 'Helvetica Neue', sans-serif;
  color: var(--ink);
  line-height: 1.4;
  font-size: 13px;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

input, textarea, select, button {
  font-family: Poppins, 'Helvetica Neue', sans-serif;
  color: var(--ink);
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.app-main::-webkit-scrollbar { width: 0; height: 0; display: none; }

.measure {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

@keyframes gn-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes gn-draw { from { stroke-dashoffset: 900; } to { stroke-dashoffset: 0; } }
@keyframes gn-pulse { 0%, 100% { opacity: .45; } 50% { opacity: .2; } }

.screen { animation: gn-rise .34s cubic-bezier(.16, 1, .3, 1); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── type ── */

.micro {
  font-size: 9px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink3);
}
.micro-sm { font-size: 8.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink3); }
.micro-accent { color: var(--accent); }
.h-screen { margin-top: 8px; font-size: 21px; font-weight: 300; letter-spacing: -.01em; }
.body-note {
  font-size: 9.5px;
  line-height: 1.7;
  color: var(--ink3);
  text-align: justify;
}
.up { color: var(--up); }
.down { color: var(--down); }

/* ── offline banner ── */

.net-banner {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 10px 24px 0;
  padding: 13px 14px;
  background: var(--panel);
  border-left: 2px solid var(--accent);
}
.net-banner.show { display: flex; }
.net-banner .t1 { font-size: 11px; font-weight: 500; letter-spacing: .04em; }
.net-banner .t2 { margin-top: 5px; font-size: 10px; font-weight: 300; line-height: 1.6; color: var(--ink2); }

.stale-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 24px 0;
  padding: 13px 14px;
  background: var(--down-tint);
  border-left: 2px solid var(--down);
}

/* ── header / tab bar ── */

.app-head {
  flex: none;
  padding: calc(10px + env(safe-area-inset-top)) 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-head img { width: 128px; opacity: .92; display: block; }
.app-head .who { display: flex; align-items: center; gap: 9px; }
.app-head .role-tag { font-size: 9px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink3); }
.app-head .initials {
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 500; letter-spacing: .04em;
}

.tabbar {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 11px 8px calc(10px + env(safe-area-inset-bottom));
  display: flex;
}
.tabbar .tab {
  flex: 1;
  padding: 6px 0 4px;
  text-align: center;
  font-size: 8px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  background: none;
  border: none;
  transition: color .2s;
}
.tabbar .tab.active { color: var(--accent); font-weight: 500; }
.tabbar .tab svg { display: block; }

/* ── pills / tabs / switches / buttons ── */

.pill {
  flex: none;
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .1em;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--line);
  color: var(--ink2);
  background: none;
}
.pill.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  font-weight: 500;
}
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-scroll {
  display: flex;
  gap: 6px;
  padding: 0 24px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pill-scroll::-webkit-scrollbar { display: none; }

.pill-sm {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 4px;
  border-radius: 999px;
  text-align: center;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border: 1px solid var(--line);
  color: var(--ink2);
  background: none;
}
.pill-sm.on { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; }

.range-tabs {
  margin: 22px 24px 0;
  display: flex;
  border-bottom: 1px solid var(--line);
}
.range-tab {
  flex: 1;
  padding: 0 0 11px;
  text-align: center;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--ink3);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}
.range-tab.on { font-weight: 600; color: var(--ink); border-bottom-color: var(--accent); }

.switch {
  width: 38px; height: 21px;
  border-radius: 999px;
  flex: none;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  background: var(--line);
  border: none;
  padding: 0;
}
.switch.on { background: var(--accent); }
.switch .knob {
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--on-accent);
  transition: left .2s;
}
.switch.on .knob { left: 19.5px; }

.btn {
  height: 54px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn[disabled] { opacity: .45; cursor: default; }
.btn-ghost {
  height: 48px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink2);
  cursor: pointer;
}
.btn-inline {
  padding: 12px 16px;
  text-align: center;
  border: 1px solid var(--line);
  background: none;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink2);
  cursor: pointer;
}
.btn-inline.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; flex: 1; }

.text-link {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ── fields ── */

.field { margin-top: 16px; }
.field label { display: block; font-size: 8.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink3); }
.field input {
  margin-top: 4px;
  width: 100%;
  height: 42px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  outline: none;
  font-size: 14px;
  font-weight: 300;
  border-radius: 0;
}
.field input:focus { border-bottom-color: var(--accent); }

.textarea {
  margin-top: 10px;
  width: 100%;
  height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  background: transparent;
  outline: none;
  resize: none;
  font-size: 12.5px;
  font-weight: 300;
  line-height: 1.6;
  border-radius: 0;
}
.textarea:focus { border-color: var(--accent); }

.form-err {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--down-tint);
  border-left: 2px solid var(--down);
  font-size: 11px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink);
}

.inline-note {
  margin-top: 14px;
  padding: 13px 14px;
  background: var(--panel);
  border-left: 2px solid var(--accent);
  font-size: 10.5px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink2);
  animation: gn-rise .3s cubic-bezier(.16, 1, .3, 1);
}

/* ── auth hero ── */

.hero {
  position: relative;
  flex: none;
  overflow: hidden;
  background: var(--hero-base);
  height: min(258px, max(150px, 30dvh));
}
.hero.compact { height: min(168px, max(110px, 20dvh)); }
.hero img.photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 62% 22%;
}
.hero .scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--hero-scrim-a) 0%, var(--hero-scrim-b) 55%, var(--hero-scrim-c) 100%);
}
.hero .nebula {
  position: absolute; left: 50%; top: 44%;
  width: 760px; height: 760px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, var(--nebula-a) 0%, var(--nebula-b) 26%, var(--nebula-c) 48%, transparent 66%);
}
.hero .ring { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); border-radius: 50%; }
.hero .ring.r1 { width: 300px; height: 300px; border: 1px solid var(--ring); }
.hero .ring.r2 { width: 470px; height: 470px; border: 1px solid var(--ring2); }
.hero .ring.r3 { width: 640px; height: 640px; border: 1px solid var(--ring3); }
.hero img.wordmark { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); width: 236px; opacity: .96; }
.hero.compact img.wordmark { width: 200px; }
.hero .strap {
  position: absolute; left: 0; right: 0; top: 44%;
  margin-top: 34px;
  text-align: center;
  font-size: 9px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--on-hero);
}
.hero .tick { position: absolute; left: 32px; bottom: 0; width: 78px; height: 2px; background: var(--accent); }

.auth-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 30px 32px 0;
  overflow-y: auto;
}
.auth-title { margin-top: 14px; font-size: 27px; font-weight: 300; line-height: 1.22; letter-spacing: -.01em; }

.pending-box {
  width: 54px; height: 54px;
  border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.pending-box .dot { width: 10px; height: 10px; background: var(--accent); animation: gn-pulse 2.4s ease-in-out infinite; }

/* ── dashboard ── */

.dash-split { display: block; padding-bottom: 4px; }
.hero-num-label { font-size: 9px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink3); }
.hero-num { display: flex; align-items: flex-end; gap: 10px; margin-top: 9px; }
.hero-num .n {
  font-size: clamp(34px, 12vw, 46px);
  font-weight: 200;
  line-height: .94;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.hero-num .cur { padding-bottom: 5px; font-size: 10px; letter-spacing: .16em; color: var(--ink3); }

.chart-wrap { margin-top: 20px; padding: 0 24px; position: relative; }
.chart-wrap svg.curve { width: 100%; height: 140px; display: block; touch-action: none; }
.chart-wrap path.now {
  stroke-dasharray: 900;
  animation: gn-draw 1s cubic-bezier(.16, 1, .3, 1) forwards;
}
.chart-axis { display: flex; justify-content: space-between; margin-top: 8px; }
.chart-axis span { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }
.chart-hint { margin-top: 10px; font-size: 9px; letter-spacing: .06em; color: var(--ink3); }
.chart-tip {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  padding: 8px 11px 9px;
  background: var(--ink);
  color: var(--bg);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}
.chart-tip .l { font-size: 8px; letter-spacing: .24em; text-transform: uppercase; opacity: .6; }
.chart-tip .v { margin-top: 3px; font-size: 14px; font-weight: 300; letter-spacing: -.01em; }

.ly-toggle {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: none;
  width: 100%;
  color: var(--ink);
}
.ly-toggle.on { background: var(--panel); border-color: transparent; }
.ly-toggle .dash-mark { width: 14px; height: 0; flex: none; border-top: 1px dashed var(--accent); opacity: .5; }
.ly-toggle.on .dash-mark { opacity: 1; }
.ly-toggle .lbl { font-size: 10px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; }
.ly-toggle .switch { margin-left: auto; }

.kpi-grid {
  margin: 26px 24px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.kpi {
  background: var(--bg);
  padding: 16px 14px 18px;
  min-width: 0;
}
.kpi .l {
  font-size: 8.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .v { margin-top: 9px; font-size: 25px; font-weight: 200; letter-spacing: -.015em; line-height: 1; overflow-wrap: anywhere; }
.kpi .u { margin-top: 8px; font-size: 8.5px; letter-spacing: .1em; color: var(--ink3); }

.panel-card { margin: 22px 24px 0; padding: 18px; background: var(--panel); }
.panel-card .t { margin-top: 9px; font-size: 13px; font-weight: 400; letter-spacing: .01em; }
.panel-card .b { margin-top: 7px; font-size: 11px; font-weight: 300; line-height: 1.65; color: var(--ink2); text-align: justify; }

.sources { margin: 28px 24px 0; }
.source-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.source-row .dot { width: 5px; height: 5px; flex: none; border-radius: 50%; background: var(--accent); }
.source-row .dot.idle { background: var(--ink3); }
.source-row .dot.off { background: transparent; border: 1px solid var(--ink3); }
.source-row .nm { flex: 1; font-size: 12.5px; font-weight: 400; letter-spacing: .01em; }
.source-row .meta { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink3); text-align: right; }

.skeleton { padding: 26px 24px 0; display: flex; flex-direction: column; gap: 14px; }
.skeleton .sk { background: var(--line); animation: gn-pulse 1.5s ease-in-out infinite; }

@media (min-width: 600px) {
  .dash-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 24px;
    align-items: start;
  }
  .dash-split .kpi-grid { margin: 26px 24px 0 0; }
}
@media (min-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── chat ── */

.chat-screen { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { flex: none; padding: 12px 24px 18px; border-bottom: 1px solid var(--line); }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: none;
}
.chat-log::-webkit-scrollbar { display: none; }
.msg { display: flex; flex-direction: column; align-items: flex-start; }
.msg.me { align-items: flex-end; }
.msg .bubble {
  max-width: 96%;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.66;
  letter-spacing: .005em;
  white-space: pre-wrap;
}
.msg.me .bubble {
  max-width: 78%;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .01em;
  white-space: pre-wrap;
}
.msg .pending-dots { font-size: 11px; color: var(--ink3); letter-spacing: .2em; animation: gn-pulse 1.5s ease-in-out infinite; }
.chat-chips {
  flex: none;
  padding: 0 24px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chips .lbl { flex: none; font-size: 8px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink3); }
.chat-chip {
  flex: none;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink2);
  white-space: nowrap;
  cursor: pointer;
  background: none;
}
.chat-input-row {
  flex: none;
  padding: 12px 24px 6px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-input-row input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: .01em;
}
.chat-send {
  width: 38px; height: 38px;
  flex: none;
  background: var(--ink);
  color: var(--bg);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.chat-send[disabled] { opacity: .45; }
.chat-foot { flex: none; padding: 0 24px 10px; font-size: 9px; letter-spacing: .04em; color: var(--ink3); }

/* ── alerts ── */

.alert-card { background: var(--panel); padding: 20px 18px 22px; border-top: 2px solid var(--accent); margin-top: 12px; }
.alert-card .head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.alert-card .tag { font-size: 9px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); }
.alert-card .pin { display: inline-flex; align-items: center; gap: 6px; }
.alert-card .when { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); white-space: nowrap; }
.alert-card .body {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
}
.alert-card .scope { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }

.empty-state { margin: 40px 24px 0; text-align: center; }
.empty-state .t { font-size: 15px; font-weight: 300; }
.empty-state .b { margin-top: 8px; font-size: 11px; font-weight: 300; line-height: 1.7; color: var(--ink3); }

/* ── lists (admin / settings) ── */

.row-list .row { padding: 15px 0; border-top: 1px solid var(--line); }
.row-flex { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row-name { font-size: 13px; font-weight: 400; letter-spacing: .01em; }
.row-when { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink3); white-space: nowrap; }
.row-sub { margin-top: 5px; font-size: 10.5px; font-weight: 300; color: var(--ink2); overflow-wrap: anywhere; }

.setting-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.setting-row .t { font-size: 13px; font-weight: 400; letter-spacing: .01em; }
.setting-row .s { margin-top: 5px; font-size: 10.5px; font-weight: 300; color: var(--ink3); }

.section-pad { padding: 12px 24px 24px; }
.gap-bottom { height: 26px; }
