/* Private operations desk — shared visual system.
   Editorial, calm, and deliberately low-chrome so the data stays in front. */

:root {
  color-scheme: light;
  --ink: #14211d;
  --ink-2: #2b3a34;
  --muted: #5f6b65;
  --faint: #626e68;
  --canvas: #f2efe7;
  --canvas-deep: #e9e3d7;
  --paper: #fbfaf6;
  --paper-2: #f6f2e9;
  --line: #d9d2c4;
  --line-strong: #bdb4a4;
  --accent: #1c4d3e;
  --accent-2: #2f6b55;
  --accent-soft: #e5eee7;
  --copper: #99562f;
  --copper-soft: #f2e3d6;
  --gold: #ad874e;
  --danger: #a33f35;
  --danger-soft: #f7e6e2;
  --success: #2e6a53;
  --success-soft: #e6efe8;
  --warning: #966127;
  --warning-soft: #f6ead8;
  --blue: #3e6373;
  --blue-soft: #e8eef1;
  --shadow-sm: 0 1px 0 rgba(20, 33, 29, .035);
  --shadow-md: 0 18px 48px rgba(20, 33, 29, .085);
  --shadow-lg: 0 30px 90px rgba(20, 33, 29, .16);
  --radius: 2px;
  --radius-md: 4px;
  --radius-lg: 7px;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, "Times New Roman", serif;
  --sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Older page styles use these names. Keep them as aliases. */
  --green: var(--accent);
  --green-light: var(--accent-soft);
  --green-soft: var(--success-soft);
  --amber: var(--warning);
  --amber-light: var(--warning-soft);
  --amber-soft: var(--warning-soft);
  --red: var(--danger);
  --surface: var(--paper);
  --soft: var(--accent-soft);
  --bg: var(--canvas);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -8%, rgba(168, 98, 58, .07), transparent 34rem),
    radial-gradient(circle at 96% 3%, rgba(28, 77, 62, .075), transparent 30rem),
    var(--canvas);
  font: 14.5px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--copper); }
