/* Altoria Cockpit — main stylesheet.
 *
 * Tokens (altoria-tokens.css) are linked from base.html BEFORE this file.
 * Every color / font / radius / spacing reference resolves to --aco-*,
 * --af-*, --ar-*, --as-*, --asd-* variables defined there.
 * Hardcoded literals are bugs (with the documented exceptions: orb
 * gradient colors and danger-button hover tint).
 */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--aco-bg);
  color: var(--aco-text);
  font-family: var(--af-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Ambient backdrop — soft floating green orbs ──────────────────────
 * Three blurred radial gradients animate slowly behind everything. Pure
 * decorative; pointer-events: none so they never interfere with layout.
 */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ambient .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.32;
  mix-blend-mode: screen;
  will-change: transform;
}
.ambient .orb.a {
  width: 720px; height: 720px;
  background: radial-gradient(circle, #1F8F63, transparent 65%);
  top: -220px; left: -200px;
  animation: float-a 38s ease-in-out infinite;
}
.ambient .orb.b {
  width: 620px; height: 620px;
  background: radial-gradient(circle, #0C5B3C, transparent 65%);
  top: 30%; right: -240px;
  animation: float-b 44s ease-in-out infinite;
}
.ambient .orb.c {
  width: 560px; height: 560px;
  background: radial-gradient(circle, #29B87F, transparent 65%);
  bottom: -240px; left: 30%;
  opacity: 0.18;
  animation: float-c 52s ease-in-out infinite;
}
@keyframes float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(60px, 40px) scale(1.05); }
  66%      { transform: translate(-30px, 80px) scale(0.97); }
}
@keyframes float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-90px, 70px) scale(1.06); }
}
@keyframes float-c {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(50px, -70px) scale(1.04); }
}

/* Subtle grain overlay — adds texture, prevents the dark-on-dark
 * looking too sterile. SVG noise filter; fixed positioning. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.30;
  z-index: 1;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* All real content sits above the backdrop */
.topbar, .content, .footer, header, main, footer { position: relative; z-index: 2; }

/* ── Topbar — sticky pill-shaped glass bar ──────────────────────────── */
.topbar {
  position: sticky;
  top: var(--as-3);
  z-index: 50;
  margin: var(--as-3) auto 0;
  max-width: calc(var(--maxw) + 28px);
  padding: 0 var(--as-3);
}
.topbar-shell {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--as-6);
  padding: var(--as-3) var(--as-5);
  border-radius: var(--ar-pill);
  background: var(--aco-glass-strong);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--aco-glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 50px rgba(0, 0, 0, 0.45);
}

/* Logo block */
.brand {
  display: flex;
  align-items: center;
  gap: var(--as-2);
  flex: none;
}
/* Real-logo image. Mirrors the partner site's `.brand-logo img` rule
 * (height-only sizing + soft emerald drop-shadow), so the cockpit and
 * altoria.hr feel like the same product visually. */
.brand-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 10px rgba(41, 184, 127, 0.25));
}
/* Legacy fallback — keeps the old inline-SVG path working for any old
 * page that still references .brand-mark; harmless for new image logo. */
.brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 10px rgba(41, 184, 127, 0.25));
}
.brand-mark path { fill: var(--aco-green); }
.logo-word {
  font-family: var(--af-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: var(--af-tight);
  color: var(--aco-text);
}
.logo-sub {
  display: none;  /* hidden on tight nav layouts; visible if needed */
  font-family: var(--af-body);
  color: var(--aco-text-mute2);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Nav links inside the pill */
.nav {
  display: flex;
  gap: var(--as-3);
  flex-wrap: wrap;
  justify-content: center;
}
.nav a {
  position: relative;
  color: var(--aco-text-muted);
  text-decoration: none;
  padding: var(--as-2) 0;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--af-body);
  letter-spacing: 0.01em;
  transition: color var(--transition-fast);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--aco-green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-medium);
}
.nav a:hover { color: var(--aco-text); }
.nav a:hover::after { transform: scaleX(1); }

/* Active link — solid green underline + brighter text. Marks the
   user's current page so the topbar always tells them where they are.
   The `.active` class is set in base.html by matching request.url.path
   against the link href. */
