/* ===================================================================
   Operator Terminal — shared stylesheet for /signin, /auth/callback,
   /terminal. Direction A ("The Terminal"). Tokens match landing.css.
   =================================================================== */

:root {
  --ground: #171717;
  --surface: #1F1F1F;
  --raised: #262626;
  --border: #2E2E2E;
  --border-strong: #454545;
  --text: #FAFAFA;
  --muted: #A3A3A3;
  --faint: #8A8A8A;
  --green: #3ECF8E;
  --green-hover: #5BD9A0;
  --green-ink: #0B1F16;
  --amber: #F2B84B;
  --red: #F0665E;
  --sans: "Space Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --radius-console: 16px;
  --radius-screen: 10px;
  --radius-field: 6px;
  --shadow-console: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 24px 48px rgba(0, 0, 0, 0.45), 0 48px 96px rgba(62, 207, 142, 0.05);
  --shadow-cta: 0 0 0 1px rgba(62, 207, 142, 0.55), 0 10px 28px rgba(62, 207, 142, 0.14), 0 2px 6px rgba(0, 0, 0, 0.4);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  --gutter: 80px;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); }
a:hover { color: var(--green-hover); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.label {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}

.readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* --- focus / interaction states (shared) ------------------------------ */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }
button, input { font: inherit; }
button { cursor: pointer; }

/* --- page background: hairline grid + grain --------------------------- */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(to right, rgba(250, 250, 250, 0.035) 0, rgba(250, 250, 250, 0.035) 1px, transparent 1px, transparent 80px),
    repeating-linear-gradient(to bottom, rgba(250, 250, 250, 0.035) 0, rgba(250, 250, 250, 0.035) 1px, transparent 1px, transparent 80px);
}
.page-bg svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.07;
  mix-blend-mode: screen;
}
.page { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* --- top bar ---------------------------------------------------------- */
.topbar {
  height: 64px;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--ground);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-height: 44px;
  transition: opacity 0.15s ease;
}
.brand:hover { color: var(--text); opacity: 0.85; }
.brand:active { opacity: 0.7; }
.brand svg { flex: none; }
.topbar-right { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-email {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-link {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  transition: color 0.15s ease, transform 0.15s var(--ease-spring);
}
.topbar-link:hover { color: var(--green); }
.topbar-link:active { transform: translateY(1px); }
.topbar-link.member { color: var(--green); }

/* --- buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s var(--ease-spring), opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--green); color: var(--green-ink); box-shadow: var(--shadow-cta); }
.btn-primary:hover { background: var(--green-hover); color: var(--green-ink); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); color: var(--text); }
.btn-block { width: 100%; }
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 40px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost svg { flex: none; }
.btn-ghost.copied { color: var(--green); border-color: rgba(62, 207, 142, 0.5); }

/* --- console bezel ---------------------------------------------------- */
.console {
  position: relative;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-console);
  padding: 10px;
  box-shadow: var(--shadow-console);
}
.console-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 4px;
  border-bottom: 1px solid var(--border);
}
.console-status { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; flex: none; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(62, 207, 142, 0.8);
  display: inline-block;
}
.status-dot.idle { background: transparent; border: 1.5px solid var(--green); box-shadow: none; }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 6px rgba(242, 184, 75, 0.7); }
.console-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.console-prompt .prompt { display: flex; align-items: center; min-width: 0; }
.console-prompt .prompt span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor {
  display: inline-block;
  width: 8px; height: 15px;
  background: var(--green);
  margin-left: 6px;
  border-radius: 1px;
  flex: none;
}
.console-screen {
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--radius-screen);
  padding: 22px 24px;
}
.console-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 2px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* --- tab strip -------------------------------------------------------- */
.tabs {
  display: flex;
  padding-right: 8px;
  align-items: flex-end;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  min-width: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 12px 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
  min-height: 44px;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab:active { opacity: 0.7; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--green); }
.tab:focus-visible { outline-offset: -2px; }

