/* ============================================================
   SKA Competency Mapping Engine
   Brand restyle: dark ground, cream type, serif display (Newsreader),
   grotesk body (Schibsted Grotesk), mono eyebrow labels (IBM Plex
   Mono). Thin rules instead of boxes, tan accents, report motion.
   ============================================================ */
:root {
  color-scheme: dark; /* native controls (date picker, scrollbars) match; phones do not re-darken */

  /* Palette: dark ground, cream type, tan accents */
  --night: #16120e;
  --night-raised: #1e1915;
  --cream: #ece4d6;
  --tan: #a8977f;
  --tan-light: #c4b9a8;
  --accent-1: #b5a48c;
  --accent-2: #c2ad8f;

  /* Roles */
  --bg: var(--night);
  --surface: var(--night-raised);   /* brand bar, dialogs */
  --ink-strong: var(--cream);       /* headings, emphasis */
  --ink: #ddd4c4;                   /* body text */
  --ink-2: #b9ae9c;                 /* secondary text */
  --ink-3: #a3988a;                 /* strapline, quiet labels */
  --muted: #8a806f;
  --line: #2f2822;
  --line-strong: #463d33;
  --field: rgba(255, 255, 255, 0.04);
  --chip: #2c251f;
  --btn-bg: var(--cream);           /* primary buttons: cream on dark */
  --btn-bg-hover: #fffaf0;
  --btn-ink: #16120e;
  --on-tan: #16120e;
  --accent: var(--tan);
  --danger: #e08a72;
  --danger-fill: #b4533f;
  --danger-fill-hover: #c4604a;

  --radius: 4px;
  --ease: cubic-bezier(.22, .7, .2, 1);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Clear the sticky brand bar + nav when anything scrolls a title into view. */
html { scroll-padding-top: 150px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
button { font-family: inherit; }

/* ---------- Shared type primitives ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--tan);
  margin-bottom: 10px;
}
.page-title, .login-heading {
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(32px, 4.4vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
  margin: 0;
}
.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
  margin: 2px 0 16px;
}

/* Big numerals (counts, progress) */
.bignum { font-family: var(--serif); font-weight: 300; font-size: clamp(40px, 6vw, 56px); line-height: 1; color: var(--ink-strong); }
.bignum-suffix { font-family: var(--serif); font-weight: 300; font-size: 20px; color: var(--tan); margin-left: 8px; }

/* Large outlined numerals (empty states, batch steps) */
.outline-num {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 64px;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px var(--tan);
  text-stroke: 1px var(--tan);
}

/* ============================================================
   Kinetic reveal (word by word) + eyebrow fade
   ============================================================ */
/* Kinetic heading primitive, matched to the SKA site: words rise out of a hard
   clipped baseline (.kin-line mask) and counter-rotate 3.2deg, staggered, with
   an expo.out feel. */
.kin-line {
  display: inline-block; overflow: hidden; vertical-align: bottom;
  padding: 0.04em 0.04em 0.12em; margin: -0.04em -0.04em -0.12em;
}
/* Visible by default. The .kin-in animation (both-filled) holds the hidden start
   state only while it is pending/running; if it never runs (throttled compositor),
   a JS failsafe removes .kin-in and the word falls back to this visible base. */
.kin-word { display: inline-block; will-change: transform; }
.page-head .eyebrow[data-eyebrow], .login-card .eyebrow[data-eyebrow] { opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .kin-word.kin-in { animation: kinWord 1.05s cubic-bezier(0.19, 1, 0.22, 1) both; }
  .eyebrow.eb-in { animation: ebFade .6s var(--ease) forwards; }
}
@media (prefers-reduced-motion: reduce) {
  .kin-word { opacity: 1; transform: none; }
  .page-head .eyebrow[data-eyebrow], .login-card .eyebrow[data-eyebrow] { opacity: 1; }
}
@keyframes kinWord { from { opacity: 0; transform: translateY(118%) rotate(3.2deg); } to { opacity: 1; transform: none; } }
@keyframes ebFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Login
   ============================================================ */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: transparent; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 14px;
  border-top: 1px solid var(--line-strong); padding-top: 34px;
}
.login-heading { font-size: clamp(30px, 6vw, 40px); margin-bottom: 4px; }
.login-sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.login-card input {
  padding: 13px 14px; border: none; border-bottom: 1px solid var(--line-strong); border-radius: 0;
  font-size: 15px; background: transparent; color: var(--ink); font-family: var(--sans);
  transition: border-color .25s var(--ease);
}
.login-card input:focus { outline: none; border-bottom-color: var(--tan); }
.login-card button {
  margin-top: 6px; padding: 13px; border: none; border-radius: var(--radius);
  background: var(--btn-bg); color: var(--btn-ink);
  font-family: var(--sans); font-weight: 600; font-size: 14px; letter-spacing: 0.02em; cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.login-card button:hover { background: var(--btn-bg-hover); transform: translateY(-1px); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; font-family: var(--mono); }

/* ============================================================
   Shell
   ============================================================ */
.appbar { position: sticky; top: 0; z-index: 20; background: var(--surface); }
/* Brand lockup bar (logo lockup): name + strapline on the left, engine label right. */
.brandbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px 32px 14px; border-bottom: 1px solid var(--line);
}
.brand-lockup { min-width: 0; }
.brand-line1 {
  font-family: var(--sans); font-weight: 600; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--ink-strong); line-height: 1.2; white-space: nowrap;
}
.brand-line2 {
  font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 17px;
  color: var(--ink-3); line-height: 1.3; margin-top: 3px; white-space: nowrap;
}
.brand-engine {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--tan); white-space: nowrap; text-align: right; flex-shrink: 0;
}
/* Narrow screens: keep the name, drop the engine label (it is also on the title). */
@media (max-width: 680px) {
  .brand-line1 { font-size: 11.5px; letter-spacing: 0.12em; white-space: normal; }
  .brand-line2 { font-size: 14px; }
  .brand-engine { display: none; }
}
.nav {
  display: flex; align-items: center; gap: 28px; padding: 0 32px; height: 50px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 26px; height: 100%; }
