@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   AJWW Trucker Issue / Dispute Tracker -- Dispatch design system
   Navy carries the structure, amber is reserved for money at risk.
   Reference codes and figures are mono so columns align and codes scan.
   ========================================================================== */

:root {
  /* Ink -- structure, rail, headings */
  --ink-900: #0B1220;
  --ink-800: #131C2E;
  --ink-700: #1E293B;
  --ink-600: #334155;
  --ink-500: #475569;
  --ink-400: #64748B;
  --ink-300: #94A3B8;
  --ink-200: #CBD5E1;

  /* Ground */
  --canvas: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --line: #E3E8EF;
  --line-soft: #EEF1F6;

  /* Money at risk -- the one loud colour, used only for exposure */
  --amber: #B45309;
  --amber-strong: #92400E;
  --amber-tint: #FDF4E7;

  /* Outcomes */
  --teal: #0F766E;
  --teal-tint: #ECFDF5;
  --red: #B91C1C;
  --red-tint: #FEF2F2;
  --slate-tint: #F1F5F9;

  /* Categorical accents. Each dispute status owns one, so a status is
     recognisable by colour before the label is read. */
  --iris: #4338CA;   --iris-tint: #EEF2FF;
  --violet: #6D28D9; --violet-tint: #F5F3FF;
  --cyan: #0E7490;   --cyan-tint: #ECFEFF;
  --rose: #BE123C;   --rose-tint: #FFF1F2;
  --lime: #4D7C0F;   --lime-tint: #F7FEE7;
  --slate: #475569;

  /* ---- Vivid layer -------------------------------------------------------
     Colour used to sit only in the status chip, which left every surface
     around it grey. Each accent now has a light end and a dark end so a tile
     can be filled rather than merely outlined. */
  --iris-lo: #6366F1;   --iris-hi: #3730A3;
  --violet-lo: #8B5CF6; --violet-hi: #5B21B6;
  --cyan-lo: #06B6D4;   --cyan-hi: #155E75;
  --rose-lo: #F43F5E;   --rose-hi: #9F1239;
  --lime-lo: #84CC16;   --lime-hi: #3F6212;
  --teal-lo: #14B8A6;   --teal-hi: #115E59;
  --amber-lo: #F59E0B;  --amber-hi: #92400E;
  --red-lo: #EF4444;    --red-hi: #991B1B;
  --blue-lo: #3B82F6;   --blue-hi: #1E3A8A;

  /* Gradients. Filled tiles, primary buttons and modal headers use these. */
  --g-brand:  linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --g-ink:    linear-gradient(135deg, #1E293B 0%, #0B1220 100%);
  --g-iris:   linear-gradient(135deg, var(--iris-lo) 0%, var(--iris-hi) 100%);
  --g-violet: linear-gradient(135deg, var(--violet-lo) 0%, var(--violet-hi) 100%);
  --g-cyan:   linear-gradient(135deg, var(--cyan-lo) 0%, var(--cyan-hi) 100%);
  --g-rose:   linear-gradient(135deg, var(--rose-lo) 0%, var(--rose-hi) 100%);
  --g-lime:   linear-gradient(135deg, var(--lime-lo) 0%, var(--lime-hi) 100%);
  --g-teal:   linear-gradient(135deg, var(--teal-lo) 0%, var(--teal-hi) 100%);
  --g-amber:  linear-gradient(135deg, var(--amber-lo) 0%, var(--amber-hi) 100%);
  --g-red:    linear-gradient(135deg, var(--red-lo) 0%, var(--red-hi) 100%);
  --g-blue:   linear-gradient(135deg, var(--blue-lo) 0%, var(--blue-hi) 100%);

  /* Coloured shadows. A tile lit by its own hue reads as raised rather than
     drawn, which is what "flat" was really describing. */
  --lift: 0 6px 16px -6px var(--tone-shadow, rgba(11, 18, 32, .28));

  /* Type */
  --sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 10.5px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14.5px;
  --fs-lg: 17px;
  --fs-xl: 21px;
  --fs-2xl: 27px;

  /* 4px grid */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 16px; --s6: 20px; --s7: 24px; --s8: 28px;

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;

  --shadow-1: 0 1px 2px rgba(11, 18, 32, .06), 0 1px 1px rgba(11, 18, 32, .04);
  --shadow-2: 0 4px 12px rgba(11, 18, 32, .08), 0 1px 3px rgba(11, 18, 32, .06);
  --shadow-3: 0 18px 44px rgba(11, 18, 32, .20), 0 4px 12px rgba(11, 18, 32, .10);

  --rail-w: 216px;
  --rail-w-collapsed: 60px;
  --topbar-h: 52px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink-700);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
img { max-width: 100%; display: block; }

a { color: var(--ink-900); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: #FDE9CE; color: var(--ink-900); }

/* Scrollbars: thin, so dense tables keep their width */
* { scrollbar-width: thin; scrollbar-color: var(--ink-200) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-300); background-clip: content-box; }

/* ==========================================================================
   Shell -- only home.php wears this. Embedded panes use .pane.
   ========================================================================== */
body.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
body.app.rail-collapsed { grid-template-columns: var(--rail-w-collapsed) 1fr; }

.rail {
  background: var(--ink-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 40;
}

.rail-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  flex-shrink: 0;
}
/* The AJ Worldwide mark. Works as an <img> or, with no image, as a text
   fallback so the rail never shows a broken icon. */
.rail-mark {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--amber);
  display: grid; place-items: center;
  font: 600 12px/1 var(--mono);
  color: #fff; flex-shrink: 0;
  letter-spacing: -.02em;
  object-fit: contain;
}
img.rail-mark { background: none; }
.rail-word {
  font-weight: 600; font-size: var(--fs-md); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden;
}
.rail-word small {
  display: block; font: 400 var(--fs-xs)/1.4 var(--mono);
  color: var(--ink-300); letter-spacing: .08em; text-transform: uppercase;
}

.rail-nav { padding: var(--s3) var(--s2); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.rail-label {
  font: 500 var(--fs-xs)/1 var(--mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-400);
  padding: var(--s4) var(--s3) var(--s2);
  white-space: nowrap; overflow: hidden;
}

.rail-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r);
  color: var(--ink-200);
  font-size: var(--fs-base); font-weight: 500;
  background: none; border: 0; width: 100%; text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background .14s var(--ease), color .14s var(--ease);
  white-space: nowrap;
}
.rail-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.rail-item .ico { width: 18px; flex-shrink: 0; display: grid; place-items: center; }
.rail-item .ico svg { width: 17px; height: 17px; stroke-width: 1.7; }
.rail-item .txt { overflow: hidden; text-overflow: ellipsis; }

.rail-item.is-active { background: rgba(255, 255, 255, .10); color: #fff; position: relative; }
.rail-item.is-active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 2px 2px 0; background: var(--amber);
}

