/* MediCats: cool paper-and-navy palette, one accent (the "Cats" blue), status colours reserved for status. */
:root {
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f8fafc; --ink: #0e2237; --muted: #56697f;
  --line: #d9e2ec; --hover: #f1f6fc; --brand: #1d6fdb; --brand-strong: #1558b3; --on-brand: #ffffff;
  --brand-soft: #e6f0fd; --focus: #1d6fdb; --danger: #b3261e;
  --radius: 8px; --radius-lg: 12px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --c-draft: #52627a; --c-ready: #2c5aa0; --c-submitted: #1b5cb8; --c-pending: #96600a;
  --c-accepted: #0b6b5a; --c-rejected: #b0470a; --c-denied: #b3162d; --c-partially_paid: #6238b0;
  --c-paid: #17703f; --c-patient_responsibility: #3a4cab; --c-resubmitted: #0b6a80; --c-closed: #55606d;
  --c-attention: #b0470a; --c-all: #34475d; --c-awaiting: #52627a;
}
[data-theme="dark"] {
  --bg: #0a1520; --surface: #10202f; --surface-2: #0d1b29; --ink: #e5edf6; --muted: #8fa4ba;
  --line: #223549; --hover: #152a3d; --brand: #5aa2f5; --brand-strong: #86bcf8; --on-brand: #06213f;
  --brand-soft: #14304f; --focus: #86bcf8; --danger: #ff8a80;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="red"] {
  --bg: #170e10; --surface: #241518; --surface-2: #1d1113; --ink: #f6e9ea; --muted: #b59a9c;
  --line: #3d272a; --hover: #2e1c1f; --brand: #ff6b60; --brand-strong: #ffa39e; --on-brand: #2a0806;
  --brand-soft: #3d1f24; --focus: #ffa39e; --danger: #ff8b9b;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="orange"] {
  --bg: #171208; --surface: #251c0e; --surface-2: #1e160a; --ink: #f6efe4; --muted: #b3a685;
  --line: #3d331e; --hover: #2e2517; --brand: #ffb454; --brand-strong: #ffd08f; --on-brand: #2a1a04;
  --brand-soft: #3d2e16; --focus: #ffd08f; --danger: #ff8b9b;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="green"] {
  --bg: #0c1510; --surface: #12241a; --surface-2: #0e1c13; --ink: #e6f5ec; --muted: #8ab39d;
  --line: #203d2c; --hover: #172e22; --brand: #4ade80; --brand-strong: #86efac; --on-brand: #042a12;
  --brand-soft: #183d28; --focus: #86efac; --danger: #ff8b9b;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="blue"] {
  --bg: #0c1424; --surface: #122038; --surface-2: #0e1a2c; --ink: #e6efff; --muted: #8aa6c5;
  --line: #203d5c; --hover: #172e45; --brand: #60a5fa; --brand-strong: #93c5fd; --on-brand: #041a3a;
  --brand-soft: #1f3d6b; --focus: #93c5fd; --danger: #ff8b9b;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="violet"] {
  --bg: #130c1e; --surface: #1d1230; --surface-2: #170e26; --ink: #efe6f6; --muted: #a68ab5;
  --line: #35244a; --hover: #2a1c3d; --brand: #a78bfa; --brand-strong: #c4b5fd; --on-brand: #1a053a;
  --brand-soft: #2e1f4a; --focus: #c4b5fd; --danger: #ff8b9b;
  --c-draft: #a9b8c9; --c-ready: #8fb6ee; --c-submitted: #7db3f5; --c-pending: #f0bd5c;
  --c-accepted: #5fd1b9; --c-rejected: #f5a26b; --c-denied: #ff8b9b; --c-partially_paid: #b79cf2;
  --c-paid: #66d492; --c-patient_responsibility: #9fabf2; --c-resubmitted: #62cfe6; --c-closed: #a3adb9;
  --c-attention: #f5a26b; --c-all: #c3d0de; --c-awaiting: #a9b8c9;
}
[data-theme="rose"] {
  --bg: #fce8ec; --surface: #ffffff; --surface-2: #fdf5f7; --ink: #3d1420; --muted: #8a5a6a;
  --line: #f5cdd5; --hover: #fbe4ea; --brand: #d81b60; --brand-strong: #ad1457; --on-brand: #ffffff;
  --brand-soft: #fce4ec; --focus: #d81b60; --danger: #c2185b;
}
[data-theme="teal"] {
  --bg: #e0f7fa; --surface: #ffffff; --surface-2: #f0fbfd; --ink: #0a3d42; --muted: #4a7c82;
  --line: #b2ebf2; --hover: #d1f5f9; --brand: #00838f; --brand-strong: #006064; --on-brand: #ffffff;
  --brand-soft: #e0f7fa; --focus: #00838f; --danger: #b3261e;
}
[data-theme="lavender"] {
  --bg: #ede7f6; --surface: #ffffff; --surface-2: #f5f1fb; --ink: #2a1a4d; --muted: #6b5a8c;
  --line: #d1c4e9; --hover: #e8def8; --brand: #5e35b1; --brand-strong: #4527a0; --on-brand: #ffffff;
  --brand-soft: #ede7f6; --focus: #5e35b1; --danger: #b3261e;
}
[data-theme="mint"] {
  --bg: #e8f5e9; --surface: #ffffff; --surface-2: #f4faf5; --ink: #0d3d1a; --muted: #4a7c5a;
  --line: #c8e6c9; --hover: #ddf2de; --brand: #2e7d32; --brand-strong: #1b5e20; --on-brand: #ffffff;
  --brand-soft: #e8f5e9; --focus: #2e7d32; --danger: #b3261e;
}
[data-theme="sand"] {
  --bg: #faf3e0; --surface: #ffffff; --surface-2: #fdfaf4; --ink: #3d2a0a; --muted: #8c7a4a;
  --line: #f5e6b8; --hover: #fbf5e8; --brand: #f9a825; --brand-strong: #f57f17; --on-brand: #3d2a0a;
  --brand-soft: #fff8e1; --focus: #f9a825; --danger: #b3261e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo-icon { 
  display: inline-block;
  -webkit-mask-image: url('/static/img/logo.svg');
  mask-image: url('/static/img/logo.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  background-color: var(--brand-strong);
}
.brand .logo-icon { width: 34px; height: 34px; }
.wordmark { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.wordmark b { color: var(--brand); font-weight: 700; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { color: var(--muted); padding: 7px 12px; border-radius: 999px; font-weight: 550; }
.topnav a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
.topnav .nav-spacer { flex-grow: 1; }
.topnav .nav-divider { width: 3px; height: 20px; background: var(--line); align-self: center; flex-shrink: 0; }
.topnav .nav-sep { position: absolute; left: 50%; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; display: block; z-index: 1; pointer-events: none; -webkit-mask-image: url('/static/img/logo.svg'); mask-image: url('/static/img/logo.svg'); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; background-color: var(--brand-strong); }

.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; font-size: .75rem;
  line-height: 20px; text-align: center; background: var(--brand); color: var(--on-brand); font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 999px; color: var(--muted); font-weight: 550; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--hover); }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(10, 21, 32, .16); padding: 6px; z-index: 20; }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0;
  background: none; color: var(--ink); font: inherit; border-radius: 6px; cursor: pointer; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--hover); text-decoration: none; }
