/* Application layer, built on css/system.css.
   The system owns tokens and primitives; this file owns the shell and the
   seven screens. Nothing here invents a colour, a radius or a duration — if a
   value is needed and the system has no name for it, the name belongs there. */

/* ══════════════════════════════════════════════════════════════════════════
   Shell
   ══════════════════════════════════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}

/* ── the rail ─────────────────────────────────────────────────────────── */

.rail {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--rail-bg); color: var(--rail-ink);
  border-right: 1px solid var(--rail-border);
}

.rail-brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-4) var(--s-4);
}
.rail-mark {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  background: var(--fill-primary); color: var(--ink-on-fill);
  font-weight: var(--weight-bold); font-size: var(--text-sm);
  letter-spacing: -0.02em;
}
.rail-names { display: flex; flex-direction: column; min-width: 0; }
.rail-kicker {
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--rail-ink-quiet);
}
.rail-name {
  font-size: var(--text-md); font-weight: var(--weight-semibold);
  color: var(--rail-ink-active); line-height: var(--leading-tight);
}

.global-search {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 44px; margin: 0 var(--s-3) var(--s-2); padding: 0 var(--s-3);
  color: var(--rail-ink-active); background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: var(--radius-md); font-size: var(--text-sm);
  font-weight: var(--weight-medium); text-decoration: none;
}
.global-search:hover {
  color: var(--rail-ink-active); background: var(--rail-bg-hover);
  text-decoration: none;
}
.global-search[aria-current='page'] {
  color: var(--rail-ink-active); background: var(--rail-bg-active);
  border-color: #5f8fd0;
}
.global-search-short { display: none; }

.rail-nav {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  overflow-y: auto; min-height: 0; flex: 1;
}
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group-items { display: flex; flex-direction: column; gap: 2px; }
.rail-section {
  padding: var(--s-4) var(--s-2) var(--s-1);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--rail-ink-quiet);
}
.rail-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 42px; padding: 0 var(--s-3);
  text-align: left; background: none; border: 0; border-radius: var(--radius-md);
  color: var(--rail-ink); font-size: var(--text-md); font-weight: var(--weight-medium);
  text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.rail-item:hover { text-decoration: none; }
.rail-item svg { flex: none; opacity: 0.85; }
.rail-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item:hover { background: var(--rail-bg-hover); color: var(--rail-ink-active); }
.rail-item[aria-current='page'] {
  background: var(--rail-bg-active); color: var(--rail-ink-active);
  font-weight: var(--weight-semibold);
}
.rail-item[aria-current='page'] svg { opacity: 1; color: #9fc3ff; }

/* A count is a quiet number, except when the screen it points at is where the
   work is waiting — then it is a filled pill you cannot miss. */
.rail-count {
  flex: none; min-width: 20px; padding: 1px 6px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  text-align: center; border-radius: var(--radius-full);
  background: var(--n-200); color: var(--n-700);
}
.rail-item[aria-current='page'] .rail-count { background: var(--blue-100); color: var(--blue-800); }
.rail-count--alert { background: var(--fill-danger); color: var(--ink-on-fill); }

.rail-foot {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-top: 1px solid var(--rail-border);
}
.rail-sync {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--text-xs); color: var(--rail-ink-quiet);
}
.rail-sync-dot {
  width: 7px; height: 7px; flex: none; border-radius: var(--radius-full);
  background: var(--green-500);
}
.rail-sync-dot--warn { background: var(--amber-500); }

.rail-user { display: flex; align-items: center; gap: var(--s-3); }
.rail-avatar {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--blue-100); color: var(--blue-800);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.rail-user-lines { display: flex; flex-direction: column; min-width: 0; }
.rail-role {
  appearance: none; background: none; border: 0; padding: 0;
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--rail-ink-active); cursor: pointer;
  min-height: 24px;
}
.rail-role option { color: var(--ink); background: var(--surface); }
.rail-role-label {
  font-size: var(--text-2xs); color: var(--rail-ink-quiet);
}
.rail-account {
  font-size: var(--text-xs); color: var(--rail-ink-quiet);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── main pane ────────────────────────────────────────────────────────── */

.main {
  display: grid;
  /* the column is stated, not left to `auto` — an auto column sizes to its
     items' max-content, so the topbar's unwrapped width set the width of the
     whole pane and pushed the page sideways by a dozen pixels */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0; overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-4) var(--s-6);
  background: var(--surface); border-bottom: 1px solid var(--border);
  z-index: var(--z-header);
}
.topbar-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; margin-right: auto; }
.topbar-eyebrow {
  font-size: var(--text-xs); color: var(--ink-subtle);
}
.topbar-title { font-size: var(--text-2xl); }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }

.location-cue {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; max-width: min(380px, 100%);
  padding: var(--s-2) var(--s-3);
  color: var(--ink-primary); background: var(--blue-50);
  border-radius: var(--radius-md); text-decoration: none;
}
.location-cue:hover { background: var(--blue-100); text-decoration: none; }
.location-cue-lines { display: flex; flex-direction: column; min-width: 0; }
.location-cue-title {
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.location-cue-note { font-size: var(--text-xs); color: var(--ink-muted); }
.location-cue--mobile-only { display: none; }

.topbar-title:focus { outline: none; }
/* Focus lands here after a navigation so the new page is announced. It is not a
   tab stop and the user did not press a key to reach it, so it draws no ring —
   the previous version focused the whole scroll region and painted a 2px box
   around the entire screen on every route change. */

/* The scroll container. data-scroll lets the focus snapshot restore its
   position; tabindex keeps it programmatically focusable without adding a tab
   stop or a full-width ring. */
.content {
  overflow: auto; padding: var(--s-6);
  scroll-behavior: smooth;
}
.content:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { .content { scroll-behavior: auto; } }

/* One measure for every screen, so the rail, the topbar and the work below
   all start and stop on the same verticals however wide the monitor is. */
.screen { max-width: 1400px; display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.screen > * { min-width: 0; }

.future-route {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3);
  max-width: 680px; padding: var(--s-8);
  background: var(--surface-raised); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.future-route-icon {
  display: grid; place-items: center; width: 44px; height: 44px;
  color: var(--ink-primary); background: var(--blue-50);
  border-radius: var(--radius-md);
}
.future-route-title { font-size: var(--text-2xl); }

/* ══════════════════════════════════════════════════════════════════════════
   The tab bar and the “Thêm” sheet — mobile only
   ══════════════════════════════════════════════════════════════════════ */

.tabbar { display: none; }
.sheet-wrap { display: none; }
.is-sheet-open body { overflow: hidden; }

@media (max-width: 900px) {
  .tabbar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-rail);
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 56px; padding: var(--s-2) var(--s-1);
    background: none; border: 0; cursor: pointer; text-decoration: none;
    color: var(--ink-muted); position: relative;
  }
  .tabbar-item:hover { text-decoration: none; }
  .tabbar-label {
    font-size: var(--text-2xs); font-weight: var(--weight-medium);
    line-height: 1.2; text-align: center;
  }
  .tabbar-item[aria-current='page'] { color: var(--ink-primary); font-weight: var(--weight-semibold); }
  /* The current destination is marked by a rule at the top of its cell as well
     as by colour, so the state survives greyscale and colour blindness. */
  .tabbar-item[aria-current='page']::before {
    content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px;
    background: var(--brand); border-radius: 0 0 2px 2px;
  }
  /* the count rides the icon rather than sitting after a label there is no room for */
  .tabbar-item .rail-count {
    position: absolute; top: 4px; left: 50%; margin-left: 4px;
    min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px;
  }

  .sheet-wrap { display: block; }
  .sheet-scrim {
    position: fixed; inset: 0; z-index: var(--z-sheet);
    background: rgb(31 35 41 / 0.45); border: 0; padding: 0; cursor: pointer;
    animation: scrim-in var(--dur) var(--ease) both;
  }
  .sheet {
    position: fixed; inset-inline: 0; bottom: 0; z-index: calc(var(--z-sheet) + 1);
    display: flex; flex-direction: column; gap: var(--s-4);
    max-height: 82dvh; overflow: auto; overscroll-behavior: contain;
    padding: var(--s-4) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom, 0));
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    animation: sheet-in var(--dur) var(--ease) both;
  }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
  .sheet-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
  .sheet-nav, .sheet-section { display: flex; flex-direction: column; gap: var(--s-2); }
  .sheet-link {
    display: flex; align-items: center; gap: var(--s-3);
    min-height: 48px; padding: var(--s-2) var(--s-3);
    background: none; border: 0; border-radius: var(--radius-md);
    color: var(--ink); font-size: var(--text-md); text-align: left;
    text-decoration: none; cursor: pointer; width: 100%;
  }
  .sheet-link:hover { background: var(--surface-hover); text-decoration: none; }
  .sheet-link[aria-current='page'] { background: var(--surface-selected); color: var(--ink-primary); font-weight: var(--weight-semibold); }
  .sheet-link .push-start { margin-right: auto; display: flex; flex-direction: column; gap: 1px; }
  .sheet-link-note { font-size: var(--text-xs); color: var(--ink-subtle); font-weight: var(--weight-normal); }
  .sheet-role-note {
    padding: var(--s-3); color: var(--navy-800); background: var(--blue-50);
    border-radius: var(--radius-md); font-size: var(--text-xs);
  }

  .switch {
    flex: none; width: 40px; height: 24px; border-radius: var(--radius-full);
    background: var(--n-300); position: relative;
    transition: background-color var(--dur-fast) var(--ease);
  }
  .switch::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: var(--radius-full);
    background: var(--n-0); box-shadow: var(--shadow-sm);
    transition: transform var(--dur-fast) var(--ease);
  }
  .switch--on { background: var(--fill-primary); }
  .switch--on::after { transform: translateX(16px); }
}

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-scrim { animation: none; }
  .chart-line, .chart-point, .chart-percent-segment, .chart-duration-bar {
    animation: none; transition: none;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Shared pieces
   ══════════════════════════════════════════════════════════════════════ */

.stack { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
/* a button in a column does not stretch to the column's width — it is as wide
   as its label, and it starts where the text above it starts */
.stack > .btn, .stack-sm > .btn { align-self: flex-start; }
.row-flex { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.push { margin-left: auto; }
.muted { color: var(--ink-muted); }
.subtle { color: var(--ink-subtle); font-size: var(--text-xs); }
.eyebrow {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-subtle);
}
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.two-col {
  display: grid; gap: var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  align-items: start;
}
.split {
  display: grid; gap: var(--s-5);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  align-items: start;
}

/* Toolbars sit above the card they filter. */
.toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.search {
  position: relative; display: flex; align-items: center;
  flex: 1; min-width: 220px; max-width: 380px;
}
.search svg { position: absolute; left: var(--s-3); color: var(--ink-subtle); pointer-events: none; }
.search .input { padding-left: var(--s-10); }

/* ── expandable register rows ─────────────────────────────────────────── */

.rows { display: flex; flex-direction: column; }
.row + .row { border-top: 1px solid var(--border); }
/* The canvas and the sunken surface are the same grey in this system, so an
   open row is marked by the accent tint it is now the subject of, not by a
   half-step of grey that would vanish against the card. */
.row.is-open { background: var(--blue-50); }

.row-btn {
  display: grid; align-items: center; gap: var(--s-3);
  grid-template-columns: 20px minmax(0, 1fr) auto auto;
  width: 100%; padding: var(--s-3) var(--s-5);
  text-align: left; background: none; border: 0; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.row-btn:hover { background: var(--surface-hover); }
.row.is-open .row-btn { background: transparent; }
.row-btn:focus-visible { outline-offset: -3px; }

.row-mark { color: var(--ink-subtle); display: grid; place-items: center; }
.row-mark svg { transition: transform var(--dur) var(--ease); }
[aria-expanded='true'] .row-mark svg { transform: rotate(90deg); }

.row-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row-title {
  font-size: var(--text-md); font-weight: var(--weight-medium);
  line-height: var(--leading-snug); color: var(--ink);
}
.row-sub {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--ink-subtle);
}
/* the move this row is waiting for */
.row-next {
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--ink-primary); font-weight: var(--weight-medium);
}
.row-next svg { flex: none; }

/* A group's heading takes the group's tone, so the urgency reads before any
   individual row does. */
.card-head--danger { background: var(--red-50); border-bottom-color: var(--red-200); }
.card-head--danger .card-title { color: var(--ink-danger); }
.card-head--warning { background: var(--amber-50); border-bottom-color: var(--amber-200); }
.card-head--warning .card-title { color: var(--ink-warning); }
.row-when { font-size: var(--text-xs); color: var(--ink-muted); white-space: nowrap; }

/* A deadline that has passed, or is today. Never colour alone: it takes a
   mark and a weight, both of which survive greyscale and colour-blindness. */
.is-alert { color: var(--ink-danger); font-weight: var(--weight-semibold); }
.is-alert-icon { display: inline-flex; align-items: center; gap: 5px; }
.is-alert-icon svg { width: 13px; height: 13px; flex: none; }

.row-detail {
  padding: 0 var(--s-5) var(--s-5) calc(20px + var(--s-3) + var(--s-5));
  display: flex; flex-direction: column; gap: var(--s-4);
}

/* ── the lifecycle bar ────────────────────────────────────────────────── */

.flow { display: flex; flex-direction: column; gap: var(--s-2); }
.flow-steps { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-1); }
.flow-step {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px var(--s-2);
  font-size: var(--text-xs); white-space: nowrap;
  border-radius: var(--radius-full);
  background: var(--n-100); color: var(--ink-subtle);
}
.flow-step svg { width: 12px; height: 12px; flex: none; }
.flow-step--done { background: var(--green-50); color: var(--green-800); }
.flow-step--now {
  background: var(--fill-primary); color: var(--ink-on-fill);
  font-weight: var(--weight-semibold);
}
.flow-sep { color: var(--n-300); display: grid; place-items: center; }
.flow-sep svg { width: 14px; height: 14px; }