.nav a.active {
  color: var(--aco-text);
  font-weight: 600;
}
.nav a.active::after {
  transform: scaleX(1);
  height: 2px;
  background: linear-gradient(90deg, var(--aco-green-light), var(--aco-green));
  box-shadow: 0 0 8px rgba(41, 184, 127, 0.45);
}

.env { display: flex; gap: var(--as-2); align-items: center; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--ar-pill);
  font-size: 11px;
  font-family: var(--af-mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--aco-glass-border);
  color: var(--aco-text-muted);
  letter-spacing: 0.03em;
}
.pill.ok { color: var(--aco-green-light); border-color: rgba(41, 184, 127, 0.40); }
.pill.warn { color: var(--aco-warn); border-color: var(--aco-warn-border); }
.pill.err { color: var(--aco-err); border-color: var(--aco-err-border); }

/* ── Language toggle ──────────────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-pill);
  padding: 2px;
  gap: 0;
  font-family: var(--af-mono);
}
.lang-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--ar-pill);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--aco-text-mute2);
  transition: all var(--transition-fast);
}
.lang-pill:hover { color: var(--aco-text); background: rgba(41, 184, 127, 0.08); }
.lang-pill.active {
  color: var(--aco-text-on-green);
  background: var(--aco-green);
  font-weight: 600;
}

/* ── Content container ─────────────────────────────────────────────── */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--as-8) var(--as-6) var(--as-12);
}

/* ── Typography ────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--af-display);
  font-weight: 600;
  letter-spacing: var(--af-tight);
  line-height: 1.12;
  margin: 0;
  color: var(--aco-text);
}
h1 {
  font-size: 28px;
  margin: 0 0 var(--as-1);
  letter-spacing: var(--af-tighter);
}
h2 { font-size: 18px; margin: var(--as-8) 0 var(--as-3); }
h3 {
  font-size: 13px;
  margin: var(--as-5) 0 var(--as-3);
  color: var(--aco-green-light);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 600;
}
.subtitle {
  color: var(--aco-text-muted);
  margin: 0 0 var(--as-8);
  font-size: 14px;
  line-height: 1.65;
}

/* Eyebrow label — tiny uppercase callout above section headings */
.eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--aco-green-light);
  font-weight: 600;
  margin-bottom: var(--as-3);
}

/* Gradient text — for hero / accent words inside h1 */
.grad {
  background: linear-gradient(120deg, var(--aco-green) 0%, var(--aco-green-light) 60%, var(--aco-text) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

a { color: var(--aco-green-light); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--aco-green); }

p { margin: 0 0 var(--as-3); line-height: 1.65; }

/* ── Grids ─────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--as-4); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

/* ── Glass card — primary content surface ─────────────────────────── */
.card {
  background: var(--aco-glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-lg);
  padding: var(--as-5) var(--as-5);
  box-shadow: var(--asd-card);
  transition: all var(--transition-medium);
}
.card.elevated { box-shadow: var(--asd-card-lg); }
.card.hoverable:hover {
  transform: translateY(-2px);
  border-color: var(--aco-green);
  box-shadow: var(--asd-hover);
}
.card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--aco-text-mute2);
  margin-bottom: var(--as-1);
  font-family: var(--af-body);
}
.card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--aco-text);
  font-family: var(--af-display);
  letter-spacing: var(--af-tighter);
}
.card .value.mint, .card .value.green { color: var(--aco-green-light); }
.card .hint { font-size: 12px; color: var(--aco-text-mute2); margin-top: var(--as-1); }

