/* ==========================================================================
   Report Studio - design system
   ========================================================================== */

:root {
  color-scheme: light;

  --ink: #101828;
  --ink-strong: #04060d;
  --muted: #5a6478;
  --faint: #8a93a6;
  --line: #e3e7ef;
  --line-strong: #cfd6e4;
  --canvas: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #f9fafd;
  --surface-sunken: #eef1f7;

  --brand: #146a68;
  --brand-strong: #0f5250;
  --brand-soft: #e3f2f1;
  --brand-ink: #ffffff;
  --accent: #b98a2b;
  --accent-soft: #fbf3e1;
  --danger: #b4232a;
  --danger-soft: #fdecec;
  --success: #1d7a45;
  --success-soft: #e7f6ec;
  --info-soft: #eaf1fb;
  --info: #29558c;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-sm: 0 2px 6px rgba(16, 24, 40, .07);
  --shadow: 0 10px 28px rgba(16, 24, 40, .09);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .16);

  --rail-width: 252px;
  --gap: 22px;
  --pad: 26px;

  --font-sans: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;

  --speed: 160ms;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --ink: #e8ecf4;
  --ink-strong: #ffffff;
  --muted: #a3adc0;
  --faint: #77839a;
  --line: #262d3b;
  --line-strong: #333c4e;
  --canvas: #0c1017;
  --surface: #141a24;
  --surface-alt: #19202b;
  --surface-sunken: #1e2531;

  --brand: #35b3ae;
  --brand-strong: #4cc9c3;
  --brand-soft: #10312f;
  --brand-ink: #04201f;
  --accent: #e2b455;
  --accent-soft: #2f2716;
  --danger: #f0777d;
  --danger-soft: #331a1c;
  --success: #55c98a;
  --success-soft: #12301f;
  --info-soft: #16243a;
  --info: #8ab2ee;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .45);
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --shadow-lg: 0 26px 64px rgba(0, 0, 0, .6);
}

html[data-density="compact"] {
  --gap: 14px;
  --pad: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink-strong); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-family: var(--font-serif); font-size: clamp(28px, 3.1vw, 40px); line-height: 1.15; }
h2 { font-family: var(--font-serif); font-size: 23px; line-height: 1.25; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0; }

a { color: var(--brand); }

kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ------------------------------------------------------------------ shell */

.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
}

.app-rail {
  position: sticky;
  top: 0;
  z-index: 40;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: background var(--speed);
}
.brand-button:hover { background: var(--surface-sunken); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: -.01em; color: var(--ink-strong); }
.brand-text small { font-size: 12px; color: var(--faint); }

.rail-nav { display: flex; flex-direction: column; gap: 4px; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--speed), color var(--speed);
}
.rail-link:hover { background: var(--surface-sunken); color: var(--ink); }
.rail-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.rail-icon { width: 18px; text-align: center; opacity: .8; }

.rail-foot { margin-top: auto; }

.rail-tip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  font-size: 12px;
  color: var(--muted);
}
.rail-tip strong { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }

.app-body { display: flex; flex-direction: column; min-width: 0; }

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 0 clamp(18px, 3vw, 44px);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-crumbs { font-size: 13px; font-weight: 500; color: var(--muted); }
.topbar-actions { display: flex; gap: 6px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.icon-button:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--line-strong); }

.app-main {
  flex: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) clamp(18px, 3vw, 44px) 96px;
}

.view { display: flex; flex-direction: column; gap: var(--gap); }
.view[hidden] { display: none; }

/* ------------------------------------------------------------------- home */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 48px);
  align-items: center;
  padding: clamp(26px, 4vw, 44px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(1100px 340px at 88% -30%, var(--brand-soft), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero-copy { display: flex; flex-direction: column; gap: 14px; }
.lede { color: var(--muted); font-size: 16px; max-width: 56ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

.hero-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hero-facts li {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.hero-facts strong { font-family: var(--font-serif); font-size: 22px; color: var(--brand); }
.hero-facts span { font-size: 13px; color: var(--muted); }

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--brand);
}

.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--gap); }

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.feature-card h3 { font-size: 16px; }
.feature-card p { font-size: 13.5px; color: var(--muted); }
.feature-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 17px;
}

.recent-section { display: flex; flex-direction: column; gap: 14px; }

