/* Instrument panel: near-black case, acid phosphor accent.
   Geist for prose and labels, Geist Mono for anything that reads as data. */

@font-face {
  font-family: 'Geist';
  src: url('/vendor/geist/geist-sans/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('/vendor/geist/geist-mono/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #08090b;
  --bg-lift: #101216;
  --bg-sink: #050608;
  --rule: #1c2027;
  --rule-soft: #14171c;
  --ink: #dfe4ea;
  --ink-dim: #7a838f;
  --ink-faint: #4b535d;

  --live: #c8ff2e;
  --live-dim: #7f9e1d;
  --warn: #ff9a3c;
  --danger: #ff4f4f;

  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --r: 3px;
  --pad: 18px;
}

* { box-sizing: border-box; }

/* display:grid/flex below beats the browser default for [hidden], so state it. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Anything that reports a reading is set in mono. */
.meter-value,
.readout-main,
.readout-sub,
.specs dd,
.cost-value,
.offer-price,
.offer-gpu,
.copyline,
.tab,
.brand-mark,
.gate-mark,
.field input,
.field select {
  font-family: var(--mono);
  font-feature-settings: 'ss01' 1, 'ss03' 1;
}

/* Micro labels stay mono but tight, so they read as engraving. */
.meter-label,
.cost-label,
.panel-head h2,
.field > span,
.phase span,
.specs dt,
.offer-meta {
  font-family: var(--mono);
  font-weight: 500;
}

/* Grain over everything — a device case, not a web page. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

/* ---------- SIGN IN ---------- */
.gate {
  display: grid;
  place-items: center;
  height: 100%;
  background:
    radial-gradient(60% 50% at 50% 40%, rgba(200, 255, 46, 0.05), transparent 70%),
    var(--bg);
}

.gate-card {
  width: min(340px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 34px 30px 30px;
  background: var(--bg-lift);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--live);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}

.gate-mark { color: var(--live); letter-spacing: 4px; font-size: 15px; }

.gate-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.5px;
}
.gate-title span { color: var(--ink-faint); font-weight: 300; }

.gate-sub {
  margin: -8px 0 8px;
  color: var(--ink-dim);
  font-size: 11px;
  letter-spacing: 0.5px;
}

.gate-error {
  min-height: 16px;
  margin: 0;
  color: var(--danger);
  font-size: 11px;
}

/* ---------- FIELDS ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }

.field > span {
  color: var(--ink-dim);
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.field input, .field select {
  background: var(--bg-sink);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 9px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus, .field select:focus { border-color: var(--live-dim); }

.field-inline { margin-bottom: 12px; }

/* ---------- BUTTONS ---------- */
.btn {
  border: 1px solid var(--rule);
  background: transparent;
  border-radius: var(--r);
  padding: 9px 14px;
  cursor: pointer;
  letter-spacing: 0.6px;
  transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.08s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-faint); background: #ffffff08; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { border-color: var(--live-dim); color: var(--live); }
.btn-primary:hover:not(:disabled) { background: rgba(200, 255, 46, 0.09); border-color: var(--live); }

