:root,
html[data-theme="dark"] {
  --bg: #12171b;
  --bg-2: #1a2228;
  --card: #222b32;
  --desk: #0c1013;
  --line: rgba(200, 208, 212, 0.14);
  --ink: #e8eef0;
  --muted: #9aa6ad;
  --accent: #3d8f8a;
  --accent-dim: rgba(61, 143, 138, 0.18);
  --btn: #3d8f8a;
  --btn-ink: #041012;
  --run: #6fad6a;
  --late: #c48a3a;
  --quiet: #7a8a94;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  --tabbar: #0c1013;
  --wash: rgba(61, 143, 138, 0.14);
  --poc: #7ec9c4;
  --btn-2: #2a343c;
  --toast-bg: #e8eef0;
  --toast-ink: #12171b;
  --sheet-dim: rgba(0, 0, 0, 0.55);
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --tab: calc(64px + env(safe-area-inset-bottom));
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #e8ecee;
  --bg-2: #f3f5f6;
  --card: #ffffff;
  --desk: #d5dcd3;
  --line: rgba(26, 34, 40, 0.14);
  --ink: #1a2228;
  --muted: #5a656c;
  --accent: #2f6f6b;
  --accent-dim: rgba(47, 111, 107, 0.14);
  --btn: #2f6f6b;
  --btn-ink: #f3f5f6;
  --run: #2f6b38;
  --late: #8a5208;
  --quiet: #5a656c;
  --shadow: 0 10px 22px rgba(26, 34, 40, 0.1);
  --tabbar: #f7f9f9;
  --wash: rgba(47, 111, 107, 0.1);
  --poc: #2f6f6b;
  --btn-2: #3a444c;
  --toast-bg: #1a2228;
  --toast-ink: #e8eef0;
  --sheet-dim: rgba(26, 34, 40, 0.4);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 0;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 400px at 80% -10%, var(--wash), transparent 50%),
    var(--bg);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 10px; }
.brand-name { font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; }
.top-right { text-align: right; display: grid; justify-items: end; gap: 4px; }
.theme-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}
.clock { font-size: 12px; color: var(--muted); }
.poc {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--poc);
}

.install {
  margin: 0 16px 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.install span { flex: 1; }
.install button, .sheet-close, .action {
  border: 0;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-ink);
  font-weight: 700;
  padding: 8px 12px;
  min-height: 40px;
}
.ghost { background: transparent !important; color: var(--muted) !important; }

.view {
  flex: 1;
  padding: 8px 16px var(--tab);
  overflow: auto;
}
.kicker {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--accent);
  font-size: 0.95rem;
  margin: 0 0 6px;
  text-transform: none;
  letter-spacing: 0;
}
h1 {
  margin: 2px 0 6px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.plant-meta {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Insight tiles — match marketing sample board */
.insight-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.insight-tile {
  display: grid;
  gap: 4px;
  padding: 12px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  text-align: left;
}
.insight-tile--run { border-left-color: var(--run); }
.insight-tile--late { border-left-color: var(--late); }
.insight-tile--quiet { border-left-color: var(--quiet); }
.insight-tile--accent { border-left-color: var(--accent); }
.insight-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.insight-value {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}
.insight-tile--run .insight-value { color: var(--run); }
.insight-tile--late .insight-value { color: var(--late); }
.insight-tile--quiet .insight-value { color: var(--quiet); }
.insight-tile--accent .insight-value { color: var(--accent); }
.insight-line {
  margin: 2px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}

/* Docket */
.sample-docket {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.sample-docket li {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  font-size: 0.92rem;
}
.bay { color: var(--muted); font-size: 0.8rem; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.pill.run { color: var(--run); background: rgba(111, 173, 106, 0.16); }
.pill.late { color: var(--late); background: rgba(196, 138, 58, 0.16); }
.pill.quiet { color: var(--quiet); background: rgba(122, 138, 148, 0.18); }
.pill.good { color: var(--run); background: rgba(111, 173, 106, 0.16); }
.pill.info { color: var(--accent); background: var(--accent-dim); }
.pill.hold { color: var(--quiet); background: rgba(122, 138, 148, 0.18); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat, .card, .chase {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.stat { padding: 12px; }
.stat b { display: block; font-size: 22px; font-family: var(--serif); }
.stat span { color: var(--muted); font-size: 12px; }

.card, .chase {
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
}
.card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.card-job {
  grid-template-columns: auto 1fr auto;
}
.job-num {
  font-weight: 800;
  color: var(--accent);
  font-size: 13px;
  min-width: 36px;
}
.title { font-weight: 700; }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; }
.note { color: var(--muted); font-size: 13px; line-height: 1.45; }
.list-head {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.chase { display: grid; gap: 4px; }
.chase .action {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 700;
  min-height: 48px;
  padding: 6px 0;
}
.tabs svg { width: 18px; height: 18px; fill: currentColor; }
.tabs button.is-on { color: var(--ink); }
.tabs button.is-on svg { color: var(--accent); }

.sheet[hidden],
.toast[hidden],
.install[hidden] {
  display: none !important;
}
.sheet {
  position: fixed;
  inset: 0;
  background: var(--sheet-dim);
  z-index: 40;
  display: grid;
  align-items: end;
}
.sheet-card {
  background: var(--bg-2);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 82dvh;
  overflow: auto;
}
.sheet-close { margin-bottom: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab) + 12px);
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 50;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.action.secondary { background: var(--btn-2); color: #fff; }

/* Modes */
.modes {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}
.modes-head { margin-bottom: 4px; }
.mode-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  color: inherit;
}
.mode-card.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), var(--shadow);
  background: color-mix(in srgb, var(--card) 88%, var(--accent) 12%);
}
.mode-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mode-title { font-weight: 800; font-size: 15px; }
.mode-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--btn-ink);
  background: transparent;
}
.mode-card.is-on .mode-check { background: var(--accent); }
.mode-blurb {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.mode-banner, .api-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: var(--bg-2);
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - 540px + 16px));
  bottom: calc(var(--tab, 72px) + 12px);
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-ink);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(61, 143, 138, 0.35);
  z-index: 30;
  display: grid;
  place-items: center;
}
.fab span { margin-top: -2px; }
.add-form { display: grid; gap: 10px; margin-top: 8px; }
.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea, .field select {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  width: 100%;
}

@media (min-width: 720px) {
  body { background: var(--desk); }
  .app {
    max-width: 840px;
    min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--line);
  }
  .view { padding: 12px 22px var(--tab); }
  .modes {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-items: stretch;
  }
  .modes-head { grid-column: 1 / -1; }
  .mode-card { height: 100%; }
  .insight-tiles { gap: 12px; }
  .jobs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .jobs-grid .card { margin-bottom: 0; }
  .jobs-grid .note-full { grid-column: 1 / -1; }
  h1 { font-size: 30px; }
  .tabs { width: min(840px, 100%); }
  .fab { right: max(24px, calc(50% - 420px + 24px)); }
}

@media (min-width: 1100px) {
  .app { max-width: 1120px; }
  .view { padding: 18px 28px calc(var(--tab) + 8px); }
  .top { padding: 18px 28px 12px; }
  .tabs { width: min(1120px, 100%); }
  .fab { right: max(28px, calc(50% - 560px + 28px)); }
  .card:hover, .mode-card:hover, .insight-tile:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  }
}

@media (max-width: 380px) {
  .insight-tiles { grid-template-columns: 1fr; }
  .tabs button { font-size: 9px; }
}
