/* Swivel console — design system.
   A control plane for regulated automation should read like an instrument, not
   a dashboard: dense, quiet, monospaced where identity matters, and unambiguous
   about state. Nothing here is decorative. */

:root {
  --bg:        #080A0E;
  --surface:   #0F131A;
  --surface-2: #151A23;
  --border:    #1F2733;
  --border-2:  #2A3341;
  --text:      #E7ECF3;
  --muted:     #8794A8;
  --faint:     #5A6577;

  --accent:    #5EEAD4;
  --accent-dim:#1F4B47;
  --ok:        #3DD68C;
  --warn:      #F5B942;
  --danger:    #FF6B6B;
  --info:      #6BA8FF;
  --violet:    #B98CFF;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;

  --r: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 13px; }
p { margin: 0 0 10px; }

/* ── layout ───────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px; }
.brand .mark { color: var(--accent); font-size: 19px; line-height: 1; }
.brand .name { font-weight: 650; letter-spacing: .04em; font-size: 13px; }
.brand .tag { color: var(--faint); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 6px; color: var(--muted); cursor: pointer;
  font-size: 13px; border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border-color: #2C6560; }
.nav-item .count { font-family: var(--mono); font-size: 11px; opacity: .8; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 4px; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--border); }

.main { padding: 22px 28px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.crumb { color: var(--faint); font-size: 12px; margin-bottom: 4px; }

/* ── primitives ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .grid.two, .grid.three { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap;
}
.pill.ok       { background: rgba(61,214,140,.12); color: var(--ok); border-color: rgba(61,214,140,.25); }
.pill.warn     { background: rgba(245,185,66,.12); color: var(--warn); border-color: rgba(245,185,66,.25); }
.pill.danger   { background: rgba(255,107,107,.12); color: var(--danger); border-color: rgba(255,107,107,.25); }
.pill.info     { background: rgba(107,168,255,.12); color: var(--info); border-color: rgba(107,168,255,.25); }
.pill.violet   { background: rgba(185,140,255,.12); color: var(--violet); border-color: rgba(185,140,255,.25); }
.pill.muted    { background: var(--surface-2); color: var(--muted); border-color: var(--border-2); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); font-family: inherit; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #1B222C; border-color: #384354; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05221F; font-weight: 600; }
.btn.primary:hover { background: #7BF0DD; }
.btn.danger { background: rgba(255,107,107,.1); border-color: rgba(255,107,107,.35); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }

input, select, textarea {
  background: var(--bg); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 6px; padding: 7px 10px; font-family: inherit; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }
label.field .hint { text-transform: none; letter-spacing: 0; color: var(--faint); font-size: 11px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--faint); font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--border);
}
td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }

.kv { display: grid; grid-template-columns: 148px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; }

.meter { height: 4px; border-radius: 3px; background: var(--border); overflow: hidden; width: 70px; display: inline-block; vertical-align: middle; }
.meter > span { display: block; height: 100%; background: var(--ok); }
.meter.low > span { background: var(--warn); }
.meter.bad > span { background: var(--danger); }

.empty { color: var(--faint); text-align: center; padding: 42px 12px; font-size: 13px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12px; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── steps / flow ─────────────────────────────────────────────────────────── */
.step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; }
.step .n { font-family: var(--mono); color: var(--faint); font-size: 12px; text-align: right; padding-top: 1px; }
.step .intent { font-size: 13.5px; }
.step .detail { color: var(--faint); font-size: 12px; margin-top: 3px; font-family: var(--mono); }
.step .check { color: var(--ok); font-size: 12px; margin-top: 3px; }

/* ── evidence timeline ────────────────────────────────────────────────────── */
.timeline { font-family: var(--mono); font-size: 12px; }
.tl-row { display: grid; grid-template-columns: 52px 168px 1fr; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(31,39,51,.5); }
.tl-row:hover { background: var(--surface-2); }
.tl-seq { color: var(--faint); }
.tl-kind { color: var(--muted); }
.tl-msg { color: var(--text); word-break: break-word; }
.tl-row.err .tl-kind, .tl-row.err .tl-msg { color: var(--danger); }
.tl-row.sig .tl-kind { color: var(--warn); }
.tl-row.rec .tl-kind { color: var(--violet); }
.tl-row.esc .tl-kind { color: var(--warn); }
.tl-row.model .tl-kind { color: var(--accent); }

