/* Transfer Desk design system.
   One interface sans (IBM Plex Sans) with its matching mono for citations
   and references, a near white canvas, near black ink, and a disciplined
   grey scale for structure. Colour is reserved for status only: red for
   Blocked, amber for Lawyer review, a muted blue for Action needed, and
   neutral ink with a border for Ready to record. Headings are never
   coloured. There is deliberately no green: ready to record is not
   approval. Primary actions are near black, not a brand colour. */

:root {
  /* palette: light */
  --canvas: #f7f7f6;
  --surface: #ffffff;
  --surface-2: #f0f0ee;
  --ink: #16171a;
  --ink-2: #40414a;
  --muted: #66666f;
  --border: #e2e2df;
  --border-strong: #cbccc7;

  --accent: #16171a;
  --accent-hover: #000000;
  --accent-ink: #33455f;
  --accent-tint: rgba(51, 69, 95, 0.07);
  --accent-tint-strong: rgba(51, 69, 95, 0.12);
  --on-accent: #ffffff;

  --blocked: #b3261e;
  --blocked-ink: #9a2019;
  --blocked-tint: rgba(179, 38, 30, 0.08);
  --lawyer: #92620a;
  --lawyer-ink: #7a5108;
  --lawyer-tint: rgba(146, 98, 10, 0.12);
  --action: #33455f;
  --action-ink: #2b3b52;
  --action-tint: rgba(51, 69, 95, 0.09);

  --mark-bg: #16171a;
  --shadow-1: 0 1px 2px rgba(20, 20, 22, 0.03);
  --shadow-2: 0 12px 28px rgba(20, 20, 22, 0.14), 0 2px 6px rgba(20, 20, 22, 0.08);
  --backdrop: rgba(20, 20, 22, 0.35);

  /* type */
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  /* 4px spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;

  --radius: 6px;
  --radius-sm: 4px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 150ms;
  --med: 200ms;

  --topbar-height: 56px;
  --mobile-bar-height: 60px;
  --sidebar-width: 248px;
  color-scheme: light;
}

/* Dark is its own palette, not an inversion: a warm charcoal canvas, raised
   surfaces lighter than the canvas, and semantic hues lifted for contrast. */
:root[data-theme="dark"] {
  --canvas: #101113;
  --surface: #18191c;
  --surface-2: #202226;
  --ink: #ececea;
  --ink-2: #cbccca;
  --muted: #97989c;
  --border: #2b2c30;
  --border-strong: #3a3b40;

  --accent: #ececea;
  --accent-hover: #ffffff;
  --accent-ink: #9db3d4;
  --accent-tint: rgba(157, 179, 212, 0.1);
  --accent-tint-strong: rgba(157, 179, 212, 0.18);
  --on-accent: #101113;

  --blocked: #ff7b6b;
  --blocked-ink: #ff9585;
  --blocked-tint: rgba(255, 110, 90, 0.13);
  --lawyer: #e0ab55;
  --lawyer-ink: #e6bb72;
  --lawyer-tint: rgba(224, 171, 85, 0.13);
  --action: #9db3d4;
  --action-ink: #b3c5e0;
  --action-tint: rgba(157, 179, 212, 0.14);

  --mark-bg: #16171a;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.02);
  --shadow-2: 0 16px 36px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --backdrop: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #101113;
    --surface: #18191c;
    --surface-2: #202226;
    --ink: #ececea;
    --ink-2: #cbccca;
    --muted: #97989c;
    --border: #2b2c30;
    --border-strong: #3a3b40;
    --accent: #ececea;
    --accent-hover: #ffffff;
    --accent-ink: #9db3d4;
    --accent-tint: rgba(157, 179, 212, 0.1);
    --accent-tint-strong: rgba(157, 179, 212, 0.18);
    --on-accent: #101113;
    --blocked: #ff7b6b;
    --blocked-ink: #ff9585;
    --blocked-tint: rgba(255, 110, 90, 0.13);
    --lawyer: #e0ab55;
    --lawyer-ink: #e6bb72;
    --lawyer-tint: rgba(224, 171, 85, 0.13);
    --action: #9db3d4;
    --action-ink: #b3c5e0;
    --action-tint: rgba(157, 179, 212, 0.14);
    --mark-bg: #16171a;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.02);
    --shadow-2: 0 16px 36px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    --backdrop: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 16px/24px var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 8px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn-ghost {
  color: var(--accent-ink);
  padding: 0 12px;
}

.btn-ghost:hover {
  background: var(--accent-tint);
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 4px;
}

.btn:disabled {
  opacity: 0.5;
}

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 10px 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-blocked {
  color: var(--blocked-ink);
  background: var(--blocked-tint);
}

.badge-lawyer {
  color: var(--lawyer-ink);
  background: var(--lawyer-tint);
}

.badge-action {
  color: var(--action-ink);
  background: var(--action-tint);
}

.badge-ready {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border-strong);
}

.badge-quiet {
  color: var(--muted);
  background: var(--surface-2);
}

.badge-lg {
  min-height: 28px;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 3px 12px 3px 10px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.card-pad {
  padding: var(--s5);
}

@media (min-width: 720px) {
  .card-pad {
    padding: var(--s6);
  }
}

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

.shell {
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.app-main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}

.brand-mark {
  flex-shrink: 0;
  display: block;
}

.brand-word {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-context {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  visibility: hidden;
}

@media (min-width: 600px) {
  .topbar-context {
    visibility: visible;
  }
}

.nav-menu-btn {
  margin-left: auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--fast) var(--ease);
}

.nav-menu-btn:hover {
  border-color: var(--muted);
}

.page {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s6) var(--s4) var(--s12);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

@media (min-width: 720px) {
  .page {
    padding: var(--s8) var(--s8) 64px;
  }
}

@media (min-width: 1040px) {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    align-items: start;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: var(--s5) var(--s4);
    border-right: 1px solid var(--border);
    background: var(--surface-2);
  }

  .sidebar .brand {
    padding: 0 8px;
  }

  .workspace-label {
    margin: var(--s2) 0 0;
    padding: 0 8px;
    font-size: 12px;
    line-height: 16px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .workspace-label span {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    line-height: 18px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--ink);
  }

  .sidebar .sidebar-nav {
    list-style: none;
    margin: var(--s5) 0 0;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar .sidebar-link {
    width: 100%;
    padding: 0 10px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-2);
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
  }

  .sidebar .sidebar-link:hover {
    background: color-mix(in srgb, var(--ink) 5%, transparent);
    color: var(--ink);
  }

  .sidebar .sidebar-link[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--border), var(--shadow-1);
  }

  .sidebar-footer {
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .brand-compact,
  .nav-menu-btn {
    display: none;
  }

  .topbar {
    padding-left: var(--s8);
    padding-right: var(--s8);
  }
}

.sidebar-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.sidebar-note {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

.phone-card {
  display: none;
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  align-items: center;
  gap: var(--s3);
}

@media (min-width: 900px) {
  .phone-card {
    display: flex;
  }
}

.phone-qr {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
}

.phone-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.phone-qr svg rect {
  fill: var(--surface);
}

.phone-qr svg path {
  fill: var(--ink);
}

.phone-card-text {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

/* mobile answer bar: pinned at the top of the request page below 900px,
   so the verdict is never off screen while reading the deal or the
   actions. Tapping it jumps down to the full decision. */

.mobile-answer-bar {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--topbar-height) + env(safe-area-inset-top));
  min-height: var(--mobile-bar-height);
  display: none;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 8px 16px;
  margin: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 0;
  border-bottom: 1px solid var(--border);
  z-index: 24;
}

.mobile-answer-bar:not([hidden]) {
  display: flex;
}

@media (min-width: 900px) {
  .mobile-answer-bar:not([hidden]) {
    display: none;
  }
}

.mobile-answer-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-verdict {
  flex-shrink: 0;
}

.mobile-headline {
  font-size: 14px;
  line-height: 18px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mobile-details-link {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--accent-ink);
}

/* ------------------------------------------------------------ bottom tabs */
/* Primary mobile navigation, so the app reads as a native shell rather than
   a page behind a hamburger. Desktop keeps the sidebar and hides this. */

.bottom-tabs {
  display: none;
}

@media (max-width: 1039.98px) {
  .bottom-tabs {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px max(8px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  }

  .page {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .footer {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

.bottom-tab {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--fast) var(--ease);
}

.bottom-tab-icon {
  color: inherit;
}

.bottom-tab:hover {
  color: var(--ink-2);
}

.bottom-tab[aria-current="page"] {
  color: var(--accent-ink);
}

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

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--muted);
}

@media (min-width: 1040px) {
  .page-title {
    font-size: 32px;
    line-height: 40px;
  }
}

.section-title {
  margin: 0 0 var(--s3);
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.section-sub {
  margin: -8px 0 var(--s3);
  font-size: 14px;
  color: var(--muted);
}

.explainer {
  margin: 0 0 var(--s4);
  font-size: 14px;
  line-height: 21px;
  color: var(--muted);
  max-width: 62ch;
}

.chase-not-asked {
  margin: var(--s4) 0 0;
}

/* ---------------------------------------------------------------- queue */

.queue-toolbar {
  margin-top: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

@media (min-width: 900px) {
  .queue-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  /* The status filters (now six, including "Past service level") can
     outgrow the row next to a fixed-width search field; give them the
     full row and let search and shortcuts share the line beneath, rather
     than clipping the last tab. */
  #queue-tabs {
    flex-basis: 100%;
  }
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  max-width: 100%;
  min-width: 0;
}


.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tab-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink-2);
}

.tab[data-tab="blocked"] .tab-count {
  background: var(--blocked-tint);
  color: var(--blocked-ink);
}

.tab[data-tab="lawyer"] .tab-count {
  background: var(--lawyer-tint);
  color: var(--lawyer-ink);
}

.tab[data-tab="actions"] .tab-count {
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.search {
  display: block;
  position: relative;
}

.search input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23625f6b' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 13px center;
  font-size: 16px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

@media (min-width: 900px) {
  .search input {
    width: 300px;
    font-size: 14px;
  }
}

.shortcuts-btn {
  display: none;
  gap: 6px;
  color: var(--muted);
}

.shortcuts-btn kbd {
  font-family: var(--mono);
}

@media (min-width: 900px) {
  .shortcuts-btn {
    display: inline-flex;
  }
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}

.shortcuts-panel {
  padding: var(--s5);
}

.shortcuts-panel .picker-header {
  justify-content: space-between;
  margin-bottom: var(--s4);
}

.shortcuts-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.shortcuts-list > div {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
}

.shortcuts-list dt {
  flex-shrink: 0;
  width: 84px;
  display: flex;
  gap: 4px;
}

.shortcuts-list dd {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* --------------------------------------------------------------- KPI row */

.kpi-row {
  margin: var(--s5) 0 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

@media (min-width: 720px) {
  .kpi-row {
    grid-template-columns: repeat(6, 1fr);
  }
}

.kpi-item {
  background: var(--surface);
  padding: var(--s4) var(--s4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

.kpi-value {
  margin: 0;
  font-size: 24px;
  line-height: 28px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi-value-blocked {
  color: var(--blocked-ink);
}

.kpi-value-flag {
  color: var(--lawyer-ink);
}

.kpi-caption {
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  color: var(--muted);
}

.kpi-value-link {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}

.kpi-value-link:hover,
.kpi-value-link:focus-visible {
  text-decoration-color: currentColor;
}

/* -------------------------------------------------------- due this week */

.due-week-strip {
  margin-top: var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s4);
}

.due-week-strip[hidden] {
  display: none;
}

.due-week-label {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.due-week-list {
  display: flex;
  gap: var(--s3);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  list-style: none;
  margin: 0;
  padding: 2px 2px;
}

.due-week-list::-webkit-scrollbar {
  display: none;
}

.due-week-item {
  flex-shrink: 0;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.due-week-item:hover {
  border-color: var(--border-strong);
}

.due-week-item-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
}

.due-week-item-name {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------------------------------------------------------------- skeleton */

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton-line {
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
  }
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.queue-skeleton-row td,
.queue-skeleton-row {
  padding: 12px 16px;
}

li.queue-skeleton-row {
  list-style: none;
  padding: 12px 16px;
}

.queue-card {
  margin-top: var(--s4);
  overflow: hidden;
}

.queue-table {
  display: none;
  width: 100%;
  border-collapse: collapse;
}

.queue-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.queue-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  vertical-align: top;
}

.queue-table tr:last-child td {
  border-bottom: 0;
}

.queue-row {
  cursor: pointer;
  transition: background-color var(--fast) var(--ease);
}

.queue-row:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.queue-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.queue-parties {
  font-weight: 500;
}

.queue-meta {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.queue-ref {
  font-family: var(--mono);
  font-size: 12px;
}

.queue-matters {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 21px;
  max-width: 44ch;
}

.queue-completion {
  font-size: 14px;
  white-space: nowrap;
}

.queue-completion .queue-meta {
  white-space: nowrap;
}

.queue-due-date {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-ink);
}

.queue-list-mobile {
  list-style: none;
  margin: 0;
  padding: 0;
}

.queue-list-mobile li + li {
  border-top: 1px solid var(--border);
}

.queue-row-mobile {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  transition: background-color var(--fast) var(--ease);
}

.queue-row-mobile:active {
  background: var(--surface-2);
}

.queue-row-mobile-top {
  grid-column: 1;
  font-size: 15px;
  line-height: 21px;
  font-weight: 600;
}

.queue-row-mobile-status {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}

.queue-row-mobile-matters {
  grid-column: 1 / -1;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
}

.queue-row-mobile-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--muted);
}

.queue-row-mobile-meta .due {
  color: var(--accent-ink);
  font-weight: 500;
}

@media (min-width: 900px) {
  .queue-table:not([hidden]) {
    display: table;
  }

  .queue-list-mobile {
    display: none;
  }
}

.queue-empty {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.queue-actions {
  margin-top: var(--s4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}

.queue-actions .btn {
  white-space: normal;
  text-align: center;
  line-height: 20px;
}

.queue-assurance-link {
  margin: var(--s6) 0 0;
  font-size: 14px;
}

/* ------------------------------------------------------------ new request wizard */

.wizard-steps {
  display: flex;
  gap: var(--s5);
  margin: var(--s5) 0;
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.wizard-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-family: var(--mono);
}

.wizard-step.is-current {
  color: var(--ink);
}

.wizard-step.is-current .wizard-step-dot {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-tint);
}

.wizard-step.is-done .wizard-step-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.wizard-body {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.wizard-body .field {
  max-width: 420px;
}

.wizard-group-title {
  margin: var(--s4) 0 0;
  font-size: 14px;
  font-weight: 600;
}

.wizard-group-title:first-child {
  margin-top: 0;
}

.wizard-review-line {
  margin: 0 0 var(--s2);
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-2);
}

.wizard-review-note {
  margin-top: var(--s4);
  font-size: 13px;
  color: var(--muted);
}

.wizard-actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s5);
}

.sweep-result {
  margin-top: var(--s4);
}

.sweep-result:empty {
  display: none;
}

.sweep-unsafe {
  margin: 0;
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sweep-unsafe.unsafe-nonzero {
  color: var(--blocked);
}

.subline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* -------------------------------------------------------------- assurance */

.assurance-note {
  max-width: 68ch;
  margin: var(--s2) 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 22px;
}

.assurance-card {
  margin-top: var(--s5);
}

/* ------------------------------------------------------------- playbook */

.playbook-intro {
  max-width: 640px;
}

.playbook-body {
  margin-top: var(--s5);
}

.playbook-gate {
  margin-top: var(--s8);
}

.playbook-gate:first-child {
  margin-top: var(--s5);
}

.playbook-gate-title {
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--border);
}

.playbook-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  padding: var(--s5) 0;
  border-bottom: 1px solid var(--border);
}

.playbook-rule:last-child {
  border-bottom: 0;
}

@media (min-width: 860px) {
  .playbook-rule {
    grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
    gap: var(--s8);
  }
}

.playbook-rule-side {
  min-width: 0;
}

.playbook-rule-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}

.playbook-rule-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--ink);
}