/* --------------------------------------------------------------- headings */

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.section-heading > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.section-heading p { color: var(--muted); font-size: 13.5px; max-width: 78ch; }
.section-heading.compact h2, .section-heading.compact h3 { font-family: var(--font-sans); font-size: 16px; }
.inner-heading { margin-top: 6px; padding-top: 14px; border-top: 1px dashed var(--line); }

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.workspace-heading > div:first-child { display: flex; flex-direction: column; gap: 6px; }
.workspace-heading p { color: var(--muted); font-size: 14px; }

.back-button {
  align-self: flex-start;
  padding: 0;
  margin-bottom: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.back-button:hover { color: var(--brand); }

.text-button {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  padding: 4px 0;
}
.text-button:hover { text-decoration: underline; }

.active-template {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.active-template small { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.active-template strong { font-size: 15px; }

/* ---------------------------------------------------------------- stepper */

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.stepper li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--faint);
  font-size: 13.5px;
  transition: border-color var(--speed), color var(--speed), background var(--speed);
}
.stepper li span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.stepper li.active { border-color: var(--brand); color: var(--ink); background: var(--brand-soft); }
.stepper li.active span { background: var(--brand); color: var(--brand-ink); }
.stepper li.complete { color: var(--muted); }
.stepper li.complete span { background: var(--success); color: #fff; }

.workflow-step { display: flex; flex-direction: column; gap: var(--gap); }
.workflow-step[hidden] { display: none; }

/* ---------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), color var(--speed), transform var(--speed), box-shadow var(--speed);
}
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button.large { padding: 12px 24px; font-size: 15px; }

.button.primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-xs); }
.button.primary:hover:not(:disabled) { background: var(--brand-strong); box-shadow: var(--shadow-sm); }

.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { background: var(--surface-sunken); }

.button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.button.ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--ink); }

.button.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.button.danger:hover:not(:disabled) { background: var(--danger-soft); }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.split-actions { justify-content: space-between; }

.workflow-actions { padding-top: 6px; }

.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------ forms */

label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.form-grid[hidden] { display: none; }
.form-grid.three { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.form-grid > label { display: flex; flex-direction: column; gap: 6px; }
.form-grid > label.wide { grid-column: 1 / -1; }
.form-grid > label[hidden] { display: none; }

input[type="text"], input[type="number"], input[type="search"], input:not([type]), select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  transition: border-color var(--speed), box-shadow var(--speed);
}
/* Native dropdown lists are painted by the browser, so options need an explicit
   background and colour or they inherit a transparent/mismatched surface and
   become unreadable (notably in dark mode and inside table cells). */
select option, select optgroup {
  background-color: var(--surface);
  color: var(--ink);
}
select:disabled { opacity: .6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
input[type="file"] {
  padding: 7px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px dashed var(--line-strong);
}
input[type="color"] { padding: 2px; height: 36px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 74px; line-height: 1.55; }

.field-hint { font-size: 11.5px; font-weight: 400; color: var(--faint); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-weight: 500;
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
}
.checkbox-row input { margin-top: 3px; }

.notes-input { min-height: 84px; }

/* ------------------------------------------------------------------ cards */

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: var(--gap); }

.template-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--speed), box-shadow var(--speed), transform var(--speed);
}
.template-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.template-card h3 { font-size: 16px; }
.template-card p { font-size: 13px; color: var(--muted); flex: 1; }

.template-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.template-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
}

.template-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.template-meta { font-size: 12px; color: var(--faint); }
.template-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.library-toolbar { display: flex; align-items: center; gap: 14px; }
.library-toolbar input { max-width: 340px; }
.library-toolbar span { font-size: 13px; color: var(--muted); }

.template-list { display: flex; flex-direction: column; gap: 10px; }

.template-list-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.template-list-item h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15.5px; }
.template-list-item p { font-size: 13px; color: var(--muted); }
.template-list-item small { font-size: 11.5px; color: var(--faint); }
.template-list-item .button-row { justify-content: flex-end; }

/* ---------------------------------------------------------------- panels */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.panel[hidden] { display: none; }

.panel > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px var(--pad);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--speed);
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary:hover { background: var(--surface-alt); }
.panel > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--faint);
  font-size: 12px;
  transition: transform var(--speed);
}
.panel[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-alt); }
.panel[open] > summary::after { transform: rotate(180deg); }

.panel-static-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px var(--pad);
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.panel-title { font-weight: 600; font-size: 15px; color: var(--ink-strong); }
.panel-hint { font-size: 12.5px; color: var(--faint); }
.panel-lede { font-size: 13.5px; color: var(--muted); max-width: 86ch; }