/* --- form fields ------------------------------------------------------ */
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  padding: 8px 12px;
  min-height: 48px;
  transition: border-color 0.15s ease;
}
.field:focus-within { border-color: var(--green); }
.field.invalid { border-color: var(--red); }
.field-label { font-size: 15px; color: var(--muted); line-height: 1.3; }
.field-label small { display: block; font-family: var(--mono); font-size: 12px; color: var(--faint); margin-top: 3px; }
.field-input { display: flex; align-items: center; gap: 4px; flex: none; }
.field-input .affix { font-family: var(--mono); font-size: 15px; color: var(--faint); }
.field input {
  width: 118px;
  background: transparent;
  border: 0;
  padding: 4px 0;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input:focus { outline: none; }
.field input::placeholder { color: var(--faint); }

.text-field {
  display: block;
  width: 100%;
  min-height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.text-field:focus { outline: none; border-color: var(--green); }
.text-field::placeholder { color: var(--faint); }
.text-field[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- badges ----------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 5px;
  padding: 7px 10px;
  line-height: 1;
  white-space: nowrap;
  color: var(--green);
  background: rgba(62, 207, 142, 0.1);
  border: 1px solid rgba(62, 207, 142, 0.4);
}
.badge.amber { color: var(--amber); background: rgba(242, 184, 75, 0.1); border-color: rgba(242, 184, 75, 0.45); }
.badge.red { color: var(--red); background: rgba(240, 102, 94, 0.1); border-color: rgba(240, 102, 94, 0.45); }
.badge.neutral { color: var(--muted); background: rgba(250, 250, 250, 0.04); border-color: var(--border); }

/* --- notices ---------------------------------------------------------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.notice svg { flex: none; margin-top: 2px; }
.notice.warn { border-color: rgba(242, 184, 75, 0.45); color: var(--text); }
.notice.error { border-color: rgba(240, 102, 94, 0.5); color: var(--text); }
.notice.ok { border-color: rgba(62, 207, 142, 0.45); color: var(--text); }
.notice[hidden] { display: none; }

/* --- footer ----------------------------------------------------------- */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 24px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
  background: var(--ground);
}
.footer-links { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.footer a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; transition: color 0.15s ease; }
.footer a:hover { color: var(--text); }
.footer a:active { opacity: 0.7; }
.footer a.accent { color: var(--green); }
.footer a.accent:hover { color: var(--green-hover); }

/* ===================================================================
   SIGN-IN / CALLBACK
   =================================================================== */
.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px var(--gutter) 64px;
  gap: 20px;
}
.auth-console { width: 100%; max-width: 480px; }
.auth-screen { display: flex; flex-direction: column; gap: 20px; }
.auth-screen h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.auth-screen p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label.label { margin-bottom: -2px; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-fine { max-width: 480px; text-align: center; font-size: 14px; color: var(--muted); line-height: 1.6; }
.auth-fine a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.auth-fine a:hover { color: var(--text); }
.auth-confirm { display: flex; flex-direction: column; gap: 14px; }
.auth-confirm .email-line {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  padding: 12px 14px;
  overflow-wrap: anywhere;
}
.link-btn {
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 44px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 14px;
  text-align: left;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.link-btn:hover { color: var(--green-hover); }
.link-btn:active { opacity: 0.7; }
.callback-line {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  padding: 32px 0;
  justify-content: center;
}

/* ===================================================================
   TERMINAL
   =================================================================== */
.terminal-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px var(--gutter) 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.terminal-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.terminal-intro h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.terminal-intro .kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.kicker-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--green); display: inline-block; }
.terminal-intro p { margin: 0; font-size: 16px; color: var(--muted); max-width: 420px; line-height: 1.6; }

.instrument {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 28px 32px;
}
.instrument[hidden] { display: none; }
.instrument-what {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
}
.instrument-what .label { flex: none; }
.block { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.block-head .mono { font-size: 13px; color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr; gap: 8px; }
.helper { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 4px 0 0; }
.helper strong { color: var(--text); font-weight: 500; }

.outputs { border-left: 1px solid var(--border); padding-left: 32px; gap: 20px; }
.big {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}
.big-label { font-size: 15px; color: var(--muted); }
.big-value { font-size: 44px; margin-top: 8px; display: block; }
.big-value.neg { color: var(--red); }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
}
.metrics.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  min-width: 0;
}
.metric-label { font-size: 14px; color: var(--muted); line-height: 1.35; }
.metric-label small { display: block; font-size: 12px; color: var(--faint); margin-top: 3px; line-height: 1.4; }
.metric-value { font-size: 22px; overflow-wrap: anywhere; margin-top: auto; }
.metric-value.neg { color: var(--red); }
.metric-value.dim { color: var(--faint); }
.subhead { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding-top: 6px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.table th, .table td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-weight: 500; color: var(--faint); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--surface); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.hl td { background: rgba(62, 207, 142, 0.06); color: var(--text); }
.table td.pos { color: var(--green); }
.table td.neg { color: var(--red); }
.table td.total { font-weight: 600; color: var(--text); }
.hint { font-family: var(--mono); font-size: 12px; color: var(--amber); line-height: 1.5; }
.hint[hidden] { display: none; }

.banner { margin-bottom: 4px; }
.share { display: flex; align-items: center; gap: 14px; min-width: 0; }
.share-help { font-size: 12px; color: var(--faint); line-height: 1.4; text-align: right; }

/* --- responsive ------------------------------------------------------- */
@media (max-width: 1080px) {
  :root { --gutter: 40px; }
  .instrument { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 24px; }
  .outputs { padding-left: 24px; }
}
@media (max-width: 860px) {
  .instrument { grid-template-columns: 1fr; gap: 24px; }
  .outputs { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 20px; }
}
@media (max-width: 640px) {
  :root { --gutter: 20px; }
  .topbar { height: 60px; }
  .brand { font-size: 16px; }
  .topbar-email { display: none; }
  .topbar-right { gap: 12px; }
  .auth-main { padding: 28px var(--gutter) 40px; }
  .console-screen { padding: 18px 16px; }
  .auth-screen h1 { font-size: 26px; }
  .terminal-main { padding: 24px var(--gutter) 48px; gap: 16px; }
  .terminal-intro h1 { font-size: 28px; }
  .big-value { font-size: 34px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 20px; }
  .field { padding: 8px 12px; }
  .field-label { font-size: 15px; }
  .field input { width: 104px; }
  .console-prompt > span:last-child { display: none; }
  .auth-console .console-prompt { flex-wrap: wrap; row-gap: 8px; }
  .auth-console .console-status { padding-bottom: 0; }
  .console-foot { flex-wrap: wrap; }
  .terminal-main .console-foot { flex-direction: column; align-items: stretch; gap: 12px; padding-top: 12px; }
  .share { flex-direction: column; align-items: stretch; gap: 8px; }
  .share-help { text-align: left; }
  .btn-ghost { min-height: 44px; }
  .instrument-what { font-size: 16px; padding-bottom: 14px; }
  .terminal-main .console-status { display: none; }
  .terminal-main .console-head { padding-right: 4px; }
  .terminal-main .tabs { width: 100%; padding-right: 0; }
  .terminal-main .tab { flex: 1 1 0; padding: 10px 6px 12px; font-size: 12px; white-space: normal; text-align: center; line-height: 1.25; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 9px 10px; }
  .table th { white-space: normal; line-height: 1.3; vertical-align: bottom; }
  .instrument { gap: 20px; }
  .outputs { gap: 16px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .footer-links { gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