.flow-note {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3);
  font-size: var(--text-sm); line-height: var(--leading-snug);
  background: var(--blue-50); border-radius: var(--radius-md); color: var(--blue-900);
}
.flow-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.flow-note--branch { background: var(--amber-50); color: var(--amber-800); }
.flow-note-key { font-weight: var(--weight-semibold); }

/* ── the AI panel ─────────────────────────────────────────────────────── */

.ai-panel {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ai-panel-head { display: flex; align-items: center; gap: var(--s-2); }
.ai-panel-head .eyebrow { display: flex; align-items: center; gap: 5px; color: var(--ink-primary); }
.ai-panel-head svg { width: 13px; height: 13px; }
.ai-summary { font-size: var(--text-md); line-height: var(--leading); }
.ai-points {
  margin: 0; padding-left: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-1);
  font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--ink-muted);
}

/* Shared, source-grounded AI result contract used by migrated surfaces. */
.ai-output {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5); background: var(--surface-raised);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.ai-output-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-3); flex-wrap: wrap;
}
.ai-output-context { font-size: var(--text-xs); color: var(--ink-subtle); }
.ai-output-summary { font-size: var(--text-md); line-height: var(--leading); }
.ai-output-meta, .chart-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: var(--s-3); margin: 0;
}
.ai-output-meta > div, .chart-meta > div {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-3); background: var(--surface-sunken);
  border-radius: var(--radius-md);
}
.ai-output-meta dt, .chart-meta dt {
  font-size: var(--text-xs); color: var(--ink-subtle);
}
.ai-output-meta dd, .chart-meta dd { margin: 0; font-size: var(--text-sm); }
.ai-output-sources { display: flex; flex-direction: column; gap: var(--s-2); }
.ai-output-sources > summary {
  width: fit-content;
  color: var(--ink-primary); cursor: pointer;
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.ai-output-sources > summary:focus-visible {
  outline: 3px solid var(--fill-primary); outline-offset: 3px;
  border-radius: var(--radius-sm);
}
.ai-output-sources ol {
  display: flex; flex-direction: column; gap: var(--s-3);
  margin: 0; padding-left: var(--s-6);
}
.ai-source { padding-left: var(--s-1); }
.ai-source-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.ai-source blockquote {
  margin: var(--s-1) 0; color: var(--ink-muted);
  font-size: var(--text-sm); line-height: var(--leading);
}
.ai-source-meta { font-size: var(--text-xs); color: var(--ink-subtle); }
.ai-source--warning { border-left: 3px solid var(--amber-500); padding-left: var(--s-3); }
.ai-source--danger { border-left: 3px solid var(--red-500); padding-left: var(--s-3); }
.ai-action-preview {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); color: var(--navy-900); background: var(--blue-50);
  border-radius: var(--radius-md);
}

/* Shared chart primitives: the SVG is always paired with an equivalent table. */
.chart-panel {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5); background: var(--surface-raised);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.chart-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
}
.chart-title { font-size: var(--text-lg); }
.chart-description { margin-top: var(--s-1); color: var(--ink-muted); font-size: var(--text-sm); }
.illustrative-notice {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3); color: var(--amber-800); background: var(--amber-50);
  border-radius: var(--radius-md); font-size: var(--text-xs);
}
.illustrative-notice svg { flex: none; margin-top: 2px; }
.chart-legend {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  margin: 0; padding: 0; list-style: none;
  font-size: var(--text-xs); color: var(--ink-muted);
}
.chart-legend li { display: inline-flex; align-items: center; gap: var(--s-2); }
.chart-legend-key { width: 22px; height: 9px; border-radius: 3px; }
.chart-series-pattern--1 { opacity: 0.7; }
.chart-series-pattern--2 {
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    rgb(255 255 255 / 0.8) 3px 5px
  );
}
.chart-graphic { overflow-x: auto; overscroll-behavior-x: contain; }
.chart-svg { width: 100%; min-width: 560px; height: auto; overflow: visible; }
.chart-line { stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-series-line--1 { stroke-dasharray: 9 5; }
.chart-series-line--2 { stroke-dasharray: 2 5; }
.chart-point { stroke: var(--surface); stroke-width: 2; }
.chart-point-target { fill: transparent; stroke: transparent; }
.chart-grid-line { stroke: var(--n-200); stroke-width: 1; }
.chart-axis-label, .chart-row-label, .chart-value-label {
  fill: var(--ink-muted); font-family: var(--font); font-size: 13px;
}
.chart-row-label { fill: var(--ink); font-weight: var(--weight-medium); }
.chart-track { fill: var(--n-100); }
.chart-fill--info { fill: var(--blue-600); background-color: var(--blue-600); }
.chart-fill--success { fill: var(--teal-600); background-color: var(--teal-600); }
.chart-fill--warning { fill: var(--amber-600); background-color: var(--amber-600); }
.chart-fill--danger { fill: var(--red-600); background-color: var(--red-600); }
.chart-fill--neutral { fill: var(--n-400); background-color: var(--n-400); }
.chart-stroke--info { stroke: var(--blue-600); }
.chart-stroke--success { stroke: var(--teal-600); }
.chart-stroke--warning { stroke: var(--amber-600); }
.chart-stroke--danger { stroke: var(--red-600); }
.chart-stroke--neutral { stroke: var(--n-500); }
.chart-text--info { fill: var(--blue-800); }
.chart-text--success { fill: var(--teal-800); }
.chart-text--warning { fill: var(--amber-800); }
.chart-text--danger { fill: var(--red-800); }
.chart-text--neutral { fill: var(--n-700); }
.chart-capacity-lead { fill: var(--navy-800); }
.chart-capacity-collaboration { fill: var(--blue-300); }
.chart-capacity-marker {
  stroke: var(--red-700); stroke-width: 2; stroke-dasharray: 4 3;
}
.chart-pattern-line { stroke: var(--red-700); stroke-width: 3; opacity: 0.7; }
.chart-risk-overlay { pointer-events: none; }
.chart-hit { cursor: pointer; }
.chart-svg-link:focus-visible { outline: none; }
.chart-svg-link:focus-visible .chart-hit {
  stroke: var(--fill-primary); stroke-width: 3; fill: rgb(51 112 255 / 0.08);
}
.chart-svg-link:focus-visible .chart-point-target {
  stroke: var(--fill-primary); stroke-width: 3; fill: rgb(51 112 255 / 0.08);
}
.chart-no-data {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-6); color: var(--ink-muted); background: var(--surface-sunken);
  border-radius: var(--radius-md); text-align: center;
}
.chart-table-disclosure {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3);
}
.chart-table-wrap { width: 100%; min-width: 0; }
.data-table-scroll {
  max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain;
}
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table caption {
  padding: 0 0 var(--s-3); color: var(--ink-muted);
  text-align: left; font-size: var(--text-xs);
}
.data-table th, .data-table td {
  padding: var(--s-3); border-bottom: 1px solid var(--n-100); text-align: left;
}
.data-table th {
  color: var(--ink-muted); background: var(--surface-sunken); font-size: var(--text-xs);
}
.data-table .is-numeric { text-align: right; }
.data-table-link { display: inline-flex; align-items: center; gap: var(--s-1); }

