/* ==========================================================================
   KAI Collections Console — "Calm Enterprise" redesign
   Warm light-neutral canvas · white surfaces · deep navy navigation ·
   restrained semantic colours · Inter with system fallbacks · 8px grid.
   Legacy variable names (--navy, --orange, …) are kept as aliases so older
   sections keep working; primary actions are navy/blue, never orange.
   ========================================================================== */

:root {
  /* Spec tokens (verbatim) */
  --canvas: #F6F7F9;
  --surface: #FFFFFF;
  --surface-subtle: #F1F4F7;

  --text-strong: #17212B;
  --text: #344250;
  --text-muted: #6B7785;
  --text-disabled: #98A2AD;

  --border: #E2E7EC;
  --border-strong: #CCD5DD;

  --navy-900: #142B45;
  --navy-800: #1E405F;
  --navy-700: #28577D;
  --blue-600: #2473B8;
  --blue-100: #E8F2FA;

  --success: #237A57;
  --success-bg: #EAF6F0;
  --warning: #A96D16;
  --warning-bg: #FFF5E4;
  --danger: #B5464B;
  --danger-bg: #FCEEEF;

  --info: #356B99;
  --info-bg: #EAF2F8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-subtle: 0 1px 2px rgba(16, 24, 40, .04);

  /* Semantic chip colours (spec) */
  --chip-high-text: #9E353D;
  --chip-high-bg: #FCEEEF;
  --chip-high-border: #F4D1D4;
  --chip-med-text: #8C5A0E;
  --chip-med-bg: #FFF5E4;
  --chip-med-border: #F9E3B6;
  --chip-low-text: #1F6C4D;
  --chip-low-bg: #EAF6F0;
  --chip-low-border: #CBE9D9;

  /* Legacy aliases — mapped onto the new token system */
  --navy: var(--navy-900);
  --navy-2: var(--navy-800);
  --orange: var(--navy-800);
  --orange-dark: var(--navy-900);
  --orange-soft: var(--blue-100);
  --bg: var(--canvas);
  --card: var(--surface);
  --muted: var(--text-muted);
  --red: var(--danger);
  --red-soft: var(--danger-bg);
  --green: var(--success);
  --green-soft: var(--success-bg);
  --yellow: var(--warning);
  --yellow-soft: var(--warning-bg);
  --radius: var(--radius-md);
  --shadow: var(--shadow-subtle);

  /* Shell metrics */
  --nav-w: 232px;
  --nav-w-collapsed: 72px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* Tabular numbers for money, dates, scores and table columns */
.num, td, .k-value, .kpi-value, .sv-kpi-value, .cc-amount, .c-value,
.queue-amounts, .ws-figures, .acct-cell .v, .worklist-kpi .k-value,
.ptp-counter .c-value {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- Focus & motion -------------------------- */

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
  border-radius: 4px;
}

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

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

/* Primary: navy fill, white text. 36px standard / 40px prominent. */
.btn-primary {
  background: var(--navy-800);
  color: #fff;
  border: 1px solid var(--navy-800);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 7px 18px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.12s ease;
}
.btn-primary:hover { background: var(--navy-900); border-color: var(--navy-900); }
.btn-primary:disabled { background: var(--text-disabled); border-color: var(--text-disabled); cursor: not-allowed; }

/* Secondary: white, bordered, dark text */
.btn-secondary,
.btn-ghost {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.btn-secondary:hover,
.btn-ghost:hover { border-color: var(--navy-700); background: var(--surface-subtle); }

/* Tertiary: transparent, navy text */
.btn-tertiary,
.link-btn {
  border: none;
  background: none;
  color: var(--navy-700);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 2px;
}
.btn-tertiary:hover,
.link-btn:hover { color: var(--navy-900); text-decoration: underline; }

/* Danger: destructive confirmation only */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 7px 16px;
  font-weight: 600;
  font-size: 13px;
}
.btn-danger:hover { background: #9e353d; }

/* Icon-only buttons (36px hit target, aria-labelled at the call site) */
.icon-btn {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--navy-800);
  border-radius: var(--radius-sm);
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  transition: background 0.12s ease;
}
.icon-btn:hover { background: var(--surface-subtle); }

/* ------------------------------- Inputs ----------------------------------- */

input, select, textarea { font-family: inherit; color: var(--text); }

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  outline: none;
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"] { min-height: 40px; padding: 8px 12px; }
select { min-height: 40px; padding: 8px 12px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 2px rgba(36, 115, 184, 0.25);
}

/* ============================== LOGIN VIEW ================================ */

.login-view {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 80px;
}

.login-head { text-align: center; margin-top: 4vh; padding: 0 20px; }

.login-head h1 {
  color: var(--text-strong);
  letter-spacing: 1px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
}

.login-head .tagline {
  color: var(--navy-700);
  letter-spacing: 2px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.login-head .sub {
  color: var(--text-muted);
  max-width: 520px;
  margin: 20px auto 0;
  font-size: 14px;
  line-height: 1.6;
}

/* Decorative orbit removed from layout; element kept for compatibility */
.login-orbit { display: none; }

/* Feature cards: quiet row of white cards instead of floating decorations */
.login-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  max-width: 1160px;
  margin: 36px auto 0;
  padding: 0 16px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 16px 18px;
}
.feature-card h3 { color: var(--text-strong); font-size: 13px; font-weight: 650; }
.feature-card p { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
.feature-card .spark { color: var(--blue-600); }

/* login card */
.login-card {
  margin-top: 32px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.login-card input { width: 100%; }

.btn-login {
  min-height: 40px;
  border: 1px solid var(--navy-800);
  border-radius: var(--radius-sm);
  background: var(--navy-800);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.12s ease;
}
.btn-login:hover { background: var(--navy-900); }

.demo-note { color: var(--text-muted); font-size: 12px; text-align: center; }

.brand-footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
  color: var(--text-disabled);
  font-size: 11px;
  letter-spacing: 2px;
}

/* ============================ ROLE SELECTION ============================== */

.role-select-view {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
}
.role-select-view .login-head.centered { margin-top: 12vh; }
.role-cards {
  display: flex;
  gap: 20px;
  margin-top: 48px;
  flex-wrap: wrap;
  justify-content: center;
}
.role-card {
  width: 260px;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-subtle);
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.role-card:hover {
  border-color: var(--navy-700);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}
.role-card.hidden { display: none; }
.role-icon {
  font-size: 22px;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 10px;
  background: var(--blue-100);
  color: var(--navy-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.role-card h3 { color: var(--text-strong); font-size: 16px; font-weight: 650; margin-bottom: 8px; }
.role-card p { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

.app-footer { padding: 12px 0; }

/* ============================ APP SHELL ================================== */

.app-shell { min-height: 100vh; }

/* ---- Fixed deep-navy left navigation ---- */
.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-w);
  background: var(--navy-900);
  color: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.15s ease;
}
.app-shell.nav-collapsed .side-nav { width: var(--nav-w-collapsed); }

.nav-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
}
.nav-brand .brand-name { font-size: 17px; font-weight: 700; letter-spacing: 1px; color: #fff; }
.nav-brand .brand-sub { font-size: 11px; color: rgba(255, 255, 255, 0.55); margin-top: 2px; }
.app-shell.nav-collapsed .nav-brand .brand-sub { display: none; }

.nav-groups { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.45);
  padding: 6px 10px;
}
.app-shell.nav-collapsed .nav-group-label { visibility: hidden; height: 14px; padding: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13.5px;
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.92); }
.nav-item.active {
  background: rgba(36, 115, 184, 0.22);
  border-left-color: var(--blue-600);
  color: #fff;
}
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.app-shell.nav-collapsed .nav-item .nav-label { display: none; }

.nav-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.nav-user .avatar { background: var(--blue-600); color: #fff; }
.app-shell.nav-collapsed .nav-user span:last-child { display: none; }

.nav-collapse-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: none;
  color: rgba(255, 255, 255, 0.68);
  border-radius: var(--radius-sm);
  min-height: 32px;
  font-size: 13px;
}
.nav-collapse-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ---- Shell right side: topbar + page ---- */
.shell-main {
  margin-left: var(--nav-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.15s ease;
}
.app-shell.nav-collapsed .shell-main { margin-left: var(--nav-w-collapsed); }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-title { min-width: 0; }
.topbar-title h2 { color: var(--text-strong); font-size: 15px; font-weight: 650; white-space: nowrap; }
.topbar-title p { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
.topbar-spacer { flex: 1; }

.app-title h2 { color: var(--text-strong); font-size: 15px; font-weight: 650; }
.app-title p { color: var(--text-muted); font-size: 11px; }
.app-title .tag { color: var(--info); font-weight: 600; }

.refresh-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 4px 0;
}
.refresh-chip small { color: var(--text-muted); font-size: 10.5px; }
.refresh-chip b { color: var(--text-strong); font-weight: 600; }
.refresh-chip .cal { color: var(--navy-700); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-strong);
  font-weight: 600;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--navy-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* language toggle */
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
}
.lang-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 7px 12px;
  transition: background 0.12s ease, color 0.12s ease;
}
.lang-toggle button + button { border-left: 1px solid var(--border); }
.lang-toggle button:hover { color: var(--navy-800); }
.lang-toggle button.active { background: var(--navy-800); color: #fff; }

.fx-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
}
.fx-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 7px 12px;
  transition: background 0.12s ease, color 0.12s ease;
}
.fx-toggle button + button { border-left: 1px solid var(--border); }
.fx-toggle button:hover { color: var(--navy-800); }
.fx-toggle button.active { background: var(--navy-800); color: #fff; }

.fx-missing-flag { color: var(--warn, #b45309); font-weight: 700; cursor: help; }

.admin-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text);
  margin-right: 14px;
}

.c-outcome {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.c-outcome-contacted { background: #e8f7ee; border-color: #bbe7cb; color: #1a7f43; }
.c-outcome-not_contacted { background: #fdecec; border-color: #f5c2c2; color: #b3261e; }
.c-outcome-awaiting_reply { background: #fff7e6; border-color: #f2dfae; color: #96690a; }
.c-outcome-other { background: #eef2f7; border-color: #d3dce8; color: #4a5a70; }

.dl-reminder-card {
  border-left: 4px solid var(--info, #2563eb);
  background: #f0f6ff;
}
.dl-reminder { margin: 0; }

.login-lang { position: absolute; top: 22px; right: 26px; z-index: 10; }

.shell-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ============================ DASHBOARD VIEW ============================= */

.dashboard-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.page {
  padding: 28px 32px 64px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 24px; line-height: 32px; font-weight: 700; color: var(--text-strong); }
.page-header .page-desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---- KPI overview: four equal cards ---- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 20px 22px;
  text-align: left;
}
.kpi .k-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-muted); }
.kpi .k-label .history-link { color: var(--navy-700); font-weight: 400; margin-left: 6px; }
.kpi .k-value {
  font-size: 26px;
  line-height: 32px;
  font-weight: 700;
  color: var(--text-strong);
  margin-top: 6px;
}
.kpi .k-value .slash { color: var(--text-disabled); font-weight: 400; }
.kpi .k-sub { font-size: 12.5px; margin-top: 6px; color: var(--text-muted); }
.kpi .k-sub b { font-weight: 600; }
.green { color: var(--success); }
.red { color: var(--danger); }

/* ---- Queue toolbar / filters ---- */
.queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.queue-head h2 { font-size: 16px; line-height: 24px; font-weight: 650; color: var(--text-strong); }
.queue-count { color: var(--text-muted); font-size: 13px; }

.queue-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--surface);
  min-height: 40px;
  min-width: 260px;
}
.search-box .magnifier { color: var(--text-muted); font-size: 15px; }
.search-box input { border: none; outline: none; flex: 1; font-size: 13.5px; background: transparent; min-height: 38px; }
.search-box input:focus-visible { box-shadow: none; }
.search-box.small { min-width: 200px; min-height: 36px; }
.search-box.small input { min-height: 34px; }

.filter-row { display: flex; gap: 8px; }

.filter-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.filter-chip:hover { border-color: var(--navy-700); }
.filter-chip.active { border-color: var(--navy-700); background: var(--blue-100); color: var(--navy-800); font-weight: 600; }

/* Segmented touch filters */
.touch-pills {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.pill {
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.12s ease, color 0.12s ease;
}
.pill:hover { color: var(--text-strong); }
.pill.active { background: var(--blue-100); color: var(--navy-800); font-weight: 600; }

.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
}
.btn-download {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--navy-800);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.btn-download:hover { border-color: var(--navy-700); background: var(--surface-subtle); }

/* ---- Queue layout: rows + priority panel ---- */
.queue-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.customer-list { display: flex; flex-direction: column; }

/* Queue row */
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 20px;
  align-items: center;
  min-height: 76px;
  padding: 14px 16px;
  background: var(--surface);
  border: none;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease;
}
.queue-row:first-child { border-top-left-radius: var(--radius-md); border-top-right-radius: var(--radius-md); }
.queue-row:last-child { border-bottom-left-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); border-bottom-color: var(--border-strong); }
.queue-row:hover { background: #F6F9FC; }
.queue-row.selected { background: var(--blue-100); border-left-color: var(--navy-800); }

.queue-main { min-width: 0; }
.queue-name-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.queue-name {
  font-weight: 650;
  color: var(--text-strong);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.queue-meta .flag {
  background: none;
  color: var(--text-muted);
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  border-radius: 0;
}
.queue-drivers { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.queue-drivers .driver-danger { color: var(--danger); }

.queue-amounts { text-align: right; white-space: nowrap; }
.queue-outstanding { font-weight: 650; color: var(--text-strong); font-size: 14px; }
.queue-outstanding.neg { color: var(--danger); }
.queue-overdue { color: var(--danger); font-size: 12.5px; margin-top: 3px; }
.queue-overdue.zero { color: var(--text-muted); }

.btn-open-case {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--navy-800);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.queue-row:hover .btn-open-case,
.btn-open-case:hover { border-color: var(--navy-700); background: var(--surface-subtle); }

/* Legacy mini-card class kept (no longer used for rows) */
.customer-card { display: none; }

/* ---- Semantic priority / touch chips ---- */
.touch-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.touch-HIGH { color: var(--chip-high-text); background: var(--chip-high-bg); border-color: var(--chip-high-border); }
.touch-MEDIUM { color: var(--chip-med-text); background: var(--chip-med-bg); border-color: var(--chip-med-border); }
.touch-LOW { color: var(--chip-low-text); background: var(--chip-low-bg); border-color: var(--chip-low-border); }
.touch-DNT { color: var(--text-muted); background: var(--surface-subtle); border-color: var(--border-strong); }

/* ---- Today's priorities panel ---- */
.priority-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 20px;
}
.priority-panel h3 { font-size: 16px; line-height: 24px; font-weight: 650; color: var(--text-strong); margin-bottom: 8px; }
.prio-group { padding: 14px 0; border-bottom: 1px solid var(--border); }
.prio-group:last-of-type { border-bottom: none; }
.prio-head { display: flex; align-items: baseline; gap: 10px; }
.prio-count { font-size: 20px; font-weight: 700; color: var(--text-strong); min-width: 24px; }
.prio-count.danger { color: var(--danger); }
.prio-count.warning { color: var(--warning); }
.prio-label { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.prio-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; margin-left: 34px; }
.prio-link { margin-left: auto; font-size: 12.5px; }
.prio-activity { list-style: none; }
.prio-activity li {
  font-size: 12.5px;
  color: var(--text);
  padding: 6px 0 6px 14px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
}
.prio-activity li small { display: block; color: var(--text-muted); }

/* ========================= CUSTOMER WORKSPACE ============================ */

.workspace { display: flex; flex-direction: column; gap: 20px; }

.ws-back {
  border: none;
  background: none;
  color: var(--navy-700);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  align-self: flex-start;
}
.ws-back:hover { text-decoration: underline; }

.ws-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 20px 24px;
}
.ws-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ws-header h2 { color: var(--text-strong); font-size: 20px; font-weight: 700; }
.ws-header .cust-id { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.ws-figures { display: flex; gap: 32px; margin-top: 16px; flex-wrap: wrap; }
.ws-figure .f-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ws-figure .f-value { font-size: 18px; font-weight: 700; color: var(--text-strong); margin-top: 2px; }
.ws-figure .f-value.red { color: var(--danger); }
.ws-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* AI recommendation card */
.ai-card {
  background: var(--info-bg);
  border: 1px solid #D3E2EE;
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.ai-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.ai-card-head .ai-title { font-size: 13px; font-weight: 650; color: var(--text-strong); }
.ai-score { font-size: 12.5px; color: var(--info); font-weight: 600; white-space: nowrap; }
.ai-reco {
  font-size: 14px;
  color: var(--text-strong);
  font-weight: 500;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-card.expanded .ai-reco { display: block; }
.ai-evidence { font-size: 12.5px; color: var(--text); margin-top: 6px; display: none; }
.ai-card.expanded .ai-evidence { display: block; }
.ai-card-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* legacy banner classes retained for safety */
.ai-banner { display: none; }

/* Account summary: four cells + risk-driver strip */
.acct-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 20px 24px;
}
.acct-cells { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 20px; }
.acct-cell .k { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.acct-cell .v { font-size: 18px; font-weight: 700; color: var(--text-strong); margin-top: 3px; }
.acct-cell .v.red { color: var(--danger); }
.risk-strip {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.risk-strip b { color: var(--text-strong); font-weight: 600; }
.risk-strip .risk-bad { color: var(--danger); font-weight: 600; }

/* Workspace body: detail cards + case tabs side by side on wide screens */
.ws-body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.ws-side { display: flex; flex-direction: column; gap: 16px; }

/* Center pane (legacy container class, now the workspace detail column) */
.center-pane { display: flex; flex-direction: column; gap: 16px; }

.cust-header { display: flex; align-items: center; gap: 14px; }
.cust-header h2 { color: var(--text-strong); font-size: 19px; }
.cust-header .cust-id { color: var(--text-muted); font-size: 12px; }

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-subtle);
}
.info-card h4 {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.info-card.accent-orange,
.info-card.accent-yellow,
.info-card.accent-navy { border-left: 3px solid var(--border-strong); }
.info-card .edit-icons { color: var(--text-muted); font-size: 13px; letter-spacing: 4px; }
.info-card h4 .card-actions { display: flex; align-items: center; gap: 4px; }
.info-card h4 .icon-btn { font-size: 14px; min-width: 30px; min-height: 30px; padding: 3px 5px; line-height: 1; }
.info-card.collapsed .info-card-body { display: none; }

.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; }
.kv-row .k { color: var(--text-muted); }
.kv-row .v { font-weight: 600; color: var(--text-strong); text-align: right; }
.kv-row .v.red { color: var(--danger); }
.kv-row .v.green { color: var(--success); }

/* Ring mini removed from layout (decorative) */
.ring-mini { display: none; }

/* ------------------------------- Case tabs -------------------------------- */

.right-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
  padding: 4px 20px 20px;
  min-width: 0;
}

.main-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 12px 2px 10px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-strong); }
.tab.active { color: var(--navy-800); border-bottom-color: var(--navy-800); font-weight: 650; }
.tab-count {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  font-size: 11px;
}
.tab.active .tab-count { background: var(--blue-100); border-color: transparent; color: var(--navy-800); }

