/* DocuWare Audit Dashboard — DashboardKit-style shell on plain Bootstrap 5. */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1d2135;
  --text-muted: #6b7188;
  --accent: #5b5fc7;
  --accent-rgb: 91, 95, 199;
  --accent-soft: rgba(91, 95, 199, 0.12);
  --sidebar-bg: #1f2233;
  --sidebar-text: #b9bdd1;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgba(29, 33, 53, 0.05), 0 6px 20px rgba(29, 33, 53, 0.06);
  --success: #2ea87e;
  --danger: #d9534f;
  --grid: rgba(29, 33, 53, 0.08);
}

[data-theme="dark"] {
  --bg: #14161f;
  --surface: #1c1f2b;
  --border: #2b3040;
  --text: #e8eaf2;
  --text-muted: #9298ae;
  --accent: #8b8ff0;
  --accent-rgb: 139, 143, 240;
  --accent-soft: rgba(139, 143, 240, 0.16);
  --sidebar-bg: #171926;
  --sidebar-text: #9298ae;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.28);
  --success: #46c79b;
  --danger: #ef7a76;
  --grid: rgba(232, 234, 242, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */

.dw-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.2s ease;
}

.dw-brand {
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
/* The logo artwork is white-background, so give it a white chip of its own. */
.dw-brand-logo {
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.dw-brand-logo img { display: block; width: 100%; height: auto; }
.dw-brand-caption {
  margin-top: 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  text-align: center;
}

.dw-nav { padding: 0.9rem 0.75rem; flex: 1; }
.dw-sidebar-foot { padding: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.07); }

.dw-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.2rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.dw-nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.dw-nav-link.active { background: var(--accent); color: var(--sidebar-active); }
.dw-nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; }

/* Sign out is a POST form, so the nav item is a button styled as a link. */
.dw-nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dw-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}
.dw-backdrop.show { display: block; }

/* ---------- Shell ---------- */

.dw-main { margin-left: 240px; min-height: 100vh; }

.dw-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 60px;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.dw-page-title { font-size: 1rem; font-weight: 600; margin: 0; }
.dw-navbar-right { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }

.dw-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.25rem 0.6rem 0.25rem 0.3rem;
  min-height: 36px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}
.dw-user-btn:hover { background: var(--accent-soft); }
.dw-user-btn i { font-size: 0.7rem; color: var(--text-muted); }
.dw-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.dw-user-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  padding: 0.35rem;
  min-width: 210px;
}
.dw-user-menu-head { padding: 0.5rem 0.7rem; font-size: 0.8rem; color: var(--text); }
.dw-user-menu .dropdown-item {
  color: var(--text);
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  width: 100%;
  font: inherit;
  cursor: pointer;
}
.dw-user-menu .dropdown-item:hover { background: var(--accent-soft); color: var(--accent); }
.dw-user-menu .dropdown-divider { border-color: var(--border); }

@media (max-width: 575.98px) { .dw-user-name { display: none; } }

.dw-icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dw-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* Only one theme icon is visible at a time. */
[data-theme="light"] [data-theme-icon="dark"],
[data-theme="dark"] [data-theme-icon="light"] { display: none; }

.dw-content { padding: 1.5rem; }

/* ---------- Cards ---------- */

.dw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  height: 100%;
}
.dw-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

