/* Gaelta Cockpit design system: tokens and primitives shared by the shell and every tool module.
   Brand orange is reserved for one job: unlocking (trial, plan, upgrade). State uses the signal colors only. */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sunken: #eef0f3;
  --hover: #f6f7f9;
  --ink: #12161b;
  --ink-2: #3a434d;
  --muted: #66717d;
  --faint: #9aa3ad;
  --line: #e4e7eb;
  --line-2: #d2d7dd;
  --brand: #ff5a1f;
  --brand-ink: #c2410c;
  --brand-soft: #fff1e9;
  --ok: #12925a;
  --ok-soft: #e4f4eb;
  --warn: #b97300;
  --warn-soft: #fcf2dc;
  --bad: #d4342b;
  --bad-soft: #fce8e6;
  --data: #3a62d8;
  --data-soft: rgba(58, 98, 216, .12);
  --focus: #3a62d8;
  --shadow-1: 0 1px 2px rgba(18, 22, 27, .05);
  --shadow-2: 0 2px 4px rgba(18, 22, 27, .04), 0 12px 32px rgba(18, 22, 27, .10);
  --r-1: 5px;
  --r-2: 8px;
  --r-3: 12px;
  --font: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f12; --surface: #13171b; --sunken: #0f1215; --hover: #181d22; --ink: #e9ecef; --ink-2: #bac2ca; --muted: #8a949e; --faint: #5f6973;
    --line: #222930; --line-2: #2d353d; --brand: #ff6a33; --brand-ink: #ff8f5e; --brand-soft: #2b1a12;
    --ok: #36c07f; --ok-soft: #10281c; --warn: #e6a73a; --warn-soft: #2a2113; --bad: #ff645b; --bad-soft: #2e1715;
    --data: #7d9bff; --data-soft: rgba(125, 155, 255, .16); --focus: #7d9bff;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, .02); --shadow-2: 0 0 0 1px #2d353d, 0 16px 40px rgba(0, 0, 0, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f12; --surface: #13171b; --sunken: #0f1215; --hover: #181d22; --ink: #e9ecef; --ink-2: #bac2ca; --muted: #8a949e; --faint: #5f6973;
  --line: #222930; --line-2: #2d353d; --brand: #ff6a33; --brand-ink: #ff8f5e; --brand-soft: #2b1a12;
  --ok: #36c07f; --ok-soft: #10281c; --warn: #e6a73a; --warn-soft: #2a2113; --bad: #ff645b; --bad-soft: #2e1715;
  --data: #7d9bff; --data-soft: rgba(125, 155, 255, .16); --focus: #7d9bff;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .02); --shadow-2: 0 0 0 1px #2d353d, 0 16px 40px rgba(0, 0, 0, .55); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.57rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.018em; }
h2 { font-size: 1.07rem; line-height: 1.35; font-weight: 600; letter-spacing: -0.006em; }
h3 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .9rem; }
.xs { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: .93rem; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); border-color: var(--faint); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.primary:hover { opacity: .9; }
.btn.unlock { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.unlock:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 26px; padding: 0 9px; font-size: .86rem; border-radius: var(--r-1); }
.btn.lg { height: 40px; padding: 0 18px; font-size: 1rem; }
.btn.block { width: 100%; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.link { color: var(--data); cursor: pointer; background: none; border: 0; padding: 0; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-1); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { flex: 1; font-size: 1rem; }
.card-b { padding: 16px; }
.well { background: var(--sunken); border-radius: var(--r-2); padding: 12px 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- state */
.lamp { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); display: inline-block; }
.lamp.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.lamp.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.lamp.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse 2s infinite; }
.lamp.trial { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--bad-soft); } }
@media (prefers-reduced-motion: reduce) { .lamp.bad { animation: none; } * { transition: none !important; } }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 7px; border-radius: 999px;
  font-size: .8rem; font-weight: 500; background: var(--sunken); color: var(--ink-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.brand { background: var(--brand-soft); color: var(--brand-ink); }
.tag.outline { background: transparent; border: 1px solid var(--line-2); }

/* ---------- tool marks (one letter tile per tool, colour = tool identity) */
.mark { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: 11px; letter-spacing: -.02em; }
.mark.lg { width: 34px; height: 34px; border-radius: 9px; font-size: 15px; }
.mark.cookix { background: #2f9e6e; }
.mark.trackix { background: #4a5bd6; }
.mark.pulsix { background: #d6455a; }
.mark.feedix { background: #c7881a; }
.mark.raportix { background: #6b7280; }
.mark.off { background: var(--sunken); color: var(--faint); box-shadow: inset 0 0 0 1px var(--line-2); }

/* ---------- forms */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 500; font-size: .93rem; }
.field small { color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface);
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.switch { position: relative; width: 32px; height: 18px; flex: none; appearance: none; background: var(--line-2); border-radius: 999px; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(14px); }
.seg { display: inline-flex; padding: 2px; background: var(--sunken); border-radius: var(--r-2); gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* ---------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: .86rem; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--hover); }
.table .r { text-align: right; }

/* ---------- charts */
.spark { display: block; overflow: visible; }
.spark path.l { fill: none; stroke: var(--data); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark path.a { fill: var(--data-soft); stroke: none; }
.spark circle { fill: var(--data); }
.chart { position: relative; }
.chart-max { position: absolute; right: 0; top: -2px; font-size: .74rem; color: var(--faint); background: var(--surface); padding-left: 4px; }
.chart-x { display: flex; justify-content: space-between; font-size: .76rem; color: var(--faint); margin-top: 4px; }
.ubars { display: flex; gap: 2px; align-items: stretch; height: 26px; }
.ubars i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--ok); opacity: .85; }
.ubars i.warn { background: var(--warn); }
.ubars i.bad { background: var(--bad); }
.ubars i.none { background: var(--line); }
.meter { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--data); }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; font-weight: 600; letter-spacing: -.02em; }

/* ---------- overlays */
.scrim { position: fixed; inset: 0; background: rgba(12, 15, 18, .38); z-index: 50; animation: fade .15s; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 51;
  display: flex; flex-direction: column; box-shadow: var(--shadow-2); animation: slide .2s cubic-bezier(.2, .8, .2, 1);
}
.sheet.wide { width: min(760px, 100vw); }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { flex: 1; font-size: 1.14rem; }
.sheet-b { flex: 1; overflow: auto; padding: 20px; }
.sheet-f { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--surface);
  padding: 10px 14px; border-radius: var(--r-2); box-shadow: var(--shadow-2); display: flex; gap: 8px; align-items: center; animation: fade .15s;
}
.tip { position: relative; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; font-size: .78rem; color: var(--muted); background: var(--surface); }

/* locked preview: real UI, blurred, with the unlock offer on top */
.locked { position: relative; overflow: hidden; border-radius: var(--r-3); }
.locked > .preview { filter: blur(2.5px) saturate(.8); opacity: .85; pointer-events: none; user-select: none; }
.locked > .offer {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  background: radial-gradient(ellipse 60% 70% at 50% 50%, color-mix(in srgb, var(--surface) 92%, transparent) 30%, color-mix(in srgb, var(--surface) 35%, transparent));
}
.offer-box { max-width: 380px; display: grid; gap: 10px; justify-items: center; }