/* ── Tables ────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: var(--as-3) var(--as-4);
  border-bottom: 1px solid var(--aco-line);
}
th {
  font-weight: 500;
  color: var(--aco-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--af-body);
}
tbody tr:hover { background: rgba(41, 184, 127, 0.04); }
td.num, th.num { text-align: right; font-family: var(--af-mono); }
.code, code {
  font-family: var(--af-mono);
  font-size: 12px;
  color: var(--aco-text-muted);
}

/* ── Status badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--ar-pill);
  font-size: 11px;
  font-family: var(--af-mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--aco-glass-border);
  color: var(--aco-text-muted);
  letter-spacing: 0.04em;
}
.badge.posted { color: var(--aco-green-light); border-color: rgba(41, 184, 127, 0.40); background: rgba(41, 184, 127, 0.08); }
.badge.pending_review { color: var(--aco-warn); border-color: var(--aco-warn-border); background: var(--aco-warn-bg); }
.badge.reversed { color: var(--aco-text-mute2); border-color: var(--aco-line-strong); }
.badge.matched { color: var(--aco-green-light); border-color: rgba(41, 184, 127, 0.40); }
.badge.danger, .badge.err { color: var(--aco-err); border-color: var(--aco-err-border); background: var(--aco-err-bg); }

/* ── Buttons — pill-shaped per partner brand ──────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--as-2);
  padding: 11px 22px;
  border-radius: var(--ar-pill);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--af-body);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  background: var(--aco-green);
  color: var(--aco-text-on-green);
  box-shadow: 0 6px 18px rgba(41, 184, 127, 0.18);
  transition: all var(--transition-medium);
}
.btn:hover {
  background: var(--aco-green-light);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(41, 184, 127, 0.28);
}
.btn.primary { /* alias of default */ }
.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--aco-glass-border);
  color: var(--aco-text);
  box-shadow: none;
}
.btn.ghost:hover {
  background: rgba(41, 184, 127, 0.08);
  border-color: var(--aco-green);
  color: var(--aco-green-light);
  transform: none;
  box-shadow: none;
}
.btn.danger { background: var(--aco-err); color: #fff; box-shadow: 0 6px 18px rgba(255, 107, 107, 0.18); }
.btn.danger:hover { background: #ff8585; box-shadow: 0 10px 26px rgba(255, 107, 107, 0.28); }
.btn.sm { padding: 6px 14px; font-size: 11px; }
.btn .arrow { transition: transform var(--transition-fast); }
.btn:hover .arrow { transform: translateX(4px); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Forms ──────────────────────────────────────────────────────── */
input[type=text], input[type=date], input[type=email], input[type=password],
input[type=number], input[type=file], select, textarea {
  background: rgba(255, 255, 255, 0.04);
  color: var(--aco-text);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--af-body);
  width: 100%;
  transition: all var(--transition-fast);
}
input[type=text]:focus, input[type=date]:focus, input[type=email]:focus,
input[type=password]:focus, input[type=number]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--aco-green);
  box-shadow: 0 0 0 3px rgba(41, 184, 127, 0.15);
  background: rgba(255, 255, 255, 0.06);
}
label {
  display: block;
  font-size: 12px;
  color: var(--aco-text-muted);
  margin-bottom: var(--as-2);
  font-family: var(--af-body);
}
.form-row { margin-bottom: var(--as-4); }
.form-row.inline { display: flex; gap: var(--as-3); align-items: end; }

/* ── Flash banners ──────────────────────────────────────────────── */
.flash {
  padding: var(--as-3) var(--as-4);
  border-radius: var(--ar-sm);
  margin-bottom: var(--as-5);
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid var(--aco-glass-border);
  background: var(--aco-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.flash.ok    { background: rgba(41, 184, 127, 0.08); border-color: rgba(41, 184, 127, 0.40); color: var(--aco-green-light); }
.flash.info  { background: var(--aco-info-bg); border-color: rgba(159, 245, 205, 0.30); color: var(--aco-info); }
.flash.warn  { background: var(--aco-warn-bg); border-color: var(--aco-warn-border); color: var(--aco-warn); }
.flash.err   { background: var(--aco-err-bg); border-color: var(--aco-err-border); color: var(--aco-err); }
.flash strong { color: inherit; font-weight: 700; }
.flash a { color: inherit; text-decoration: underline; }

/* ── Footer ──────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--aco-glass-border);
  padding: var(--as-3) var(--as-6);
  display: flex; justify-content: space-between;
  gap: var(--as-6); flex-wrap: wrap;
  font-size: 11px;
  color: var(--aco-text-mute2);
  font-family: var(--af-mono);
  background: rgba(15, 22, 18, 0.50);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ── Section heading row ────────────────────────────────────────── */
.section-title {
  display: flex; align-items: center; gap: var(--as-3);
  margin: var(--as-6) 0 var(--as-3);
}
.section-title h2 { margin: 0; }
.section-title .meta { color: var(--aco-text-mute2); font-size: 12px; font-family: var(--af-mono); }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--as-2); margin-bottom: var(--as-4); flex-wrap: wrap; }
.tabs a {
  padding: var(--as-2) var(--as-4);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-pill);
  text-decoration: none;
  color: var(--aco-text-muted);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  transition: all var(--transition-fast);
}
.tabs a:hover { color: var(--aco-text); border-color: rgba(41, 184, 127, 0.40); }
.tabs a.active {
  color: var(--aco-text-on-green);
  border-color: var(--aco-green);
  background: var(--aco-green);
  font-weight: 600;
}