.panel-body { display: flex; flex-direction: column; gap: 14px; padding: var(--pad); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.report-kind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }

.report-kind-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  cursor: pointer;
  transition: border-color var(--speed), background var(--speed), box-shadow var(--speed);
}
.report-kind-option:hover { border-color: var(--line-strong); }
.report-kind-option input { margin-top: 3px; }
.report-kind-option:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.report-kind-option span { display: flex; flex-direction: column; gap: 3px; }
.report-kind-option strong { font-size: 14px; color: var(--ink-strong); font-weight: 600; }
.report-kind-option small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.report-kind-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

/* ----------------------------------------------------------- narrative UI */

.narrative-list { display: flex; flex-direction: column; gap: 8px; }

.narrative-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.4fr);
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.narrative-row.off { opacity: .55; }
.narrative-toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--ink); cursor: pointer; }
.narrative-row input[type="text"] { font-size: 13.5px; }

.narrative-preview {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
}
.narrative-preview strong {
  display: block;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}

/* ------------------------------------------------------------ upload zone */

.upload-zone {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  transition: border-color var(--speed), background var(--speed);
}
.upload-zone:hover { border-color: var(--brand); }
.upload-zone input[type="file"] { flex: 1 1 240px; }
.upload-copy { display: flex; flex-direction: column; gap: 2px; }
.upload-copy strong { font-size: 14px; color: var(--ink-strong); }
.upload-copy span { font-size: 12px; color: var(--faint); }

.upload-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 17px;
  font-weight: 700;
}

.sample-upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sample-upload-row input[type="file"] { flex: 1 1 260px; }

.mapping-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--pad);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand-soft);
}
.mapping-panel[hidden] { display: none; }
.mapping-panel label { color: var(--ink); font-size: 13.5px; }
.mapping-panel select,
.mapping-panel select option {
  background-color: #FFFFFF;
  color: #17202A;
}
.mapping-panel select { min-height: 72px; padding: 4px; }
.mapping-panel select option { padding: 8px 10px; white-space: normal; }

/* ------------------------------------------------------------ data tables */

.data-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 12px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-alt); }

td input, td select {
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  font-size: 13px;
}
td input:hover, td select:hover { border-color: var(--line-strong); background: var(--surface); }
td input:focus, td select:focus { background: var(--surface); }
td input[type="checkbox"] { width: 16px; height: 16px; }

.row-del {
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}
.row-del:hover { background: var(--danger-soft); color: var(--danger); }

/* --------------------------------------------------- editors and lists */

.chart-list, .schema-list { display: flex; flex-direction: column; gap: 12px; }

.chart-editor, .kpi-editor, .benchmark-editor, .schema-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.chart-editor label, .kpi-editor label, .benchmark-editor label, .schema-row label { display: flex; flex-direction: column; gap: 5px; }
.chart-editor label[hidden], .schema-row label[hidden] { display: none; }
.chart-editor .button, .kpi-editor .button, .benchmark-editor .button, .schema-row .button { align-self: end; }
.chart-editor .wide, .schema-row .wide { grid-column: 1 / -1; }
.chart-order-control {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.chart-order-control > strong { margin-right: auto; align-self: center; color: var(--ink-strong); }
.chart-order-control label { min-width: 150px; }
.chart-move-actions { display: flex; gap: 6px; }
.chart-move-button { width: 38px; min-width: 38px; padding-inline: 0; font-size: 17px; }

.chart-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  font-weight: 400;
}

.suggestion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.suggestion-grid > * {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--speed), background var(--speed);
}
.suggestion-grid > *:hover { border-color: var(--brand); background: var(--brand-soft); }
.suggestion-type { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--brand); }

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}

.student-notes {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  overflow: hidden;
}
.student-notes > summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.student-notes > summary::-webkit-details-marker { display: none; }
.student-notes > summary::before { content: "▸ "; color: var(--faint); }
.student-notes[open] > summary::before { content: "▾ "; }

.student-notes-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }

.student-note-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.student-note-row > span { padding-top: 8px; font-size: 13px; font-weight: 600; color: var(--ink); }

.growth-coverage {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 13px;
  color: var(--muted);
}