.sub-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sub-tab {
  border: none;
  background: none;
  padding: 8px 2px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.sub-tab:hover { color: var(--text-strong); }
.sub-tab.active { color: var(--navy-800); border-bottom-color: var(--navy-800); font-weight: 650; }

/* doc filters */
.doc-filters { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.doc-filters select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 12.5px;
  background: var(--surface);
  outline: none;
}
.doc-filters .search-box { flex: 1; min-width: 200px; }

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

.table-wrap { overflow-x: auto; max-height: 60vh; overflow-y: auto; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.doc-table th.sorted { color: var(--navy-800); }
.doc-table th[data-sort] { cursor: pointer; }
.doc-table td {
  padding: 0 8px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.doc-table tr:hover td { background: #F6F9FC; }
.doc-table .num { text-align: right; }
.doc-table td.num { font-weight: 600; color: var(--text-strong); }
.doc-table td.num.neg { color: var(--danger); }
.doc-table .empty-row td {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 34px 0;
  height: auto;
}
.sort-arrow { color: var(--text-disabled); font-size: 11px; }

/* Status pills: labelled semantic chips */
.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.status-CURRENT { background: var(--success-bg); color: var(--success); border-color: #CBE9D9; }
.status-KEPT { background: var(--success-bg); color: var(--success); border-color: #CBE9D9; }
.status-OVERDUE { background: var(--danger-bg); color: var(--danger); border-color: var(--chip-high-border); }
.status-BROKEN { background: var(--danger-bg); color: var(--danger); border-color: var(--chip-high-border); }
.status-OPEN { background: var(--warning-bg); color: var(--warning); border-color: var(--chip-med-border); }

/* --------------------------- PTP & disputes ------------------------------- */

.ptp-card, .disputes-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
  background: var(--surface);
}
.ptp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.ptp-title { font-weight: 650; color: var(--text-strong); font-size: 14px; }
.ptp-actions { display: flex; gap: 8px; align-items: center; }
.ptp-actions select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 12.5px;
  background: var(--surface);
  outline: none;
}

.ptp-counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0 16px; }
.ptp-counter {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-subtle);
}
.ptp-counter .c-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.ptp-counter .c-value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--text-strong); }
.ptp-counter.KEPT .c-value { color: var(--success); }
.ptp-counter.BROKEN .c-value { color: var(--danger); }
.ptp-counter.OPEN .c-value { color: var(--warning); }