.rail-foot {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: var(--s3);
  display: flex; align-items: center; gap: var(--s3);
  flex-shrink: 0;
}
.rail-user { min-width: 0; flex: 1; }
.rail-user b { display: block; font-size: var(--fs-sm); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user span { font: 400 var(--fs-xs)/1.4 var(--mono); color: var(--ink-400); text-transform: uppercase; letter-spacing: .07em; }
/* Read-only accounts say so, otherwise a missing Edit button reads as a bug. */
.rail-user span.is-viewer { color: var(--amber, #F59E0B); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink-700); color: #fff;
  display: grid; place-items: center;
  font: 600 var(--fs-sm)/1 var(--sans);
  flex-shrink: 0; text-transform: uppercase;
}

body.app.rail-collapsed .rail-word,
body.app.rail-collapsed .rail-label,
body.app.rail-collapsed .rail-item .txt,
body.app.rail-collapsed .rail-user { display: none; }
body.app.rail-collapsed .rail-item { justify-content: center; padding-inline: 0; }
body.app.rail-collapsed .rail-head { justify-content: center; padding: 0; }
body.app.rail-collapsed .rail-foot { justify-content: center; }

/* ---------- shell main ---------- */
.shell { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s5);
  position: sticky; top: 0; z-index: 30;
  flex-shrink: 0;
}
.topbar h1 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.01em; color: var(--ink-900); }
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r);
  border: 1px solid transparent; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-500);
  transition: background .14s var(--ease), color .14s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--slate-tint); color: var(--ink-900); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.8; }
.rail .icon-btn { color: var(--ink-300); }
.rail .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.frame-wrap { flex: 1; min-height: 0; position: relative; }
.frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; position: absolute; inset: 0; }
.frame-pane { display: none; position: absolute; inset: 0; }
.frame-pane.is-active { display: block; }

/* ==========================================================================
   Pane -- pages rendered inside an iframe
   ========================================================================== */
body.pane { background: var(--canvas); padding: 0; }
.pane-inner { padding: var(--s4) var(--s5) var(--s6); max-width: 1560px; margin: 0 auto; }
.pane-inner.narrow { max-width: 1080px; }

/* ---------- page head ---------- */
.page-head {
  display: flex; align-items: flex-end; gap: var(--s4);
  margin-bottom: var(--s4); flex-wrap: wrap;
}
.page-head .grow { flex: 1; min-width: 220px; }
.eyebrow {
  font: 500 var(--fs-xs)/1 var(--mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-400); margin-bottom: var(--s2);
}
.page-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.02em; color: var(--ink-900); line-height: 1.2; }
.page-sub { color: var(--ink-400); font-size: var(--fs-sm); margin-top: var(--s1); }

/* ==========================================================================
   Surfaces
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: var(--s3); }
.card-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line-soft);
}
.card-head .grow { flex: 1; min-width: 0; }
.card-title { font-size: var(--fs-md); font-weight: 600; color: var(--ink-900); letter-spacing: -.01em; }
.card-note { font-size: var(--fs-sm); color: var(--ink-400); }
.card-body { padding: var(--s4); }
.card-body.tight { padding: var(--s4); }
.card-body.flush { padding: 0; }
.card-foot {
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
}
.card-foot .spacer { flex: 1; }

/* Numbered section, used where the form really is a sequence */
.sec { margin-bottom: var(--s5); }
.sec-head {
  display: flex; align-items: center; gap: var(--s3);
  padding-bottom: var(--s3); margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}
.sec-num {
  font: 500 var(--fs-xs)/1 var(--mono);
  color: var(--amber); letter-spacing: .1em;
  background: var(--amber-tint);
  padding: 5px 7px; border-radius: var(--r-sm);
  flex-shrink: 0;
}
.sec-title { font-size: var(--fs-md); font-weight: 600; color: var(--ink-900); letter-spacing: -.01em; }

/* ==========================================================================
   Forms
   ========================================================================== */
.grid { display: grid; gap: var(--s3) var(--s4); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > label, .lbl {
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-600);
  display: flex; align-items: center; gap: var(--s2);
}
.field .hint { font-size: var(--fs-xs); color: var(--ink-400); }
.req { color: var(--amber); font-weight: 600; }

.input, .select, .textarea,
input[type="text"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="file"], select, textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: var(--fs-base);
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--r);
  padding: 5px 9px;
  min-height: 30px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
textarea { min-height: 58px; resize: vertical; line-height: 1.55; }

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--ink-300); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink-700);
  box-shadow: 0 0 0 3px rgba(30, 41, 59, .10);
}

input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  background: var(--slate-tint); color: var(--ink-500); cursor: not-allowed;
}
input[readonly]:focus, textarea[readonly]:focus { box-shadow: none; border-color: var(--ink-200); }

::placeholder { color: var(--ink-300); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 30px;
}

input[type="file"] { padding: 5px 8px; font-size: var(--fs-sm); color: var(--ink-500); }
input[type="file"]::file-selector-button {
  font: 500 var(--fs-sm) var(--sans);
  background: var(--slate-tint); color: var(--ink-700);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 4px 10px; margin-right: var(--s3); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--line-soft); }

/* Codes and figures read as data, not prose */
.mono, input.mono, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.num { text-align: right; }
.money::before { content: '$'; color: var(--ink-300); margin-right: 1px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--sans); font-size: var(--fs-base); font-weight: 500;
  padding: 6px 13px; min-height: 30px;
  border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease), transform .06s var(--ease);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.is-busy { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke-width: 1.9; flex-shrink: 0; }

.btn-primary { background: var(--ink-900); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ink-700); color: #fff; }

.btn-ghost { background: var(--surface); color: var(--ink-700); border-color: var(--ink-200); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-300); color: var(--ink-900); }

.btn-quiet { background: transparent; color: var(--ink-500); }
.btn-quiet:hover:not(:disabled) { background: var(--slate-tint); color: var(--ink-900); }

.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover:not(:disabled) { background: var(--amber-strong); color: #fff; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991B1B; color: #fff; }

.btn-sm { padding: 5px 10px; min-height: 28px; font-size: var(--fs-sm); }
.btn-icon { padding: 0; width: 30px; min-height: 30px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.btn-row .spacer { flex: 1; }

/* ==========================================================================
   Status chips
   ========================================================================== */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 var(--fs-xs)/1 var(--sans);
  letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 8px; border-radius: var(--r-sm);
  background: var(--slate-tint); color: var(--ink-600);
  white-space: nowrap;
}
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip-new     { background: var(--iris-tint);   color: var(--iris); }
.chip-review  { background: var(--amber-tint);  color: var(--amber-strong); }
.chip-action  { background: var(--rose-tint);   color: var(--rose); }
.chip-info    { background: var(--cyan-tint);   color: var(--cyan); }
.chip-done    { background: var(--lime-tint);   color: var(--lime); }
.chip-closed  { background: var(--teal-tint);   color: var(--teal); }
.chip-reject  { background: var(--red-tint);    color: var(--red); }
.chip-reopen  { background: var(--violet-tint); color: var(--violet); }
.chip-plain::before { display: none; }

/* Status also tints the row edge, so a long table reads by colour while
   scrolling rather than only at the status column. */
tr[data-status] > td:first-child { box-shadow: inset 3px 0 0 var(--row-accent, transparent); }
tr[data-status="new"]    { --row-accent: var(--iris); }
tr[data-status="review"] { --row-accent: var(--amber); }
tr[data-status="action"] { --row-accent: var(--rose); }
tr[data-status="info"]   { --row-accent: var(--cyan); }
tr[data-status="done"]   { --row-accent: var(--lime); }
tr[data-status="closed"] { --row-accent: var(--teal); }
tr[data-status="reject"] { --row-accent: var(--red); }
tr[data-status="reopen"] { --row-accent: var(--violet); }

/* Ageing: how long a dispute has been sitting. */
.age { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); white-space: nowrap; }
.age-ok   { color: var(--teal); }
.age-warn { color: var(--amber); }
.age-bad  { color: var(--red); font-weight: 500; }