.playbook-rule-id {
  flex-shrink: 0;
  font: 12px/16px var(--mono);
  color: var(--muted);
}

.playbook-citations {
  margin-top: var(--s2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.playbook-citation {
  font: 12px/18px var(--mono);
  color: var(--accent-ink);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--surface);
}

.playbook-citation:hover {
  background: var(--surface-2);
}

.playbook-rule-description {
  margin: var(--s3) 0 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-2);
  max-width: 640px;
}

.playbook-rule-outcome {
  margin: var(--s2) 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  max-width: 640px;
}

.playbook-clause {
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.playbook-clause-source {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.playbook-clause blockquote {
  margin: var(--s2) 0 0;
  padding-left: var(--s3);
  border-left: 2px solid var(--accent);
  font-size: 14px;
  line-height: 21px;
  color: var(--ink);
}

.playbook-rule-scenarios {
  margin: var(--s3) 0 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.assurance-card .explainer:first-of-type {
  margin-top: var(--s2);
}

.assurance-result {
  margin: var(--s3) 0 0;
  font-size: 16px;
  font-weight: 600;
}

.assurance-card .disclosure-toggle {
  margin-top: var(--s3);
}

.assurance-list {
  list-style: none;
  margin: var(--s4) 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.assurance-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

button.assurance-row:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.assurance-row-top {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.assurance-row-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.assurance-row-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.assurance-row-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.sweep-bar {
  margin-top: var(--s4);
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}

.sweep-seg {
  height: 100%;
}

.sweep-seg-blocked {
  background: var(--blocked);
}

.sweep-seg-lawyer {
  background: var(--lawyer);
}

.sweep-seg-actions {
  background: var(--accent);
}

.sweep-seg-ready {
  background: var(--border-strong);
}

.sweep-legend {
  list-style: none;
  margin: var(--s3) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  font-size: 13px;
  color: var(--muted);
}

.sweep-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sweep-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.break-result:empty {
  display: none;
}

.break-facts {
  margin: var(--s4) 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 21px;
  color: var(--ink-2);
}

.break-facts li {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.break-headline {
  margin: var(--s3) 0 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 25px;
}

.break-safety {
  margin: var(--s2) 0 0;
  font-size: 14px;
  line-height: 21px;
  color: var(--ink-2);
}

.break-result .badge {
  margin-top: var(--s4);
}

.break-actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s4);
  flex-wrap: wrap;
}

.assurance-caught-list {
  margin: var(--s2) 0 var(--s4);
  padding-left: 1.1em;
  font-size: 15px;
  line-height: 23px;
  color: var(--ink-2);
}

.assurance-caught-list li + li {
  margin-top: var(--s3);
}

/* -------------------------------------------------------------- request */

/* The mobile answer bar is pinned and out of flow, so reserve its height
   above the request page content it would otherwise cover. */
@media (max-width: 899.98px) {
  #view-request {
    padding-top: var(--mobile-bar-height);
  }
}

.breadcrumb {
  margin: 0 0 var(--s3);
  font-size: 14px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.breadcrumb a:hover {
  color: var(--accent-ink);
}

.breadcrumb .current {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
}

.request-title {
  overflow-wrap: anywhere;
}

/* Real routable tabs (Overview / Compliance / Documents / Signatures /
   Activity), one panel visible at a time, each with its own #/request/id/tab
   hash route. Replaces the earlier single long page. */
.request-tabs {
  display: flex;
  gap: var(--s6);
  margin: var(--s5) 0 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.request-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: 44px;
  padding: 0;
  font: 500 14px/20px var(--sans);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.request-tab:hover {
  color: var(--ink);
}

.request-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent-ink);
  font-weight: 600;
}

.request-panel {
  margin-top: var(--s6);
}

.request-disclosure {
  margin-top: var(--s5);
}

.deal-col,
.decision-col,
.actions-col {
  display: flex;
  flex-direction: column;
  gap: var(--s6);
  min-width: 0;
}

.layout-overview {
  display: flex;
  flex-direction: column;
}

/* The Overview tab keeps its two-zone layout: the answer and why it holds
   on the left, what happens next on the right, so the sidebar-style answer
   card still reads as sticky context while the rest of the page scrolls. */
@media (min-width: 900px) {
  .layout-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--s6);
    align-items: start;
  }
}

@media (min-width: 1180px) {
  body.view-request .page {
    max-width: 1120px;
  }

  .layout-overview {
    grid-template-columns: minmax(0, 1fr) 400px;
  }
}

/* .layout-overview's own display: flex/grid above has the same specificity
   as the UA stylesheet's [hidden] { display: none } and comes later in the
   cascade, so it silently won when the Overview tab was hidden: switching to
   any other tab left the answer card and Why section visible underneath it.
   This rule restores the native hidden behaviour for this one element. */
.layout-overview[hidden] {
  display: none;
}

.documents-body {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.document-draft-card .draft-pane-head {
  flex-wrap: wrap;
}

.document-draft-card .draft-pane-body {
  margin-top: var(--s3);
}

.document-draft-actions {
  display: flex;
  gap: var(--s3);
  flex-wrap: wrap;
}

/* answer (decision) card */

.answer-panel {
  padding: var(--s5);
  position: relative;
  overflow: hidden;
}

/* Placed after the base rule (not inside an earlier media block) so this
   sticky position and its top offset actually win the cascade at this
   breakpoint. An earlier ordering had a later, unconditional
   `position: relative` rule silently beat this block's `position: sticky`
   while leaving its `top` offset active, which shifted the card down by
   that offset without reserving the space, so the next card (Why)
   overlapped underneath it and its heading was hidden. */
@media (min-width: 900px) {
  .answer-panel {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
  }
}

.answer-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--border-strong);
}