.disputes-head { font-weight: 650; color: var(--text-strong); margin-bottom: 10px; font-size: 14px; }

/* --------------------------- Communications ------------------------------- */

.comm-list { display: flex; flex-direction: column; gap: 12px; }
.comm-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  background: var(--surface);
}
.comm-item .c-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.comm-item .c-channel {
  background: var(--navy-800);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 10.5px;
  font-weight: 600;
}
.c-direction {
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 10.5px;
  border: 1px solid var(--border);
}
.c-direction.inbound { background: var(--success-bg); color: var(--success); border-color: #CBE9D9; }
.c-direction.outbound { background: var(--blue-100); color: var(--navy-700); border-color: transparent; }
.comm-item h5 { color: var(--text-strong); font-size: 13px; font-weight: 650; }
.comm-item p { color: var(--text); font-size: 12.5px; margin-top: 4px; line-height: 1.5; }
.comm-empty { color: var(--text-muted); font-style: italic; text-align: center; padding: 40px 0; }

/* ------------------------------ Action bar -------------------------------- */

.action-bar {
  position: sticky;
  bottom: 12px;
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin-top: 14px;
  z-index: 10;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.action-bar.has-selection { opacity: 1; }
.selected-count { color: var(--text-strong); font-size: 13px; margin-right: 8px; }
.action-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--navy-800);
  font-weight: 500;
}
.action-btn:hover { border-color: var(--navy-700); background: var(--blue-100); }
.action-bar:not(.has-selection) .action-btn { pointer-events: none; opacity: 0.6; }

