/* ── Shared tokens & components (field app + control station) ── */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e3e6ee;
  --text: #141824;
  --text-2: #4b5468;
  --text-3: #8a92a6;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eceafd;
  --go: #0f9d58;      --go-soft: #e3f6ec;
  --info: #2563eb;    --info-soft: #e6eefe;
  --warn: #d97706;    --warn-soft: #fdf1df;
  --high: #dc2626;    --high-soft: #fde8e8;
  --done: #64748b;    --done-soft: #eef1f5;
  --stage0: #cbd2df;
  --stage1: #2563eb;
  --stage2: #0f9d58;
  --shadow: 0 1px 2px rgba(20, 24, 36, .06), 0 2px 8px rgba(20, 24, 36, .05);
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #121829;
  --surface-2: #161d31;
  --surface-3: #1d2540;
  --border: #252e4a;
  --text: #e8ebf4;
  --text-2: #a9b1c7;
  --text-3: #6d7690;
  --brand: #7c74ff;
  --brand-soft: #24224d;
  --go: #34d399;      --go-soft: #10322a;
  --info: #60a5fa;    --info-soft: #162a4a;
  --warn: #fbbf24;    --warn-soft: #3a2c0e;
  --high: #f87171;    --high-soft: #3d1717;
  --done: #94a3b8;    --done-soft: #1f2639;
  --stage0: #3a4462;
  --stage1: #60a5fa;
  --stage2: #34d399;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 14px 16px; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 18px 4px 8px; }