img, svg, video { max-width: 100%; }
::selection { background: #cfdfc9; color: var(--ink); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */

.admin-body { min-height: 100vh; }
.admin-shell {
  min-height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}
.admin-rail {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 20px 22px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(251, 250, 246, .86), rgba(246, 242, 233, .72)),
    var(--canvas);
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.admin-brand:hover { color: var(--ink); }
.admin-brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 1px;
  background: var(--accent);
  color: #f8f4e9;
  font: 600 19px/1 var(--serif);
}
.admin-brand-copy { display: grid; gap: 1px; min-width: 0; }
.admin-brand-copy strong { font: 600 17px/1.2 var(--serif); letter-spacing: .02em; }
.admin-brand-copy small {
  color: var(--faint);
  font: 9px/1.4 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.admin-nav { display: grid; gap: 18px; }
.admin-nav { scrollbar-width: none; -ms-overflow-style: none; }
.admin-nav::-webkit-scrollbar { display: none; width: 0; height: 0; background: transparent; }
.admin-nav-group { display: grid; gap: 2px; }
.admin-nav-label {
  padding: 0 10px 5px;
  color: var(--faint);
  font: 9px/1.2 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
}
.admin-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 560;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.admin-nav-link::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: transparent;
  transition: background .2s ease;
}
.admin-nav-link:hover { background: rgba(255, 255, 255, .52); color: var(--accent); transform: translateX(1px); }
.admin-nav-link.is-active { background: rgba(255, 255, 255, .7); color: var(--accent); }
.admin-nav-link.is-active::before { background: var(--copper); }
.nav-index {
  width: 17px;
  flex: none;
  color: var(--faint);
  font: 9px/1 var(--mono);
  letter-spacing: .04em;
}
.admin-nav-link.is-active .nav-index { color: var(--copper); }
.admin-rail-foot { margin-top: auto; display: grid; gap: 9px; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.admin-public-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.admin-public-link span { transition: transform .2s ease; }
.admin-public-link:hover span { transform: translate(2px, -2px); }
.admin-rail-note { margin: 0; color: var(--faint); font: 9px/1.5 var(--mono); letter-spacing: .05em; }

.admin-stage { min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(189, 180, 164, .6);
  background: rgba(242, 239, 231, .84);
  backdrop-filter: blur(14px) saturate(1.15);
}
.admin-topbar-inner {
  min-height: 54px;
  padding: 0 clamp(20px, 3.2vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.admin-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font: 10px/1.4 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.admin-context-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(47, 107, 85, .12);
}
.admin-context-sep { width: 1px; height: 11px; background: var(--line); }
.admin-top-actions { display: flex; align-items: center; gap: 16px; }
.admin-top-actions a {
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}
.admin-top-actions a:hover { color: var(--copper); }
.admin-top-actions form { margin: 0; }
.logout-button, .logout {
  border: 0;
  padding: 3px 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
}
.logout-button:hover, .logout:hover { color: var(--copper); text-decoration: underline; }

.admin-page {
  width: 100%;
  min-width: 0;
  max-width: 1680px;
  margin: 0 auto;
  padding: clamp(28px, 3.8vw, 54px) clamp(20px, 3.4vw, 56px) 96px;
}

/* ---------- Login ---------- */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-page { width: min(100%, 430px); }
.login-brand { margin-bottom: 34px; }
.login-card {
  padding: clamp(26px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-md);
}
.login-card .eyebrow { margin-bottom: 11px; }
.login-card h1 { font-size: clamp(2rem, 7vw, 2.7rem); }
.login-card p { color: var(--muted); font-size: 12.5px; }
.login-card form { display: grid; gap: 16px; margin-top: 26px; }
.login-card button { width: 100%; min-height: 44px; }
.login-foot { margin-top: 18px; color: var(--faint); font: 9.5px/1.7 var(--mono); letter-spacing: .05em; text-align: center; }

/* ---------- Headings ---------- */

.page-head, .heading, .page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: clamp(24px, 3vw, 38px);
}
.page-head-copy { max-width: 760px; }
.page-head-copy, .page-lede, h1 { min-width: 0; }
.eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--copper);
  font: 9px/1.3 var(--mono);
  letter-spacing: .2em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font: 600 clamp(2rem, 3.1vw, 3.25rem)/1.08 var(--serif);
  letter-spacing: -.035em;
  text-wrap: balance;
}
.page-lede, .page-head .sub, .heading .sub, .page-heading p {
  max-width: 66ch;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}