/* --------------------------------- Toast ---------------------------------- */

.toast {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: var(--navy-900);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.25);
  z-index: 100;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ======================= OUTBOUND COMMUNICATION ============================ */

.outbound-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--surface);
}
.outbound-card h4 { color: var(--text-strong); font-size: 14px; font-weight: 650; margin-bottom: 12px; }

.outbound-status {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 14px;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #CBE9D9;
}
.outbound-status.warning { background: var(--warning-bg); color: var(--warning); border-color: var(--chip-med-border); }

.outbound-field { margin-bottom: 14px; }
.outbound-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.outbound-field input,
.outbound-field select,
.outbound-field textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
}
.outbound-field textarea { resize: vertical; line-height: 1.5; }

.outbound-scenarios { display: flex; gap: 8px; flex-wrap: wrap; }
.scenario-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text);
}
.scenario-btn:hover { border-color: var(--navy-700); }
.scenario-btn.active { background: var(--blue-100); border-color: var(--navy-700); color: var(--navy-800); font-weight: 600; }

.outbound-checks { display: flex; flex-direction: column; gap: 8px; }
.outbound-checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.outbound-checks input { width: auto; }
.outbound-checks .invalid { color: var(--danger); }

.outbound-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.btn-send {
  border: 1px solid var(--navy-800);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--navy-800);
}
.btn-send:hover { background: var(--navy-900); }