/* ── Key-value grid ─────────────────────────────────────────────── */
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--as-2) var(--as-4);
  font-size: 13px;
}
.kv .k { color: var(--aco-text-muted); }
.kv .v { color: var(--aco-text); font-family: var(--af-mono); }

/* ── Ask renderer (markdown answer pane) ─────────────────────────── */
.ask-answer {
  background: var(--aco-glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-lg);
  padding: var(--as-6) var(--as-6);
  margin-top: var(--as-5);
  line-height: 1.65;
  box-shadow: var(--asd-card);
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--aco-text);
  margin-top: var(--as-6);
  margin-bottom: var(--as-2);
  font-family: var(--af-display);
}
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 17px; color: var(--aco-green-light); }
.markdown-body h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--aco-text-muted);
}
.markdown-body p { margin: var(--as-2) 0 var(--as-3); }
.markdown-body p:first-child { margin-top: 0; }
.markdown-body ul, .markdown-body ol { padding-left: 24px; margin: var(--as-2) 0; }
.markdown-body li { margin: var(--as-1) 0; }
.markdown-body code {
  font-family: var(--af-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.markdown-body hr { border: 0; border-top: 1px solid var(--aco-line); margin: var(--as-5) 0; }
.markdown-body em { color: var(--aco-text-mute2); font-style: italic; }
.markdown-body a { color: var(--aco-green-light); }

.markdown-body table {
  border-collapse: collapse;
  margin: var(--as-4) 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-sm);
  overflow: hidden;
  font-size: 13px;
  width: auto;
  min-width: 60%;
}
.markdown-body thead { background: rgba(41, 184, 127, 0.08); }
.markdown-body th {
  text-align: left;
  padding: var(--as-2) var(--as-4);
  border-bottom: 1px solid var(--aco-line);
  color: var(--aco-green-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.markdown-body td {
  padding: var(--as-2) var(--as-4);
  border-bottom: 1px solid var(--aco-line);
  vertical-align: top;
}
.markdown-body tbody tr:last-child td { border-bottom: 0; }
.markdown-body tbody tr:hover { background: rgba(41, 184, 127, 0.04); }
.markdown-body th[align="right"], .markdown-body td[align="right"] {
  text-align: right;
  font-family: var(--af-mono);
}
.markdown-body strong { color: var(--aco-green-light); font-weight: 600; }

.citations { margin-top: var(--as-5); }
.citations li { margin-bottom: var(--as-2); font-size: 13px; }

/* ── Ask loader ──────────────────────────────────────────────────── */
.ask-loader {
  background: var(--aco-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-lg);
  padding: var(--as-4) var(--as-5);
  margin: var(--as-3) 0 var(--as-5);
}
.ask-loader-row { display: flex; align-items: center; gap: var(--as-4); }
.ask-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--aco-line-strong);
  border-top-color: var(--aco-green);
  border-radius: 50%;
  animation: ask-spin 800ms linear infinite;
  flex-shrink: 0;
}
@keyframes ask-spin { to { transform: rotate(360deg); } }
.ask-loader-text { display: flex; flex-direction: column; gap: 2px; }
.ask-loader-stage { font-size: 14px; color: var(--aco-text); font-weight: 500; }
.ask-loader-meta { font-size: 12px; color: var(--aco-text-mute2); font-family: var(--af-mono); }
.ask-loader-progress {
  margin-top: var(--as-2);
  font-size: 12px; color: var(--aco-text-mute2);
  font-family: var(--af-mono);
}

/* ── JE side-by-side review ──────────────────────────────────────── */
.review-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--as-5);
  flex-wrap: wrap;
  margin: -12px 0 var(--as-4);
  padding-bottom: var(--as-3);
  border-bottom: 1px solid var(--aco-glass-border);
}
.review-title { display: flex; flex-direction: column; gap: var(--as-1); }
.review-presets { display: flex; gap: var(--as-2); flex-wrap: wrap; }