.tab-btn {
  border: none; background: transparent; padding: 0; height: 100%; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 1.5px solid transparent; transition: color .25s var(--ease), border-color .25s var(--ease);
}
.tab-btn:hover { color: var(--ink-2); }
.tab-btn.active { color: var(--ink-strong); border-bottom-color: var(--tan); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.logout-btn {
  border: none; background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  cursor: pointer; padding: 6px 2px; transition: color .25s var(--ease);
}
.logout-btn:hover { color: var(--ink-strong); }
.logout-btn.active {
  color: var(--ink-strong); text-decoration: underline; text-decoration-color: var(--tan);
  text-decoration-thickness: 1.5px; text-underline-offset: 6px;
}
.main { max-width: 1120px; margin: 0 auto; padding: 44px 32px 110px; }

.page-head { margin-bottom: 34px; }
.panel-sub { color: var(--ink-2); font-size: 15px; margin: 14px 0 0; max-width: 620px; }

/* Panel enter */
@media (prefers-reduced-motion: no-preference) {
  .tab-panel:not(.hidden) { animation: panelIn .5s var(--ease); }
}
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.secondary-btn {
  border: 1px solid var(--line-strong); background: transparent; border-radius: var(--radius);
  padding: 9px 15px; cursor: pointer; font-family: var(--sans); font-size: 13px; color: var(--ink-2);
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.secondary-btn:hover { border-color: var(--tan); color: var(--ink-strong); }
.link-btn {
  border: none; background: transparent; color: var(--accent-2); cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; padding: 4px 8px;
  transition: color .2s var(--ease);
}
.link-btn:hover { color: var(--ink-strong); text-decoration: underline; }

.empty-state {
  display: flex; align-items: center; gap: 20px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 30px 4px; color: var(--muted); font-size: 14px;
}
.empty-num {
  font-family: var(--serif); font-weight: 400; font-size: 64px; line-height: 1;
  color: transparent; -webkit-text-stroke: 1px var(--tan); text-stroke: 1px var(--tan); flex-shrink: 0;
}

/* ============================================================
   Single test
   ============================================================ */
.single-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; align-items: start; }
/* Below 1024px the right column is too narrow for the labelled ring, so the scene stacks under the input. */
@media (max-width: 1023px) { .single-grid { grid-template-columns: 1fr; gap: 26px; } }

.input-section { border-top: 1px solid var(--line-strong); padding-top: 20px; }
.input-label {
  display: block; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--tan);
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.14em;
}
textarea {
  width: 100%; resize: vertical; font-family: var(--sans); font-size: 15px; line-height: 1.6;
  padding: 14px 15px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--field); color: var(--ink); min-height: 128px;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