/* Confidence, stated as a figure and a bar rather than a bare percentage. */
/* Mức căn cứ — three states, not a score. A percentage from an uncalibrated
   model reads as a measurement; a state reads as a decision, which is what the
   person in front of it actually has to make. */
.grounding {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 2px var(--s-2); border-radius: var(--radius-full);
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  background: var(--n-100); color: var(--ink-muted); cursor: help;
}
.grounding svg { flex: none; }
.grounding--success { background: var(--green-50); color: var(--ink-success); }
.grounding--warning { background: var(--amber-50); color: var(--ink-warning); }
.grounding--danger  { background: var(--red-50);   color: var(--ink-danger); }

/* A number whose formula and period are not in the data. It is still shown —
   the bar beside it compares units usefully — but it is marked, so nobody
   quotes it in a report as though it were defined. */
.metric-undefined {
  display: inline-flex; align-items: center; gap: 3px; cursor: help;
  text-decoration: underline dotted currentColor; text-underline-offset: 3px;
}
.metric-undefined svg { flex: none; opacity: 0.65; }

/* ── key/value lists ──────────────────────────────────────────────────── */

.kv { display: flex; flex-direction: column; }
.kv-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: var(--s-3);
  padding: var(--s-2) 0; font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-k { color: var(--ink-subtle); }
.kv-v { color: var(--ink); }

/* ── the written confirmation an action leaves behind ─────────────────── */

.done {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3);
  font-size: var(--text-sm); line-height: var(--leading-snug);
  background: var(--green-50); color: var(--green-800);
  border-radius: var(--radius-md);
}
.done svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════════════
   Tổng quan điều hành
   ══════════════════════════════════════════════════════════════════════ */

.metrics {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}
/* The decisions band. The two blocks are not siblings of everything below —
   they are the answer to the question the page is opened with, so they sit
   above the first card and read as one unit. */
.decisions { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
/* two by two against the alert column, so the band reads as one block rather
   than three figures and an orphan */
.decisions .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.alert-strip {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4); border-radius: var(--radius-lg);
  background: var(--amber-50); border: 1px solid var(--amber-200); color: var(--ink-warning);
}
.alert-strip-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; min-width: 0; }
.alert-strip-head svg { flex: none; }
.alert-strip-head .eyebrow { min-width: 0; }
.alert-strip-list { display: flex; flex-direction: column; }
.alert-strip .alert-row { padding: var(--s-2) 0; border-color: var(--amber-200); }
.alert-strip .alert-kind { color: var(--ink-warning); opacity: 0.85; }
.alert-strip .alert-text { color: var(--ink); }

.metric {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  color: inherit; text-decoration: none; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.metric:hover { text-decoration: none; }
/* The urgent figure is the loudest thing on the page, which is the point. */
.metric--alert { border-color: var(--red-200); background: var(--red-50); }
.metric:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.metric:active { transform: translateY(1px); }
.metric-top { display: flex; align-items: center; gap: var(--s-2); }
.metric-icon {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: var(--radius-md); background: var(--n-100); color: var(--ink-muted);
}
.metric--alert .metric-icon { background: var(--red-50); color: var(--red-700); }
.metric--warn .metric-icon { background: var(--amber-50); color: var(--amber-700); }
.metric--info .metric-icon { background: var(--blue-50); color: var(--blue-700); }
.metric-label { font-size: var(--text-sm); color: var(--ink-muted); }
.metric-value {
  font-size: var(--text-4xl); font-weight: var(--weight-semibold);
  line-height: 1; letter-spacing: -0.02em;
}
.metric--alert .metric-value { color: var(--ink-danger); }

/* my work — a compact table */
.mywork { display: flex; flex-direction: column; }
.mywork-row {
  display: grid; align-items: center; gap: var(--s-3);
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: var(--s-3) var(--s-5);
}
.mywork-row + .mywork-row { border-top: 1px solid var(--border); }
.mywork-title { font-size: var(--text-md); line-height: var(--leading-snug); }
.mywork-who { font-size: var(--text-xs); color: var(--ink-subtle); white-space: nowrap; }
.mywork-when { font-size: var(--text-xs); color: var(--ink-muted); white-space: nowrap; }

/* workload table */
.load-head, .load-btn {
  display: grid; align-items: center; gap: var(--s-4);
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 1.6fr) 64px 72px 76px;
}
.load-head {
  padding: var(--s-2) var(--s-5);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-subtle);
  background: var(--surface-sunken); border-bottom: 1px solid var(--border);
}
.load-head > :nth-child(n + 3) { text-align: right; }
.load-btn { width: 100%; padding: var(--s-3) var(--s-5); text-align: left; background: none; border: 0; cursor: pointer; }
.load-btn:hover { background: var(--surface-hover); }
.load-btn:focus-visible { outline-offset: -3px; }
.load-name { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.load-name-lines { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.load-name-main { font-size: var(--text-md); font-weight: var(--weight-medium); }
.load-sub { font-size: var(--text-xs); color: var(--ink-subtle); }
.load-meter { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.load-pct { font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; min-width: 58px; text-align: right; }
.load-num { font-size: var(--text-md); text-align: right; }

.drill {
  display: grid; gap: var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  padding: 0 var(--s-5) var(--s-5) calc(var(--s-5) + var(--s-6));
}
.member {
  display: grid; align-items: center; gap: var(--s-3);
  grid-template-columns: minmax(0, 1.1fr) minmax(60px, 1fr) 64px;
  padding: var(--s-2) 0; font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.member:last-of-type { border-bottom: 0; }
.member .meter { height: 6px; }
.member-pct { text-align: right; font-size: var(--text-xs); white-space: nowrap; }

.case-line {
  display: grid; grid-template-columns: minmax(0, 1.5fr) auto; gap: var(--s-3);
  align-items: center; padding: var(--s-2) 0; font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.case-line:last-of-type { border-bottom: 0; }

/* A card that folds. Reference material stays reachable without paying for a
   full card in the daily view. */
.fold { overflow: hidden; }
.fold-summary {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); cursor: pointer; list-style: none;
  min-height: var(--control-h);
}
.fold-summary::-webkit-details-marker { display: none; }
.fold-summary:hover { background: var(--surface-hover); }
.fold-summary:focus-visible { outline-offset: -3px; }
.fold-summary svg { flex: none; color: var(--ink-subtle); }
.fold-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-right: auto; }
.fold-mark { display: grid; place-items: center; transition: transform var(--dur) var(--ease); }
.fold[open] .fold-mark { transform: rotate(180deg); }
.fold[open] .fold-summary { border-bottom: 1px solid var(--border); }

/* committee */
.leaders {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
}
.leader {
  display: flex; flex-direction: column; gap: 2px;
  padding-left: var(--s-3); border-left: 2px solid var(--border);
}
.leader-name { font-size: var(--text-md); font-weight: var(--weight-medium); }
.leader-note { font-size: var(--text-xs); color: var(--ink-subtle); line-height: var(--leading-snug); }

/* agenda + alerts */
.agenda-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s-3);
  padding: var(--s-3) 0; align-items: baseline;
}
.agenda-row + .agenda-row { border-top: 1px solid var(--border); }
.agenda-time { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--ink-muted); }
.agenda-title { font-size: var(--text-md); line-height: var(--leading-snug); }

.alert-row {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) 0;
}
.alert-row + .alert-row { border-top: 1px solid var(--border); }
.alert-icon {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: var(--radius-md); background: var(--amber-50); color: var(--amber-700);
}
.alert-lines { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.alert-kind {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-subtle);
}
.alert-text { font-size: var(--text-sm); line-height: var(--leading-snug); }

/* ══════════════════════════════════════════════════════════════════════════
   Văn thư cơ quan
   ══════════════════════════════════════════════════════════════════════ */

/* The intake desk is one working surface: the queue on the left, and beside it
   the source the machine read next to the fields it produced. */
.intake-screen { height: 100%; }
.intake-layout {
  display: grid; gap: var(--s-4);
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  align-items: start;
}

/* ── queue ─────────────────────────────────────────────────────────────── */

.queue { display: flex; flex-direction: column; min-width: 0; }
.queue-head {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-bottom: 1px solid var(--border);
}
.queue-head .meter { height: 4px; }
.queue-list { display: flex; flex-direction: column; overflow: auto; }

.intake {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; padding: var(--s-3) var(--s-4); text-align: left;
  background: none; border: 0; border-left: 3px solid transparent; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.intake + .intake { border-top: 1px solid var(--border); }
.intake:hover { background: var(--surface-hover); }
.intake[aria-pressed='true'] {
  background: var(--surface-selected); border-left-color: var(--brand);
}
.intake:focus-visible { outline-offset: -3px; }
/* Registered items stay in the list — the clerk can go back — but they step
   out of the way of the ones still waiting. */
.intake--done { opacity: 0.62; }
.intake-top { display: flex; align-items: center; gap: var(--s-2); width: 100%; }
.intake-title {
  font-size: var(--text-md); font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}
.intake-note {
  display: flex; flex-direction: column; gap: 3px;
  font-size: var(--text-xs); color: var(--ink-subtle);
}
.intake-flag {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink-warning); font-weight: var(--weight-medium);
}
.intake-flag svg { flex: none; }

/* ── workspace ─────────────────────────────────────────────────────────── */