.btn-warn { border-color: #6b4a1e; color: var(--warn); }
.btn-warn:hover:not(:disabled) { background: rgba(255, 154, 60, 0.1); }

.btn-danger { border-color: #6b2626; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 79, 79, 0.1); }
.btn-danger.armed { background: var(--danger); color: #0b0b0b; border-color: var(--danger); }

.btn-ghost { color: var(--ink-dim); }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-wide { width: 100%; }

/* ---------- FRAME ---------- */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 var(--pad);
  height: 48px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-lift);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { color: var(--live); letter-spacing: 3px; }
.brand-name {
  font-family: var(--mono);
  font-weight: 300;
  letter-spacing: -0.2px;
  color: var(--ink-faint);
}
.brand-name b { color: var(--ink); font-weight: 600; }

.meters { display: flex; gap: 22px; margin-left: auto; }

.meter { display: flex; flex-direction: column; line-height: 1.25; }
.meter-label {
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}
.meter-value { font-size: 13px; font-variant-numeric: tabular-nums; }

.views { flex: 1; min-height: 0; position: relative; }

.view { position: absolute; inset: 0; }

.view-setup { overflow-y: auto; background: var(--bg-sink); }
.view-term { display: flex; flex-direction: column; background: var(--bg-sink); }

/* On a wide screen the panels sit in columns instead of stretching. */
.view-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  /* A one-pixel gap over a rule-coloured background draws the dividers. */
  gap: 1px;
  background: var(--rule-soft);
}

.view-setup::-webkit-scrollbar, .offers::-webkit-scrollbar { width: 8px; }
.view-setup::-webkit-scrollbar-thumb, .offers::-webkit-scrollbar-thumb { background: var(--rule); }

/* ---------- BOTTOM TAB BAR ---------- */
.bottombar {
  display: flex;
  flex: none;
  height: 54px;
  border-top: 1px solid var(--rule);
  background: var(--bg-lift);
  padding-bottom: env(safe-area-inset-bottom);
}

.navbtn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  border-top: 2px solid transparent;
  margin-top: -1px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  position: relative;
  transition: color 0.15s, background 0.15s;
}
.navbtn:hover { color: var(--ink); background: #ffffff05; }
.navbtn.active { color: var(--live); border-top-color: var(--live); background: var(--bg-sink); }

.navbtn-mark { font-family: var(--mono); font-size: 14px; opacity: 0.85; }
.navbtn-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.navbtn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.navbtn-dot.on { background: var(--live); box-shadow: 0 0 7px var(--live); }
.navbtn-dot.busy { background: var(--warn); animation: blink 1.1s steps(2, start) infinite; }

.navbtn-badge {
  font-family: var(--mono);
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  background: var(--rule);
  color: var(--ink-dim);
  text-align: center;
}
.navbtn.active .navbtn-badge { background: var(--live-dim); color: #0b0b0b; }

/* ---------- PANELS ---------- */
.panel { padding: var(--pad); background: var(--bg-sink); }

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.panel-head .btn { margin-left: auto; }

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  margin-left: auto;
}
.led.on { background: var(--live); box-shadow: 0 0 8px var(--live); }
.led.busy { background: var(--warn); animation: blink 1.1s steps(2, start) infinite; }
.led.off { background: var(--ink-faint); }

@keyframes blink { 50% { opacity: 0.25; } }

.empty { color: var(--ink-dim); }
.empty p { margin: 0 0 4px; }
.empty-note { color: var(--ink-faint); font-size: 11px; }

/* ---------- READOUTS ---------- */
.readout { margin-bottom: 16px; }
.readout-main {
  font-size: 19px;
  letter-spacing: -0.3px;
}
.readout-sub {
  color: var(--ink-faint);
  font-size: 11px;
  min-height: 16px;
  word-break: break-word;
}

.phases {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 18px;
}
.phase { text-align: center; }
.phase i {
  display: block;
  height: 3px;
  background: var(--rule);
  margin-bottom: 6px;
}
.phase span {
  font-size: 9px;
  letter-spacing: 0.8px;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.phase.done i { background: var(--live-dim); }
.phase.done span { color: var(--ink-dim); }
.phase.active i { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.phase.active span { color: var(--warn); }

@keyframes pulse { 50% { opacity: 0.4; } }

.specs { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.specs dt { color: var(--ink-faint); font-size: 11px; }
.specs dd {
  margin: 0;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.cost {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
  margin-bottom: 16px;
}
.cost-cell { background: var(--bg-lift); padding: 10px 12px; }
.cost-label {
  display: block;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.cost-value {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  color: var(--live);
}

.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; }

.hint {
  margin: 10px 0 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.copyline {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-lift);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 11px;
  cursor: pointer;
  word-break: break-all;
  transition: border-color 0.14s;
}
.copyline:hover { border-color: var(--live-dim); }

/* ---------- OFFERS ---------- */
.offers {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--rule-soft);
  margin-bottom: 12px;
}

.offer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: background 0.12s;
}
.offer:last-child { border-bottom: none; }
.offer:hover { background: #ffffff06; }
.offer.sel { background: rgba(200, 255, 46, 0.08); box-shadow: inset 2px 0 0 var(--live); }

.offer-gpu { font-size: 12px; }
.offer-price { color: var(--live); font-variant-numeric: tabular-nums; }
.offer-meta { grid-column: 1 / -1; color: var(--ink-faint); font-size: 10px; }

/* ---------- TERMINAL ---------- */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 1px;
  height: 34px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-lift);
  flex: none;
  overflow-x: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--live); border-bottom-color: var(--live); background: var(--bg-sink); }
.tab-close { color: var(--ink-faint); font-size: 14px; line-height: 1; }
.tab-close:hover { color: var(--danger); }

.tab-add {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  padding: 0 14px;
  cursor: pointer;
  font-size: 15px;
}
.tab-add:hover { color: var(--live); }

.term-wrap { flex: 1; position: relative; min-height: 0; padding: 8px 10px; }
.term-pane { position: absolute; inset: 8px 10px; }
.term-pane[hidden] { display: none; }

.term-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-dim);
  text-align: center;
  padding: 20px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--bg-lift);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--live);
  padding: 10px 16px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: min(520px, 90vw);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-left-color: var(--danger); }

/* ---------- PHONE ---------- */
@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .meters { gap: 14px; }
  .brand-name { display: none; }
  .navbtn-mark { display: none; }
  :root { --pad: 14px; }
}