.user-menu .menu a.danger { color: var(--danger); }
.menu .who { padding: 8px 10px; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.icon-btn { border: 0; background: none; color: var(--muted); width: 36px; height: 36px; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-menu { position: relative; }
.theme-menu summary { list-style: none; cursor: pointer; }
.theme-menu summary::-webkit-details-marker { display: none; }
.theme-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(10, 21, 32, .16); padding: 6px; z-index: 20; }
.theme-menu .menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0;
  background: none; color: var(--ink); font: inherit; border-radius: 6px; cursor: pointer; }
.theme-menu .menu button:hover { background: var(--hover); }
.theme-menu .menu button.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 550; }
.theme-menu .swatch { width: 14px; height: 14px; border-radius: 999px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.swatch-light { background: #1d6fdb; }
.swatch-dark { background: #5aa2f5; }
.swatch-red { background: #ff6b60; }
.swatch-orange { background: #ffb454; }
.swatch-green { background: #4ade80; }
.swatch-blue { background: #60a5fa; }
.swatch-violet { background: #a78bfa; }
.swatch-rose { background: #d81b60; }
.swatch-teal { background: #00838f; }
.swatch-lavender { background: #5e35b1; }
.swatch-mint { background: #2e7d32; }
.swatch-sand { background: #f9a825; }

/* ---------- layout ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 18px 20px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel > h2 { margin-bottom: 12px; }
.stack > * + * { margin-top: 16px; }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 14px; display: grid; gap: 8px; }
.flash { padding: 0px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.flash.error { border-color: color-mix(in srgb, var(--c-denied) 45%, var(--line)); background: color-mix(in srgb, var(--c-denied) 9%, var(--surface)); }
.flash.info { border: none; background: var(--brand-soft); padding-left: 0; }

/* ---------- toasts (temporary floating alerts) ---------- */
.toast-stack { 
  position: fixed; 
  top: 50%; 
  left: 50%; 
  transform: translate(-50%, -50%); 
  z-index: 1000; 
  display: grid; 
  gap: 12px; 
  width: min(400px, calc(100vw - 64px));
  pointer-events: none;
}
.toast { 
  box-shadow: 0 20px 50px rgb(14 34 55 / 25%), 0 8px 20px rgb(14 34 55 / 15%); 
  cursor: pointer; 
  padding: 24px 32px;
  font-size: 15px;
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: scale(.9) translateY(12px);
  
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Show animation */
.toast.show {
  animation: toast-in .3s cubic-bezier(.68, -0.55, .27, 1.55) forwards;
}

/* Hide animation */
.toast.hide {
  animation: toast-out .3s ease forwards;
}

@keyframes toast-in { 
  from { 
    opacity: 0; 
    transform: scale(.9) translateY(12px); 
  } to { 
    opacity: 1; 
    transform: none; 
  } 
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: scale(.95) translateY(-8px);
  }
}

/* Toast-specific enhancements */
.toast {
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
}
.toast.success::before { background: var(--c-paid); }
.toast.error::before { background: var(--c-denied); }
.toast.info::before { background: var(--brand); }

/* Toast backgrounds with graceful degradation.
   Browsers without color-mix() support fall back to .flash's base surface colour. */
.toast.flash {
  background-color: var(--surface);
}
.toast.success {
  background-color: color-mix(in srgb, var(--c-paid) 10%, var(--surface));
}
.toast.error {
  background-color: color-mix(in srgb, var(--c-denied) 9%, var(--surface));
}
.toast.info {
  background-color: var(--brand-soft);
}

/* Backdrop blur with fallback - only applies if supported */
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .toast {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* ---------- five-stage pipeline (the banner) ---------- */
.pipeline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 10px; position: relative; overflow: hidden; }
.pipeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 24px; flex-wrap: wrap; margin-bottom: 8px; padding-right: 150px; }
.pipeline-head:last-child { margin-bottom: 0; }
.tagline-visits { font-size: 3vh; font-weight: 900; margin: 0; color: var(--ink); letter-spacing: -0.02em; line-height: 1; opacity: 0.5; }
.tagline-claims { font-size: 3vh; font-weight: 900; margin: 0; color: var(--ink); letter-spacing: -0.02em; line-height: 1; opacity: 0.5; }
.tagline-payments { font-size: 3vh; font-weight: 900; margin: 0; color: var(--ink); letter-spacing: -0.02em; line-height: 1; opacity: 0.5; }


.tagline { font-size: .95rem; color: var(--muted); margin: 0; }
.tagline b, .tagline-strong { color: var(--brand); font-weight: 750; }
.brandline { margin: 0; font-weight: 600; color: var(--ink); }
.brandline-img { position: absolute; top: 0; right: 0; height: 100%; width: auto; border: none; outline: none; }

.stages { list-style: none; display: flex; margin: 0 0 14px; padding: 0; }
.stages li { flex: 1; margin-left: -10px; min-width: 0; }
.stages li:first-child { margin-left: 0; }
.stage {
  --notch: 16px; width: 100%; border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  background: var(--brand-soft); padding: 12px 8px 12px calc(var(--notch) + 10px); min-height: 72px;
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%, var(--notch) 50%);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.stages li:first-child .stage { clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% 50%, calc(100% - var(--notch)) 100%, 0 100%); padding-left: 16px; }
.stages li:last-child .stage { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, var(--notch) 50%); }
.stage:hover { background: color-mix(in srgb, var(--brand) 20%, var(--surface)); }
.stage:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--focus); }
.stage-name { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stage-count { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stage[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.stage[aria-pressed="true"] .stage-name { color: inherit; opacity: .9; }

/* ---------- pills ---------- */
.pill {
  --c: var(--c-draft); display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; border: 1px solid transparent;
  font: 600 .82rem/1.4 var(--font); color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface)); white-space: nowrap;
}
.pill .n { font-variant-numeric: tabular-nums; opacity: .9; }
button.pill { cursor: pointer; }
button.pill:hover { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
button.pill[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 24%, var(--surface)); box-shadow: 0 0 0 1px var(--c); }
.s-draft { --c: var(--c-draft); } .s-ready { --c: var(--c-ready); } .s-submitted { --c: var(--c-submitted); }
.s-pending { --c: var(--c-pending); } .s-accepted { --c: var(--c-accepted); } .s-rejected { --c: var(--c-rejected); }
.s-denied { --c: var(--c-denied); } .s-partially_paid { --c: var(--c-partially_paid); } .s-paid { --c: var(--c-paid); }
.s-patient_responsibility { --c: var(--c-patient_responsibility); } .s-resubmitted { --c: var(--c-resubmitted); }
.s-closed { --c: var(--c-closed); } .s-attention { --c: var(--c-attention); } .s-all { --c: var(--c-all); } .s-awaiting { --c: var(--c-awaiting); }
.s-processed { --c: var(--c-paid); } .s-needs_review { --c: var(--c-attention); } .s-failed { --c: var(--c-denied); }
.s-queued, .s-duplicate { --c: var(--c-draft); } .s-processing { --c: var(--c-pending); }
.s-auto { --c: var(--c-paid); } .s-manual { --c: var(--c-submitted); } .s-unmatched { --c: var(--c-attention); } .s-unable { --c: var(--c-closed); }
.flag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 650;
  color: var(--c-attention); background: color-mix(in srgb, var(--c-attention) 14%, var(--surface)); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: space-between; }

/* ---------- toolbar / forms ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 10px; }
.field { display: grid; gap: 4px; }
.field label { font-size: .82rem; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="email"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.grow { flex: 1; min-width: 200px; }
.grow input { width: 100%; }
.btn {
  font: 600 .95rem var(--font); border-radius: 6px; padding: 8px 16px; min-height: 38px; cursor: pointer; border: 1px solid var(--brand);
  background: var(--brand); color: var(--on-brand); display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--brand-strong); border-color: var(--brand-strong); text-decoration: none; }
.btn.quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.quiet:hover { background: var(--hover); }
.btn.small { padding: 4px 12px; min-height: 30px; font-size: .85rem; }
.btn.danger-quiet { background: var(--surface); color: var(--danger); border-color: var(--line); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-form.center { align-items: center; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }

/* ---------- table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow-x: auto; }
.audit-table-scroll { max-height: calc(100vh - 320px); overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 7px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { font-size: .82rem; color: var(--muted); font-weight: 650; background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr[data-href] { cursor: pointer; }
table.data tbody tr:hover { background: var(--hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
td.wrap .details-scroll { max-height: 135px; overflow-y: auto; padding-right: 6px; white-space: normal; word-break: break-word; }
.sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; }
.sort:focus-visible { outline: 2px solid var(--focus); border-radius: 4px; }
th[aria-sort] .sort::after { content: ""; border: 4px solid transparent; }
th[aria-sort="descending"] .sort::after { border-top-color: currentColor; margin-top: 4px; }
th[aria-sort="ascending"] .sort::after { border-bottom-color: currentColor; margin-bottom: 4px; }
th[aria-sort] { color: var(--ink); }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; flex-wrap: wrap; }
.pager { display: flex; gap: 6px; }
.table-wrap > .pager { align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.table-title { padding: 14px 16px 0; }

/* ---------- claim detail ---------- */
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .875rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 0; }
.chain .sep { color: var(--muted); }
.track { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 14px 0 0; padding: 0; }
.track li { padding-top: 10px; border-top: 4px solid var(--line); font-size: .85rem; color: var(--muted); font-weight: 600; }
.track li.done { border-top-color: color-mix(in srgb, var(--brand) 55%, var(--line)); color: var(--ink); }
.track li.current { border-top-color: var(--brand); color: var(--brand-strong); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -27px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--c, var(--c-draft)); border: 2px solid var(--surface); }
.timeline .when { color: var(--muted); font-size: .85rem; }
.timeline .why { margin: 4px 0 0; white-space: pre-wrap; }
.timeline .src { font-size: .85rem; color: var(--muted); margin-top: 2px; }
details.disclose > summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
details.disclose[open] > summary { margin-bottom: 10px; }
.callout { padding: 12px 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--c-attention) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c-attention) 40%, var(--line)); }
.callout p:last-child { margin-bottom: 0; }
.candidate { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.candidate + .candidate { margin-top: 8px; }
.score { font-size: 1.3rem; font-weight: 700; min-width: 48px; }
.reasons { margin: 2px 0 0; padding-left: 18px; color: var(--muted); font-size: .875rem; }
.conflict { color: var(--danger); }
.hist-row + .hist-row { margin-top: 8px; }

/* ---------- uploads ---------- */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius-lg); padding: 28px 20px; text-align: center; background: var(--surface-2); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone label.pick { color: var(--brand); font-weight: 650; cursor: pointer; }
.dropzone:focus-within { outline: 2px solid var(--focus); }
.llm-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c-draft); }
.dot.ok { background: var(--c-paid); } .dot.bad { background: var(--c-denied); }
.doc-view { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
img.doc-view { object-fit: contain; height: auto; max-height: 700px; }
pre.text { margin: 0; max-height: 420px; overflow: auto; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); font: .82rem/1.5 var(--mono); white-space: pre-wrap; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); }
.login-brand { padding: 48px clamp(24px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px; background: var(--brand); color: var(--on-brand); text-align: center; position: relative; }
.login-brand .brand { color: inherit; }
.login-brand .logo-icon { 
  width: 180px; 
  height: 180px; 
  margin-bottom: 24px;
}
.login-brand .wordmark { font-size: clamp(3rem, 6vw, 5rem); letter-spacing: -0.03em; }
.login-brand .wordmark b { color: inherit; opacity: .8; }
.login-brand h1 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); font-weight: 700; max-width: 18ch; }
.login-brand .tagline { color: inherit; opacity: .9; font-size: clamp(1rem, 2vw, 1.35rem); }
.login-brand .tagline b { color: inherit; opacity: 1; font-weight: 800; }
.login-brand .brand-text { display: flex; flex-direction: column; gap: 8px; }
.login-brand .brandline { color: inherit; font-size: clamp(.9rem, 1.6vw, 1.2rem); font-weight: 600; }
.login-stages { list-style: none; padding: 0; margin: 0; display: flex; gap: 0; }
.login-stages li { flex: 1; margin-left: -8px; padding: 10px 6px 10px 22px; min-width: 0; background: rgba(255, 255, 255, .16); font-size: .8rem; font-weight: 600;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%); }
.login-stages li:first-child { margin-left: 0; padding-left: 12px; clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); }
.login-stages li:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%); }
.login-form-side { display: grid; place-items: center; padding: 32px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 1.4rem; margin-bottom: 4px; }
.login-card form { margin-top: 18px; display: grid; gap: 14px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; }
.login-brand .copyright { position: absolute; bottom: 32px; left: 0; right: 0; margin-top: 0; font-size: .85rem; opacity: .7; }
.session-info { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; }
.session-info p { margin: 0 0 .5rem; font-size: .95rem; }
.session-info p:last-child { margin-bottom: 0; }
.error-text { color: var(--danger); margin: 0; }