.workspace { min-width: 0; }
.workspace-head {
  display: flex; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border);
}
.workspace-body {
  display: grid; gap: var(--s-5);
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  padding: var(--s-5); align-items: start;
}
.workspace-source { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.workspace-form { min-width: 0; }
.workspace-foot { padding: 0 var(--s-5) var(--s-5); }

/* ── the source panel ──────────────────────────────────────────────────── */

.source {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-sunken); overflow: hidden;
}
.source-bar {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); font-size: var(--text-xs); color: var(--ink-muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.source-bar svg { flex: none; color: var(--ink-subtle); }
.source-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The page frame. There is no raster in the prototype and inventing a
   convincing one would mislead; the frame says so and shows the text the
   reader actually produced. */
.source-page {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); min-height: 260px;
}
.source-page-note {
  align-self: center; padding: var(--s-2) var(--s-3);
  font-size: var(--text-xs); color: var(--ink-subtle);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
}
.source-extract {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.source-extract-text { font-size: var(--text-md); line-height: var(--leading); }

/* When the source is missing or broken, that IS the panel. */
.source-state {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-5); min-height: 200px; justify-content: center;
}
.source-state-icon { display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: var(--radius-md); background: var(--n-100); color: var(--ink-muted); }
.source-state-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.source-state-body { font-size: var(--text-sm); color: var(--ink-muted); line-height: var(--leading); }
.source--danger { border-color: var(--red-200); background: var(--red-50); }
.source--danger .source-state-icon { background: var(--red-100); color: var(--ink-danger); }
.source--warning { border-color: var(--amber-200); background: var(--amber-50); }
.source--warning .source-state-icon { background: var(--amber-100); color: var(--ink-warning); }
.source--info { border-color: var(--blue-100); background: var(--blue-50); }
.source--info .source-state-icon { background: var(--blue-100); color: var(--ink-primary); }

/* ── fields ────────────────────────────────────────────────────────────── */

.field-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
}
.field-labels { display: flex; align-items: center; gap: var(--s-2); }
.field-labels .field-label { margin-right: auto; }

/* Provenance, not validation. Says where the value came from and whether a
   person has looked at it — deliberately quieter than an error, because the
   machine being unsure is not the clerk making a mistake. */
.prov {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  padding: 1px 6px; border-radius: var(--radius-full);
  background: var(--n-100); color: var(--ink-muted);
}
.prov svg { flex: none; }
.prov--warning { background: var(--amber-50); color: var(--ink-warning); }
.prov--success { background: var(--green-50); color: var(--ink-success); }

.field--error .input { border-color: var(--fill-danger); }
.field-error {
  display: flex; align-items: center; gap: var(--s-1);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--ink-danger);
}
.field-error svg { flex: none; }

/* The shortcut, taught at the point of use. A translucent white plate over the
   button measured 3.2:1; this one is solid and clears AA on its own. */
.kbd {
  font-family: var(--font-mono); font-size: var(--text-2xs); line-height: 1.4;
  padding: 1px 5px; border-radius: var(--radius-sm);
  background: var(--blue-900); color: var(--n-0);
}

.file-row {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-3); font-size: var(--text-sm); color: var(--ink-muted);
  background: var(--surface-sunken); border-radius: var(--radius-md);
}
.file-row svg { width: 15px; height: 15px; flex: none; color: var(--ink-subtle); }

/* ══════════════════════════════════════════════════════════════════════════
   Văn bản
   ══════════════════════════════════════════════════════════════════════ */

.doc-detail { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.doc-body {
  font-size: var(--text-md); line-height: var(--leading); color: var(--ink-muted);
  padding-left: var(--s-4); border-left: 2px solid var(--border);
}
.timeline { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-3); padding: var(--s-2) 0; }
.tl-row + .tl-row { border-top: 1px solid var(--border); }
.tl-when { font-size: var(--text-xs); color: var(--ink-subtle); }
.tl-what { font-size: var(--text-sm); line-height: var(--leading-snug); }

.owner-row { display: flex; align-items: flex-start; gap: var(--s-2); flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════════════════
   Hồ sơ công việc
   ══════════════════════════════════════════════════════════════════════ */

.case-head { display: flex; flex-direction: column; gap: var(--s-2); }
.case-title { font-size: var(--text-2xl); line-height: var(--leading-tight); max-width: 34ch; }

.case-tl-item { border-bottom: 1px solid var(--border); }
.case-tl-item:last-child { border-bottom: 0; }
.case-tl-btn {
  display: grid; align-items: center; gap: var(--s-3);
  grid-template-columns: 64px auto minmax(0, 1fr) 20px;
  width: 100%; padding: var(--s-3) var(--s-5); text-align: left;
  background: none; border: 0; cursor: pointer;
}
.case-tl-btn:hover { background: var(--surface-hover); }
.case-tl-btn:focus-visible { outline-offset: -3px; }
.case-tl-title { font-size: var(--text-md); line-height: var(--leading-snug); }
.case-tl-more {
  padding: 0 var(--s-5) var(--s-4) calc(64px + var(--s-3) + var(--s-5));
  display: flex; flex-direction: column; gap: var(--s-3);
  font-size: var(--text-sm); line-height: var(--leading);
}

.task { padding: var(--s-3) var(--s-5); }
.task + .task { border-top: 1px solid var(--border); }
.task-btn {
  display: flex; flex-direction: column; gap: var(--s-2);
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
}
.task-btn:focus-visible { outline-offset: 2px; }
.task-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.task-title { font-size: var(--text-md); font-weight: var(--weight-medium); line-height: var(--leading-snug); }
.task-progress { display: flex; align-items: center; gap: var(--s-3); }
.task-progress .meter { height: 6px; }
.task-owner { font-size: var(--text-xs); color: var(--ink-subtle); white-space: nowrap; }
.task-detail { display: flex; flex-direction: column; gap: var(--s-3); padding-top: var(--s-3); }
.task-meta {
  display: grid; gap: var(--s-2) var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  font-size: var(--text-sm);
}

/* ══════════════════════════════════════════════════════════════════════════
   Lịch công tác
   ══════════════════════════════════════════════════════════════════════ */

.week {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  align-items: start;
}
.day { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2);
  padding-bottom: var(--s-2); border-bottom: 2px solid var(--border);
}
.day--today .day-head { border-bottom-color: var(--fill-primary); }
.day-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.day--today .day-name { color: var(--ink-primary); }
.day-date { font-size: var(--text-xs); color: var(--ink-subtle); }

.event {
  display: flex; flex-direction: column; gap: var(--s-1);
  width: 100%; padding: var(--s-3); text-align: left;
  background: var(--surface); color: inherit;
  border: 1px solid var(--border); border-left: 3px solid var(--blue-400);
  border-radius: var(--radius-md); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.event:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); border-left-color: var(--blue-500); }
.event--warn { border-left-color: var(--amber-500); background: var(--amber-50); }
.event[aria-pressed='true'] {
  border-color: var(--fill-primary); border-left-color: var(--fill-primary);
  box-shadow: var(--ring);
}
.event-time { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--ink-muted); }
.event-title { font-size: var(--text-sm); line-height: var(--leading-snug); }

.event-detail { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.event-place { font-size: var(--text-sm); color: var(--ink-subtle); }
.warn-card {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-4); border-radius: var(--radius-md);
  background: var(--amber-50); color: var(--amber-800);
}
.warn-head { display: flex; align-items: center; gap: var(--s-2); }
.warn-head svg { width: 15px; height: 15px; }
.warn-text { font-size: var(--text-sm); line-height: var(--leading-snug); }

/* ══════════════════════════════════════════════════════════════════════════
   Trợ lý AI
   ══════════════════════════════════════════════════════════════════════ */

.chat { display: flex; flex-direction: column; gap: var(--s-5); }
.msg { display: flex; gap: var(--s-3); }
.msg-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--radius-full); font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--n-100); color: var(--ink-muted);
}
.msg--bot .msg-avatar { background: var(--fill-primary); color: var(--ink-on-fill); }
.msg-lines { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; flex: 1; }
.msg-who { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--ink-muted); }
.msg-text { font-size: var(--text-md); line-height: var(--leading); }

.sources { display: flex; flex-direction: column; gap: var(--s-1); }
.source-row { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-2); font-size: var(--text-sm); }
.source-n {
  display: grid; place-items: center; width: 18px; height: 18px;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  border-radius: var(--radius-sm); background: var(--n-100); color: var(--ink-muted);
}

.proposal {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--radius-md);
  background: var(--blue-50); border: 1px solid var(--blue-100);
}
.proposal-grid {
  display: grid; gap: var(--s-2) var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  font-size: var(--text-sm);
}

/* The chat fills the pane and the composer stays put at its foot, so the
   question box never scrolls away from the answers it is about. */
/* the chat is the only screen that wants the full height of the pane */
.content:has(.screen--chat) { display: flex; flex-direction: column; }
.screen--chat { flex: 1; min-height: 0; max-width: 980px; }
.chat-card { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-scroll { flex: 1; min-height: 0; overflow: auto; padding: var(--s-5); }
.chat-prompts { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-6); }
.chat-prompt-list { display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }

.composer {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border); background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.composer-row { display: flex; gap: var(--s-2); align-items: center; }
.composer-row .input { flex: 1; }
.composer-scope { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.composer-scope > svg { flex: none; color: var(--ink-subtle); }
.scope-select {
  appearance: none; background: none; border: 0; padding: 0 var(--s-4) 0 0;
  font: inherit; font-size: var(--text-xs); font-weight: var(--weight-medium);
  color: var(--ink-primary); cursor: pointer; min-height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23245bdb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 13px;
}

.prompt-btn {
  display: flex; align-items: flex-start; gap: var(--s-2);
  width: 100%; padding: var(--s-3); text-align: left;
  font-size: var(--text-sm); line-height: var(--leading-snug);
  background: none; color: var(--ink-primary);
  border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.prompt-btn svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.prompt-btn:hover { background: var(--blue-50); border-color: var(--blue-200); }

.scope-list { display: flex; flex-direction: column; gap: var(--s-2); }
.scope {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; padding: var(--s-3); text-align: left;
  font-size: var(--text-sm); background: var(--surface); color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.scope:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.scope[aria-pressed='true'] {
  background: var(--surface-selected); border-color: var(--fill-primary);
  font-weight: var(--weight-medium);
}
.scope svg { flex: none; color: var(--ink-primary); }

/* ══════════════════════════════════════════════════════════════════════════
   Operational routes — queue health, document register, calendar, assistant
   ══════════════════════════════════════════════════════════════════════ */

.section-title { font-size: var(--text-xl); line-height: var(--leading-tight); }

/* Văn thư keeps the queue/workspace loop intact; this compact band only makes
   the quality of what entered that loop visible before the clerk starts. */
.intake-screen { gap: var(--s-4); }
.clerk-health {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5); background: var(--surface);
  border-top: 3px solid var(--brand); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.clerk-health-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5);
}
.clerk-health-head .illustrative-notice { max-width: 440px; }
.clerk-quality-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3);
}
.clerk-quality {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 0; padding: var(--s-3);
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.clerk-quality--warning { background: var(--amber-50); border-color: var(--amber-200); }
.clerk-quality--danger { background: var(--red-50); border-color: var(--red-200); }
.clerk-quality-icon {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  color: var(--ink-muted); background: var(--surface);
  border-radius: var(--radius-md);
}
.clerk-quality--warning .clerk-quality-icon { color: var(--ink-warning); }
.clerk-quality--danger .clerk-quality-icon { color: var(--ink-danger); }
.clerk-quality-copy { display: flex; flex-direction: column; min-width: 0; }
.clerk-quality-copy strong { font-size: var(--text-xl); line-height: var(--leading-tight); }
.clerk-quality-copy span { color: var(--ink-muted); font-size: var(--text-xs); }
.clerk-next {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding-top: var(--s-3); border-top: 1px solid var(--border);
}
.clerk-next strong { min-width: 0; margin-right: auto; }

.document-register-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5);
  padding: var(--s-5); color: var(--rail-ink-active);
  background: var(--navy-900); border-radius: var(--radius-xl);
}
.document-register-head .eyebrow { color: #b9cdf0; }
.document-register-head .subtle { color: var(--rail-ink); max-width: 74ch; }
.document-register-count {
  display: flex; flex-direction: column; flex: none; min-width: 140px;
  padding: var(--s-3) var(--s-4); background: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.16); border-radius: var(--radius-md);
}
.document-register-count strong { font-size: var(--text-3xl); line-height: 1; }
.document-register-count span { margin-top: var(--s-1); font-size: var(--text-xs); }
.doc-workspace {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.65fr);
  gap: var(--s-5); align-items: start;
}
.doc-reading, .doc-register-meta { min-width: 0; }
.doc-register-meta {
  padding: var(--s-4); background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.doc-summary, .doc-source-extract {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--radius-md);
}
.doc-summary { background: var(--surface-sunken); border-left: 3px solid var(--n-400); }
.doc-source-extract { border: 1px solid var(--border); }
.doc-source-extract .doc-body { padding-left: 0; border-left: 0; }
.source-unavailable {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3); color: var(--ink-muted); background: var(--surface-sunken);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  font-size: var(--text-sm); line-height: var(--leading-snug);
}
.source-unavailable svg { flex: none; margin-top: 2px; }

.calendar-screen { gap: var(--s-5); }
.calendar-brief {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.7fr);
  gap: var(--s-4); align-items: stretch;
}
.calendar-brief .ai-output { border-left: 4px solid var(--brand); }
.calendar-status-grid { display: grid; gap: var(--s-3); }
.calendar-status {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--s-3);
  align-items: center; padding: var(--s-3) var(--s-4);
  background: var(--surface); border-left: 3px solid var(--n-400);
  border-radius: var(--radius-md); box-shadow: var(--shadow-xs);
}
.calendar-status--warning { border-left-color: var(--amber-600); }
.calendar-status--danger { border-left-color: var(--red-700); }
.calendar-status-value {
  font-size: var(--text-2xl); font-weight: var(--weight-semibold); text-align: center;
}
.calendar-status-copy { display: flex; flex-direction: column; min-width: 0; }
.calendar-status-copy span { color: var(--ink-muted); font-size: var(--text-xs); }
.calendar-controls {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.calendar-view-toolbar, .calendar-filter-toolbar { padding: 0; }
.calendar-workspace { display: flex; flex-direction: column; gap: var(--s-4); }

.calendar-selection-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--amber-200);
  border-radius: var(--radius-md);
  background: var(--amber-50);
}
.calendar-event-detail {
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
}
.calendar-reference-link {
  align-self: flex-start; font-size: var(--text-sm); font-weight: var(--weight-semibold);
}
.event-status-strip {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2); margin: 0;
}
.event-status-strip > div {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-3); background: var(--surface-sunken);
  border-radius: var(--radius-md);
}
.event-status-strip dt { color: var(--ink-subtle); font-size: var(--text-xs); }
.event-status-strip dd { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.calendar-reference-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.warn-card--danger { color: var(--red-800); background: var(--red-50); }
.calendar-list-item { display: flex; flex-direction: column; gap: var(--s-3); }
.calendar-detail-region { min-width: 0; }
.calendar-list-item .calendar-detail-region { margin: 0 0 var(--s-3) var(--s-5); }
.calendar-view-note { padding-inline: var(--s-1); }

.assistant-disclaimer {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3) var(--s-5); color: var(--blue-800);
  background: var(--blue-50); border-bottom: 1px solid var(--blue-100);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-size: var(--text-xs); line-height: var(--leading-snug);
}
.assistant-disclaimer svg { flex: none; margin-top: 2px; }
.msg--bot .msg-lines > .ai-output {
  border-left: 3px solid var(--brand); box-shadow: var(--shadow-xs);
}
.assistant-dismiss { align-self: flex-start; }
.composer-row .input { min-width: 0; }

/* ══════════════════════════════════════════════════════════════════════════
   Work command center, deterministic inbox and case workspace
   ══════════════════════════════════════════════════════════════════════ */

.command-center { gap: var(--s-6); }
.command-context {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-6);
  padding: var(--s-6);
  color: var(--rail-ink-active);
  background:
    linear-gradient(120deg, rgb(51 112 255 / 0.18), transparent 55%),
    var(--navy-900);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.command-context-copy {
  display: flex; flex-direction: column; gap: var(--s-2); max-width: 760px;
}
.command-context .eyebrow { color: #b9cdf0; }
.command-question {
  max-width: 28ch; color: var(--rail-ink-active);
  font-size: clamp(var(--text-2xl), 2.2vw, var(--text-4xl));
  line-height: var(--leading-tight); letter-spacing: -0.025em;
}
.command-context-note {
  max-width: 70ch; color: var(--rail-ink); font-size: var(--text-sm);
}
.command-context-controls {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: var(--s-2);
  align-items: end; min-width: min(360px, 100%);
}
.scope-readout {
  display: flex; flex-direction: column; gap: var(--s-1);
  min-height: var(--input-h); padding: var(--s-2) var(--s-3);
  color: var(--rail-ink-active); background: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.18); border-radius: var(--radius-md);
}
.scope-readout .field-label {
  color: #c4d6ee; font-size: var(--text-xs);
}
.period-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: var(--input-h); padding: 0 var(--s-3);
  color: var(--rail-ink-active); background: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.18); border-radius: var(--radius-md);
  font-size: var(--text-xs); white-space: nowrap;
}

.command-brief .ai-output {
  border-left: 4px solid var(--brand); box-shadow: var(--shadow-xs);
}
.command-section-heading,
.command-panel-heading,
.case-section-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
}
.command-section-heading > div,
.command-panel-heading > div,
.case-section-heading > div {
  display: flex; flex-direction: column; gap: var(--s-1); min-width: 0;
}
.command-section-heading h2,
.command-panel-heading h2,
.case-section-heading h2 { font-size: var(--text-xl); }
.command-section-heading p,
.command-panel-heading p,
.case-section-heading p {
  color: var(--ink-muted); font-size: var(--text-sm);
}
.command-section-heading .illustrative-notice { max-width: 420px; }

.command-metrics { display: flex; flex-direction: column; gap: var(--s-4); }
.command-metric-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-3);
}
.command-metric {
  position: relative; display: flex; flex-direction: column; gap: var(--s-2);
  min-height: 150px; padding: var(--s-4);
  color: inherit; background: var(--surface);
  border-top: 3px solid var(--n-400); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); text-decoration: none;
  overflow: hidden;
}
.command-metric:hover {
  color: inherit; box-shadow: var(--shadow-sm); text-decoration: none;
  transform: translateY(-1px);
}
.command-metric-target {
  display: flex; flex-direction: column; gap: var(--s-2);
  width: 100%; padding: 0; color: inherit; background: none; border: 0;
  font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.command-metric-target:hover { color: inherit; text-decoration: none; }
.command-metric--info { border-top-color: var(--blue-600); }
.command-metric--success { border-top-color: var(--teal-600); }
.command-metric--warning { border-top-color: var(--amber-600); }
.command-metric--danger { border-top-color: var(--red-700); }
.command-metric-label { color: var(--ink-muted); font-size: var(--text-sm); }
.command-metric-main {
  display: flex; align-items: baseline; gap: var(--s-2);
  line-height: 1;
}
.command-metric-main strong {
  font-size: clamp(var(--text-2xl), 2.2vw, var(--text-4xl));
  letter-spacing: -0.025em;
}
.command-metric-main > span { color: var(--ink-muted); font-size: var(--text-xs); }
.command-metric-foot {
  color: var(--ink-muted); font-size: var(--text-xs); line-height: var(--leading-snug);
}
.decision-sparkline {
  display: flex; flex-direction: column; gap: var(--s-2); margin-top: auto;
}
.decision-sparkline .chart-graphic { overflow: hidden; }
.decision-sparkline .chart-svg { min-width: 0; }
.decision-sparkline .chart-meta {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-1);
}
.decision-sparkline .chart-meta > div { padding: var(--s-2); }
.decision-sparkline .chart-table-toggle {
  min-height: 44px; align-self: stretch; justify-content: center;
}