.outbound-log { margin-top: 16px; }
.outbound-log h5 { color: var(--text-strong); font-size: 13px; font-weight: 650; margin-bottom: 10px; }

/* =========================== MODALS ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 43, 69, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.2);
  width: 100%;
  max-width: 980px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { color: var(--text-strong); font-size: 16px; font-weight: 650; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.worklist-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.worklist-kpi {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
}
.worklist-kpi .k-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.worklist-kpi .k-value { font-size: 20px; font-weight: 700; color: var(--text-strong); margin-top: 4px; }
.worklist-kpi.failed .k-value { color: var(--danger); }
.worklist-kpi.success .k-value { color: var(--success); }

.worklist-table { font-size: 12.5px; }
.worklist-table td { white-space: normal; }
.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}
.status-badge.eligible { background: var(--success-bg); color: var(--success); border-color: #CBE9D9; }
.status-badge.suppressed { background: var(--warning-bg); color: var(--warning); border-color: var(--chip-med-border); }
.status-badge.excluded { background: var(--surface-subtle); color: var(--text-muted); border-color: var(--border-strong); }

.modal-small { max-width: 420px; }
.collector-checks { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.collector-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.collector-check:hover { background: var(--surface-subtle); }
.collector-check input { width: 18px; height: 18px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 10px; gap: 10px; }
.modal-note { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.form-row input,
.form-row select,
.form-row textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  outline: none;
}
.form-row textarea { resize: vertical; line-height: 1.5; }

/* ============================ SUPERVISOR VIEW ============================== */