.dw-kpi { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dw-kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.dw-kpi-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.dw-kpi-sub { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; }
.dw-kpi-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.dw-chart-wrap { position: relative; height: 280px; }
.dw-chart-wrap.sm { height: 240px; }

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

.dw-table { width: 100%; margin: 0; color: var(--text); border-collapse: collapse; }
.dw-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dw-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dw-table tbody tr:last-child td { border-bottom: 0; }
.dw-table tbody tr:hover { background: var(--accent-soft); }
.dw-table-wrap { overflow-x: auto; }
.dw-truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-mono { font-variant-numeric: tabular-nums; white-space: nowrap; }

.dw-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.dw-badge.store { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dw-badge.edit { background: rgba(230, 162, 60, 0.15); color: #d08700; border-color: transparent; }
[data-theme="dark"] .dw-badge.edit { color: #f0b64c; }
.dw-badge.ok { background: rgba(46, 168, 126, 0.15); color: var(--success); border-color: transparent; }
.dw-badge.error { background: rgba(217, 83, 79, 0.16); color: var(--danger); border-color: transparent; }

/* ---------- Forms / controls ---------- */

.dw-filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.dw-field { display: flex; flex-direction: column; gap: 0.25rem; }
.dw-field label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.dw-input,
.dw-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.42rem 0.6rem;
  font-size: 0.85rem;
  min-height: 36px;
}
.dw-input:focus,
.dw-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dw-input::placeholder { color: var(--text-muted); }

.dw-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dw-btn-primary { background: var(--accent); color: #fff; }
.dw-btn-primary:hover { filter: brightness(1.06); color: #fff; text-decoration: none; }
.dw-btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.dw-btn-ghost:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.dw-pagination { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.dw-pagination a,
.dw-pagination span {
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.dw-pagination a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.dw-pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.dw-pagination .disabled { opacity: 0.4; }

.dw-empty { padding: 2.25rem 1rem; text-align: center; color: var(--text-muted); }
.dw-muted { color: var(--text-muted); }

.dw-row-link { cursor: pointer; }

.dw-crumb { font-size: 0.82rem; }
.dw-crumb a { color: var(--text-muted); }
.dw-crumb a:hover { color: var(--accent); }

.dw-userhead { display: flex; align-items: center; gap: 1rem; }
.dw-userhead-name { font-size: 1.25rem; font-weight: 700; margin: 0; }
.dw-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ---------- Date range control ---------- */

.dw-range-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
}
.dw-range-slider-col { flex: 1 1 340px; min-width: 260px; }
.dw-range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.dw-range-readout { font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dw-range-fields { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }

/* noUiSlider, restyled to the dashboard palette. Extra bottom room for pips. */
#dwRangeSlider { margin: 0.35rem 0.6rem 2.6rem; }
.noUi-target {
  background: var(--border);
  border: 0;
  box-shadow: none;
  height: 6px;
  border-radius: 999px;
}
.noUi-connect { background: var(--accent); }
.noUi-handle {
  width: 18px !important;
  height: 18px !important;
  right: -9px !important;
  top: -7px !important;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}
.noUi-handle:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.noUi-handle::before, .noUi-handle::after { display: none; }
.noUi-handle:active { cursor: grabbing; }
.noUi-pips { color: var(--text-muted); padding-top: 6px; height: auto; }
.noUi-marker-horizontal.noUi-marker { background: var(--border); }
.noUi-value {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.noUi-value:hover { color: var(--accent); }
.noUi-tooltip { display: none; }

/* ---------- Login ---------- */
/* Split screen, matching the JOH Expense sign-in. Colours come from the JOH
   logo: navy #0A2041 (the ribbon) and red #BF2F38. The page is always light
   (it ignores the dark-mode switch), so its colours are hard-coded. */

.signin-body { margin: 0; background: #ffffff; }
.signin {
  --joh-navy: #0A2041; --joh-red: #BF2F38;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  background: #ffffff;
  color: #10182E;
}
/* This page doesn't load Bootstrap, which normally sets this for every element. */
.signin, .signin *, .signin *::before, .signin *::after { box-sizing: border-box; }
.signin-form { text-align: left; }

/* Left: brand panel */
.signin-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 56px 64px;
  color: #ffffff;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(191, 47, 56, 0.20) 0%, rgba(191, 47, 56, 0) 55%),
    radial-gradient(90% 70% at 100% 100%, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, #0A2041 0%, #111827 100%);
}
.signin-hero::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--joh-red), rgba(191, 47, 56, 0.4));
}
.signin-hero::after {  /* faint grid texture */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, transparent 0%, #000 40%, #000 70%, transparent 100%);
}
.signin-hero-inner { position: relative; z-index: 1; margin: auto 0; max-width: 520px; }
.signin-headline {
  font-family: 'Oswald', 'Inter', sans-serif;
  font-weight: 600;
  font-size: clamp(38px, 4.6vw, 60px);
  line-height: 1.05;
  letter-spacing: 0.01em;
  margin: 0 0 18px;
  text-wrap: balance;
}
.signin-lede { font-size: 17px; line-height: 1.6; color: #C9D0EC; margin: 0; max-width: 42ch; }

/* Right: sign-in */
.signin-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px 28px;
  background: linear-gradient(180deg, #ffffff 0%, #F7F8FB 100%);
}
.signin-box { width: 100%; max-width: 380px; margin: auto 0; text-align: center; }
.signin-logo { display: block; width: 240px; max-width: 80%; height: auto; margin: 0 auto 28px; }
.signin-welcome { font-size: 16px; font-weight: 500; line-height: 1.5; color: #545F7D; margin: 0 auto 28px; }

.signin-error {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  text-align: left;
  background: #F6E1DE;
  color: #A80000;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* "Sign in with Microsoft": Microsoft's light button style (white, grey border, four-colour logo). */
.signin-ms {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 48px;
  background: #ffffff;
  color: #3C3C3C;
  border: 1px solid #8C8C8C;
  border-radius: 8px;
  font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(10, 32, 65, 0.06), 0 4px 14px -6px rgba(10, 32, 65, 0.22);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.signin-ms:hover {
  background: #F5F6F8;
  color: #3C3C3C;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(10, 32, 65, 0.08), 0 8px 20px -8px rgba(10, 32, 65, 0.30);
}
.signin-ms:active { transform: translateY(1px); }
.signin-ms:focus-visible { outline: 3px solid var(--joh-navy); outline-offset: 3px; }
.signin-ms-logo { flex: none; }
.signin-note { font-size: 12px; color: #8B93AC; margin: 14px 0 0; }

/* Local / break-glass accounts: the username + password form, folded away. */
.signin-local { margin-top: 26px; text-align: left; border-top: 1px solid #DBE0EE; padding-top: 14px; }
.signin-local summary { cursor: pointer; font-size: 12px; color: #8B93AC; text-align: center; list-style: none; }
.signin-local summary::-webkit-details-marker { display: none; }
.signin-local[open] summary { margin-bottom: 14px; }
.signin-field { margin-bottom: 0.9rem; }
.signin-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #545F7D;
  margin-bottom: 0.3rem;
}
/* Inputs here follow the light page, not the theme. */
.signin .dw-input { width: 100%; background: #F7F8FC; border: 1px solid #DBE0EE; color: #10182E; min-height: 42px; }
.signin .dw-input:focus { border-color: var(--joh-navy); box-shadow: 0 0 0 3px rgba(10, 32, 65, 0.15); }
.signin-submit { width: 100%; justify-content: center; min-height: 42px; margin-top: 0.4rem; background: var(--joh-navy); }

.signin-foot { margin: 28px 0 0; font-size: 11.5px; color: #8B93AC; }

/* Tablets and phones: one clean column, with a thin JOH navy/red bar on top. */
@media (max-width: 860px) {
  .signin { grid-template-columns: 1fr; }
  .signin-hero { display: none; }
  .signin-panel {
    min-height: 100vh;
    padding: 40px 22px 22px;
    border-top: 6px solid var(--joh-navy);
    box-shadow: inset 0 3px 0 var(--joh-red);
  }
  .signin-logo { width: 200px; }
}

/* ---------- KPI period-over-period delta ---------- */

.dw-kpi-delta { font-size: 0.76rem; font-weight: 600; margin-top: 0.25rem; }
.dw-delta-up { color: var(--success); }
.dw-delta-down { color: var(--danger); }
.dw-delta-flat, .dw-delta-none { color: var(--text-muted); }

/* ---------- Day x hour heatmap ---------- */

.dw-heatmap-wrap { overflow-x: auto; padding-top: 0.4rem; }
.dw-heatmap {
  display: grid;
  grid-template-columns: max-content repeat(24, minmax(14px, 1fr));
  gap: 3px;
  min-width: 560px;
}
.dw-heat-corner { grid-column: 1; }
.dw-heat-hour {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
  align-self: end;
  padding-bottom: 2px;
}
.dw-heat-day {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-right: 0.6rem;
  display: flex;
  align-items: center;
}
.dw-heat-cell {
  height: 22px;
  border-radius: 3px;
  background: var(--accent);           /* overridden inline with per-cell opacity */
  border: 1px solid transparent;
}
.dw-heat-cell.empty {
  background: var(--bg);
  border-color: var(--border);
}
.dw-heat-cell:hover { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Users-table sparkline ---------- */

.dw-spark {
  display: block;
  overflow: visible;
}
.dw-spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* ---------- Entity links, sortable headers, copy button ---------- */

.dw-entity-link { color: var(--text); border-bottom: 1px dotted var(--border); }
.dw-entity-link:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

.dw-sortable a {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.dw-sortable a:hover { color: var(--accent); text-decoration: none; }
.dw-sortable i { font-size: 0.7rem; }
/* Idle columns advertise that they sort, without competing with the active one. */
.dw-sort-idle { opacity: 0.35; font-size: 0.65rem; }
.dw-sortable a:hover .dw-sort-idle { opacity: 1; }

.dw-copy-link.dw-copied { color: var(--success); border-color: var(--success); }

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
  .dw-sidebar { transform: translateX(-100%); }
  .dw-sidebar.open { transform: translateX(0); }
  .dw-main { margin-left: 0; }
  .dw-content { padding: 1rem; }
}

/* ---------- Sidebar sections ---------- */

.dw-nav-section {
  margin: 1.1rem 0.8rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.7;
}
.dw-nav-section:first-child { margin-top: 0.1rem; }
.dw-nav-sep { border-top: 1px solid rgba(255, 255, 255, 0.07); margin: 0.9rem 0.2rem 0; }

/* ---------- Deductions aging report ---------- */

:root { --b0: #2ea87e; --b1: #d08700; --b2: #e0703a; --b3: #d9534f; }
[data-theme="dark"] { --b0: #46c79b; --b1: #f0b64c; --b2: #f28c5a; --b3: #ef7a76; }

.ag-asof {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; padding: 0.55rem 0.85rem; font-size: 0.8rem; font-weight: 500;
  margin-bottom: 1rem;
}

.ag-bucket {
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color 0.15s ease;
}
.ag-bucket::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--bc); }
.ag-bucket:hover, .ag-bucket:focus-visible { border-color: var(--bc); outline: none; }
.ag-bucket.active {
  border-color: var(--bc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bc) 20%, transparent), var(--shadow);
}
.ag-bucket-bar { height: 6px; border-radius: 999px; background: var(--border); margin-top: 0.7rem; overflow: hidden; }
.ag-bucket-bar span { display: block; height: 100%; background: var(--bc); }

.ag-age {
  display: inline-block; min-width: 2.4rem; text-align: center;
  padding: 0.15rem 0.45rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  background: color-mix(in srgb, var(--bc) 16%, transparent); color: var(--bc);
  font-variant-numeric: tabular-nums;
}

/* Analyst name tags: every assigned analyst is shown. */
.ag-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 300px; max-width: 380px; }
.ag-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.12rem 0.5rem 0.12rem 0.18rem; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: 0.74rem; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.ag-chip:hover { border-color: var(--accent); color: var(--accent); }
.ag-chip b {
  width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.58rem; font-weight: 700; color: #fff; background: var(--accent);
}

.dw-badge.new { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dw-badge.prog { background: rgba(230, 162, 60, 0.15); color: #d08700; border-color: transparent; }
[data-theme="dark"] .dw-badge.prog { color: #f0b64c; }
.dw-badge.dup { background: rgba(217, 83, 79, 0.16); color: var(--danger); border-color: transparent; }

.ag-th { cursor: pointer; user-select: none; }
.ag-th:hover { color: var(--accent); }
.ag-th i { font-size: 0.65rem; }
.ag-th .idle { opacity: 0.35; }

.ag-matrix td.cell { text-align: right; font-variant-numeric: tabular-nums; }
/* Counts with dollars under them make the table wide; keep it inside its card. */
.ag-matrix th, .ag-matrix td { padding-left: 0.35rem; padding-right: 0.35rem; }
.ag-matrix td.dw-truncate { max-width: 12rem; }
.ag-heat { display: inline-block; min-width: 2.6rem; padding: 0.1rem 0.4rem; border-radius: 6px; }
/* Dollar total under a count (aging table cells, bucket cards). */
.ag-cell-amt { display: block; font-size: 0.68rem; font-weight: 400; color: var(--text-muted); margin-top: 0.1rem; white-space: nowrap; }
.ag-bucket-amt { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 0.1rem; }
.ag-amt-bad { color: var(--danger); font-size: 0.78rem; white-space: nowrap; }
.ag-amt-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}
.ag-amt-note[hidden] { display: none; }
.ag-matrix tbody tr[data-k] { cursor: pointer; }
.ag-matrix-scroll { max-height: 430px; overflow: auto; }
.ag-matrix thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

.ag-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ag-seg button {
  border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 0.35rem 0.7rem; cursor: pointer;
}
.ag-seg button + button { border-left: 1px solid var(--border); }
.ag-seg button.on { background: var(--accent); color: #fff; }

.ag-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ag-pill {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0.15rem 0.55rem;
}
.ag-pill button { border: 0; background: none; color: inherit; padding: 0; line-height: 1; cursor: pointer; }

#agBody .dw-badge { white-space: nowrap; }