.command-grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4);
  align-items: start;
}
.command-span--12 { grid-column: 1 / -1; }
.command-span--8 { grid-column: span 8; }
.command-span--7 { grid-column: span 7; }
.command-span--5 { grid-column: span 5; }
.command-span--4 { grid-column: span 4; }
.command-grid--single > .command-span { grid-column: 1 / -1; }
.command-work,
.command-today {
  display: flex; flex-direction: column; gap: var(--s-4);
  min-width: 0; padding: var(--s-5);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.command-work { border-top: 3px solid var(--brand); }
.command-today { background: var(--surface-sunken); border: 1px solid var(--border); }
.specialist-status-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3); margin: 0; padding: var(--s-5);
}
.specialist-status-list > div {
  padding: var(--s-3); background: var(--surface-sunken); border-radius: var(--radius-md);
}
.specialist-status-list dt { color: var(--ink-muted); font-size: var(--text-xs); }
.specialist-status-list dd {
  margin: var(--s-1) 0 0; font-size: var(--text-2xl); font-weight: var(--weight-semibold);
}
.specialist-case-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3);
}
.specialist-case-grid article {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3); background: var(--surface-sunken); border-radius: var(--radius-md);
}
.specialist-case-grid p { display: flex; flex-direction: column; gap: 2px; }
.specialist-case-grid small { color: var(--ink-muted); }
.decision-list { display: flex; flex-direction: column; }
.decision-row {
  display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: var(--s-4);
  align-items: center; padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
}
.decision-row:last-child { border-bottom: 0; }
.decision-row-status { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.decision-row-copy { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.decision-row-title {
  color: var(--ink); font-weight: var(--weight-semibold); line-height: var(--leading-snug);
}
.decision-row-copy p { color: var(--ink-muted); font-size: var(--text-sm); }
.decision-row-action { justify-self: end; white-space: nowrap; }
.today-timeline {
  display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none;
}
.today-timeline li {
  position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr);
  gap: var(--s-3); padding: var(--s-3) 0 var(--s-3) var(--s-3);
  border-left: 2px solid var(--blue-200);
}
.today-timeline li::before {
  position: absolute; top: 20px; left: -5px; width: 8px; height: 8px;
  background: var(--blue-600); border: 2px solid var(--surface-sunken);
  border-radius: var(--radius-full); content: '';
}
.today-timeline time { color: var(--ink-muted); font-size: var(--text-xs); }
.today-timeline li > div { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); }
.today-timeline a { color: var(--ink); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.today-timeline li > div > span:not(.badge) { color: var(--ink-muted); font-size: var(--text-xs); }
.today-conflict {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3); color: var(--ink-danger);
  background: var(--red-50); border-radius: var(--radius-md); font-size: var(--text-sm);
}

.inbox-screen { gap: var(--s-5); }
.inbox-intro {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5);
  padding: var(--s-5) 0; border-bottom: 1px solid var(--border);
}
.inbox-intro > div { display: flex; flex-direction: column; gap: var(--s-2); }
.inbox-intro h2 { font-size: var(--text-2xl); }
.inbox-intro p { max-width: 68ch; color: var(--ink-muted); }
.priority-groups { display: flex; flex-direction: column; gap: var(--s-5); }
.priority-group {
  --priority-color: var(--n-500);
  overflow: hidden; background: var(--surface);
  border-left: 4px solid var(--priority-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.priority-group--danger { --priority-color: var(--red-700); }
.priority-group--warning { --priority-color: var(--amber-600); }
.priority-group--info { --priority-color: var(--blue-600); }
.priority-group-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-4) var(--s-5); background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.priority-group-head > div { display: flex; flex-direction: column; gap: var(--s-1); }
.priority-group-head h2 { font-size: var(--text-lg); }
.priority-group-head p { color: var(--ink-muted); font-size: var(--text-sm); }
.priority-list { display: flex; flex-direction: column; }
.priority-item + .priority-item { border-top: 1px solid var(--border); }
.priority-item-main {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4);
  align-items: center; padding: var(--s-2) var(--s-5);
}
.priority-item:hover .priority-item-main { background: var(--surface-hover); }
.priority-item-toggle {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-3);
  align-items: start; width: 100%; padding: var(--s-3) 0;
  color: inherit; background: none; border: 0; text-align: left; cursor: pointer;
}
.priority-item-copy { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.priority-item-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.priority-item-title { color: var(--ink); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.priority-item-reason { color: var(--ink-muted); font-size: var(--text-sm); }
.priority-item-source { color: var(--ink-subtle); font-size: var(--text-xs); }
.priority-item-action { white-space: nowrap; }
.priority-item-detail {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: 0 var(--s-5) var(--s-5) calc(var(--s-5) + 32px);
}
.inbox-detail-grid {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr); gap: var(--s-5);
}
.secondary-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.ai-output--empty {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-4); color: var(--ink-warning); background: var(--amber-50);
  border-radius: var(--radius-md); font-size: var(--text-sm);
}

.case-workspace { gap: var(--s-5); }
.case-command-header {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 0.34fr); gap: var(--s-8);
  align-items: center; padding: var(--s-6);
  background: var(--surface); border-top: 4px solid var(--brand);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.case-command-copy { display: flex; flex-direction: column; gap: var(--s-3); }
.case-command-copy h2 {
  max-width: 34ch; font-size: var(--text-3xl); line-height: var(--leading-tight);
}
.case-priority-reason { color: var(--ink-muted); font-size: var(--text-md); }
.case-command-meta {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3);
  margin: 0; padding-top: var(--s-2);
}
.case-command-meta div { display: flex; flex-direction: column; gap: var(--s-1); }
.case-command-meta dt { color: var(--ink-subtle); font-size: var(--text-xs); }
.case-command-meta dd { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.case-next-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-5); background: var(--blue-50); border-radius: var(--radius-lg);
}
.case-work-grid {
  display: grid; grid-template-columns: minmax(0, 8fr) minmax(300px, 4fr);
  gap: var(--s-5); align-items: start;
}
.case-main, .case-context { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.case-context { position: sticky; top: var(--s-4); }
.case-section, .case-reference {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5); background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.case-task-list { display: flex; flex-direction: column; }
.case-task + .case-task { border-top: 1px solid var(--border); }
.case-task-main {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4);
  align-items: center; padding: var(--s-3) 0;
}
.case-task-toggle {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) minmax(100px, 0.35fr);
  gap: var(--s-3); align-items: center; width: 100%; padding: var(--s-2) 0;
  color: inherit; background: none; border: 0; text-align: left; cursor: pointer;
}
.case-task-copy { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.case-task-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.case-task-progress { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-xs); }
.case-task-progress .meter { flex: 1; }
.case-task-action { white-space: nowrap; }
.case-task-detail {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
  gap: var(--s-4); padding: 0 0 var(--s-4) calc(20px + var(--s-3));
}
.case-task-detail .secondary-actions { align-content: start; }
.case-product-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3);
}
.case-product {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--s-3);
  padding: var(--s-4); color: inherit; background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md); text-decoration: none;
}
.case-product:hover { border-color: var(--border-strong); text-decoration: none; }
.case-product .row-flex { justify-content: space-between; }
.case-product-ratio { color: var(--ink-muted); font-size: var(--text-xs); }
.case-reference-group { display: flex; flex-direction: column; gap: var(--s-2); }
.case-reference-group + .case-reference-group {
  padding-top: var(--s-3); border-top: 1px solid var(--border);
}
.case-reference-group h4 { color: var(--ink-muted); font-size: var(--text-xs); text-transform: uppercase; }
.case-reference-group a {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-2);
  align-items: start; padding: var(--s-2); color: inherit; border-radius: var(--radius-md);
}
.case-reference-group a:hover { background: var(--surface-hover); text-decoration: none; }
.case-reference-group a > span { display: flex; flex-direction: column; gap: 2px; }
.case-reference-group small { color: var(--ink-muted); line-height: var(--leading-snug); }
.case-activity-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.case-activity-list > li + li { border-top: 1px solid var(--border); }
.case-activity-toggle {
  display: grid; grid-template-columns: 76px auto minmax(0, 1fr) 20px; gap: var(--s-3);
  align-items: center; width: 100%; padding: var(--s-3) 0;
  color: inherit; background: none; border: 0; text-align: left; cursor: pointer;
}
.case-activity-toggle:hover { background: var(--surface-hover); }
.case-activity-detail {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: 0 var(--s-4) var(--s-4) calc(76px + var(--s-3));
  color: var(--ink-muted); font-size: var(--text-sm);
}

/* ══════════════════════════════════════════════════════════════════════════
   Tiểu ban, reports and global search workspaces
   ══════════════════════════════════════════════════════════════════════ */

.subcommittee-workspace,
.reports-workspace,
.search-workspace { gap: var(--s-5); }
.subcommittee-header,
.reports-header,
.search-hero {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-6); background: var(--surface);
  border-top: 4px solid var(--brand); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.subcommittee-header > div:first-child,
.reports-header > div:first-child,
.search-hero { align-items: flex-start; }
.subcommittee-header h2,
.reports-header h2,
.search-hero h2 { font-size: var(--text-3xl); line-height: var(--leading-tight); }
.subcommittee-header p,
.reports-header p,
.search-hero > p { max-width: 74ch; color: var(--ink-muted); }
.subcommittee-totals {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3);
  margin: 0;
}
.subcommittee-totals > div,
.subcommittee-detail-metrics > div {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-3); background: var(--surface-sunken);
  border-radius: var(--radius-md);
}
.subcommittee-totals dt,
.subcommittee-detail-metrics dt { color: var(--ink-subtle); font-size: var(--text-xs); }
.subcommittee-totals dd,
.subcommittee-detail-metrics dd {
  margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold);
}
.scope-mismatch {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); color: var(--ink-danger); background: var(--red-50);
  border: 1px solid var(--red-200); border-radius: var(--radius-md);
}
.scope-mismatch svg { flex: none; margin-top: 2px; }
.scope-mismatch p { margin-top: var(--s-1); color: var(--ink); font-size: var(--text-sm); }
.subcommittee-grid {
  display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: var(--s-5); align-items: start;
}
.subcommittee-list {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.subcommittee-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; gap: var(--s-3);
  align-items: center; min-height: 72px; padding: var(--s-3) var(--s-4);
  color: inherit; border-left: 3px solid transparent; text-decoration: none;
}
.subcommittee-row + .subcommittee-row { border-top: 1px solid var(--border); }
.subcommittee-row:hover { background: var(--surface-hover); text-decoration: none; }
.subcommittee-row.is-current {
  background: var(--surface-selected); border-left-color: var(--brand);
}
.subcommittee-row-main { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.subcommittee-row-main small,
.subcommittee-row-risk { color: var(--ink-muted); font-size: var(--text-xs); }
.subcommittee-row-risk { grid-column: 1 / 3; }
.subcommittee-detail {
  display: flex; flex-direction: column; gap: var(--s-5);
  padding: var(--s-5); background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.subcommittee-detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
}
.subcommittee-detail-head > div { display: flex; flex-direction: column; gap: var(--s-2); }
.subcommittee-detail-head h2 { font-size: var(--text-2xl); }
.subcommittee-detail-head p { color: var(--ink-muted); }
.subcommittee-detail-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3);
  margin: 0;
}
.subcommittee-products { display: flex; flex-direction: column; gap: var(--s-3); }
.subcommittee-products h3 { font-size: var(--text-lg); }
.subcommittee-products > a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3); color: inherit; background: var(--surface-sunken);
  border-radius: var(--radius-md); text-decoration: none;
}
.subcommittee-products > a:hover { background: var(--surface-hover); text-decoration: none; }
.subcommittee-products > a > span:first-child {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1);
}
.subcommittee-products small { color: var(--ink-muted); }