textarea:focus { outline: none; border-color: var(--tan); box-shadow: 0 0 0 3px rgba(158, 142, 122, 0.16); }
.actions { margin-top: 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
#classify-btn {
  background: var(--btn-bg); color: var(--btn-ink); border: none; border-radius: var(--radius);
  padding: 12px 26px; font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
  cursor: pointer; transition: background .25s var(--ease), transform .25s var(--ease);
}
#classify-btn:hover:not(:disabled) { background: var(--btn-bg-hover); transform: translateY(-1px); }
#classify-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.error-msg { color: var(--danger); font-size: 12.5px; font-family: var(--mono); }

/* ---------- Taxonomy cloud (site Diagnostic point cloud, dark ground) ---------- */
.scene-section { display: flex; flex-direction: column; }
.scene-section .eyebrow { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* The scene: a square, centred, transparent canvas with the six domain names
   placed around it like a clock. Label positions and max width are set in JS
   from the square's size so no label is ever clipped. */
.orbit { position: relative; width: 100%; max-width: 560px; aspect-ratio: 1 / 1; margin: 0 auto; }
.orbit canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.orbit-label {
  position: absolute; display: flex; flex-direction: column; gap: 3px;
  width: max-content; pointer-events: none; opacity: 0.7;
  transition: opacity .5s var(--ease);
}
.orbit-label .d { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--tan); }
.orbit-label .n {
  font-family: var(--serif); font-size: 15px; font-weight: 400; line-height: 1.15; color: var(--tan);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color .5s var(--ease);
}
/* Text aligned away from the centre. */
.orbit-label.side-top { transform: translate(-50%, -100%); text-align: center; align-items: center; }
.orbit-label.side-bottom { transform: translate(-50%, 0); text-align: center; align-items: center; }
.orbit-label.side-right { transform: translate(0, -50%); text-align: left; align-items: flex-start; }
.orbit-label.side-left { transform: translate(-100%, -50%); text-align: right; align-items: flex-end; }
/* Matched: cream with a short tan underline. */
.orbit-label.act { opacity: 1; }
.orbit-label.act .n { color: var(--ink-strong); }
.orbit-label::after {
  content: ""; display: block; width: 26px; height: 1.5px; margin-top: 6px;
  background: var(--tan); transform: scaleX(0); transition: transform .5s var(--ease);
}
.orbit-label.side-right::after { transform-origin: left center; }
.orbit-label.side-left::after { transform-origin: right center; }
.orbit-label.act::after { transform: scaleX(1); }

/* The vertical list is the fallback below 900px. */
.layers { display: none; list-style: none; margin: 0; padding: 0; }
.layer {
  display: flex; flex-direction: column; justify-content: center;
  padding: 7px 0 7px 12px; border-left: 2px solid rgba(158, 142, 122, 0.25);
  transition: border-left-color .5s var(--ease);
}
.layer .d {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--tan); transition: color .5s var(--ease);
}
.layer .n {
  font-family: var(--serif); font-size: 15px; font-weight: 400; line-height: 1.15; margin-top: 3px;
  color: var(--tan); transition: color .5s var(--ease);
}
.layer.act { border-left-color: var(--tan); }
.layer.act .d, .layer.act .n { color: var(--ink-strong); }

@media (max-width: 899px) {
  .layers { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .orbit { aspect-ratio: 4 / 3; max-width: 420px; }
  .orbit-label { display: none; }
}

.scene-caption {
  margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--muted); min-height: 16px;
}