.page-head-actions, .heading > div:last-child {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 18px;
}
.page-head-actions a, .heading a, .heading-link {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}
.page-head-actions a:hover, .heading a:hover, .heading-link:hover { color: var(--copper); }
h2 { margin: 0; font: 600 17px/1.35 var(--sans); letter-spacing: -.01em; }
h3 { margin: 0; font: 650 15px/1.4 var(--sans); }
h4 { margin: 0 0 12px; font: 600 12px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.muted, small { color: var(--muted); }
p { margin: 6px 0; }

/* ---------- KPI / summary ---------- */

.stats, .summary-strip, .kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0 0 clamp(24px, 3vw, 38px);
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .5);
}
.stat, .summary-item, .kpi {
  min-width: 0;
  padding: 18px 22px 16px;
  border-right: 1px solid var(--line);
}
.stat:last-child, .summary-item:last-child, .kpi:last-child { border-right: 0; }
.stat span, .summary-item span, .kpi span {
  display: block;
  color: var(--muted);
  font: 9px/1.4 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.stat strong, .summary-item strong, .kpi strong {
  display: block;
  margin: 5px 0 1px;
  font: 500 clamp(2rem, 3vw, 3.1rem)/1 var(--serif);
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
}
.stat small, .summary-item small, .kpi small {
  display: block;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.5;
}
.stat.warn strong, .summary-item.warn strong, .kpi.warn strong { color: var(--copper); }

/* ---------- Panels ---------- */

.panel, .workspace-main, .section-panel {
  min-width: 0;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease;
}
.admin-page > section:not(.monitor-band):not(.preview) {
  min-width: 0;
  margin-bottom: 20px;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.admin-page > section:not(.monitor-band):not(.preview) > h2:first-child { margin-top: 0; }
.admin-page > section > form { display: grid; gap: 14px; margin-top: 16px; }
.admin-page > section > form > .actions { margin-top: 2px; padding-top: 14px; border-top: 1px solid var(--line); }
.panel:hover, .workspace-main:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.panel > h2:first-child, .panel > .panel-head:first-child { margin-top: 0; }
.wide { margin-bottom: 20px; }
.panel-head, .section-head, .section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head p, .section-head p, .section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-head h2, .section-head h2, .section-heading h2 { margin: 0; }
.section-head small, .panel-head small { color: var(--faint); font: 10px/1.4 var(--mono); letter-spacing: .04em; }
.monitor-band {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--copper);
  border-radius: var(--radius-md);
  background: linear-gradient(100deg, rgba(251, 250, 246, .96), rgba(246, 242, 233, .7));
}
.monitor-band > div { display: flex; flex-direction: column; min-width: 200px; gap: 2px; }
.monitor-kicker { color: var(--copper); font: 9px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.monitor-band strong { font: 600 20px/1.2 var(--serif); }
.monitor-band small { color: var(--muted); font-size: 11px; }
.monitor-band ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11.5px; }
.notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--accent);
  font-size: 12.5px;
}
.notice.error, .error { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.notice.success, .success { border-left-color: var(--success); background: var(--success-soft); color: var(--success); }
.insight {
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(251, 250, 246, .72);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.8;
}
.insight strong { color: var(--accent); }

/* ---------- Toolbar / tabs / search ---------- */

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.toolbar-left, .toolbar-right, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.toolbar-left { flex-wrap: nowrap; }
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.tab, .filter {
  min-height: 36px;
  padding: 8px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.tab:hover, .filter:hover { color: var(--ink); }
.tab[aria-pressed="true"], .filter[aria-pressed="true"], .tab.active, .filter.active {
  border-bottom-color: var(--copper);
  background: transparent;
  color: var(--accent);
}
.search, input[type="search"], input[type="date"] {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  font-size: 12.5px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.search { width: 280px; }
.search:focus, input[type="search"]:focus, input[type="date"]:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(28, 77, 62, .08);
}
::placeholder { color: var(--faint); opacity: 1; }
.result-line { min-height: 32px; display: flex; align-items: center; justify-content: space-between; color: var(--faint); font: 10px/1.4 var(--mono); letter-spacing: .04em; }

/* ---------- Buttons ---------- */

.button, .primary-button, .secondary-button, .new-link, .save-button, .continue-link,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #f9f6ee;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:hover, .primary-button:hover, .new-link:hover, .save-button:hover, .continue-link:hover,
button[type="submit"]:hover {
  border-color: #123a2f;
  background: #123a2f;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(20, 33, 29, .12);
}
.button:active, .primary-button:active, .save-button:active, button[type="submit"]:active { transform: translateY(0); }
.button.secondary, .secondary-button, .new-link, .continue-link,
button[type="submit"].secondary, .extract-action button[type="submit"] {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink-2);
}
.button.secondary:hover, .secondary-button:hover, .new-link:hover, .continue-link:hover,
button[type="submit"].secondary:hover, .extract-action button[type="submit"]:hover {
  border-color: var(--copper);
  background: var(--copper-soft);
  color: var(--ink);
  box-shadow: none;
}
.text-button, .row-action, .row-link, .expand-button, .clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 650;
  text-decoration: none;
}
.text-button:hover, .row-action:hover, .row-link:hover, .expand-button:hover, .clear:hover {
  color: var(--copper);
  text-decoration: underline;
}
.text-button::after, .row-link::after, .external-link::after { content: "↗"; font-size: 10px; transition: transform .18s ease; }
.text-button:hover::after, .row-link:hover::after, .external-link:hover::after { transform: translate(1px, -1px); }
button:disabled, fieldset:disabled, .button[aria-disabled="true"] { opacity: .52; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ---------- Forms ---------- */

label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
input:not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .76);
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(28, 77, 62, .08);
  outline: none;
}
textarea { min-height: 104px; resize: vertical; line-height: 1.65; }
input[type="file"] { width: 100%; padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.form-grid, .edit-fields, .field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 18px;
}
.form-grid .wide, .edit-fields label.wide { grid-column: 1 / -1; }
.edit-actions, .form-actions, .upload-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.edit-actions span, .form-actions span, .upload-actions span { color: var(--muted); font-size: 11.5px; }
.field { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; gap: 5px; padding: 9px 0; border-top: 1px solid var(--line); }
.field > span { color: var(--ink-2); font-size: 11.5px; font-weight: 650; }
.field small { color: var(--faint); font-size: 10px; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); background: rgba(242, 239, 231, .92); backdrop-filter: blur(10px); }