.reports-header {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 0.55fr);
  align-items: end;
}
.reports-header > .illustrative-notice { grid-column: 1 / -1; }
.reports-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.reports-controls label { display: flex; flex-direction: column; gap: var(--s-1); }
.report-source-filter {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); color: var(--ink-primary);
  background: var(--blue-50); border-radius: var(--radius-md); font-size: var(--text-sm);
}

.is-route-target {
  outline: 3px solid color-mix(in srgb, var(--blue-600) 28%, transparent);
  outline-offset: 3px;
}
.reports-stack { display: flex; flex-direction: column; gap: var(--s-5); }
.report-kpis {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5); background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.report-section-head > div { display: flex; flex-direction: column; gap: var(--s-1); }
.report-section-head h2 { font-size: var(--text-xl); }
.report-section-head p { color: var(--ink-muted); font-size: var(--text-sm); }
.report-kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3);
}
.report-kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-4); color: inherit; background: var(--surface-sunken);
  border-top: 3px solid var(--brand); border-radius: var(--radius-md); text-decoration: none;
}
.report-kpi:hover { background: var(--surface-hover); text-decoration: none; }
.report-kpi > span:not(.badge) { color: var(--ink-muted); font-size: var(--text-sm); }
.report-kpi strong { font-size: var(--text-2xl); }
.report-kpi small { color: var(--ink-subtle); font-size: var(--text-xs); }
.report-kpi p { color: var(--ink-muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
.report-export-preview {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4);
  align-items: center; padding: var(--s-5);
  color: var(--ink); background: var(--amber-50);
  border: 1px solid var(--amber-200); border-radius: var(--radius-lg);
}
.report-export-preview > div:first-child { display: flex; flex-direction: column; gap: var(--s-1); }
.report-export-preview p { color: var(--ink-warning); font-size: var(--text-sm); }
.report-export-preview .done { grid-column: 1 / -1; }

.search-hero {
  align-items: stretch; color: var(--rail-ink-active); background: var(--navy-900);
}
.search-hero .eyebrow { color: #b9cdf0; }
.search-hero h2 { color: var(--rail-ink-active); }
.search-hero > p { color: var(--rail-ink); }
.global-search-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3);
  width: min(860px, 100%);
}
.global-search-input {
  display: flex; align-items: center; gap: var(--s-2);
  min-width: 0; padding-left: var(--s-3);
  color: var(--ink-muted); background: var(--surface);
  border-radius: var(--radius-md);
}
.global-search-input .input { flex: 1; min-width: 0; border: 0; background: transparent; }
.global-search-input .btn { flex: none; }
.search-type-filter { padding: 0; }
.search-results { display: flex; flex-direction: column; gap: var(--s-4); }
.search-results-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
}
.search-results-head h2 { font-size: var(--text-xl); }
.search-results-head p { color: var(--ink-muted); font-size: var(--text-sm); }
.search-result-list {
  display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none;
  overflow: hidden; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.search-result-list > li + li { border-top: 1px solid var(--border); }
.search-result {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-4) var(--s-5); color: inherit; text-decoration: none;
}
.search-result:hover { background: var(--surface-hover); text-decoration: none; }
.search-result-top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  width: 100%; color: var(--ink-muted); font-size: var(--text-xs);
}
.search-result > strong { font-size: var(--text-lg); }
.search-result > p { color: var(--ink-muted); font-size: var(--text-sm); }
.search-result mark {
  padding: 0 2px; color: inherit; background: var(--amber-100); border-radius: 2px;
}
.search-result-link {
  display: inline-flex; align-items: center; gap: var(--s-1);
  color: var(--ink-primary); font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.search-guidance {
  display: grid; grid-template-columns: minmax(260px, 0.6fr) minmax(0, 1.4fr);
  gap: var(--s-6); align-items: start; padding: var(--s-6);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.search-guidance > div:first-child { display: flex; flex-direction: column; gap: var(--s-2); }
.search-guidance p { color: var(--ink-muted); }
.search-domain-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3);
}
.search-domain-grid > a {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-4); color: inherit; background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md); text-decoration: none;
}
.search-domain-grid > a:hover { border-color: var(--border-strong); text-decoration: none; }
.search-domain-grid > a > span:not(.badge) { color: var(--ink-muted); font-size: var(--text-xs); }

/* ══════════════════════════════════════════════════════════════════════════
   Loading, empty and error states
   ══════════════════════════════════════════════════════════════════════ */

.sk-title { width: 200px; height: 22px; }
.sk-line { height: 14px; }
.sk-line-sm { width: 60%; height: 11px; }
.sk-metric { height: 96px; border-radius: var(--radius-lg); }
.sk-chip { width: 108px; height: 32px; border-radius: var(--radius-full); }
.sk-input { height: 38px; border-radius: var(--radius-md); }
.sk-field { height: 60px; border-radius: var(--radius-md); }
.sk-block { height: 120px; border-radius: var(--radius-md); }
.sk-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: var(--s-4);
  align-items: center; padding: var(--s-4) var(--s-5);
}
.sk-row + .sk-row { border-top: 1px solid var(--border); }

.state {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-12) var(--s-5); text-align: center;
}
.state-icon {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: var(--radius-full); background: var(--n-100); color: var(--ink-subtle);
}
.state--error .state-icon { background: var(--red-50); color: var(--red-700); }
.state-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.state-text { font-size: var(--text-md); color: var(--ink-muted); max-width: 52ch; line-height: var(--leading); }
.state-text code {
  font-family: var(--font-mono); font-size: var(--text-sm);
  padding: 1px 5px; border-radius: var(--radius-sm);
  background: var(--n-100); color: var(--ink);
}