.supervisor-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.sv-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin: 20px 32px 0;
  align-self: flex-start;
}
.sv-tab {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.sv-tab:hover { color: var(--text-strong); }
.sv-tab.active { background: var(--surface); color: var(--navy-800); font-weight: 650; box-shadow: var(--shadow-subtle); }

.sv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
}
.sv-filter { display: flex; flex-direction: column; gap: 4px; min-width: 150px; flex: 1; }
.sv-filter label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.sv-filter input,
.sv-filter select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  outline: none;
}

.sv-body { flex: 1; padding: 24px 32px 48px; overflow-y: auto; }
.sv-empty { text-align: center; color: var(--text-muted); padding: 60px 20px; }

.sv-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.sv-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-subtle);
}
.sv-kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.sv-kpi-value { font-size: 24px; font-weight: 700; color: var(--text-strong); }
.sv-kpi-value.red { color: var(--danger); }
.sv-kpi-value.green { color: var(--success); }

.sv-note {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid #D3E2EE;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 22px;
}

.sv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.sv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-subtle);
}
.sv-card-wide { grid-column: span 2; }
.sv-card h4 { font-size: 14px; color: var(--text-strong); margin-bottom: 16px; font-weight: 650; }
.sv-card h4 small { font-size: 11.5px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }

.trend-chart {
  position: relative;
  height: 220px;
  border-left: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  margin: 10px 0 30px;
}
.trend-canvas { position: absolute; inset: 0; display: block; }
.trend-legend {
  display: inline-flex;
  gap: 14px;
  margin-left: 16px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  vertical-align: middle;
}
.trend-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.trend-legend-swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch-collectable { background: var(--success); }
.swatch-overdue { background: var(--danger); }
.trend-col { position: absolute; bottom: 0; width: 60px; transform: translateX(-50%); height: 100%; pointer-events: none; }
.trend-label {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.strategy-mix { display: flex; flex-direction: column; gap: 10px; }
.mix-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.mix-color { width: 14px; height: 14px; border-radius: 4px; }
.mix-name { width: 80px; font-weight: 600; color: var(--text-strong); }
.mix-value { flex: 1; text-align: right; }
.mix-pct { width: 50px; text-align: right; color: var(--text-muted); }
.mix-total { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); text-align: right; font-weight: 700; color: var(--text-strong); }