/* ---------- Tables ---------- */

.table-wrap, .grid-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}
.table-wrap::-webkit-scrollbar, .grid-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-thumb, .grid-scroll::-webkit-scrollbar-thumb { border: 3px solid var(--paper); border-radius: 10px; background: var(--line-strong); }
.table-wrap::-webkit-scrollbar-track, .grid-scroll::-webkit-scrollbar-track { background: transparent; }
.grid-scroll { max-height: 68vh; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12.5px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper-2);
  color: var(--muted);
  font: 9px/1.4 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr { transition: background .18s ease; }
tbody tr:hover { background: rgba(255, 255, 255, .75); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.building-table { min-width: 980px; }
.building-row { background: transparent; }
.building-row:hover { background: rgba(255, 255, 255, .8); }
.building-row th strong, .case-row th strong { display: block; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.building-row small, .case-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 10.5px; overflow-wrap: anywhere; }
.building-row td strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.summary-copy { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--ink-2); font-size: 11.5px; }
.case-panel > td { padding: 0 14px 18px 34px; background: var(--paper-2); }
.case-wrap { border-left: 2px solid var(--line-strong); overflow-x: auto; }
.case-table { min-width: 920px; background: var(--paper); }
.case-table th, .case-table td { padding: 10px 12px; }
.quote { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.missing { color: var(--copper); font-weight: 650; }
.empty, .empty-history {
  padding: 44px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(251, 250, 246, .5);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.queue-empty { padding: 18px 11px; color: var(--faint); font-size: 11.5px; }
details summary { cursor: pointer; color: var(--accent); font-size: 11.5px; }
details summary:hover { color: var(--copper); }
.pager { display: flex; gap: 18px; padding: 14px 0; font-weight: 650; }

/* ---------- Badges / status ---------- */

.badge, .pill, .status, .issue, .queue-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font: 9.5px/1.3 var(--mono);
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before, .status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status.live, .pill.live, .badge.verified, .queue-state.reviewed { background: var(--success-soft); color: var(--success); }
.status.off, .pill.muted { background: #ece9e2; color: var(--muted); }
.badge.claimed, .queue-state.pending { background: var(--warning-soft); color: var(--warning); }
.badge.fail, .queue-state.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.diagnostic { background: var(--blue-soft); color: var(--blue); }
.issue { border-radius: var(--radius); background: var(--warning-soft); color: var(--warning); }
.clean { color: var(--success); font-size: 11px; }

/* ---------- Property list ---------- */

.column-head {
  display: grid;
  grid-template-columns: minmax(310px, 1.8fr) minmax(115px, .48fr) minmax(130px, .6fr) 98px;
  gap: 20px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font: 9px/1.4 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.properties { border-top: 1px solid var(--line); }
.property {
  display: grid;
  grid-template-columns: minmax(310px, 1.8fr) minmax(115px, .48fr) minmax(130px, .6fr) 98px;
  gap: 20px;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .55);
  transition: background .2s ease, box-shadow .2s ease;
}
.property:hover { background: var(--paper); box-shadow: inset 2px 0 0 var(--copper); }
.property-main { min-width: 0; }
.property-title { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.property h3 { margin: 0; font: 600 16px/1.35 var(--serif); overflow-wrap: anywhere; }
.property-meta { display: flex; flex-wrap: wrap; gap: 0 10px; margin-top: 5px; color: var(--muted); font-size: 11.5px; }
.property-meta span + span::before { content: "·"; margin-right: 10px; color: var(--faint); }
.property-issues { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; min-height: 19px; }
.property-signal { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.signal-label { display: none; color: var(--faint); font: 9px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.property-signal strong { font-size: 11.5px; font-weight: 600; overflow-wrap: anywhere; }
.property-signal small { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.property-action { text-align: right; }
.property-detail { grid-column: 1 / -1; padding: 20px 0 3px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: minmax(190px, .9fr) minmax(230px, 1.2fr) minmax(230px, 1fr); gap: 28px; }
.detail-grid section { min-width: 0; }
.detail-grid section > h4:first-child { margin-top: 0; }
dl { display: grid; grid-template-columns: 72px 1fr; gap: 8px 11px; margin: 0 0 14px; font-size: 11.5px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.history { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; }
.history li { display: grid; grid-template-columns: 78px 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 11.5px; }
.history li:first-child { border-top: 0; padding-top: 0; }
.history time { color: var(--faint); font: 10px/1.5 var(--mono); }
.history strong { font-size: 11.5px; }
.history span, .history small { grid-column: 2; color: var(--muted); overflow-wrap: anywhere; }
.history small { font-size: 10.5px; }
.record-form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.record-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.record-form label:nth-of-type(3), .record-form label:nth-of-type(4), .record-form label:nth-of-type(5) { grid-column: 1 / -1; }
.record-form input, .record-form select, .record-form textarea { width: 100%; min-width: 0; font-size: 12px; }

/* ---------- Dialogs ---------- */

dialog {
  width: min(790px, calc(100vw - 24px));
  max-height: min(90vh, 960px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(20, 33, 29, .48); backdrop-filter: blur(3px); }
.editor-dialog { width: min(790px, calc(100vw - 24px)); }
.import-dialog { width: min(470px, calc(100vw - 24px)); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--paper); }
.dialog-head h2 { margin: 0; font: 600 21px/1.3 var(--serif); }
.dialog-head-actions { display: flex; align-items: center; flex: none; gap: 14px; }
.dialog-body { padding: 0 24px 26px; }
.edit-hint { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--line); background: var(--paper-deep, #f6f3ec); color: var(--muted, #6b6b63); font-size: 13px; line-height: 1.6; }
.close-dialog, .close {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.close-dialog:hover, .close:hover { background: var(--copper-soft); color: var(--ink); transform: rotate(4deg); }

/* ---------- Discovery-specific ---------- */

.controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0 12px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(251, 250, 246, .7);
}
.controls label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10.5px; }
.controls input, .controls select { min-height: 36px; padding: 7px 10px; font-size: 11.5px; }
.advanced { flex: 1 0 100%; }
.advanced summary { cursor: pointer; color: var(--accent); font-size: 11px; font-weight: 650; }
.advanced-fields { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; }
.quick button { min-height: 30px; padding: 4px 9px; border: 1px solid transparent; background: transparent; font-size: 11px; }
.quick .selected { border-color: var(--line-strong); background: var(--paper); color: var(--accent); }
.filter-note { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 20px; color: var(--faint); font: 10px/1.5 var(--mono); }
.chart { position: relative; height: 225px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--faint); font: 10px/1 var(--mono); }
.axis { stroke: var(--line); stroke-width: 1; }
.chart rect { cursor: pointer; transition: opacity .18s ease; }
.chart rect:hover { opacity: .72; }
.legend { display: flex; flex-wrap: wrap; gap: 13px; color: var(--muted); font-size: 10.5px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; }
.agent-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.agent-row:last-child { border: 0; }
.agent-title { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.agent-title button { border: 0; padding: 0; min-height: 0; background: none; font-size: 11.5px; font-weight: 650; text-align: left; }
.agent-title strong { font: 600 14px/1 var(--mono); }
.track { height: 4px; margin: 8px 0 5px; border-radius: 9px; background: var(--paper-2); overflow: hidden; }
.track span { display: block; height: 100%; border-radius: 9px; background: var(--accent-2); }
.agent-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--faint); font-size: 9.5px; }
.outcomes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.outcome { padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-2); }
.outcome span { display: block; color: var(--muted); font-size: 10.5px; }
.outcome strong { font: 500 26px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.sources { display: flex; flex-wrap: wrap; gap: 10px; }
.source { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 10.5px; }
.source b { display: block; margin-bottom: 2px; font-size: 11.5px; }
.source.dim { color: var(--faint); }
.evidence { max-width: 650px; padding: 9px 0; color: var(--muted); font: 10px/1.7 var(--mono); white-space: normal; overflow-wrap: anywhere; }
.page-link { display: block; max-width: 420px; padding: 0; border: 0; background: none; color: var(--ink); font-size: 11.5px; font-weight: 650; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.page-path { display: block; max-width: 430px; color: var(--faint); font: 9.5px/1.8 var(--mono); white-space: normal; overflow-wrap: anywhere; }
.daily-tabs { display: flex; gap: 6px; }
.daily-tabs button[aria-pressed="true"] { border-color: var(--line-strong); background: var(--paper-2); color: var(--accent); }
.table-note { margin: 10px 0 0; color: var(--faint); font-size: 10.5px; }
.load { color: var(--muted); font-size: 11px; }
.auto { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; }
.auto input { min-height: auto; }

/* ---------- Utility ---------- */

.stack { display: grid; gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 26px; align-items: start; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.queue { position: sticky; top: 78px; padding-top: 14px; border-top: 1px solid var(--line); }
.queue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 2px 1px 13px; border-bottom: 1px solid var(--line); }
.queue-head h2 { font-size: 15px; }
.queue-head span { color: var(--faint); font: 10px/1.4 var(--mono); }
.queue-list { list-style: none; padding: 0; margin: 0; max-height: calc(100vh - 190px); overflow: auto; }
.queue-list li { border-bottom: 1px solid var(--line); }
.queue-item { display: block; padding: 14px 11px; border-left: 2px solid transparent; color: var(--ink); text-decoration: none; transition: background .18s ease, border-color .18s ease; }
.queue-item:hover, .queue-item.current { border-left-color: var(--copper); background: rgba(255, 255, 255, .62); }
.queue-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.queue-top strong { font-size: 12px; }
.queue-copy { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 6px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.queue-meta { display: block; margin-top: 7px; color: var(--faint); font: 9.5px/1.4 var(--mono); }
.upload-section + .upload-section { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--line); }
.upload-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 128px; padding: 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); background: var(--paper-2); text-align: center; transition: border-color .2s ease, background .2s ease; }
.upload-drop:hover, .upload-drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.upload-drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-drop span { color: var(--accent); font-weight: 650; }
.upload-drop small { color: var(--muted); font-size: 11px; }
.upload-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.upload-preview figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.upload-preview img, .upload-preview video { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--paper-2); }
.upload-preview figcaption { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 5px 7px; }
.upload-preview .file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.file-actions { display: flex; gap: 1px; }
.file-actions button { width: 25px; height: 25px; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 15px; }
.file-actions button:hover { background: var(--accent-soft); }
.previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.previews figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.previews img, .previews video { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--paper-2); }
.previews figcaption { padding: 5px 7px; color: var(--muted); font-size: 10px; }
pre { min-height: 118px; max-height: 320px; margin: 0; padding: 14px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); font: 11.5px/1.7 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.checks { list-style: none; padding: 0; margin: 12px 0; }
.checks li { margin-bottom: 6px; padding: 8px 11px; border-left: 2px solid var(--line); background: var(--paper-2); font-size: 11.5px; }
.checks li.block { border-color: var(--danger); color: var(--danger); }
.checks li.warn { border-color: var(--warning); color: var(--warning); }
.checks li.ok { border-color: var(--success); color: var(--success); }
.titles { display: flex; flex-wrap: wrap; gap: 8px; }
.titles form { margin: 0; }
.titles button { text-align: left; }
.external-link { font-size: 11px; font-weight: 650; }

/* ---------- Motion ---------- */

@keyframes admin-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes admin-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(47, 107, 85, .12); }
  50% { box-shadow: 0 0 0 5px rgba(47, 107, 85, .04); }
}
.admin-page > * { animation: admin-rise .52s cubic-bezier(.22, .8, .2, 1) both; }
.admin-page > *:nth-child(2) { animation-delay: .04s; }
.admin-page > *:nth-child(3) { animation-delay: .08s; }
.admin-page > *:nth-child(4) { animation-delay: .12s; }
.admin-page > *:nth-child(5) { animation-delay: .16s; }
.admin-context-dot { animation: admin-pulse 3.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .admin-shell { display: block; }
  .admin-rail {
    position: relative;
    height: auto;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    padding: 16px 20px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .admin-brand { flex: none; }
  .admin-nav { order: 3; display: flex; width: 100%; flex-wrap: wrap; gap: 2px; overflow: visible; scrollbar-width: auto; }
  .admin-nav-group { display: contents; }
  .admin-nav-label, .admin-rail-foot { display: none; }
  .admin-nav-link { min-height: 38px; padding: 9px 11px; border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap; }
  .admin-nav { scroll-snap-type: x proximity; }
  .admin-nav-link { scroll-snap-align: start; }
  .admin-nav-link::before { display: none; }
  .admin-nav-link.is-active { border-bottom-color: var(--copper); background: transparent; }
  .admin-nav-link:hover { background: rgba(255, 255, 255, .5); transform: none; }
  .admin-topbar { position: relative; }
  .workspace, .split { grid-template-columns: 1fr; }
  .queue { position: static; }
  .queue-list { max-height: 300px; }
}

@media (max-width: 900px) {
  .stats, .summary-strip, .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat, .summary-item, .kpi { border-bottom: 1px solid var(--line); }
  .stat:nth-child(3n), .summary-item:nth-child(3n), .kpi:nth-child(3n) { border-right: 0; }
  .column-head { display: none; }
  .property { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 9px 14px; }
  .property-main, .property-detail { grid-column: 1 / -1; }
  .property-action { grid-column: 3; text-align: right; }
  .signal-label { display: block; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid section:last-child { grid-column: 1 / -1; }
  .form-grid, .edit-fields, .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .workspace { gap: 20px; }
}

@media (max-width: 680px) {
  .admin-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent); }
  .admin-topbar-inner { min-height: 48px; flex-wrap: wrap; gap: 4px 12px; padding: 7px 16px; }
  .admin-context span:nth-child(n+3) { display: none; }
  .admin-page { padding: 24px 16px 72px; }
  h1 { font-size: clamp(1.9rem, 9vw, 2.6rem); }
  h1, .page-lede, .heading .sub, .page-heading p { overflow-wrap: anywhere; }
  .page-head, .heading, .page-heading { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 24px; }
  .page-head-copy, .page-head-actions { width: 100%; }
  .page-head-actions, .heading > div:last-child { justify-content: flex-start; }
  .stats, .summary-strip, .kpi-row { grid-template-columns: 1fr 1fr; }
  .stat, .summary-item, .kpi { padding: 14px 15px; border-right: 1px solid var(--line); }
  .stat:nth-child(2n), .summary-item:nth-child(2n), .kpi:nth-child(2n) { border-right: 0; }
  .stat:last-child, .summary-item:last-child, .kpi:last-child { grid-column: 1 / -1; border-right: 0; }
  .stat strong, .summary-item strong, .kpi strong { font-size: 2rem; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar { display: flex; }
  .toolbar-left { flex-wrap: wrap; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search { width: 100%; }
  .tabs { width: 100%; }
  .property { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 15px 12px; }
  .property-action { grid-column: 1 / -1; text-align: left; }
  .detail-grid { grid-template-columns: 1fr; gap: 20px; }
  .detail-grid section:last-child { grid-column: auto; }
  .form-grid, .edit-fields, .field-grid { grid-template-columns: 1fr; }
  .edit-heading, .panel-head, .section-head, .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .monitor-band { flex-direction: column; gap: 10px; padding: 16px; }
  .outcomes { grid-template-columns: 1fr; }
  .upload-preview, .previews { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-head { padding: 16px; }
  .dialog-body { padding: 0 16px 22px; }
  .editor-dialog, dialog { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .table-wrap, .grid-scroll { border-radius: var(--radius); }
}

@media print {
  .admin-rail, .admin-topbar, .page-head-actions, .toolbar, .pager { display: none !important; }
  .admin-shell { display: block; }
  .admin-page { padding: 0; max-width: none; }
  body { background: #fff; }
}