.error-page { text-align: center; padding: 80px 20px; }
.error-page .code { font-size: 4rem; font-weight: 750; color: var(--brand); line-height: 1; }

/* ---------- modal ---------- */
[data-theme="dark"], [data-theme="red"], [data-theme="orange"], [data-theme="green"], [data-theme="blue"], [data-theme="violet"] { --modal-overlay-bg: rgba(0, 0, 0, .6); }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--modal-overlay-bg, rgba(14, 34, 55, .45)); }
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: 0 18px 50px rgba(14, 34, 55, .28); }
.modal h2 { margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 960px) {
  .detail-grid { grid-template-columns: 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px 14px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; flex: none; }
  .stages { flex-direction: column; gap: 6px; }
  .stages li, .stages li:first-child { margin-left: 0; }
  .stage, .stages li:first-child .stage, .stages li:last-child .stage { clip-path: none; border-radius: var(--radius); padding: 10px 14px; min-height: 0; flex-direction: row; justify-content: space-between; align-items: center; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px; }
  .login-brand .logo-icon { 
    width: 120px; 
    height: 120px; 
    margin-bottom: 16px;
  }
  .login-brand .wordmark { font-size: clamp(2rem, 8vw, 3.5rem); }
  .login-brand .tagline { font-size: clamp(.9rem, 3.4vw, 1.2rem); }
  .login-brand .brandline { font-size: clamp(.8rem, 3vw, 1rem); }
  .login-stages { flex-direction: column; gap: 4px; }
  .login-stages li, .login-stages li:first-child, .login-stages li:last-child { margin-left: 0; clip-path: none; padding: 8px 12px; border-radius: 6px; }
  .track { grid-template-columns: 1fr; }
  .track li { border-top: 0; border-left: 4px solid var(--line); padding: 2px 0 2px 10px; }
  .track li.done { border-left-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
  .track li.current { border-left-color: var(--brand); }
  .shell { padding: 16px 14px 48px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .pill, .stage, .topnav a { transition: background-color .12s ease, border-color .12s ease; }
}
.narrow { max-width: 460px; }
.pager-note { align-self: center; }
.mt-10 { margin-top: 10px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; }

/* ---------- drag and drop overlay (entire page) ---------- */
body.drag-over::after {
  content: 'Drop files to upload';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  border: 4px dashed var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--brand-strong);
  z-index: 9999;
  pointer-events: none;
  animation: drag-pulse 1.5s ease-in-out infinite;
}

@keyframes drag-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}