/* ---------- Loading ---------- */
.loading { display: flex; align-items: center; gap: 12px; padding: 34px 0; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--tan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result cards ---------- */
/* Cards hinge down from their top edge (matched to the SKA .ev HingeGrid:
   rotateX -78 -> 0, power3.out, 1.05s, staggered, perspective 1400px). */
.results { display: flex; flex-direction: column; gap: 0; margin-top: 40px; perspective: 1400px; perspective-origin: 50% 0%; }
.card {
  border-top: 1px solid var(--line); padding: 22px 0;
  transform-origin: top center; transform-style: preserve-3d; backface-visibility: hidden;
}
.results .card:last-child { border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .card.flip-in { animation: cardFlip 1.05s cubic-bezier(0.215, 0.61, 0.355, 1) both; }
}
@keyframes cardFlip {
  from { opacity: 0; transform: rotateX(-78deg); }
  to { opacity: 1; transform: rotateX(0); }
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rank-badge { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--tan); }
.card-domain { font-family: var(--serif); font-size: 24px; font-weight: 400; letter-spacing: -0.01em; color: var(--ink-strong); }
.card-subdomain { font-family: var(--sans); font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.card-indicator { font-family: var(--sans); font-size: 14.5px; color: var(--ink); border-left: 2px solid var(--tan); padding: 6px 0 6px 14px; margin: 14px 0; }
.card-id { color: var(--muted); font-size: 12px; margin-left: 6px; font-family: var(--mono); }
.card-depth { margin-bottom: 4px; }
.card-rationale { font-family: var(--serif); font-size: 15px; font-style: italic; color: var(--ink-2); margin: 10px 0 0; }

.no-match { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 28px 4px; color: var(--ink-2); font-family: var(--serif); font-style: italic; font-size: 17px; margin-top: 30px; }
.pie-section { border-top: 1px solid var(--line-strong); padding-top: 22px; margin-top: 40px; }

/* ---------- Confidence + depth ---------- */
.conf-pill {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em;
}
.pill-ink { background: var(--btn-bg); color: var(--btn-ink); }
.pill-tan { background: var(--tan); color: var(--on-tan); }
.pill-outline { background: transparent; color: var(--ink-2); border: 1px solid var(--line-strong); }

.depth-seg { display: inline-flex; align-items: center; gap: 4px; }
.depth-seg .seg { width: 16px; height: 5px; border-radius: 1px; background: var(--line-strong); transform-origin: left center; }
.depth-seg .seg.on { background: var(--ink-strong); }
/* Default (no .draw / reduced motion): segments are already drawn. When JS adds
   .draw, each segment sweeps in from scaleX(0) with a staggered animation-delay. */
@media (prefers-reduced-motion: no-preference) {
  .depth-seg.draw .seg { animation: segDraw .35s var(--ease) both; }
}
@keyframes segDraw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.depth-num { margin-left: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }

/* ---------- Donut ---------- */
.donut { display: block; overflow: visible; }
.donut-block { display: flex; flex-direction: column; }
@media (prefers-reduced-motion: no-preference) {
  .donut .slice { transition: stroke-dasharray .9s var(--ease); }
}
.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-family: var(--sans); }
.legend-swatch { width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; }
.legend-pct { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.donut-caption { margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--ink-2); }

/* ============================================================
   Batch
   ============================================================ */
.batch-steps { list-style: none; display: flex; gap: 48px; padding: 0; margin: 0 0 36px; }
.step { display: flex; align-items: baseline; gap: 12px; opacity: 0.4; transition: opacity .4s var(--ease); }
.step.active { opacity: 1; }
.step-num {
  font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1;
  color: transparent; -webkit-text-stroke: 1px var(--tan); text-stroke: 1px var(--tan);
}
.step.active .step-num { color: var(--tan); -webkit-text-stroke: 0; }
.step-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-2); }

.dropzone {
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 48px 24px; text-align: center;
  cursor: pointer; background: transparent; transition: border-color .3s var(--ease), background .3s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--tan); background: rgba(158, 142, 122, 0.06); }
.dropzone-title { font-family: var(--serif); font-size: 19px; font-weight: 400; color: var(--ink-strong); }
.dropzone-or { margin-top: 8px; color: var(--muted); font-size: 13.5px; }
.dropzone .link { color: var(--accent-2); text-decoration: underline; }
.upload-note { margin: 14px 2px 0; color: var(--muted); font-size: 12.5px; }
.batch-fileinfo { margin: 22px 0 0; font-size: 14px; color: var(--ink-2); font-family: var(--sans); }
.batch-fileinfo strong { font-weight: 600; color: var(--ink-strong); }

.batch-progress { margin: 30px 0; }
.progress-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.progress-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--tan); }
.progress-count { display: inline-flex; align-items: baseline; }
.progress-track { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0; background: var(--tan); border-radius: 999px; transition: width .6s var(--ease); position: relative; overflow: hidden; }
.progress-bar.bar-failed { background: var(--danger); }
.progress-bar.bar-paused { background: var(--accent-1); }
/* Shimmer streak while processing */
@media (prefers-reduced-motion: no-preference) {
  .progress-bar.bar-active::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(236, 228, 214, 0.35), transparent);
    transform: translateX(-100%); animation: shimmer 1.6s var(--ease) infinite;
  }
}
@keyframes shimmer { to { transform: translateX(100%); } }
.progress-eta { margin-top: 12px; font-size: 12.5px; color: var(--muted); font-family: var(--sans); }
.batch-actions { margin: 22px 0; }
#batch-download-btn {
  border: none; background: var(--btn-bg); color: var(--btn-ink); border-radius: var(--radius);
  padding: 11px 20px; font-family: var(--sans); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