.review-split {
  display: grid;
  grid-template-columns: 50% 6px 50%;
  height: calc(100vh - 220px);
  min-height: 480px;
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-lg);
  overflow: hidden;
  background: var(--aco-bg-2);
}
.review-pane { overflow: hidden; display: flex; background: var(--aco-bg-2); }
.review-pane-left { background: #ffffff; }     /* white for PDF readability */
.review-pane-right { background: var(--aco-bg-2); overflow-y: auto; }
.review-pane-inner { padding: var(--as-5) var(--as-5); width: 100%; box-sizing: border-box; }

.review-doc-shell {
  width: 100%;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.review-doc-tools {
  min-height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  box-sizing: border-box;
  overflow-x: auto;
  background: #323433;
  color: #f5f7f5;
  border-bottom: 1px solid rgba(0,0,0,0.35);
}
.review-doc-tool-group { display: inline-flex; align-items: center; gap: 6px; }
.review-doc-tool-spacer { flex: 1 1 auto; min-width: 8px; }
.review-doc-tool,
a.review-doc-tool {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: #f5f7f5;
  font: 700 16px/1 var(--af-sans);
  text-decoration: none;
  cursor: pointer;
}
.review-doc-tool.wide {
  width: 54px;
  flex-basis: 54px;
  font-size: 12px;
  font-weight: 700;
}
.review-doc-tool:hover,
a.review-doc-tool:hover {
  background: rgba(132, 216, 184, 0.18);
  border-color: rgba(132, 216, 184, 0.45);
}
.review-doc-tool:focus-visible {
  outline: 2px solid var(--aco-green);
  outline-offset: 2px;
}
.review-doc-tool:disabled {
  opacity: 0.55;
  cursor: progress;
}
.review-doc-zoom {
  min-width: 46px;
  text-align: center;
  color: rgba(245,247,245,0.86);
  font: 700 12px/1 var(--af-mono);
}
.review-doc-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #fff;
}
.review-doc-transform {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  transform-origin: top left;
  transition: transform var(--transition-fast);
}
.review-doc-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
  transform-origin: top left;
}
.review-empty {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  background: var(--aco-bg-2);
}

.review-divider {
  background: var(--aco-glass-border);
  cursor: col-resize;
  position: relative;
  transition: background var(--transition-fast);
}
.review-divider:hover { background: var(--aco-green-deep); }
.review-divider-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 40px;
  background: var(--aco-text-mute2);
  border-radius: 1px;
}

/* Review fullscreen mode */
body.review-fullscreen .topbar,
body.review-fullscreen .footer { display: none; }
body.review-fullscreen .content { max-width: 100%; padding: var(--as-3) var(--as-4); }
body.review-fullscreen .review-split { height: calc(100vh - 80px); }

.save-propose-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--aco-green-light);
  font-size: 13px;
  font-weight: 600;
}
.save-propose-status[hidden] { display: none; }
.save-propose-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--aco-green);
  box-shadow: 0 0 0 0 rgba(132, 216, 184, 0.68);
  animation: reprocess-dot-pulse 1.4s ease-in-out infinite;
}

/* ── Utilities ──────────────────────────────────────────────────── */
.muted { color: var(--aco-text-mute2); }
.right { text-align: right; }
.mono { font-family: var(--af-mono); }
.row { display: flex; gap: var(--as-4); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--as-2); }
hr.sep { border: 0; border-top: 1px solid var(--aco-glass-border); margin: var(--as-6) 0; }