/* ── live operator view ───────────────────────────────────────────────────── */
.live-wrap { background: #000; border: 1px solid var(--border-2); border-radius: var(--r); overflow: hidden; position: relative; }
.live-wrap img { display: block; width: 100%; height: auto; cursor: crosshair; }
.live-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.live-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 13px; background: repeating-linear-gradient(45deg, #0b0d12, #0b0d12 10px, #0e1118 10px, #0e1118 20px); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,214,140,.18); animation: pulse 2s infinite; }
.dot.idle { background: var(--faint); }
.dot.err { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

.action-log { max-height: 260px; overflow-y: auto; font-family: var(--mono); font-size: 12px; }
.action-log div { padding: 3px 0; border-bottom: 1px solid rgba(31,39,51,.5); color: var(--muted); }

/* ── login ────────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; padding-bottom: 26px; flex-direction: column; gap: 6px; text-align: center; }
.login .brand .mark { font-size: 30px; }
.login .hint { margin-top: 14px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; color: var(--muted); }
.err-box { background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.3); color: var(--danger); padding: 9px 11px; border-radius: 6px; font-size: 12.5px; margin-bottom: 12px; }
.ok-box { background: rgba(61,214,140,.1); border: 1px solid rgba(61,214,140,.3); color: var(--ok); padding: 9px 11px; border-radius: 6px; font-size: 12.5px; margin-bottom: 12px; }

pre.json {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; overflow: auto; font-family: var(--mono); font-size: 12px;
  color: #BCC7D6; max-height: 420px;
  /* A failure's `observed` field is a sentence, not a token, and it is the most
     useful line on this page. Wrapping keeps it inside the card instead of
     pushing the layout sideways. */
  white-space: pre-wrap; word-break: break-word;
}
/* The definition list this sits in must not be widened by its own content. */
dl.kv { min-width: 0; }
dl.kv dd { min-width: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 7px 13px; color: var(--muted); cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 50; max-width: 420px;
  background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px;
}
.toast.err { border-left-color: var(--danger); }

/* Guided demo and a usable layout from phone to desktop. */
:root { --faint: #8793a5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, [tabindex] { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.main, .card, .grid > *, .execution-panel { min-width: 0; }
.card { overflow-x: auto; }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; }
.tabs { overflow-x: auto; }
.btn.large { min-height: 48px; padding: 12px 20px; font-size: 14px; gap: 22px; }
.eyebrow, .section-kicker { font: 10px var(--mono); letter-spacing: .13em; color: var(--muted); display:flex; align-items:center; gap:10px; }
.wordmark { font-size: 20px; font-weight: 700; letter-spacing: .13em; color: var(--text); }
.welcome { min-height:100vh; max-width:1440px; margin:auto; padding:36px 64px; background:radial-gradient(ellipse at 85% 40%, #16342d55, transparent 55%); display:flex; flex-direction:column; }
.welcome-nav, .welcome-footer { display:flex; justify-content:space-between; align-items:center; gap:20px; }
.welcome-nav > a:last-child { color:var(--muted); font-size:13px; }
.welcome-grid { flex:1; display:grid; grid-template-columns:1.1fr 1fr; align-items:center; gap:70px; padding:90px 0; }
.welcome h1 { font-size:clamp(40px,4.8vw,68px); letter-spacing:-.06em; line-height:1.06; margin:28px 0; font-weight:600; }
.welcome h1 span { color:var(--accent); }
.lead { color:#a8b5c5; font-size:17px; line-height:1.75; max-width:530px; margin-bottom:30px; }
.welcome-diagram { border:1px solid #2b4540; background:linear-gradient(140deg,#14201e,#10151c); border-radius:18px; padding:30px; box-shadow:0 24px 80px #0005; }
.diagram-label { color:var(--muted); font:10px var(--mono); letter-spacing:.12em; margin-bottom:28px; }
.diagram-step { display:grid; grid-template-columns:34px 1fr; gap:14px; padding:22px 0; border-bottom:1px solid #273b36; }
.diagram-number { color:var(--accent); font:13px var(--mono); padding-top:3px; }
.diagram-step h2 { font-size:18px; }
.diagram-step p { font-size:13px; color:#a8b5c5; margin:5px 0 0; }
.diagram-step .pill { grid-column:2; justify-self:start; }
.diagram-foot { font-size:12px; color:var(--muted); padding-top:22px; }
.welcome-footer { border-top:1px solid var(--border); padding:24px 0 0; font-size:12px; color:var(--muted); }
.demo-page { max-width:1100px; margin:auto; }
.demo-topline { display:flex; justify-content:space-between; gap:16px; margin:4px 0 28px; }
.demo-heading h1 { font-size:clamp(28px,3vw,40px); letter-spacing:-.04em; font-weight:550; }
.demo-heading p { color:#a6b2c2; font-size:14px; margin:12px 0 26px; max-width:670px; }
.journey { display:grid; grid-template-columns:repeat(3,1fr); gap:22px; margin-bottom:32px; border-top:1px solid var(--border); border-bottom:1px solid var(--border); padding:24px 0 16px; }
.journey > div { position:relative; padding-left:34px; }
.journey-number { position:absolute; left:0; color:var(--accent); font:11px var(--mono); top:3px; }
.journey h3 { font-size:13px; font-weight:500; }
.journey p { color:var(--muted); font-size:12px; margin-top:5px; }
.demo-layout { display:grid; grid-template-columns:290px 1fr; gap:18px; align-items:start; }
.demo-layout .card { margin:0; padding:24px; border-radius:12px; }
.scenario-panel .section-kicker { margin-bottom:20px; }
.scenario { display:flex; align-items:center; justify-content:space-between; width:100%; color:var(--muted); text-align:left; border:1px solid transparent; border-radius:8px; padding:13px 12px; background:transparent; margin:3px 0; cursor:pointer; }
.scenario strong { display:block; font-size:13px; font-weight:500; color:var(--text); }
.scenario small { display:block; font-size:11px; margin-top:4px; }
.scenario.selected { background:#162c29; border-color:#315b53; color:#82cabe; }
.scenario:hover:not(:disabled) { background:var(--surface-2); }
.scenario-arrow { font-size:18px; }
.execution-panel > h2 { font-size:22px; letter-spacing:-.02em; margin-top:22px; }
.request-preview { background:#090e13; border:1px solid var(--border); border-radius:8px; display:grid; grid-template-columns:140px 1fr; gap:16px; padding:20px; margin:24px 0; font-size:12px; overflow-wrap:anywhere; }
.request-preview > span { font:9px var(--mono); letter-spacing:.07em; color:var(--muted); padding-top:3px; }
.request-preview strong { font-weight:450; }
.result-box { border-top:1px solid var(--border-2); padding-top:20px; margin-top:25px; }
.balance-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin:20px 0; }
.balance-grid span { display:block; text-transform:capitalize; color:var(--muted); font-size:12px; }
.balance-grid strong { display:block; font:24px var(--mono); letter-spacing:-.05em; color:var(--accent); margin-top:6px; }
.evidence-link { font-size:12px; }
.activity-card { margin-top:20px!important; padding:24px; border-radius:12px; }
.activity-empty { display:flex; align-items:center; gap:18px; padding:20px 0 12px; color:var(--muted); }
.activity-empty > span { font-size:34px; color:#59756e; }
.activity-empty strong { font-size:13px; font-weight:450; color:var(--text); }
.activity-empty p { font-size:12px; margin:4px 0; }
.demo-events > div { display:grid; grid-template-columns:10px 150px 1fr; gap:12px; padding:9px 0; font-size:12px; border-bottom:1px solid var(--border); }
.demo-events code { color:var(--accent); font-size:10px; padding-top:2px; }
.demo-events > div > span:last-child { color:#acb8c8; overflow-wrap:anywhere; }
.event-dot { width:5px; height:5px; border-radius:50%; background:var(--accent); margin-top:7px; }
.demo-footer-links { display:flex; justify-content:space-between; gap:16px; flex-wrap:wrap; margin:22px 0; font-size:11px; }
.demo-footer-links a { color:var(--muted); }
.handoff-callout { background:#282114; border:1px solid #665027; border-radius:8px; padding:18px; margin-top:20px; }
.handoff-callout p { font-size:12px; color:var(--muted); margin:8px 0 14px; }
@media (min-width:1001px) { .main { width:100%; max-width:1400px; padding:30px 38px 60px; } }
@media (max-width:1100px) { .demo-layout { grid-template-columns:240px 1fr; } .demo-layout .card { padding:18px; } .request-preview { grid-template-columns:1fr; gap:7px; } .request-preview > span:not(:first-child) { margin-top:9px; } }
@media (max-width:1000px) { .sidebar { display:flex; flex-direction:row; flex-wrap:wrap; align-items:center; padding:14px 18px; border-bottom:1px solid var(--border); } .sidebar .brand { padding:5px 18px 5px 0; } .sidebar .brand .tag, .sidebar .nav-sep, .sidebar-foot .small { display:none; } .sidebar-foot { margin:0 0 0 auto; border:0; padding:0; } .sidebar-foot .btn { margin:0; } .nav-item { padding:9px; } .welcome { padding:28px; } .welcome-grid { gap:35px; } }
@media (max-width:700px) { .main { padding:24px 16px 40px; } .demo-layout, .welcome-grid { grid-template-columns:1fr; } .welcome-grid { padding:60px 0; } .welcome-diagram { padding:22px; } .welcome-footer { align-items:flex-start; flex-direction:column; } .journey { gap:15px; grid-template-columns:1fr; padding-bottom:10px; } .journey p { margin-bottom:6px; } .scenario-panel { display:grid; grid-template-columns:1fr 1fr; gap:3px; } .scenario-panel .section-kicker { grid-column:1/-1; margin-bottom:10px; } .scenario { padding:10px 8px; } .scenario strong { font-size:12px; } .scenario-arrow { display:none; } .demo-events > div { grid-template-columns:8px 1fr; } .demo-events > div > span:last-child { grid-column:2; } .demo-events code { font-size:11px; } .demo-topline { margin-bottom:22px; } .demo-topline .eyebrow { font-size:9px; } .sidebar { gap:1px; padding:12px; } .sidebar .brand { width:100%; padding-bottom:12px; } .sidebar-foot { margin-left:auto; } .nav-item { font-size:11px; padding:8px; } .nav-item .count { display:none; } .balance-grid strong { font-size:22px; } .page-head { flex-wrap:wrap; } .kv { grid-template-columns:1fr; gap:4px; } .kv dd { margin-bottom:8px; } .tl-row { grid-template-columns:28px 1fr; } .tl-msg { grid-column:2; } .toast { left:16px; right:16px; max-width:none; } .btn { min-height:40px; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; } }