/* Pills & chips */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.tone-neutral { background: var(--surface-3); color: var(--text-2); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-go { background: var(--go-soft); color: var(--go); }
.tone-done { background: var(--done-soft); color: var(--done); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-high { background: var(--high-soft); color: var(--high); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip.flag { background: var(--warn-soft); color: var(--warn); }
.chip.vip { background: var(--brand-soft); color: var(--brand); }
.flight-code { font-family: var(--mono); font-weight: 700; letter-spacing: -.01em; }

/* Progress (3-stage stacked bar) */
.stagebar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--stage0); }
.stagebar > i { display: block; height: 100%; }
.stagebar .s1 { background: var(--stage1); }
.stagebar .s2 { background: var(--stage2); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* Stage segmented control */
.stage-ctl { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-shrink: 0; }
.stage-ctl button { border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); min-width: 44px; white-space: nowrap; }
.stage-ctl button.on.s0 { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stage-ctl button.on.s1 { background: var(--stage1); color: #fff; }
.stage-ctl button.on.s2 { background: var(--stage2); color: #fff; }
:root[data-theme="dark"] .stage-ctl button.on.s1, :root[data-theme="dark"] .stage-ctl button.on.s2 { color: #0b0f19; }

/* Check-off rows: tap anywhere on the row to tick / untick */
.pax-row { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; padding: 12px 8px 12px 14px !important; }
.pax-row:active { background: var(--surface-2); }
.pax-row .tick { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--stage0); display: grid; place-items: center; flex-shrink: 0; color: #fff; transition: background .12s, border-color .12s; }
.pax-row .nm { font-weight: 700; }
.pax-row.checked .tick { background: var(--go); border-color: var(--go); }
.pax-row.checked .nm { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--text-3); }
.pax-row.checked .muted { color: var(--text-3); }
.pax-row .info { border: 0; background: transparent; color: var(--text-3); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.pax-row .info:hover { background: var(--surface-3); color: var(--text); }
.ok { color: var(--go); font-weight: 600; }
:root[data-theme="dark"] .pax-row.checked .tick { color: #0b0f19; }
/* Every app's header starts the same: home button + app title */
.app-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-id { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; flex-shrink: 0; }
.app-home { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: #fff; flex-shrink: 0; }
a.app-home:hover { filter: brightness(1.1); }
.app-title { font-weight: 800; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.pax-row .call, .pax-line .call { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--brand); flex-shrink: 0; }
.pax-row .call:hover, .pax-line .call:hover { background: var(--brand-soft); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 3000; background: rgba(15, 23, 42, .45); display: grid; place-items: end center; padding: 16px; }
@media (min-width: 600px) { .sheet-backdrop { place-items: center; } }
.sheet { background: var(--surface); color: var(--text); border-radius: 16px; padding: 18px; width: min(420px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.sheet-title { font-weight: 800; font-size: 17px; }
.stay-tile { border-left: 3px solid var(--brand); }
/* passenger journey blocks: flight, coach, host — one design */
.jblock { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start; border-left: 3px solid var(--border); }
.jblock.flight { border-left-color: var(--info); }
.jblock.coach { border-left-color: var(--brand); }
.jblock.host { border-left-color: var(--go); }
.jb-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--info-soft); color: var(--info); }
.jblock.coach .jb-ic { background: var(--brand-soft); color: var(--brand); }
.jblock.host .jb-ic { background: var(--go-soft); color: var(--go); }
.jb-body { min-width: 0; }
.jb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 22px; }
.jb-head b { font-size: 15px; }
.jb-head .flight-code { font-size: 15px; }
.jb-right { display: flex; gap: 6px; align-items: center; flex-shrink: 0; font-size: 12px; color: var(--text-3); }
.jb-line { margin-top: 3px; }
.jb-act { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; align-self: center; }
/* a simple tick: circle and a short label, no box around it */
.jb-act .checkbtn { border: 0; background: transparent; padding: 0; gap: 3px; flex-direction: column; font-size: 10.5px; font-weight: 600; color: var(--text-3); white-space: nowrap; min-width: 56px; }
.jb-act .checkbtn .box { width: 28px; height: 28px; }
.jb-head { flex-wrap: wrap; }
.jb-act .checkbtn.on { color: var(--go); }
.stay-full { margin-bottom: 10px; }
.stay-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--brand-soft); color: var(--brand); }
.stay-ic.host { background: var(--go-soft); color: var(--go); }
.stay-tile:has(.stay-ic.host) { border-left-color: var(--go); }
.sheet-btns { display: flex; gap: 10px; margin-top: 16px; }
.sheet-btns .btn { flex: 1; padding: 12px; justify-content: center; font-size: 15px; }
.checkbtn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 6px 12px 6px 6px; font-weight: 600; font-size: 13px; }
.checkbtn .box { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--stage0); display: grid; place-items: center; color: #fff; }
.checkbtn.on { border-color: var(--go); color: var(--go); }
.checkbtn.on .box { background: var(--go); border-color: var(--go); }

/* Connection status */
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.conn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--go); box-shadow: 0 0 0 3px color-mix(in srgb, var(--go) 25%, transparent); }
.conn.off::before { background: var(--high); box-shadow: 0 0 0 3px color-mix(in srgb, var(--high) 25%, transparent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; }
.search input { border: 0; outline: 0; background: transparent; padding: 11px 0; flex: 1; font-size: 15px; min-width: 0; }
.search svg { color: var(--text-3); flex-shrink: 0; }

/* Times */
.times { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 4px 14px; font-size: 13px; align-items: baseline; }
.times .h { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.times .late { color: var(--high); font-weight: 600; }
.strike { text-decoration: line-through; color: var(--text-3); }

/* Route */
.route { display: flex; align-items: center; gap: 12px; }
.route .ap { min-width: 0; }
.route .code { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.route .city { font-size: 12px; color: var(--text-2); }
.route .track { flex: 1; position: relative; height: 24px; }
.route .track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed var(--border); }
.route .track .fill { position: absolute; left: 0; top: 50%; border-top: 2px solid var(--brand); }
.route .track .plane { position: absolute; top: 50%; transform: translate(-50%, -50%); color: var(--brand); background: var(--surface); padding: 0 2px; }

/* Milestone list */
.ms { list-style: none; margin: 0; padding: 0; position: relative; }
.ms li { display: grid; grid-template-columns: 52px 22px 1fr; gap: 8px; align-items: start; padding: 6px 0; position: relative; }
.ms li .t { font-family: var(--mono); font-size: 13px; color: var(--text-2); padding-top: 1px; text-align: right; }
.ms li .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--stage0); background: var(--surface); margin: 3px auto 0; position: relative; z-index: 1; }
.ms li.done .dot { background: var(--go); border-color: var(--go); }
.ms li.next .dot { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.ms li::before { content: ''; position: absolute; left: 71px; top: 0; bottom: 0; border-left: 2px solid var(--border); }
.ms li:first-child::before { top: 14px; }
.ms li:last-child::before { bottom: calc(100% - 14px); }
.ms li.done::before { border-color: var(--go); }
.ms li .lbl { font-weight: 600; }
.ms li.done .lbl { color: var(--text-2); }
.ms li .sub { font-size: 12px; color: var(--text-3); }

/* Lists */
.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.list > .item:first-child { border-top: 0; }
.list > .item.tap { cursor: pointer; }
.list > .item.tap:hover { background: var(--surface-2); }

.empty { padding: 32px 16px; text-align: center; color: var(--text-3); }

/* Alerts */
.alert { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; padding: 11px 14px 11px 0; border-top: 1px solid var(--border); align-items: start; }
.alert:first-child { border-top: 0; }
.alert .bar { align-self: stretch; border-radius: 0 3px 3px 0; }
.alert.high .bar { background: var(--high); }
.alert.warn .bar { background: var(--warn); }
.alert.info .bar { background: var(--info); opacity: .5; }
.alert .title { font-weight: 700; font-size: 13px; }
.alert .text { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.alert .meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.alert.acked { opacity: .55; }
.alert .title .type { font-weight: 600; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; margin-right: 6px; }
.alert.high .type { color: var(--high); }
.alert.warn .type { color: var(--warn); }
.alert.info .type { color: var(--info); }

/* Leaflet markers */
.mk-plane { color: var(--brand); filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.mk-plane.delayed { color: var(--warn); }
.mk-label { font: 600 11px var(--mono); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; white-space: nowrap; box-shadow: var(--shadow); }
.mk-bus { width: 26px; height: 26px; border-radius: 8px; background: var(--go); color: #fff; display: grid; place-items: center; font: 700 10px var(--font); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk-bus.idle { background: var(--done); }
.mk-bus.loading { background: var(--warn); }
.mk-ap { width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--text-2); }
.mk-ap.staffed { width: 14px; height: 14px; border-color: var(--brand); border-width: 3.5px; }
.mk-ap.dest { width: 18px; height: 18px; background: var(--brand); border-color: #fff; }
.mk-hotel { width: 22px; height: 22px; border-radius: 6px; background: #db2777; color: #fff; display: grid; place-items: center; font: 700 11px var(--font); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.leaflet-container { font-family: var(--font); background: var(--surface-3); }
.leaflet-div-icon { background: transparent; border: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 13px; z-index: 9999; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* Demo badge */
.demo-badge { font-size: 10px; font-weight: 800; letter-spacing: .08em; background: var(--warn-soft); color: var(--warn); padding: 2px 6px; border-radius: 5px; }