/* ── Legacy cockpit mobile chrome ────────────────────────────────────
 *
 * The legacy topbar (base.html) was desktop-only. On phones the
 * 17-item nav wrapped vertically and looked like a list of bullets.
 * Below 768px we now hide the inline nav, show a hamburger that
 * opens a drawer with the same items in a clean vertical list.
 * Same pattern as Klijent's mobile drawer for muscle-memory parity.
 */

.legacy-mobile-hamburger,
.legacy-mobile-drawer,
.legacy-mobile-drawer-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .legacy-mobile-hamburger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 8px;
    margin-right: 4px;
  }
  .legacy-mobile-hamburger span {
    display: block;
    height: 2px;
    background: var(--aco-text);
    border-radius: 1px;
  }

  /* Hide the inline nav — replaced by the drawer */
  .topbar .nav { display: none; }

  /* Compact the topbar shell on mobile */
  .topbar { padding: 8px 6px; }
  .topbar-shell {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand-logo { height: 26px; }

  /* Hide the .env pills (api-key, tenant) on small screens — they're
   * still reachable via /settings. Lang toggle stays. */
  .topbar .env .pill { display: none; }
  .topbar .env .pill:last-child,
  .topbar .env .pill:nth-last-child(2) { display: inline-flex; }
}

/* Drawer for the legacy topbar — slides from left */
@media (max-width: 768px) {
  .legacy-mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 998;
    pointer-events: none;
    transition: background var(--transition-medium);
  }
  body.legacy-drawer-open .legacy-mobile-drawer-backdrop {
    background: rgba(0, 0, 0, 0.55);
    pointer-events: auto;
  }
  .legacy-mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 78%;
    max-width: 320px;
    background: var(--aco-bg-2);
    border-right: 1px solid var(--aco-glass-border);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform var(--transition-medium);
    padding-top: env(safe-area-inset-top);
  }
  body.legacy-drawer-open .legacy-mobile-drawer {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }
  .legacy-mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--as-3) var(--as-4);
    border-bottom: 1px solid var(--aco-glass-border);
  }
  .legacy-mobile-drawer-header img { height: 24px; width: auto; }
  .legacy-mobile-drawer-header button {
    background: transparent; border: 0;
    color: var(--aco-text); font-size: 24px; line-height: 1;
    cursor: pointer; width: 36px; height: 36px;
  }
  .legacy-mobile-drawer-nav {
    flex: 1; overflow-y: auto;
    padding: var(--as-3); display: flex;
    flex-direction: column; gap: 2px;
  }
  .legacy-mobile-drawer-nav a {
    padding: 12px 14px;
    font-size: 14px; font-weight: 500;
    color: var(--aco-text-muted);
    text-decoration: none;
    border-radius: var(--ar-md);
  }
  .legacy-mobile-drawer-nav a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--aco-text);
  }

  /* Mobile-friendly content padding on legacy pages */
  .content { padding: var(--as-3); }
}

/* Theme picker — 4-card grid in /settings · Display.
 * Each card has a swatch (the theme's body bg color) + a colored dot
 * (the theme's accent), so the operator sees what they're picking
 * before they click. Selected option highlighted with emerald border. */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--as-3);
  margin-top: var(--as-3);
}
@media (max-width: 700px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--aco-bg-2);
}
.theme-option:hover {
  border-color: rgba(41, 184, 127, 0.30);
  transform: translateY(-1px);
}
/* Active state — driven by :has(:checked) so it updates instantly when
 * the user clicks a card, before the form round-trip completes. Falls
 * back to the .active class for browsers without :has() support. */
.theme-option.active,
.theme-option:has(input:checked) {
  border-color: var(--aco-green);
  box-shadow: 0 0 0 3px rgba(41, 184, 127, 0.18);
}
.theme-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.theme-swatch {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.theme-swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}
.theme-label {
  font-size: 13px;
  font-weight: 500;
}

/* Back-to-portal breadcrumb — Sprint 2 polish.
 * Appears at the top of every legacy page for logged-in users so the
 * route home is always one click away. Glass pill, emerald hover.
 */