#batch-download-btn:hover { background: var(--btn-bg-hover); transform: translateY(-1px); }
.batch-error { color: var(--danger); font-size: 13px; margin: 14px 0; font-family: var(--mono); }

/* ============================================================
   Results table (batch + history)
   ============================================================ */
.table-scroll { overflow: auto; max-height: 640px; border-top: 1px solid var(--line-strong); }
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: var(--sans); }
.results-table th, .results-table td { padding: 13px 16px 13px 0; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.results-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--bg);
  font-family: var(--mono); font-weight: 500; color: var(--tan); white-space: nowrap;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; padding-top: 10px; padding-bottom: 10px;
}
.results-table tbody tr.row-main:hover { background: rgba(158, 142, 122, 0.07); }
.results-table td:first-child, .results-table th:first-child { padding-left: 4px; }
.row-error td { background: rgba(217, 120, 95, 0.08); }
.cell-domain { font-family: var(--serif); font-size: 15px; color: var(--ink-strong); }
.cell-input { max-width: 340px; color: var(--ink-2); }
.cell-ind { max-width: 280px; }
.cell-pie { width: 64px; }
.cell-actions { white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clamp.clamp-open { -webkit-line-clamp: unset; overflow: visible; }
.showmore-btn, .more-btn { border: none; background: transparent; color: var(--accent-2); cursor: pointer; font-family: var(--mono); font-size: 11px; padding: 2px 0; margin-top: 6px; }
.showmore-btn:hover, .more-btn:hover { color: var(--ink-strong); text-decoration: underline; }

/* Top-2 / Top-3 expansion: a quiet toggle under the Top-1 domain, and indented
   alternate rows on a faint tan wash so they read as part of the row above. */
.more-toggle {
  display: block; margin-top: 7px; padding: 2px 0; border: none; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tan);
  transition: color .25s var(--ease);
}
.more-toggle:hover, .more-toggle[aria-expanded="true"] { color: var(--ink-strong); }
.results-table tr.row-extra td { background: rgba(158, 142, 122, 0.06); border-bottom-color: rgba(158, 142, 122, 0.18); }
.results-table tr.row-extra .cell-domain { font-size: 14px; color: var(--ink-2); }
.cell-rank { padding-left: 14px !important; }
.rank-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tan); }
.cell-share { font-family: var(--mono); font-size: 12px; color: var(--ink-strong); white-space: nowrap; }
.share-label { display: block; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
/* Calm row fade-in */
@media (prefers-reduced-motion: no-preference) {
  .results-table tbody tr.row-reveal { animation: rowFade .5s var(--ease) both; }
}
@keyframes rowFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================
   History
   ============================================================ */
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.detail-actions { margin: 8px 0 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.status-pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.pill-done { background: var(--tan); color: var(--on-tan); }
.pill-failed { background: rgba(217, 120, 95, 0.16); color: var(--danger); }
.pill-running { background: var(--chip); color: var(--ink-2); }


/* ============================================================
   Reports
   ============================================================ */
.batch-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.primary-btn {
  border: none; background: var(--btn-bg); color: var(--btn-ink); border-radius: var(--radius);
  padding: 10px 18px; font-family: var(--sans); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.primary-btn:hover { background: var(--btn-bg-hover); transform: translateY(-1px); }
.mono-cell { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.report-list-eyebrow { margin-top: 40px; }

/* Upload feedback: errors are listed one per row, exactly as the server reports them. */
.report-msg { margin: 16px 0 0; padding: 14px 16px; border-left: 2px solid var(--tan); background: rgba(158, 142, 122, 0.08); font-size: 13.5px; }
.report-msg.ok { border-left-color: var(--ink-strong); }
.report-msg.error { border-left-color: var(--danger); background: rgba(217, 120, 95, 0.08); }
.report-msg .msg-head { font-weight: 600; color: var(--ink-strong); }
.report-msg.error .msg-head { color: var(--danger); }
.report-msg .msg-list { margin: 8px 0 0; padding-left: 18px; font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--ink-2); }

/* Viewer: actions bar above the print-styled page */
.report-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line-strong); }
.report-meta { flex: 1 1 auto; min-width: 0; }
.report-title { font-family: var(--serif); font-size: 20px; color: var(--ink-strong); }
.report-status { margin-top: 4px; }
.report-actions { display: flex; gap: 10px; }
.report-frame { display: block; width: 100%; height: 2400px; border: 1px solid var(--line); border-radius: var(--radius); background: #E9E5DE; }

/* Dialogs (report details, review) */
.dialog { border: none; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.dialog form { padding: 28px 28px 24px; }
.dialog-title { font-family: var(--serif); font-weight: 400; font-size: 28px; letter-spacing: -0.01em; margin: 0; color: var(--ink-strong); }
.dialog-sub { margin: 8px 0 18px; color: var(--ink-2); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1 1 0; min-width: 0; }
.field span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--tan); }
.field input { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--field); font-family: var(--sans); font-size: 14.5px; color: var(--ink); }
.field input:focus { outline: none; border-color: var(--tan); box-shadow: 0 0 0 3px rgba(158, 142, 122, 0.16); }
.field-row { display: flex; gap: 14px; }
.dialog-error { min-height: 18px; margin: 0 0 6px; color: var(--danger); font-family: var(--mono); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 520px) { .field-row { flex-direction: column; gap: 0; } }
.field textarea { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--field); font-family: var(--sans); font-size: 13.5px; line-height: 1.45; color: var(--ink); resize: vertical; min-height: 88px; overflow-x: hidden; }
.field textarea:focus { outline: none; border-color: var(--tan); box-shadow: 0 0 0 3px rgba(158, 142, 122, 0.16); }
.field textarea::placeholder { color: var(--muted); }