/* ==========================================================================
   Exposure bar -- the signature. How much of the invoice is contested.
   ========================================================================== */
.expo { display: flex; flex-direction: column; gap: 4px; min-width: 96px; }
.expo-track {
  height: 4px; border-radius: 2px;
  background: var(--line); overflow: hidden;
}
.expo-fill { height: 100%; background: var(--amber); border-radius: 2px; transition: width .5s var(--ease); }
.expo-fill.is-settled { background: var(--teal); }
.expo-fill.is-lost { background: var(--red); }
.expo-meta {
  font: 400 var(--fs-xs)/1 var(--mono);
  color: var(--ink-400); letter-spacing: .02em;
}

/* ==========================================================================
   Stat tiles
   ========================================================================== */
.stats { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); margin-bottom: var(--s5); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s4);
  display: flex; flex-direction: column; gap: var(--s2);
  box-shadow: var(--shadow-1);
}
.stat-k { font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400); }
.stat-v {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xl); font-weight: 500; color: var(--ink-900);
  letter-spacing: -.03em; line-height: 1.05;
}
.stat-v.is-risk { color: var(--amber); }
.stat-v.is-good { color: var(--teal); }
.stat-v.is-bad  { color: var(--red); }
.stat-foot { font-size: var(--fs-xs); color: var(--ink-400); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  -webkit-overflow-scrolling: touch;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  font: 500 var(--fs-xs)/1 var(--mono);
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-400);
  text-align: left; white-space: nowrap;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}
table.tbl tbody td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-700);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background .12s var(--ease); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .num, table.tbl th.num { text-align: right; }
table.tbl .ref { font-family: var(--mono); font-size: var(--fs-sm); color: var(--ink-900); font-weight: 500; white-space: nowrap; }
table.tbl .row-actions { display: flex; gap: var(--s1); justify-content: flex-end; }

.empty {
  padding: var(--s8) var(--s5); text-align: center; color: var(--ink-400);
}
.empty svg { width: 30px; height: 30px; stroke-width: 1.4; margin: 0 auto var(--s3); display: block; color: var(--ink-300); }
.empty b { display: block; color: var(--ink-700); font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s1); }

/* ---------- toolbar / filters ---------- */
.toolbar {
  display: flex; align-items: center; gap: var(--s3);
  flex-wrap: wrap; padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line-soft);
}
.toolbar .spacer { flex: 1; }
.search { position: relative; min-width: 190px; flex: 0 1 260px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-300); pointer-events: none; }
.search input { padding-left: 30px; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.pager .page-btn {
  min-width: 28px; height: 28px; padding: 0 7px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); cursor: pointer;
  font: 500 var(--fs-sm)/1 var(--mono); color: var(--ink-600);
  display: inline-grid; place-items: center;
}
.pager .page-btn:hover:not(:disabled) { border-color: var(--ink-300); color: var(--ink-900); }
.pager .page-btn.is-active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.pager .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ==========================================================================
   Loader -- overlay with a slow amber sweep, plus an inline spinner
   ========================================================================== */
.loader {
  position: fixed; inset: 0; z-index: 90;
  display: none; place-items: center;
  background: rgba(11, 18, 32, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.loader.is-on { display: grid; }
.loader-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--s6) var(--s7);
  display: flex; flex-direction: column; align-items: center; gap: var(--s4);
  min-width: 190px;
  animation: pop .22s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0turn, var(--amber) 1turn);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.spinner.sm { width: 15px; height: 15px; -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0); mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0); }