.aging-chart { display: flex; flex-direction: column; gap: 12px; }
.aging-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.aging-label { width: 90px; color: var(--text-muted); }
.aging-bar { flex: 1; height: 10px; background: var(--surface-subtle); border-radius: 5px; overflow: hidden; }
.aging-bar span { display: block; height: 100%; background: var(--danger); border-radius: 5px; }
.aging-row:first-child .aging-bar span { background: var(--success); }
.aging-value { width: 90px; text-align: right; font-weight: 600; }
.aging-pct { width: 40px; text-align: right; color: var(--text-muted); }

.ptp-chart { display: flex; align-items: flex-end; justify-content: center; gap: 40px; height: 200px; padding-bottom: 30px; }
.ptp-bar-col { display: flex; flex-direction: column; align-items: center; width: 80px; }
.ptp-bar-wrap {
  width: 50px;
  height: 150px;
  background: var(--surface-subtle);
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.ptp-bar { width: 100%; border-radius: 6px 6px 0 0; }
.ptp-bar.commitments { background: var(--success); }
.ptp-bar.paid { background: var(--navy-800); }
.ptp-bar.broken { background: var(--danger); }
.ptp-bar-label { margin-top: 10px; font-size: 11px; color: var(--text-muted); text-align: center; }
.ptp-bar-value { font-size: 13px; font-weight: 700; color: var(--text-strong); margin-top: 4px; }

.progress-bar {
  display: inline-block;
  width: 80px;
  height: 8px;
  background: var(--surface-subtle);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}
.progress-bar span { display: block; height: 100%; background: var(--danger); }

.sv-collectors-table td { vertical-align: middle; }
.activity-cell { font-size: 12px; white-space: nowrap; }

/* ============================== ADMIN PANEL ================================ */

.admin-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.admin-body {
  flex: 1;
  padding: 24px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-subtle);
}
.admin-card h3 { font-size: 15px; color: var(--text-strong); margin-bottom: 16px; font-weight: 650; }
.admin-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.admin-form select { min-width: 240px; }
.admin-tabs { margin-bottom: 2px; }
.admin-pane { display: flex; flex-direction: column; gap: 22px; }
.admin-email-form { align-items: stretch; }
.admin-field { display: flex; flex-direction: column; gap: 5px; min-width: 240px; flex: 1 1 240px; max-width: 340px; }
.admin-field span { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.admin-form input,
.admin-field input { min-width: 240px; }
.admin-field input:disabled,
.admin-field select:disabled { background: var(--surface-subtle); color: var(--text-muted); cursor: not-allowed; }
.admin-hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 12px; }
.admin-status { font-size: 12px; color: var(--navy-800); align-self: center; }
.admin-subhead { font-size: 13px; font-weight: 650; color: var(--text-strong); margin: 16px 0 8px; }