/* Generate dialog: details and next steps on the left, live report preview on the right */
.dialog-wide { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: hidden; }
/* A fixed height (not just max-height) so each column scrolls on its own. */
.dialog .gen-form { padding: 0; display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: calc(100vh - 32px); height: calc(100dvh - 32px); }
.gen-fields { padding: 28px 28px 24px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.steps-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.steps-head > span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-strong); }
.steps-head .link-btn { padding: 0; }
.steps-hint { margin: 6px 0 12px; font-size: 12.5px; color: var(--ink-2); }
.step-field { margin-bottom: 10px; }
.gen-preview { background: var(--bg); border-left: 1px solid var(--line-strong); display: flex; flex-direction: column; min-height: 0; }
.gen-preview-label { padding: 12px 18px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); border-bottom: 1px solid var(--line-strong); }
.gen-preview-box { position: relative; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.gen-preview-box iframe { position: absolute; top: 0; left: 0; width: 794px; height: 2400px; border: 0; transform-origin: 0 0; background: #E9E5DE; visibility: hidden; }
.gen-preview-box.ready iframe { visibility: visible; }
.gen-preview-box.ready .gen-preview-msg { display: none; }
.gen-preview-msg { padding: 18px; margin: 0; }
.gen-preview-msg.error { color: var(--danger); font-family: var(--mono); font-size: 12px; }
@media (max-width: 860px) {
  .dialog-wide { overflow-y: auto; }
  .dialog .gen-form { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .gen-fields { overflow: visible; }
  .gen-preview { border-left: none; border-top: 1px solid var(--line-strong); }
  .gen-preview-box { flex: none; height: 70vh; }
}

/* Permanent delete */
.danger-btn {
  border: none; background: var(--danger-fill); color: #fff; border-radius: var(--radius);
  padding: 10px 18px; font-family: var(--sans); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: background .25s var(--ease);
}
.danger-btn:hover { background: var(--danger-fill-hover); }
.danger-btn:disabled { opacity: 0.6; cursor: default; }
.delete-warning { margin: 0 0 14px; padding: 12px 14px; border-left: 2px solid var(--danger); background: rgba(217, 120, 95, 0.08); font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.link-btn.del-btn { color: var(--danger); }
.link-btn.del-btn:hover { color: #f0a08a; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 820px) {
  .running-header { padding: 11px 18px 9px; }
  .nav { gap: 14px; padding: 0 18px; }
  .tabs { gap: 16px; }
  .main { padding: 30px 18px 80px; }
  .batch-steps { gap: 26px; }
  .step-num { font-size: 34px; }
}
/* Phones: the tab row scrolls sideways; Settings and Log out stay in view. */
@media (max-width: 520px) {
  .nav { gap: 12px; padding: 0 16px; }
  .tabs { gap: 14px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn, .logout-btn { white-space: nowrap; flex: none; }
  .nav-right { gap: 12px; flex: none; }
}