/* ══════════════════════════════════════════════════════════════════════════
   Narrow viewports
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  /* the source and the fields stop being side by side before the queue does —
     the fields are the thing being typed into, so they get the full width */
  .workspace-body { grid-template-columns: minmax(0, 1fr); }
  .source-page { min-height: 0; }
  .source-state { min-height: 0; padding: var(--s-4); }
  .command-metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .intake-layout { grid-template-columns: minmax(0, 1fr); }
  .queue-list { max-height: 320px; }
  .command-grid--analytics > .command-span { grid-column: 1 / -1; }
  .case-work-grid { grid-template-columns: minmax(0, 1fr); }
  .case-context { position: static; }
  .doc-workspace, .calendar-brief { grid-template-columns: minmax(0, 1fr); }
  .calendar-status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .subcommittee-grid, .reports-header, .search-guidance { grid-template-columns: minmax(0, 1fr); }
  .reports-header > .illustrative-notice { grid-column: auto; }
  .subcommittee-detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.rail-account-btn { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100dvh; overflow: visible; }

  /* The rail becomes a header strip: brand on the left, account on the right.
     Navigation moves to the tab bar at the bottom of the screen — a 1261px-wide
     scrolling row inside a 390px viewport gave no sign that anything existed to
     the right of "Văn bản", and the current item never scrolled into view. */
  .rail {
    position: sticky; top: 0; z-index: var(--z-rail);
    flex-direction: row; align-items: center; gap: var(--s-3);
    border-right: 0; border-bottom: 1px solid var(--rail-border);
    background: var(--rail-bg);
  }
  .rail-brand { padding: var(--s-3) var(--s-4); margin-right: auto; min-width: 0; }
  .rail-nav, .rail-foot, .rail-section { display: none; }
  .global-search {
    order: 2; width: 44px; min-width: 44px; height: 44px;
    margin: 0; padding: 0; justify-content: center; border-color: transparent;
  }
  .global-search-label, .global-search-short { display: none; }
  .rail-account-btn {
    display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; margin-right: var(--s-2);
    color: var(--rail-ink-active); background: none; border: 0;
    border-radius: var(--radius-full); cursor: pointer;
  }
  .rail-account-btn:hover { background: var(--rail-bg-hover); }

  .main { overflow: visible; grid-template-rows: auto auto; }
  .topbar { padding: var(--s-4); position: static; }
  .topbar-title { font-size: var(--text-xl); }
  .location-cue--mobile-only { display: inline-flex; }
  /* clear the fixed tab bar, plus the home indicator on a notched phone */
  .content {
    overflow: visible;
    padding: var(--s-4) var(--s-4) calc(72px + env(safe-area-inset-bottom, 0));
  }
  .content :is(button, select, input, textarea, summary),
  .content a[href],
  .location-cue,
  .sheet a[href],
  .sheet button,
  .sheet select {
    min-height: 44px;
  }
  .content a[href] { display: inline-flex; align-items: center; }
  .chart-panel { padding: var(--s-4); }
  .chart-svg { min-width: 620px; }
  .data-table th, .data-table td { padding: var(--s-3) var(--s-2); }

  .command-context { align-items: stretch; flex-direction: column; padding: var(--s-5); }
  .command-context-controls { min-width: 0; }
  .command-section-heading { align-items: stretch; flex-direction: column; }
  .command-section-heading .illustrative-notice { max-width: none; }
  .command-center > .command-context { order: 1; }
  .command-center > .command-brief { order: 2; }
  .command-center > .command-grid--primary { order: 3; }
  .command-center > .command-metrics { order: 4; }
  .command-center--executive > .command-grid--primary { order: 2; }
  .command-center--executive > .command-brief { order: 3; }
  .command-grid--primary > .command-span { grid-column: 1 / -1; }
  .command-center > :is(.command-grid--analytics, .command-grid--secondary) { display: contents; }
  .command-grid--secondary > :first-child { order: 5; }
  .command-grid--analytics > :first-child { order: 6; }
  .command-grid--analytics > :last-child { order: 7; }
  .command-grid--secondary > :last-child { order: 8; }
  .command-center--reporting > .command-metrics { order: 3; }
  .command-center--reporting > .command-grid--analytics > :first-child { order: 4; }
  .command-center--reporting > .command-grid--primary { order: 5; }
  .command-center--reporting > .command-grid--secondary > :first-child { order: 6; }
  .command-center--reporting > .command-grid--analytics > :last-child { order: 7; }
  .command-center--scope-lead > .command-grid--analytics > :first-child { order: 5; }
  .command-center--scope-lead > .command-grid--secondary > :first-child { order: 6; }
  .command-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .decision-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'status action' 'copy copy';
    gap: var(--s-3);
  }
  .decision-row-status { grid-area: status; flex-direction: row; align-items: center; }
  .decision-row-copy { grid-area: copy; }
  .decision-row-action { grid-area: action; }
  .inbox-intro { align-items: flex-start; flex-direction: column; }
  .priority-item-main {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--s-2) var(--s-4) var(--s-4);
  }
  .priority-item-action { justify-self: start; margin-left: 32px; }
  .priority-item-detail { padding: 0 var(--s-4) var(--s-4); }
  .inbox-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .case-command-header { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .case-next-action { align-items: flex-start; }
  .case-task-main { grid-template-columns: minmax(0, 1fr); }
  .case-task-action { justify-self: start; margin-left: 32px; }
  .case-task-detail { grid-template-columns: minmax(0, 1fr); padding-left: 0; }
  .case-command-meta { grid-template-columns: minmax(0, 1fr); }

  .row-btn {
    grid-template-columns: 20px auto minmax(0, 1fr);
    grid-template-areas: 'mark title title' '.    tag   when';
    gap: var(--s-2) var(--s-3); align-items: start;
    padding: var(--s-3) var(--s-4);
  }
  .row-btn > .row-mark { grid-area: mark; margin-top: 2px; }
  .row-btn > .row-titles { grid-area: title; }
  .row-btn > .badge { grid-area: tag; }
  .row-btn > .row-when { grid-area: when; justify-self: end; align-self: center; }
  .row-detail { padding: 0 var(--s-4) var(--s-4); }

  .mywork-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'kind title' 'who  when';
    gap: var(--s-2) var(--s-3); align-items: start; padding: var(--s-3) var(--s-4);
  }
  .mywork-row > .badge { grid-area: kind; }
  .mywork-title { grid-area: title; }
  .mywork-who { grid-area: who; }
  .mywork-when { grid-area: when; justify-self: end; }

  .load-head, .load-btn {
    grid-template-columns: minmax(0, 1fr) repeat(3, minmax(50px, auto));
    grid-template-areas: 'name name name name' 'load n1 n2 n3';
    gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4);
  }
  .load-head > :nth-child(1), .load-btn > :nth-child(1) { grid-area: name; }
  .load-head > :nth-child(2), .load-btn > :nth-child(2) { grid-area: load; }
  .load-head > :nth-child(3), .load-btn > :nth-child(3) { grid-area: n1; }
  .load-head > :nth-child(4), .load-btn > :nth-child(4) { grid-area: n2; }
  .load-head > :nth-child(5), .load-btn > :nth-child(5) { grid-area: n3; }
  .drill { padding: 0 var(--s-4) var(--s-4); }

  .case-tl-btn {
    grid-template-columns: auto minmax(0, 1fr) 20px;
    grid-template-areas: 'when kind mark' 'subj subj subj';
    gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4);
  }
  .case-tl-btn > :nth-child(1) { grid-area: when; }
  .case-tl-btn > .badge { grid-area: kind; justify-self: start; }
  .case-tl-title { grid-area: subj; }
  .case-tl-btn > .row-mark { grid-area: mark; }
  .case-tl-more { padding: 0 var(--s-4) var(--s-4); }

  .card-head, .card-body { padding: var(--s-4); }
  .toast-region { right: var(--s-3); left: var(--s-3); bottom: calc(72px + env(safe-area-inset-bottom, 0)); }
  .toast { max-width: none; }

  /* Five filter chips wrapped to three rows and took 130px of a phone screen
     before the first item. One row that scrolls, with a fade at the edge so it
     is obvious more exists — the mistake the old nav strip made was having no
     such sign. Chips reach 44px here: they are the primary control on the
     screen and a thumb has to hit them. */
  .toolbar {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none;
    /* A flex item's default floor is its min-content width — for a nowrap row of
       chips that is the sum of all of them, which pushed the whole column past
       the viewport before overflow-x ever got a chance to scroll. */
    min-width: 0;
    /* no negative-margin bleed: the content column has overflow:visible here so
       a bled strip escapes the page and scrolls it sideways by its own margin */
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
            mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex: none; }
  .toolbar .search { min-width: 240px; }
  .chip { min-height: 44px; }

  .clerk-health-head, .document-register-head { align-items: stretch; flex-direction: column; }
  .clerk-health-head .illustrative-notice { max-width: none; }
  .clerk-quality-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-register-count { min-width: 0; }
  .calendar-status-grid { grid-template-columns: minmax(0, 1fr); }
  .calendar-controls .toolbar { width: 100%; }
  .calendar-event-detail { grid-template-columns: minmax(0, 1fr); }
  .assistant-disclaimer { padding-inline: var(--s-4); }
  .subcommittee-header, .reports-header, .search-hero { padding: var(--s-5); }
  .search-results-head { align-items: flex-start; flex-direction: column; }
  .search-result { padding: var(--s-4); }
  .documents-screen > .toolbar {
    flex-wrap: wrap; overflow: visible;
    -webkit-mask-image: none; mask-image: none;
  }
  .documents-screen > .toolbar > .search { flex: 1 0 100%; width: 100%; min-width: 0; }
  .documents-screen > .toolbar > .row-flex {
    width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--s-1);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
            mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
  }
  .documents-screen > .toolbar > .row-flex::-webkit-scrollbar { display: none; }
  .screen--chat .composer {
    position: sticky; bottom: calc(56px + env(safe-area-inset-bottom, 0));
    z-index: var(--z-header);
  }
}

@media (max-width: 560px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: var(--s-3) var(--s-4); }
  .metric-value { font-size: var(--text-3xl); }
  .command-metric-grid { grid-template-columns: minmax(0, 1fr); }
  .command-context { padding: var(--s-4); }
  .command-context-controls {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .command-context-controls .field-label { grid-column: auto; }
  .command-context-controls .period-chip { min-width: 96px; }
  .period-chip { justify-content: center; }
  .command-work, .command-today, .case-section, .case-reference { padding: var(--s-4); }
  .command-panel-heading, .case-section-heading { align-items: stretch; flex-direction: column; }
  .command-panel-heading .btn { align-self: flex-start; }
  .decision-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'status action' 'copy copy';
  }
  .decision-row-action { justify-self: stretch; }
  .priority-item-top { align-items: flex-start; flex-direction: column; }
  .priority-item-action { justify-self: stretch; margin-left: 0; }
  .case-command-header { padding: var(--s-4); }
  .case-command-copy h2 { font-size: var(--text-2xl); }
  .case-product-grid { grid-template-columns: minmax(0, 1fr); }
  .specialist-case-grid { grid-template-columns: minmax(0, 1fr); }
  .case-task-toggle { grid-template-columns: 20px minmax(0, 1fr); }
  .case-task-progress { grid-column: 2; }
  .case-task-action { justify-self: stretch; margin-left: 0; }
  .case-activity-toggle {
    grid-template-columns: auto minmax(0, 1fr) 20px;
    grid-template-areas: 'when kind mark' 'title title title';
  }
  .case-activity-toggle time { grid-area: when; }
  .case-activity-toggle .badge { grid-area: kind; justify-self: start; }
  .case-activity-toggle strong { grid-area: title; }
  .case-activity-toggle .row-mark { grid-area: mark; }
  .case-activity-detail {
    align-items: flex-start; flex-direction: column; padding-left: 0;
  }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
  .search { max-width: none; }
  .clerk-quality-grid, .event-status-strip { grid-template-columns: minmax(0, 1fr); }
  .clerk-next { align-items: flex-start; flex-direction: column; }
  .clerk-next strong { margin-right: 0; }
  .document-register-head { padding: var(--s-4); }
  .doc-summary, .doc-source-extract, .doc-register-meta { padding: var(--s-3); }
  .calendar-brief .ai-output { padding: var(--s-4); }
  .calendar-view-toolbar { align-items: flex-start; flex-direction: column; }
  .calendar-view-toolbar .push { margin-left: 0; }
  .calendar-list-item .calendar-detail-region { margin-left: 0; }
  .subcommittee-totals,
  .subcommittee-detail-metrics,
  .reports-controls,
  .report-kpi-grid,
  .search-domain-grid { grid-template-columns: minmax(0, 1fr); }
  .subcommittee-row { grid-template-columns: minmax(0, 1fr) 20px; }
  .subcommittee-row .badge { grid-row: 2; justify-self: start; }
  .subcommittee-row-risk { grid-column: 1; }
  .subcommittee-row > svg { grid-column: 2; grid-row: 1 / 3; }
  .subcommittee-detail-head { flex-direction: column; }
  .subcommittee-products > a { align-items: flex-start; flex-direction: column; }
  .report-export-preview { grid-template-columns: minmax(0, 1fr); }
  .report-export-preview .done { grid-column: auto; }
  .global-search-form { grid-template-columns: minmax(0, 1fr); }
  .global-search-form > .btn { width: 100%; }
  .global-search-input .btn { padding-inline: var(--s-2); }
  .search-result-top { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 360px) {
  .decision-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'status' 'copy' 'action';
  }
  .decision-row-action { white-space: normal; }
  .case-task-top {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--s-1);
  }
}

@media print {
  .chart-table-toggle, .chart-graphic { display: none !important; }
  .chart-table-wrap[hidden] { display: block !important; }
  .chart-panel { box-shadow: none; border: 1px solid var(--n-300); }
}