/* multi-class growth: one card per class, one slot per assessment */
.mcg-class {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.mcg-class-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.mcg-class-head label { display: flex; flex-direction: column; gap: 5px; flex: 1 1 220px; }
.mcg-class-head .button { flex: 0 0 auto; }
.mcg-slot {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.mcg-slot.filled { border-left-color: var(--success, #1d9e75); }
.mcg-slot-title { display: flex; flex-direction: column; gap: 3px; }
.mcg-slot-title strong { font-size: 13px; color: var(--ink-strong); }
.mcg-slot-title span { font-size: 12px; color: var(--faint); }
.mcg-slot-locked { font-size: 12px; font-weight: 600; color: var(--faint); text-align: right; }
.mcg-slot input[type="file"] { font-size: 12px; }
.mcg-class-footer { margin: 0; font-size: 12px; color: var(--faint); }

@media (max-width: 700px) {
  .mcg-slot { grid-template-columns: 1fr; }
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 0 16px;
}
.advanced-settings > summary { padding: 12px 0; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary::before { content: "▸ "; color: var(--faint); }
.advanced-settings[open] > summary::before { content: "▾ "; }
.advanced-settings .form-grid { padding-bottom: 16px; }

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.generate-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.generate-summary > div { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; background: var(--surface); }
.generate-summary small { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.generate-summary strong { font-family: var(--font-serif); font-size: 24px; color: var(--brand); }

/* ---------------------------------------------------------------- notices */

.notice {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 13.5px;
}
.notice[hidden] { display: none; }
.notice.success { border-left-color: var(--success); background: var(--success-soft); color: var(--success); }
.notice.error { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.notice.warning { border-left-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.notice.info { border-left-color: var(--info); background: var(--info-soft); color: var(--ink); }

/* ----------------------------------------------------------------- toasts */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 250px;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toast-in 220ms ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { animation: toast-out 200ms ease-in forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 13, 20, .55);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.compact-modal { width: min(480px, 100%); }
.compact-modal .modal-head { align-items: flex-start; }
.compact-modal .modal-head p { margin-top: 4px; color: var(--muted); }
.wording-settings-modal { width: min(760px, 100%); }
.wording-settings-modal .modal-head { align-items: flex-start; }
.wording-settings-modal .modal-head p { margin-top: 4px; color: var(--muted); }
.compact-settings-section { padding: 14px; box-shadow: none; }
.finding-category-settings { margin-top: 14px; }
.finding-category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-sunken);
}
.finding-category-list .checkbox-row { margin: 0; }
.finding-category-list .empty-state { margin: 0; color: var(--muted); font-size: 13px; }
.modal-actions { justify-content: flex-end; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.chart-preview-image {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.chart-preview-image[hidden] { display: none; }

/* ------------------------------------------------------------------ guide */

.guide-view {
  --guide-mark: #e2622b;
  gap: clamp(28px, 4vw, 52px);
}

.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .9fr);
  gap: clamp(22px, 4vw, 46px);
  align-items: center;
  padding: clamp(26px, 4vw, 46px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(900px 420px at 8% -40%, var(--accent-soft), transparent 58%),
    radial-gradient(1100px 380px at 92% -20%, var(--brand-soft), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}
.guide-hero-copy { display: flex; flex-direction: column; gap: 14px; }
.guide-hero h1 { max-width: 20ch; }

.guide-chips { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.guide-chips li {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-alt);
  font-size: 12.5px;
  color: var(--muted);
}
.guide-chips strong { color: var(--brand); }

.hero-guide-link { align-self: flex-start; margin-top: 4px; }

.guide-map { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: guidemap; }
.guide-map li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.guide-map li span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 14px;
}
.guide-map li div { display: flex; flex-direction: column; }
.guide-map strong { font-size: 14.5px; color: var(--ink-strong); }
.guide-map small { font-size: 12.5px; color: var(--muted); }

.guide-toc {
  position: sticky;
  top: 66px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-xs);
}
.guide-toc a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--speed), color var(--speed);
}
.guide-toc a:hover { background: var(--brand-soft); color: var(--brand); }

.guide-section { display: flex; flex-direction: column; gap: var(--gap); scroll-margin-top: 120px; }

.guide-type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--gap); }
.guide-type-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed);
}
.guide-type-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.guide-type-card h3 { font-size: 16.5px; }
.guide-type-card p { font-size: 13.5px; color: var(--muted); }
.guide-type-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 17px;
}
.guide-type-points { list-style: none; margin: auto 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line-strong); display: flex; flex-direction: column; gap: 4px; }
.guide-type-points li { font-size: 12.5px; color: var(--faint); }
.guide-type-points li::before { content: "› "; color: var(--brand); font-weight: 700; }