.back-breadcrumb {
  margin: var(--as-3) 0 var(--as-2);
}
.back-breadcrumb .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--aco-text-muted);
  text-decoration: none;
  background: var(--aco-glass);
  border: 1px solid var(--aco-glass-border);
  border-radius: var(--ar-pill);
  transition: all var(--transition-fast);
}
.back-breadcrumb .back-link:hover {
  color: var(--aco-text);
  border-color: rgba(41, 184, 127, 0.30);
  background: rgba(41, 184, 127, 0.08);
}

/* Reveal-on-scroll utility (paired with brand site for visual continuity).
 * Default state is hidden + shifted down a touch; .visible (set by the
 * IntersectionObserver in base.html) lifts and fades them in. The
 * @media query below skips the animation entirely for users who have
 * "reduce motion" enabled — they see content immediately, no delay. */
.reveal { opacity: 0; transform: translateY(12px); transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── AI Assistant chat bubble (floating bottom-right) ────────────────
 * Matches the green circle visible in the partner's mobile-app design.
 * Default link target is /ask (existing tax-legal Q&A); can be replaced
 * later with an inline chat panel without moving the bubble.
 */
.ai-bubble {
  position: fixed;
  bottom: var(--as-6);
  right: var(--as-6);
  z-index: 100;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aco-green) 0%, var(--aco-green-deep) 100%);
  border: 1px solid var(--aco-green);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    0 0 0 0 rgba(41, 184, 127, 0.55);
  transition: all var(--transition-medium);
  animation: ai-bubble-pulse 2.6s ease-out infinite;
}
.ai-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.45),
    0 0 30px rgba(41, 184, 127, 0.4);
  animation: none;
}
.ai-bubble svg { width: 26px; height: 26px; fill: var(--aco-text-on-green); }

@keyframes ai-bubble-pulse {
  0%   { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(41, 184, 127, 0.55); }
  60%  { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 14px rgba(41, 184, 127, 0); }
  100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(41, 184, 127, 0); }
}

@media (max-width: 800px) {
  .ai-bubble { bottom: var(--as-4); right: var(--as-4); width: 48px; height: 48px; }
  .ai-bubble svg { width: 22px; height: 22px; }
}

/* Phase 1 role/scope clarity — shared workspace and boundary notices. */
.workspace-banner,
.workspace-boundary-card {
  border: 1px solid rgba(132, 216, 184, 0.34);
  background: linear-gradient(135deg,
    rgba(132, 216, 184, 0.16),
    rgba(255, 255, 255, 0.035));
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.workspace-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  margin: 0 0 18px;
}

.workspace-banner-body {
  min-width: 0;
}

.workspace-banner-label,
.workspace-boundary-eyebrow {
  color: var(--aco-green, #84d8b8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-banner-title {
  display: block;
  color: var(--aco-text, #fff);
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

.workspace-banner-subtitle {
  color: var(--aco-text-muted, rgba(255, 255, 255, 0.68));
  font-size: 13px;
  line-height: 1.45;
  margin: 4px 0 0;
}

.workspace-banner-actions,
.workspace-boundary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace-banner-warning {
  border-color: rgba(255, 184, 77, 0.5);
  background: rgba(255, 184, 77, 0.12);
}

.workspace-boundary-card {
  max-width: 860px;
  padding: clamp(24px, 4vw, 42px);
  margin: var(--as-4, 24px) 0;
}

.workspace-boundary-card h1 {
  margin: 8px 0 12px;
}

.workspace-boundary-card p {
  color: var(--aco-text-muted, rgba(255, 255, 255, 0.72));
  font-size: 16px;
  line-height: 1.55;
  max-width: 760px;
}

.operator-role-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--as-4, 18px);
  margin: var(--as-4, 18px) 0;
}

.operator-role-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
}

.operator-role-card strong {
  font-size: 18px;
}

.operator-role-card p {
  color: var(--aco-text-muted, rgba(255, 255, 255, 0.68));
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

@media (max-width: 720px) {
  .workspace-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-banner-actions {
    justify-content: flex-start;
  }
}