.spinner.on-dark { background: conic-gradient(from 0deg, transparent 0turn, #fff 1turn); }

.loader-txt { font-size: var(--fs-sm); color: var(--ink-500); text-align: center; }

/* Thin top bar for background requests */
.topline {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 95;
  background: transparent; overflow: hidden; display: none;
}
.topline.is-on { display: block; }
.topline::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  animation: sweep 1.1s var(--ease) infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ==========================================================================
   Toasts -- replace alert()
   ========================================================================== */
.toasts {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: 100;
  display: flex; flex-direction: column-reverse; gap: var(--s2);
  max-width: min(370px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink-900); color: #fff;
  border-radius: var(--r); box-shadow: var(--shadow-3);
  padding: var(--s3) var(--s4);
  display: flex; align-items: flex-start; gap: var(--s3);
  animation: toast-in .24s var(--ease);
  border-left: 3px solid var(--ink-400);
}
.toast.is-out { animation: toast-out .18s var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(14px); } }

.toast .t-ico { flex-shrink: 0; margin-top: 1px; }
.toast .t-ico svg { width: 16px; height: 16px; stroke-width: 2; }
.toast .t-body { flex: 1; min-width: 0; }
.toast b { display: block; font-size: var(--fs-base); font-weight: 600; }
.toast p { font-size: var(--fs-sm); color: var(--ink-200); margin-top: 2px; word-break: break-word; }
.toast .t-x {
  background: none; border: 0; cursor: pointer; color: var(--ink-300);
  padding: 0; width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0;
}
.toast .t-x:hover { color: #fff; }
.toast .t-x svg { width: 13px; height: 13px; stroke-width: 2.2; }

.toast-ok    { border-left-color: #34D399; } .toast-ok .t-ico    { color: #34D399; }
.toast-err   { border-left-color: #F87171; } .toast-err .t-ico   { color: #F87171; }
.toast-warn  { border-left-color: #FBBF24; } .toast-warn .t-ico  { color: #FBBF24; }
.toast-info  { border-left-color: #60A5FA; } .toast-info .t-ico  { color: #60A5FA; }

/* ==========================================================================
   Modal / confirm
   ========================================================================== */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: none; place-items: center;
  background: rgba(11, 18, 32, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: var(--s5);
}
.modal.is-on { display: grid; }
.modal-box {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  width: min(430px, 100%);
  animation: pop .2s var(--ease);
  overflow: hidden;
}
.modal-box.wide { width: min(1080px, 100%); }
.modal-box.full { width: min(1320px, 100%); height: min(88vh, 900px); display: flex; flex-direction: column; }
.modal-box.full .modal-body { flex: 1; padding: 0; min-height: 0; }
.modal-box.full iframe { width: 100%; height: 100%; border: 0; display: block; }

.modal-head {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: var(--s3);
}
.modal-head h3 { font-size: var(--fs-md); font-weight: 600; color: var(--ink-900); flex: 1; }
.modal-body { padding: var(--s5); }
.modal-body p { color: var(--ink-500); font-size: var(--fs-base); }
.modal-foot {
  padding: var(--s4) var(--s5); background: var(--surface-2);
  border-top: 1px solid var(--line-soft);
  display: flex; gap: var(--s3); justify-content: flex-end;
}

/* ==========================================================================
   Auth -- login only
   ========================================================================== */
body.auth {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1100px 520px at 12% -10%, #1B2942 0%, transparent 60%),
    var(--ink-900);
  padding: var(--s5);
}
.auth-card {
  width: min(380px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.auth-head { padding: var(--s7) var(--s7) var(--s5); text-align: center; }
.auth-head .rail-mark { width: 34px; height: 34px; margin: 0 auto var(--s4); font-size: var(--fs-base); }
.auth-head h1 { font-size: var(--fs-lg); font-weight: 600; color: var(--ink-900); letter-spacing: -.01em; }
.auth-head p { font-size: var(--fs-sm); color: var(--ink-400); margin-top: var(--s1); }
.auth-body { padding: 0 var(--s7) var(--s7); display: flex; flex-direction: column; gap: var(--s4); }

/* ==========================================================================
   Utilities
   ========================================================================== */
.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-400); }
.strong { font-weight: 600; color: var(--ink-900); }
.risk { color: var(--amber); font-weight: 600; }
.good { color: var(--teal); font-weight: 600; }
.bad  { color: var(--red);  font-weight: 600; }
.divider { height: 1px; background: var(--line-soft); margin: var(--s5) 0; border: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

.note {
  border-left: 3px solid var(--ink-200);
  background: var(--surface-2);
  padding: var(--s3) var(--s4);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: var(--fs-sm); color: var(--ink-600);
  white-space: pre-wrap; word-break: break-word;
}
.note + .note { margin-top: var(--s2); }
.note-meta { font: 400 var(--fs-xs)/1.4 var(--mono); color: var(--ink-400); margin-top: var(--s2); }

.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--slate-tint); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 4px 8px;
  font-size: var(--fs-sm); color: var(--ink-700); max-width: 100%;
}
.file-chip svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--ink-400); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Responsive -- tuned for the laptop sizes this tool actually runs on
   ========================================================================== */

/* 1600+ : roomier gutters, the data has space to breathe */
@media (min-width: 1600px) {
  .pane-inner { padding: var(--s6) var(--s8) var(--s8); }
  :root { --fs-base: 13.5px; --fs-sm: 12.5px; }
}

/* 1440-1599 : the default this was designed at, no overrides needed */

/* 1280-1439 : the most common laptop. Tighten gutters, keep density. */
@media (max-width: 1439px) {
  .pane-inner { padding: var(--s5) var(--s5) var(--s7); }
  .grid.c4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 1152-1279 : small laptops (MacBook Air scaled, 1280x800) */
@media (max-width: 1279px) {
  :root { --rail-w: 190px; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .card-body { padding: var(--s4); }
  .toolbar { padding: var(--s3) var(--s4); }
  table.tbl thead th, table.tbl tbody td { padding: var(--s2) var(--s3); }
}

/* under 1152 : rail collapses to icons automatically */
@media (max-width: 1151px) {
  body.app { grid-template-columns: var(--rail-w-collapsed) 1fr; }
  .rail-word, .rail-label, .rail-item .txt, .rail-user { display: none; }
  .rail-item { justify-content: center; padding-inline: 0; }
  .rail-head { justify-content: center; padding: 0; }
  .rail-foot { justify-content: center; }
}

/* tablets and narrow windows : rail becomes a drawer */
@media (max-width: 900px) {
  body.app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: var(--rail-w);
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
    box-shadow: var(--shadow-3);
  }
  .rail-word, .rail-label, .rail-item .txt, .rail-user { display: block; }
  .rail-item { justify-content: flex-start; padding-inline: var(--s3); }
  .rail-head { justify-content: flex-start; padding: 0 var(--s4); }
  .rail-foot { justify-content: flex-start; }
  body.app.rail-open .rail { transform: none; }
  body.app.rail-open::after {
    content: ''; position: fixed; inset: 0; z-index: 35;
    background: rgba(11, 18, 32, .45);
  }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .pane-inner { padding: var(--s4); }
  .toasts { right: var(--s3); left: var(--s3); bottom: var(--s3); max-width: none; }
}

@media (max-width: 600px) {
  .page-head { align-items: flex-start; flex-direction: column; gap: var(--s3); }
  .card-foot, .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .card-foot .btn, .modal-foot .btn { width: 100%; }
  .search { flex: 1 1 100%; }
}

/* Short laptop screens (1366x768 and similar) -- claw back vertical space */
@media (max-height: 820px) and (min-width: 901px) {
  :root { --topbar-h: 46px; --s5: 16px; --s6: 20px; --s7: 24px; --s8: 28px; }
  .page-head { margin-bottom: var(--s4); }
  .stat-v { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spinner { animation: spin 1.2s linear infinite !important; }
}

@media print {
  .rail, .topbar, .toolbar, .btn, .toasts, .loader { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ==========================================================================
   ==========================================================================
   VIVID LAYER
   ==========================================================================
   The first pass hit the density target and missed the colour one: structure
   was navy, everything else was grey, and every surface sat on the same plane.
   This layer keeps the density exactly as it is -- no padding grows here -- and
   spends the budget on hue, depth and motion instead.
   ==========================================================================
   ========================================================================== */

/* ---------- Ground: a tinted field rather than flat grey ---------- */
body.pane, body.app {
  background:
    radial-gradient(900px 420px at 100% -8%, rgba(99, 102, 241, .10) 0%, transparent 62%),
    radial-gradient(760px 380px at -6% 8%, rgba(14, 165, 233, .09) 0%, transparent 58%),
    radial-gradient(680px 500px at 45% 110%, rgba(180, 83, 9, .06) 0%, transparent 60%),
    var(--canvas);
  background-attachment: fixed;
}

/* ---------- Rail ---------- */
.rail {
  background:
    radial-gradient(420px 240px at 0% 0%, rgba(99, 102, 241, .30) 0%, transparent 65%),
    radial-gradient(360px 300px at 100% 100%, rgba(180, 83, 9, .22) 0%, transparent 62%),
    var(--ink-900);
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.rail-item.is-active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .34) 0%, rgba(99, 102, 241, .06) 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10);
}
.rail-item.is-active::before {
  background: var(--g-amber);
  box-shadow: 0 0 10px rgba(245, 158, 11, .8);
  height: 20px; width: 3px;
}
.rail-item.is-active .ico { color: #C7D2FE; }
.rail-item:hover { background: rgba(255, 255, 255, .09); }
.avatar { background: var(--g-brand); box-shadow: 0 2px 8px -2px rgba(79, 70, 229, .8); }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFE 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(11, 18, 32, .03), 0 6px 18px -14px rgba(11, 18, 32, .28);
}
/* A hairline of brand colour under the bar ties the shell to the panes. */
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--iris-lo), var(--violet-lo) 28%, var(--cyan-lo) 55%, var(--amber-lo) 82%, var(--rose-lo));
  opacity: .85;
}

/* ---------- Page head ---------- */
.eyebrow {
  color: var(--iris);
  background: var(--iris-tint);
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(67, 56, 202, .16);
}
.page-title {
  background: linear-gradient(120deg, var(--ink-900) 0%, #334155 60%, var(--iris) 130%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--ink-900);
}

/* ---------- Cards ---------- */
.card {
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(11, 18, 32, .05), 0 10px 26px -20px rgba(11, 18, 32, .34);
  position: relative;
  overflow: hidden;
}
.card-head, .card-strip, .fset-head.card-strip {
  background: linear-gradient(180deg, #FCFDFF 0%, #F5F7FB 100%);
}
.card-foot { background: linear-gradient(180deg, #FAFBFD 0%, #F3F6FA 100%); }

/* A card can declare a tone; it then wears a coloured cap and a tinted head. */
.card[data-tone]::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--tone-g, var(--g-brand));
  z-index: 1;
}
.card[data-tone="iris"]   { --tone-g: var(--g-iris);   --tone-t: var(--iris-tint); }
.card[data-tone="violet"] { --tone-g: var(--g-violet); --tone-t: var(--violet-tint); }
.card[data-tone="cyan"]   { --tone-g: var(--g-cyan);   --tone-t: var(--cyan-tint); }
.card[data-tone="rose"]   { --tone-g: var(--g-rose);   --tone-t: var(--rose-tint); }
.card[data-tone="lime"]   { --tone-g: var(--g-lime);   --tone-t: var(--lime-tint); }
.card[data-tone="teal"]   { --tone-g: var(--g-teal);   --tone-t: var(--teal-tint); }
.card[data-tone="amber"]  { --tone-g: var(--g-amber);  --tone-t: var(--amber-tint); }
.card[data-tone="brand"]  { --tone-g: var(--g-brand);  --tone-t: var(--iris-tint); }

/* A toned card tints its own strip and numbers it in the same hue, so the
   six panels of the view screen are told apart by colour, not by reading. */
.card[data-tone] .card-head,
.card[data-tone] .card-strip,
.card[data-tone] .fset-head.card-strip {
  background: linear-gradient(90deg, var(--tone-t, var(--surface-2)) 0%, #FCFDFF 72%);
}
.card[data-tone] .sec-num { background: var(--tone-g); box-shadow: none; }

/* The numbered strip is declared in four page-level <style> blocks, and
   claimEdit.php's copy left out the flex row -- so its badge sat straight
   against its label and read as "01Charges". Declared here so the component
   cannot drift page by page again. */
.fset-head, .card-strip {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.fset-head .spacer, .card-strip .spacer { flex: 1; }

/* Numbered section markers become filled counters instead of pale tags. */
.sec-num {
  background: var(--g-brand);
  color: #fff;
  border-radius: var(--r-sm);
  box-shadow: 0 2px 6px -2px rgba(79, 70, 229, .75);
  letter-spacing: .06em;
}
.fset-head, .card-strip, .sec-title { color: var(--ink-900); }

/* Each numbered strip takes the next hue round, so a long form reads as
   sections at a glance rather than as one grey column. */
.fset:nth-of-type(1) .sec-num, .card-strip .sec-num { background: var(--g-iris);   box-shadow: 0 2px 6px -2px rgba(99, 102, 241, .8); }
.fset:nth-of-type(2) .sec-num { background: var(--g-cyan);   box-shadow: 0 2px 6px -2px rgba(6, 182, 212, .8); }
.fset:nth-of-type(3) .sec-num { background: var(--g-amber);  box-shadow: 0 2px 6px -2px rgba(245, 158, 11, .8); }
.fset:nth-of-type(4) .sec-num { background: var(--g-teal);   box-shadow: 0 2px 6px -2px rgba(20, 184, 166, .8); }
.fset:nth-of-type(5) .sec-num { background: var(--g-violet); box-shadow: 0 2px 6px -2px rgba(139, 92, 246, .8); }

.fset { position: relative; }
.fset::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--fset-c, transparent);
}
.fset:nth-of-type(1)::before { background: linear-gradient(180deg, var(--iris-lo), transparent); }
.fset:nth-of-type(2)::before { background: linear-gradient(180deg, var(--cyan-lo), transparent); }
.fset:nth-of-type(3)::before { background: linear-gradient(180deg, var(--amber-lo), transparent); }
.fset:nth-of-type(4)::before { background: linear-gradient(180deg, var(--teal-lo), transparent); }
.fset:nth-of-type(5)::before { background: linear-gradient(180deg, var(--violet-lo), transparent); }

/* ---------- Fields ---------- */
.field > label, .lbl { color: var(--ink-600); }
input:focus, select:focus, textarea:focus {
  border-color: var(--iris-lo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #A5B4FC; }
.req { color: var(--rose); }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--g-brand);
  box-shadow: 0 2px 8px -3px rgba(79, 70, 229, .85);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338CA 0%, #6D28D9 100%);
  box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .95);
}
.btn-amber { background: var(--g-amber); box-shadow: 0 2px 8px -3px rgba(180, 83, 9, .8); }
.btn-amber:hover:not(:disabled) { background: linear-gradient(135deg, #D97706 0%, #7C2D12 100%); }
.btn-danger { background: var(--g-red); box-shadow: 0 2px 8px -3px rgba(185, 28, 28, .8); }
.btn-ghost {
  border-color: var(--ink-200);
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
}
.btn-ghost:hover:not(:disabled) {
  border-color: #A5B4FC; color: var(--iris);
  background: linear-gradient(180deg, #FFFFFF 0%, var(--iris-tint) 100%);
}
.btn-quiet:hover:not(:disabled) { background: var(--iris-tint); color: var(--iris); }
.icon-btn:hover { background: var(--iris-tint); color: var(--iris); }

/* ---------- Chips ---------- */
.chip {
  border: 1px solid currentColor;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55);
}
.chip::before { width: 6px; height: 6px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.chip-new     { background: var(--iris-tint);   color: var(--iris);   border-color: rgba(67, 56, 202, .26); }
.chip-review  { background: var(--amber-tint);  color: var(--amber-strong); border-color: rgba(146, 64, 14, .26); }
.chip-action  { background: var(--rose-tint);   color: var(--rose);   border-color: rgba(190, 18, 60, .24); }
.chip-info    { background: var(--cyan-tint);   color: var(--cyan);   border-color: rgba(14, 116, 144, .24); }
.chip-done    { background: var(--lime-tint);   color: var(--lime);   border-color: rgba(77, 124, 15, .26); }
.chip-closed  { background: var(--teal-tint);   color: var(--teal);   border-color: rgba(15, 118, 110, .24); }
.chip-reject  { background: var(--red-tint);    color: var(--red);    border-color: rgba(185, 28, 28, .24); }
.chip-reopen  { background: var(--violet-tint); color: var(--violet); border-color: rgba(109, 40, 217, .24); }

/* ---------- Status row accents ---------- */
tr[data-status] > td:first-child { box-shadow: inset 4px 0 0 var(--row-accent, transparent); }
tr[data-status]:hover { background: var(--row-tint, var(--surface-2)) !important; }
tr[data-status="new"]    { --row-tint: var(--iris-tint); }
tr[data-status="review"] { --row-tint: var(--amber-tint); }
tr[data-status="action"] { --row-tint: var(--rose-tint); }
tr[data-status="info"]   { --row-tint: var(--cyan-tint); }
tr[data-status="done"]   { --row-tint: var(--lime-tint); }
tr[data-status="closed"] { --row-tint: var(--teal-tint); }
tr[data-status="reject"] { --row-tint: var(--red-tint); }
tr[data-status="reopen"] { --row-tint: var(--violet-tint); }

/* ---------- Exposure bar ---------- */
.expo-track { background: #E2E8F0; height: 5px; border-radius: 3px; }
.expo-fill {
  background: var(--g-amber);
  box-shadow: 0 0 6px -1px rgba(245, 158, 11, .9);
}
.expo-fill.is-settled { background: var(--g-teal); box-shadow: 0 0 6px -1px rgba(20, 184, 166, .9); }
.expo-fill.is-lost { background: var(--g-red); box-shadow: 0 0 6px -1px rgba(239, 68, 68, .9); }
.expo-meta { color: var(--ink-500); font-weight: 500; }

/* ==========================================================================
   Hero tiles -- filled, not outlined. These are the "flat" cards.
   Same height as before; the change is fill, depth and a watermark digit.
   ========================================================================== */
.stats { gap: var(--s3); }

.stat {
  position: relative;
  overflow: hidden;
  border: 0;
  /* A share bar and a footnote were added to each tile, so the gap tightens to
     pay for them. The row is no taller than it was before the fill. */
  gap: 4px;
  padding: var(--s3) var(--s4);
  background: var(--tile-g, var(--g-ink));
  color: #fff;
  box-shadow: 0 2px 4px rgba(11, 18, 32, .10), 0 14px 28px -18px var(--tile-sh, rgba(11, 18, 32, .8));
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}
.stat::after {
  /* A soft light source in the corner, so the fill is not one solid block. */
  content: ''; position: absolute; right: -30px; top: -46px;
  width: 118px; height: 118px; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  pointer-events: none;
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(11, 18, 32, .12), 0 20px 34px -18px var(--tile-sh, rgba(11, 18, 32, .9)); }
.stat > * { position: relative; z-index: 1; }
.stat-k { color: rgba(255, 255, 255, .78); letter-spacing: .11em; }
.stat-v { color: #fff; text-shadow: 0 1px 12px rgba(0, 0, 0, .22); }
.stat-v.is-risk, .stat-v.is-good, .stat-v.is-bad { color: #fff; }
.stat-foot { color: rgba(255, 255, 255, .72); }

/* Tones for the hero row. */
.stat.tone-brand  { --tile-g: var(--g-brand);  --tile-sh: rgba(79, 70, 229, .9); }
.stat.tone-iris   { --tile-g: var(--g-iris);   --tile-sh: rgba(99, 102, 241, .9); }
.stat.tone-amber  { --tile-g: var(--g-amber);  --tile-sh: rgba(180, 83, 9, .9); }
.stat.tone-rose   { --tile-g: var(--g-rose);   --tile-sh: rgba(244, 63, 94, .9); }
.stat.tone-teal   { --tile-g: var(--g-teal);   --tile-sh: rgba(20, 184, 166, .9); }
.stat.tone-lime   { --tile-g: var(--g-lime);   --tile-sh: rgba(132, 204, 22, .9); }
.stat.tone-cyan   { --tile-g: var(--g-cyan);   --tile-sh: rgba(6, 182, 212, .9); }
.stat.tone-violet { --tile-g: var(--g-violet); --tile-sh: rgba(139, 92, 246, .9); }

/* Optional icon badge inside a hero tile. */
.stat-ico {
  position: absolute; right: var(--s3); top: var(--s3);
  width: 26px; height: 26px; border-radius: var(--r);
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .18);
  color: #fff; z-index: 1;
}
.stat-ico svg { width: 15px; height: 15px; stroke-width: 2; }

/* A thin progress rule at the base of a tile, when the tile has a share. */
.stat-bar { position: relative; z-index: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .26); overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: #fff; border-radius: 2px; }

/* ==========================================================================
   Count tiles -- the clickable status filters above the disputes table
   ========================================================================== */
.count-tile {
  position: relative; overflow: hidden;
  border: 0 !important;
  color: #fff;
  background: var(--tile-g, var(--g-ink));
  box-shadow: 0 2px 4px rgba(11, 18, 32, .10), 0 12px 24px -18px var(--tile-sh, rgba(11, 18, 32, .9));
}
.count-tile::after {
  content: ''; position: absolute; right: -26px; top: -40px;
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(255, 255, 255, .14); pointer-events: none;
}
.count-tile > * { position: relative; z-index: 1; }
.count-tile:hover { box-shadow: 0 4px 8px rgba(11, 18, 32, .12), 0 18px 30px -16px var(--tile-sh, rgba(11, 18, 32, .95)); }
.count-v { color: #fff !important; text-shadow: 0 1px 10px rgba(0, 0, 0, .2); }
.count-k { color: rgba(255, 255, 255, .82) !important; font-weight: 500; }
.count-tile.is-on {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tile-ring, var(--iris-lo)), 0 12px 24px -14px var(--tile-sh);
}
.count-tile.is-on::before {
  content: ''; position: absolute; inset: auto 0 0 0; height: 3px; background: rgba(255, 255, 255, .9); z-index: 2;
}
.tile-new    { --tile-g: var(--g-iris);  --tile-sh: rgba(99, 102, 241, .95); --tile-ring: var(--iris-lo); }
.tile-action { --tile-g: var(--g-rose);  --tile-sh: rgba(244, 63, 94, .95);  --tile-ring: var(--rose-lo); }
.tile-done   { --tile-g: var(--g-lime);  --tile-sh: rgba(132, 204, 22, .95); --tile-ring: var(--lime-lo); }
.tile-closed { --tile-g: var(--g-teal);  --tile-sh: rgba(20, 184, 166, .95); --tile-ring: var(--teal-lo); }
.tile-amber  { --tile-g: var(--g-amber); --tile-sh: rgba(180, 83, 9, .95);   --tile-ring: var(--amber-lo); }
.tile-cyan   { --tile-g: var(--g-cyan);  --tile-sh: rgba(6, 182, 212, .95);  --tile-ring: var(--cyan-lo); }

/* ==========================================================================
   Toolbar and filters -- compact pill bar
   ========================================================================== */
.toolbar {
  background: linear-gradient(180deg, #FCFDFF 0%, #F6F8FC 100%);
  border-bottom: 1px solid var(--line);
  padding: var(--s2) var(--s3);
  gap: var(--s2);
}
.search input, .toolbar input, .toolbar select {
  border-radius: 999px;
  background: var(--surface);
  border-color: #DDE3EC;
  min-height: 28px;
  padding-top: 3px; padding-bottom: 3px;
}
.search input { padding-left: 28px; }
.search svg { left: 10px; width: 14px; height: 14px; color: var(--iris); opacity: .7; }
.search { min-width: 150px; flex: 0 1 190px; }
.search input:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.toolbar .btn { border-radius: 999px; }

/* The expandable filter drawer */
.filter-panel {
  background: linear-gradient(180deg, var(--iris-tint) 0%, #FBFCFE 100%) !important;
  border-bottom: 1px solid var(--line) !important;
  padding: var(--s3) !important;
  animation: drawer .18s var(--ease);
}
@keyframes drawer { from { opacity: 0; transform: translateY(-4px); } }
.filter-panel .field > label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--iris); font-weight: 600;
}
.filter-panel input, .filter-panel select { border-radius: var(--r); min-height: 28px; }
.chip-count { background: var(--g-rose) !important; color: #fff !important; border: 0 !important; }

/* Segmented control */
.seg {
  background: #EEF1F7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.seg label { border-radius: 999px; padding: 3px 11px; }
.seg input:checked + label {
  background: var(--g-brand);
  color: #fff;
  box-shadow: 0 2px 7px -2px rgba(79, 70, 229, .9);
}
.seg label:hover { color: var(--iris); }
.seg input:checked + label:hover { color: #fff; }

/* ==========================================================================
   Tables
   ========================================================================== */
table.tbl thead th {
  background: linear-gradient(180deg, #F1F4F9 0%, #E8EDF5 100%);
  color: var(--ink-600);
  border-bottom: 1px solid #D8E0EA;
  padding: var(--s2) var(--s3);
}
table.tbl tbody td { padding: var(--s2) var(--s3); }
table.tbl tbody tr:nth-child(even) { background: #FBFCFE; }
table.tbl .ref { color: var(--iris); font-weight: 600; }

/* Frozen leading columns. The old table pinned its first six columns and the
   rebuild lost that, which made a 15 column table unreadable once scrolled. */
table.tbl th.stick, table.tbl td.stick {
  position: sticky;
  left: var(--stick-l, 0);
  z-index: 2;
  background: var(--surface);
}
table.tbl tbody tr:nth-child(even) td.stick { background: #FBFCFE; }
table.tbl thead th.stick { z-index: 6; background: linear-gradient(180deg, #F1F4F9 0%, #E8EDF5 100%); }
table.tbl tbody tr:hover td.stick { background: var(--row-tint, var(--surface-2)); }
/* The seam between frozen and scrolling columns. Drawn entirely with a shadow:
   under border-collapse a real border belongs to the table, not to the cell,
   so it stays behind while the sticky cell moves and leaves a gap. */
table.tbl th.stick-last, table.tbl td.stick-last {
  box-shadow: 1px 0 0 var(--line), 7px 0 11px -8px rgba(11, 18, 32, .45);
}

/* Row action buttons, coloured by what they do. */
table.tbl .row-actions { justify-content: flex-start; gap: 4px; }
.act-btn {
  width: 26px; height: 26px; padding: 0; border-radius: var(--r-sm);
  /* The actions column is sized by its content now, so these must not shrink
     or the whole frozen block narrows with them. */
  flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .1s var(--ease), box-shadow .14s var(--ease), background .14s var(--ease);
}
.act-btn svg { width: 14px; height: 14px; stroke-width: 1.9; }
.act-btn:hover { transform: translateY(-1px); }
.act-edit { background: var(--g-brand); color: #fff; box-shadow: 0 2px 6px -2px rgba(79, 70, 229, .9); }
.act-edit:hover { box-shadow: 0 4px 10px -3px rgba(79, 70, 229, 1); }
.act-view { background: var(--cyan-tint); color: var(--cyan); border-color: rgba(14, 116, 144, .28); }
.act-view:hover { background: var(--g-cyan); color: #fff; border-color: transparent; box-shadow: 0 4px 10px -3px rgba(6, 182, 212, .9); }

/* Ageing */
.age { font-weight: 600; padding: 2px 6px; border-radius: 999px; }
.age-ok   { color: var(--teal);  background: var(--teal-tint); }
.age-warn { color: var(--amber-strong); background: var(--amber-tint); }
.age-bad  { color: var(--red);   background: var(--red-tint); }

/* Pagination */
.pager .page-btn { border-radius: 999px; }
.pager .page-btn:hover:not(:disabled) { border-color: var(--iris-lo); color: var(--iris); background: var(--iris-tint); }
.pager .page-btn.is-active { background: var(--g-brand); border-color: transparent; }

/* Empty state */
.empty svg { color: var(--iris); opacity: .55; }

/* ==========================================================================
   Modals -- coloured header, springy entrance
   ========================================================================== */
.modal { background: rgba(11, 18, 32, .55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal-box {
  box-shadow: 0 24px 60px -12px rgba(11, 18, 32, .48), 0 0 0 1px rgba(255, 255, 255, .06);
  animation: modal-in .26s cubic-bezier(.22, 1.2, .36, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  background: var(--g-brand);
  border-bottom: 0;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.modal-head::after {
  content: ''; position: absolute; right: -30px; top: -60px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255, 255, 255, .13);
}
.modal-head h3 { color: #fff; position: relative; z-index: 1; }
/* Optional badge at the head of a dialog. UI.confirm adds one automatically. */
.modal-ico {
  position: relative; z-index: 1; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .2); color: #fff;
  display: grid; place-items: center;
}
.modal-ico svg { width: 15px; height: 15px; stroke-width: 2; fill: none; stroke: currentColor; }
.modal-head .icon-btn { color: rgba(255, 255, 255, .82); position: relative; z-index: 1; }
.modal-head .icon-btn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.modal-foot { background: linear-gradient(180deg, #FAFBFD 0%, #F1F4F9 100%); border-top: 1px solid var(--line); }
.modal-head.tone-amber  { background: var(--g-amber); }
.modal-head.tone-cyan   { background: var(--g-cyan); }
.modal-head.tone-rose   { background: var(--g-rose); }
.modal-head.tone-teal   { background: var(--g-teal); }

/* The confirm dialog raised by UI.confirm inherits all of the above; the
   danger variant recolours the header so a destructive prompt looks it. */
.modal-box.is-danger .modal-head { background: var(--g-red); }

/* ==========================================================================
   Loader and toasts
   ========================================================================== */
.loader { background: rgba(11, 18, 32, .48); }
.loader-card { box-shadow: 0 24px 60px -12px rgba(11, 18, 32, .5); border-top: 3px solid transparent; border-image: var(--g-brand) 1; }
.spinner { background: conic-gradient(from 0deg, transparent 0turn, var(--iris-lo) .55turn, var(--violet-lo) 1turn); }
.topline::after { background: linear-gradient(90deg, transparent, var(--iris-lo), var(--violet-lo), transparent); }
.toast { background: var(--g-ink); border-left-width: 4px; }

/* ==========================================================================
   Auth and the sign-in modal
   ========================================================================== */
body.auth {
  background:
    radial-gradient(760px 520px at 8% -12%, rgba(99, 102, 241, .55) 0%, transparent 58%),
    radial-gradient(700px 480px at 96% 8%, rgba(139, 92, 246, .40) 0%, transparent 55%),
    radial-gradient(820px 560px at 60% 108%, rgba(245, 158, 11, .30) 0%, transparent 58%),
    var(--ink-900);
  position: relative;
  overflow: hidden;
}
/* Two slow drifting blooms, so the sign-in screen is alive rather than a
   static navy rectangle. Both are disabled under reduced motion. */
body.auth::before, body.auth::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(60px);
  pointer-events: none; z-index: 0;
}
body.auth::before {
  width: 420px; height: 420px; left: -120px; top: -110px;
  background: radial-gradient(circle, rgba(99, 102, 241, .55), transparent 70%);
  animation: drift-a 17s ease-in-out infinite alternate;
}
body.auth::after {
  width: 380px; height: 380px; right: -110px; bottom: -120px;
  background: radial-gradient(circle, rgba(245, 158, 11, .40), transparent 70%);
  animation: drift-b 21s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(90px, 70px) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-80px, -60px) scale(1.12); } }

.auth-card {
  position: relative; z-index: 1;
  box-shadow: 0 30px 70px -18px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
  animation: modal-in .3s cubic-bezier(.22, 1.2, .36, 1);
}
.auth-head { background: var(--g-brand); color: #fff; position: relative; overflow: hidden; }
.auth-head::after {
  content: ''; position: absolute; right: -50px; top: -80px;
  width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .13);
}
.auth-head h1, .auth-head p { position: relative; z-index: 1; color: #fff; }
.auth-head p { color: rgba(255, 255, 255, .8); }
.auth-head .rail-mark { position: relative; z-index: 1; background: rgba(255, 255, 255, .18); box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .5); }
.auth-body { padding-top: var(--s5); }

/* ---------- Notes, facts, file chips ---------- */
.note {
  border-left: 3px solid var(--iris-lo);
  background: linear-gradient(90deg, var(--iris-tint) 0%, var(--surface-2) 70%);
  color: var(--ink-700);
}
.fact b { color: var(--ink-900); }
.fact span { color: var(--iris); opacity: .8; font-weight: 600; }
.file-chip {
  background: linear-gradient(180deg, #FFFFFF 0%, var(--cyan-tint) 100%);
  border-color: rgba(14, 116, 144, .22); color: var(--cyan);
}
.file-chip:hover { border-color: var(--cyan-lo); text-decoration: none; }
.file-chip svg { color: var(--cyan-lo); }

/* Totals strip, shared by the form, the view and the edit screen. */
.totals-strip {
  background: linear-gradient(120deg, #F8FAFF 0%, #FFF9F0 55%, #F5FDFB 100%) !important;
  border: 1px solid var(--line) !important;
  position: relative; overflow: hidden;
}
.totals-strip::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--g-brand);
}
.tot b { color: var(--ink-900); }
.tot b.risk { color: var(--amber); }
.tot b.good { color: var(--teal); }
.tot b.bad  { color: var(--red); }

/* A total can declare its own hue. The label and a short rule above the
   figure carry it, which keeps the strip readable at this density. */
.tot[class*="tone-"] { padding-left: var(--s3); border-left: 2px solid var(--tot-c, var(--ink-200)); }
.tot[class*="tone-"] .stat-k { color: var(--tot-c, var(--ink-400)); }
.tot[class*="tone-"] .stat-k svg { width: 12px; height: 12px; stroke-width: 2; vertical-align: -2px; margin-right: 3px; }
.tot.tone-blue   { --tot-c: var(--blue-hi, #1E3A8A); }
.tot.tone-amber  { --tot-c: var(--amber); }
.tot.tone-teal   { --tot-c: var(--teal); }
.tot.tone-violet { --tot-c: var(--violet); }
.tot.tone-rose   { --tot-c: var(--rose); }
.tot.tone-cyan   { --tot-c: var(--cyan); }
.tot.tone-iris   { --tot-c: var(--iris); }
.tot.tone-lime   { --tot-c: var(--lime); }

/* Charge rows read as cards with a hue, not as grey boxes. */
.charge-entry {
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F9FD 100%) !important;
  border-color: #DFE5EE !important;
  border-left: 3px solid var(--iris-lo) !important;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.charge-entry:hover { box-shadow: 0 4px 14px -10px rgba(11, 18, 32, .6); border-left-color: var(--violet-lo) !important; }

@media (prefers-reduced-motion: reduce) {
  body.auth::before, body.auth::after { animation: none !important; }
}

@media print {
  .stat, .count-tile { background: #fff !important; color: #000 !important; box-shadow: none !important; border: 1px solid #ccc !important; }
  .stat-k, .stat-v, .count-v, .count-k { color: #000 !important; }
  .modal-head, .auth-head { background: #fff !important; color: #000 !important; }
  .modal-head h3, .auth-head h1, .auth-head p { color: #000 !important; }
  /* The page title is painted through a gradient, so its fill has to be given
     back or it prints as a blank line. */
  .page-title { background: none !important; -webkit-text-fill-color: #000 !important; color: #000 !important; }
  body.pane, body.app, body.auth { background: #fff !important; }
  body.auth::before, body.auth::after, .topbar::after { display: none !important; }
}

/* ==========================================================================
   Claims & Disputes additions (not in the trucker copy yet)
   ========================================================================== */
/* The segmented control above only skins the labels. Its radios are meant to
   be invisible, with the label doing the clicking. */
.seg { display: inline-flex; align-items: center; gap: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  cursor: pointer; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-500);
  line-height: 1.4; white-space: nowrap; user-select: none;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.seg input:focus-visible + label { outline: 2px solid var(--amber); outline-offset: 1px; }

/* Claim vs dispute. A claim is filled ink so the two read apart in a list. */
.chip-type[data-type="claim"] { background: var(--ink-900); color: #fff; }

/* Compact page furniture: title and blurb share one line. Used by the list,
   form, dashboard and report heads. */
.form-top {
  display: flex; align-items: baseline; gap: var(--s4);
  flex-wrap: wrap; margin-bottom: var(--s3);
}
.form-top .page-title { line-height: 1.1; }
.form-top .page-sub { margin: 0; }