/* Email templates editor */
.templates-list { display: flex; flex-direction: column; gap: 14px; }
.template-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); }
.template-row .t-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.template-row .t-head b { color: var(--text-strong); }
.template-row input, .template-row textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  outline: none;
}
.template-row input { margin-bottom: 8px; }
.template-row textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.template-row .t-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.doc-table input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12.5px;
  width: 100%;
  min-width: 140px;
}

/* Filter popover (Category button) */
.filter-popover {
  position: absolute;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}
.filter-popover-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
}
.filter-popover-item:hover { background: var(--surface-subtle); }
.filter-popover-item.active { background: var(--blue-100); color: var(--navy-800); font-weight: 600; }
.queue-filters { position: relative; }
.filter-row { position: relative; }

/* Item rows in PTP/dispute modals: doc + editable amount */
.item-rows .item-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 0 6px;
}
.item-rows .item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
}
.item-rows .item-row input {
  width: 150px;
  text-align: right;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 13px;
}

/* Scoring rules */
.scoring-rule { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.scoring-rule:last-child { border-bottom: none; }
.scoring-rule .sr-label { flex: 1; font-size: 13px; color: var(--text); }
.scoring-rule .sr-label small { display: block; color: var(--text-muted); font-size: 11.5px; }
.scoring-rule input { width: 90px; text-align: right; }

/* AI usage bar */
.usage-bar { background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 6px; height: 14px; overflow: hidden; margin: 8px 0 4px; max-width: 480px; }
.usage-bar > span { display: block; height: 100%; background: var(--navy-800); transition: width 0.2s ease; }
.usage-bar.over > span { background: var(--danger); }
.usage-meta { font-size: 12px; color: var(--text-muted); }

/* ============================= RESPONSIVE ================================== */

/* 1024–1439: collapsed sidebar, 2x2 KPI, priority panel below the queue */
@media (max-width: 1439px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .queue-layout { grid-template-columns: 1fr; }
  .ws-body { grid-template-columns: 1fr; }
  .sv-grid { grid-template-columns: 1fr; }
  .sv-card-wide { grid-column: span 1; }
}

/* 768–1023: tighter chrome, stacked filters */
@media (max-width: 1023px) {
  .page { padding: 20px 16px 56px; }
  .sv-filters, .sv-body, .admin-body { padding-left: 16px; padding-right: 16px; }
  .sv-tabs { margin-left: 16px; margin-right: 16px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .refresh-chip .refresh-text small { display: none; }
  .queue-row { grid-template-columns: minmax(0, 1fr) auto; }
  .queue-row .btn-open-case { grid-column: 1 / -1; justify-self: start; }
}

/* <768: single column; invoice table keeps only key columns */
@media (max-width: 767px) {
  .kpi-strip { grid-template-columns: 1fr; }
  .queue-filters { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 0; width: 100%; }
  .acct-cells { grid-template-columns: repeat(2, 1fr); }
  .ws-figures { gap: 20px; }
  .doc-table .col-secondary { display: none; }
  .page-header h1 { font-size: 20px; }
  .role-cards { margin-top: 28px; }
  .login-features { grid-template-columns: 1fr; }
}