.guide-note {
  padding: 14px 18px;
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-xs);
  background: var(--brand-soft);
  font-size: 13.5px;
  color: var(--ink);
}

.guide-step {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr);
  gap: clamp(20px, 3.4vw, 40px);
  align-items: center;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  scroll-margin-top: 130px;
}
.guide-step.reverse .guide-step-body { order: 2; }
.guide-step-body { display: flex; flex-direction: column; gap: 14px; }
.guide-step-head { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start; }
.guide-step-index {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink);
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
}
.guide-step-head h3 { font-size: 19px; letter-spacing: -.01em; }
.guide-step-lede { font-size: 14px; color: var(--muted); margin-top: 4px; }

.guide-points { margin: 0; padding: 0; list-style: none; counter-reset: guidepoint; display: flex; flex-direction: column; gap: 10px; }
.guide-points li {
  position: relative;
  counter-increment: guidepoint;
  padding-left: 34px;
  font-size: 14px;
  color: var(--ink);
}
.guide-points li::before {
  content: counter(guidepoint);
  position: absolute;
  left: 0;
  top: -1px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--guide-mark);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.guide-points strong { color: var(--ink-strong); }
.guide-points a { color: var(--brand); }

.guide-aside {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 13px;
  color: var(--muted);
}

.guide-figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  box-shadow: var(--shadow);
}
.guide-figure figcaption { font-size: 12.5px; color: var(--faint); text-align: center; }
.guide-figure figcaption strong {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin: 0 1px;
  border-radius: 50%;
  background: var(--guide-mark);
  color: #fff;
  font-size: 11px;
  vertical-align: -3px;
}
.guide-figure.inline img { box-shadow: var(--shadow-xs); border-radius: var(--radius-sm); }
.guide-figure.wide img { box-shadow: var(--shadow); }

.guide-subgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); }
.guide-sub {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.guide-sub h4 { font-size: 15.5px; }
.guide-sub p { font-size: 13.5px; color: var(--muted); }
.guide-sub .guide-figure.inline img { max-height: 190px; object-fit: cover; object-position: top center; }

.guide-route-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); }
.guide-route {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.guide-route h3 { font-size: 17px; }
.guide-route p { font-size: 13.5px; color: var(--muted); }
.guide-route-tag {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.guide-route .guide-figure { margin-top: auto; }

.guide-fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.guide-fact {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.guide-fact strong { font-size: 13.5px; color: var(--ink-strong); }
.guide-fact span { font-size: 13px; color: var(--muted); }

.guide-tip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.guide-tip {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: var(--pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.guide-tip span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 15px;
}
.guide-tip h4 { font-size: 14.5px; }
.guide-tip p { font-size: 13px; color: var(--muted); }

.guide-faq { display: flex; flex-direction: column; gap: 10px; }
.guide-faq .panel-body p { font-size: 13.5px; color: var(--muted); }

.guide-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(24px, 3.6vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(700px 300px at 90% 120%, var(--accent-soft), transparent 60%),
    var(--brand-soft);
}
.guide-cta h2 { font-size: clamp(21px, 2.6vw, 28px); }
.guide-cta p { color: var(--muted); font-size: 14.5px; margin-top: 6px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-hero { grid-template-columns: minmax(0, 1fr); }
  .guide-step { grid-template-columns: minmax(0, 1fr); }
  .guide-step.reverse .guide-step-body { order: 0; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-topbar { position: static; }
  .guide-toc { position: static; border-radius: var(--radius); }
  .app-rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand-text small { display: none; }
  .brand-button { width: auto; flex: 0 0 auto; }
  .rail-nav { flex-direction: row; flex: 1 1 auto; }
  .rail-foot { display: none; }
  .template-list-item { grid-template-columns: minmax(0, 1fr); }
  .template-list-item .button-row { justify-content: flex-start; }
  .narrative-row { grid-template-columns: minmax(0, 1fr); }
  .student-note-row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .stepper { grid-template-columns: minmax(0, 1fr); }
  .split-actions { flex-direction: column-reverse; align-items: stretch; }
  .split-actions .button { width: 100%; }
  .sticky-actions { position: static; }
}

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

@media print {
  .app-rail, .app-topbar, .sticky-actions, .toast-host { display: none !important; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .panel, .editor-section, .template-card { box-shadow: none; }
}