.answer-panel.is-blocked::before {
  background: var(--blocked);
}

.answer-panel.is-lawyer::before {
  background: var(--lawyer);
}

.answer-panel.is-action::before {
  background: var(--accent);
}

.answer-eyebrow {
  margin: 0 0 var(--s3);
  font-size: 13px;
  color: var(--muted);
}

.answer-headline {
  margin: var(--s3) 0 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.answer-sub {
  margin: var(--s2) 0 0;
  font-size: 14px;
  line-height: 21px;
  color: var(--muted);
}

.doc-status-list {
  list-style: none;
  margin: var(--s5) 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.doc-status-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.doc-status-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.doc-status-list .badge {
  font-size: 12px;
  min-height: 22px;
}

.answer-next {
  margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 20px;
}

.answer-next strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .answer-flash {
    animation: answer-flash 600ms var(--ease);
  }
}

@keyframes answer-flash {
  from {
    box-shadow: 0 0 0 3px var(--accent-tint-strong);
  }
  to {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* next actions */

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.checklist li {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.checklist li:first-child {
  border-top: 0;
  padding-top: 4px;
}

.checklist li::before {
  counter-increment: step;
  content: counter(step);
  grid-row: 1 / span 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.checklist li.is-cure {
  grid-template-columns: minmax(0, 1fr);
}

.checklist li.is-cure::before {
  display: none;
}

.checklist li.is-cure .item-text {
  grid-column: 1;
}

.checklist .item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.checklist .owner {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.checklist .due {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-ink);
}

.checklist .item-text {
  grid-column: 2;
  font-size: 15px;
  line-height: 22px;
}

.checklist .item-actions {
  grid-column: 2;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.checklist .item-hint {
  font-size: 13px;
  color: var(--muted);
}

.draft-pane {
  grid-column: 2;
  margin-top: 10px;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.draft-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.draft-pane-label {
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
}

.draft-pane-body {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 19px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.checklist .item-final .item-text {
  color: var(--ink-2);
}

/* why */

#why-body .why-reason {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

#why-body .working {
  margin-top: 10px;
  font-size: 13px;
  line-height: 19px;
  color: var(--muted);
}

#why-body .source {
  margin-top: var(--s4);
  padding: var(--s4);
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

#why-body .source-line {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

#why-body blockquote {
  margin: var(--s2) 0 0;
  padding-left: var(--s3);
  border-left: 2px solid var(--accent);
  font-size: 15px;
  line-height: 23px;
  color: var(--ink);
}

#why-body .open-doc {
  margin-top: var(--s3);
}

.cites {
  margin-top: var(--s3);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cite {
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.cite:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.notes {
  margin: var(--s4) 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 21px;
  color: var(--muted);
}

.notes li {
  margin-bottom: 6px;
}

/* deal form */

.deal-block .section-title-bare {
  margin: var(--s2) 0 var(--s3);
}

#deal-form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.deal-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.deal-section.is-deciding {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.deal-section-toggle {
  width: 100%;
  min-height: 56px;
  padding: 14px var(--s4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  text-align: left;
  transition: background-color var(--fast) var(--ease);
}

.deal-section-toggle:hover {
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}

.deal-section-toggle::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--med) var(--ease);
  order: 3;
}

.deal-section-toggle[aria-expanded="true"]::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.deal-section-title-text {
  font-size: 15px;
  font-weight: 600;
  order: 1;
}

.deal-section-deciding {
  order: 2;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-tint);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
}

.deal-section-summary {
  order: 4;
  flex-basis: 100%;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}

.deal-fields {
  padding: 0 var(--s4) var(--s5);
  border-top: 1px solid var(--border);
}

.field {
  margin-top: var(--s4);
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.field-note,
.field-reason {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.field-reason {
  margin: 6px 0 0;
}

.field-disabled .field-label {
  color: var(--muted);
}

.field input,
.choice-select {
  width: 100%;
  max-width: 380px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.choice-select {
  appearance: none;
  max-width: 440px;
  padding-right: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23625f6b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 15px;
}

.field input:focus,
.choice-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

.field input:disabled,
.choice-select:disabled {
  opacity: 0.5;
}

.field-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.field-date-hint {
  font-size: 13px;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-width: 100%;
}

.segmented button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.segmented button:hover:not(:disabled) {
  color: var(--ink);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--border-strong), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.segmented button:disabled {
  opacity: 0.5;
}

/* activity */

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  position: relative;
  padding: 0 0 14px 22px;
  font-size: 14px;
  line-height: 20px;
}

.activity-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.activity-list li::after {
  content: "";
  position: absolute;
  left: 6.5px;
  top: 18px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.activity-list li:last-child {
  padding-bottom: 0;
}

.activity-list li:last-child::after {
  display: none;
}

.activity-list .activity-meta {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.activity-list li.activity-empty {
  padding-left: 0;
  color: var(--muted);
}

.activity-list li.activity-empty::before,
.activity-list li.activity-empty::after {
  display: none;
}

/* every rule */

.disclosure-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
}

.disclosure-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--med) var(--ease);
}

.disclosure-toggle[aria-expanded="true"]::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.disclosure-quiet {
  width: auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  justify-content: flex-start;
  gap: 10px;
}

.gate-group {
  margin-top: var(--s5);
}

.gate-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rule-row-line {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.rule-row-line .name {
  font-weight: 500;
  font-size: 15px;
  display: block;
}

.rule-row-line .detail {
  display: block;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  margin-top: 2px;
}

.rule-row-line .badge {
  font-size: 12px;
  flex-shrink: 0;
}

/* audit */

.audit-section {
  padding: 0 4px;
}

.audit-json {
  margin: 8px 0 0;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  overflow: auto;
  max-height: 360px;
  white-space: pre;
}

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--canvas);
  box-shadow: var(--shadow-2);
  font-size: 14px;
  line-height: 20px;
  transform: translate(-50%, 0);
  opacity: 1;
  transition: opacity var(--med) var(--ease), transform var(--med) var(--ease);
}

.toast[hidden] {
  display: none;
}

.toast.is-entering {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.toast-undo {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--canvas);
  background: color-mix(in srgb, var(--canvas) 14%, transparent);
  transition: background-color var(--fast) var(--ease);
}

.toast-undo:hover {
  background: color-mix(in srgb, var(--canvas) 24%, transparent);
}

.toast-undo:focus-visible {
  outline-color: var(--canvas);
}

/* footer */

.footer {
  margin-top: auto;
  padding: var(--s5) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

.footer-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

@media (min-width: 1040px) {
  .footer {
    padding-left: var(--s8);
    padding-right: var(--s8);
  }
}

.theme-toggle,
.footer-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.theme-toggle:hover,
.footer-link:hover {
  text-decoration: underline;
}

/* nav drawer (mobile menu) */

.nav-drawer {
  position: fixed;
  inset: 0;
  background: var(--canvas);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.nav-drawer[hidden] {
  display: none;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.nav-drawer .sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-drawer .sidebar-link {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 17px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.nav-drawer .sidebar-link[aria-current="page"] {
  color: var(--accent-ink);
}

.nav-drawer .sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

@media (min-width: 1040px) {
  #nav-drawer {
    display: none;
  }
}

/* scenario picker */

.scenario-picker {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--backdrop);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.scenario-picker[hidden] {
  display: none;
}

.picker-panel {
  width: 100%;
  max-height: 82vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  padding: 10px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-2);
  position: relative;
}

.picker-panel::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  margin: 2px auto 12px;
  border-radius: 2px;
  background: var(--border);
}

@media (prefers-reduced-motion: no-preference) {
  .scenario-picker:not([hidden]) .picker-panel {
    animation: sheet-up var(--med) var(--ease);
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (min-width: 720px) {
  .scenario-picker {
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
  }

  .picker-panel {
    width: 640px;
    max-height: 76vh;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
  }

  .picker-panel::before {
    display: none;
  }
}

.picker-header {
  display: flex;
  gap: 8px;
  align-items: center;
}

#scenario-search {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}

#scenario-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

.scenario-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
}

.scenario-list li button {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 12px;
  align-items: baseline;
  transition: background-color var(--fast) var(--ease);
}

.scenario-list li button:hover {
  background: var(--accent-tint);
}

.scenario-list li button .id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  width: 32px;
}

/* document viewer */

.doc-viewer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 44;
}

.doc-viewer-backdrop[hidden] {
  display: none;
}

.doc-viewer {
  position: fixed;
  inset: 8vh 0 0 0;
  z-index: 45;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-2);
  padding-top: 2px;
}

.doc-viewer[hidden] {
  display: none;
}

.doc-viewer::before {
  content: '';
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--border);
}

@media (prefers-reduced-motion: no-preference) {
  .doc-viewer:not([hidden]) {
    animation: sheet-up var(--med) var(--ease);
  }
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.doc-viewer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.doc-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.doc-tab {
  padding: 0 12px;
  min-height: 36px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.doc-tab:hover {
  color: var(--ink);
}

.doc-tab[aria-selected="true"] {
  color: var(--ink);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.doc-viewer-close {
  flex-shrink: 0;
}

.doc-viewer-meta {
  flex-shrink: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.doc-viewer-meta a {
  flex-shrink: 0;
  font-weight: 500;
}

.doc-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 64px;
}

.doc-viewer-body > * {
  max-width: 640px;
}

.doc-viewer-body h2 {
  font-size: 20px;
  line-height: 26px;
  font-weight: 600;
  margin: 0 0 8px;
}

.doc-viewer-body h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 16px;
}

.doc-viewer-body h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 28px 0 12px;
}

.doc-viewer-body p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 23px;
}

.doc-viewer-body .doc-notice {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}

.doc-viewer-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.doc-viewer-body [data-section] {
  scroll-margin-top: 16px;
}

.doc-viewer-body .clause-highlight {
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
  padding: 8px 12px 8px 14px;
  margin-left: -14px;
}

@media (prefers-reduced-motion: no-preference) {
  .doc-viewer-body .clause-flash {
    animation: answer-flash 900ms var(--ease);
  }
}

@media (min-width: 1040px) {
  .doc-viewer {
    inset: 0 0 0 auto;
    width: min(48vw, 680px);
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
  }

  .doc-viewer::before {
    display: none;
  }

  @media (prefers-reduced-motion: no-preference) {
    .doc-viewer:not([hidden]) {
      animation: slide-in var(--med) var(--ease);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

/* --------------------------------------------------------- lifecycle stage */

.queue-stage {
  margin-top: 2px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

.queue-stage-flag {
  margin-left: 6px;
  color: var(--blocked-ink);
  font-weight: 500;
}

.stage-tracker {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--s1);
  margin: var(--s3) 0 0;
  padding: 0;
  list-style: none;
}

.stage-step {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.stage-step.is-done {
  background: var(--border-strong);
}

.stage-step.is-current {
  background: var(--accent-ink);
}

.stage-tracker-meta {
  margin: var(--s2) 0 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- signatures */

.signatures-list {
  margin: var(--s3) 0 0;
  padding: 0;
  list-style: none;
}

.signature-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-top: 1px solid var(--border);
}

.signature-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.signature-name {
  flex: 1 1 auto;
  font-size: 14px;
  color: var(--ink);
}

.signature-actions {
  display: flex;
  gap: var(--s2);
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .signature-row {
    flex-wrap: wrap;
  }
  .signature-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

/* ---------------------------------------------------------- register */

.register-table {
  margin-top: var(--s3);
  font-variant-numeric: tabular-nums;
  /* This table sits in the narrow actions-column card (360-400px), not the
     full-width queue it otherwise shares a class with. table-layout:auto's
     min-content sizing (unbreakable strings like "US$50,000" next to a
     "Party" column with a full name) grew the table past the card's right
     edge; fixed layout makes it honour the card's own width instead. Column
     widths are set explicitly, tighter than the queue table's own 16px cell
     padding allows, so a currency figure never has to break mid-number. */
  table-layout: fixed;
  width: 100%;
}

.register-table th,
.register-table td {
  padding: 10px 6px;
  font-size: 14px;
}

.register-table th:first-child,
.register-table td:first-child {
  width: 26%;
  padding-left: 0;
}

.register-table th:nth-child(2),
.register-table td:nth-child(2) {
  width: 24%;
  white-space: nowrap;
}

.register-table th:nth-child(3),
.register-table td:nth-child(3),
.register-table th:last-child,
.register-table td:last-child {
  width: 25%;
  white-space: nowrap;
}

.register-export {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s4);
}

/* ---------------------------------------------------------------- chase */

/* Reuses .queue-table and .card from the queue and Deadlines views, so a
   chase item looks like the same object everywhere it is shown. */

/* --------------------------------------------------------------- counsel */

.counsel-body {
  margin-top: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.counsel-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}

.counsel-item-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--ink);
}

.counsel-decisions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s4);
}

.counsel-log {
  margin: var(--s3) 0 0;
  padding: var(--s3) 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
