/* Reconciliation Command Center — design system.
   Operations UI: dense, calm, legible. Tokens first, then layout, then
   components. Legacy class names (.card, .grid, .btn, .flash, .muted, .drop…)
   are kept working so older templates render correctly inside the layout. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --brand: #1d4ed8;
  --brand-600: #1e40af;
  --brand-50: #eff4ff;
  --side-bg: #0b1324;
  --side-text: #aab4c5;
  --side-active: #ffffff;
  --side-hover: #16213a;
  --ok: #047857;      --ok-bg: #ecfdf5;     --ok-bd: #a7f3d0;
  --warn: #b45309;    --warn-bg: #fffbeb;   --warn-bd: #fde68a;
  --danger: #b91c1c;  --danger-bg: #fef2f2; --danger-bd: #fecaca;
  --info: #1d4ed8;    --info-bg: #eff6ff;   --info-bd: #bfdbfe;
  --neutral-bg: #f1f5f9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial,
          "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", Mangal, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 244px;
  --top-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 28px 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--neutral-bg); padding: 1px 6px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; height: var(--top-h);
  padding: 0 18px; color: #fff; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.06); text-decoration: none;
}
.sidebar .brand .logo {
  width: 28px; height: 28px; border-radius: 7px; background: var(--brand);
  display: grid; place-items: center; font-size: 15px;
}
.sidebar .brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-text); }
.nav-section { padding: 14px 10px 4px; }
.nav-section > .label {
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: #6b778c; font-weight: 700; padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 7px; color: var(--side-text); font-size: 13.5px; text-decoration: none;
}
.nav-item:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: #1e3a8a; color: var(--side-active); }
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: rgba(255,255,255,.12);
  padding: 0 7px; border-radius: 10px; color: #fff;
}
.nav-item.sub { padding-left: 36px; font-size: 13px; }
.sidebar .foot { margin-top: auto; padding: 12px 18px; font-size: 11.5px; color: #6b778c; }

.main { margin-left: var(--side-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* The page itself never scrolls sideways: wide tables/matrices scroll inside
   their own .table-scroll. `clip` (not hidden) keeps sticky headers working. */
.content { overflow-x: clip; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.topbar .menu-btn { display: none; }
.search {
  position: relative; flex: 1; max-width: 560px;
}
.search input, .search input[type=search] {
  width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px 0 34px; background: var(--surface-2); font: inherit;
}
.search input:focus { outline: 2px solid var(--brand-50); border-color: var(--brand); background: #fff; }
.search svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--text-3); }
.search .kbd { position: absolute; right: 8px; top: 8px; }
.search-results {
  position: absolute; top: 42px; left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  max-height: 70vh; overflow: auto; display: none; z-index: 50;
}
.search-results.open { display: block; }
.search-results .group { padding: 8px 0; border-bottom: 1px solid var(--border); }
.search-results .group:last-child { border-bottom: 0; }
.search-results .group > .label { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 0 14px 4px; text-transform: uppercase; letter-spacing: .06em; }
.search-results a { display: flex; justify-content: space-between; gap: 12px; padding: 6px 14px; color: var(--text); }
.search-results a:hover, .search-results a.focus { background: var(--brand-50); text-decoration: none; }
.search-results .meta { color: var(--text-3); font-size: 12px; }
.topbar .spacer { flex: 1; }
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-btn .who { text-align: left; line-height: 1.15; }
.user-btn .who small { color: var(--text-3); font-size: 11px; display: block; }
.dropdown {
  position: absolute; right: 0; top: 44px; min-width: 200px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 6px; display: none; z-index: 60;
}
.dropdown.open { display: block; }
.dropdown a, .dropdown button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }

.content { padding: 22px 26px 60px; max-width: 1600px; width: 100%; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header .sub { color: var(--text-3); margin-top: 4px; font-size: 13px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumbs { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.breadcrumbs a { color: var(--text-3); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--neutral-bg); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-link, button.btn-link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.btn-row { display: flex; gap: 8px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 7px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--neutral-bg); }
.icon-btn svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------ forms */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; color: var(--text); height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 7px; background: #fff;
}
textarea { height: auto; padding: 8px 10px; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-50); border-color: var(--brand); }
label { font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.field .hint { color: var(--text-3); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: inline-flex; gap: 7px; align-items: center; }

/* ------------------------------------------------------------ cards */
.panel, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.card { padding: 16px; display: flex; flex-direction: column; }
.card h3 { margin: 0 0 4px; }
.card .big { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card.ok { border-left: 3px solid var(--ok); }
.card.warn { border-left: 3px solid #f59e0b; }
.card.danger { border-left: 3px solid var(--danger); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 12px 0 20px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; position: relative;
}
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi .label { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kpi.ok .dot { background: var(--ok); } .kpi.warn .dot { background: #f59e0b; }
.kpi.danger .dot { background: var(--danger); } .kpi.info .dot { background: var(--brand); }
.kpi.danger .value { color: var(--danger); }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-bg); color: var(--text-2); border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bd); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-bd); }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.badge.muted { background: var(--surface-2); color: var(--text-3); }
.pill-prio { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pill-prio.critical { color: #7f1d1d; } .pill-prio.high { color: var(--danger); }
.pill-prio.medium { color: var(--warn); } .pill-prio.low { color: var(--text-3); }

/* ------------------------------------------------------------ flash / toast */
.flash {
  padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; border: 1px solid var(--info-bd);
  background: var(--info-bg); color: #1e3a8a; font-size: 13.5px;
}
.flash.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: #065f46; }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: #78350f; }
.flash.danger { background: var(--danger-bg); border-color: var(--danger-bd); color: #7f1d1d; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 420px; background: var(--text); color: #fff; padding: 10px 14px;
  border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .18s ease-out;
}
.toast.ok { background: #064e3b; } .toast.danger { background: #7f1d1d; } .toast.warn { background: #78350f; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------ tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.table-wrap > .table-toolbar { border-radius: var(--radius) var(--radius) 0 0; }
.table-wrap > .table-foot { border-radius: 0 0 var(--radius) var(--radius); }
.table-scroll { overflow: auto; max-height: calc(100vh - 250px); position: relative; }
/* position: relative makes the scroll box the containing block for absolutely
   positioned children (e.g. visually-hidden .sr labels) so they can't escape it
   and widen the page. */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
th, td { padding: 8px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
th { background: var(--surface-2); font-weight: 650; color: var(--text-2); font-size: 12px; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .sort { opacity: .5; font-size: 10px; margin-left: 4px; }
th.sorted .sort { opacity: 1; color: var(--brand); }
tbody tr:hover { background: #f8fbff; }
tbody tr.selected { background: var(--brand-50); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { color: var(--text-3); font-size: 12px; }
td.nowrap, td code, .kpi .sub { white-space: nowrap; }
/* Tables inside panels/cards scroll instead of clipping their last columns. */
.panel { min-width: 0; }
.panel > table, .panel > .table-scroll { display: block; overflow-x: auto; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.table-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fff;
}
.table-toolbar .grow { flex: 1; }
.table-toolbar input[type=search] { width: 260px; max-width: 100%; }
.table-filters { display: none; gap: 10px 14px; flex-wrap: wrap; padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table-filters.open { display: flex; }
.table-filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.table-filters .f label { font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.table-filters .f .range { display: flex; gap: 4px; }
.table-filters .f .range input { width: 90px; }
.bulk-bar {
  display: none; align-items: center; gap: 8px; padding: 8px 12px; background: var(--brand-50);
  border-bottom: 1px solid var(--info-bd); font-size: 13px; flex-wrap: wrap;
}
.bulk-bar.open { display: flex; }
.table-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); background: #fff;
}
.pager { display: flex; gap: 4px; align-items: center; }
.col-menu { max-height: 360px; overflow: auto; min-width: 220px; }
.col-menu label { display: flex; gap: 8px; padding: 5px 8px; align-items: center; cursor: grab; }
.col-menu label:hover { background: var(--surface-2); border-radius: 5px; }
.thumb { width: 44px; height: 60px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 12px; background: var(--neutral-bg); font-size: 12px; margin: 0 4px 4px 0; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0; }

/* legacy table colouring */
tr.phantom { background: #fff6f6; } tr.duplicate { background: #fff7ed; }
tr.ambiguous { background: #f5f3ff; } tr.orphan { background: #fffbeb; }

/* ------------------------------------------------------------ drawer / modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.38); z-index: 80; display: none; }
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); z-index: 90;
  background: #fff; box-shadow: var(--shadow-lg); transform: translateX(100%);
  transition: transform .2s ease-out; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { flex: 1; font-size: 15px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; background: var(--surface-2); }
.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); z-index: 95;
  width: min(520px, calc(100vw - 32px)); background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg);
  display: none;
}
.modal.open { display: block; }
.modal-head { padding: 16px 18px 0; } .modal-body { padding: 12px 18px; } .modal-foot { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--text-3); } dl.kv dd { margin: 0; word-break: break-word; }
.section-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 18px 0 8px; }
.section-title:first-child { margin-top: 0; }

/* ------------------------------------------------------------ states */
.empty { text-align: center; padding: 42px 20px; color: var(--text-3); }
.empty .icon { font-size: 30px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, #eef1f5 25%, #f6f8fb 37%, #eef1f5 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 5px; height: 12px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.muted { color: var(--text-3); font-size: 12.5px; }
.danger { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.ok-text { color: var(--ok); font-weight: 600; }
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 5px 8px; border-radius: 6px; font-size: 12px; font-weight: 500;
  white-space: nowrap; z-index: 70; pointer-events: none;
}

/* ------------------------------------------------------------ tabs / steps / funnel */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--text-2); border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a, .seg button { padding: 6px 12px; font-size: 12.5px; color: var(--text-2); border: 0; background: none; cursor: pointer; font: inherit; border-right: 1px solid var(--border); }
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg a.active, .seg button.active { background: var(--brand); color: #fff; }
.seg a:hover { text-decoration: none; }
.steps { display: flex; flex-direction: column; gap: 14px; counter-reset: step; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 700; display: grid; place-items: center; }
.step.done .n { background: var(--ok-bg); color: var(--ok); }
.funnel { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.funnel .stage { flex: 1; min-width: 130px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); position: relative; }
.funnel .stage:first-child { border-radius: 8px 0 0 8px; } .funnel .stage:last-child { border-radius: 0 8px 8px 0; }
.funnel .stage + .stage { border-left: 0; }
.funnel .stage .t { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.funnel .stage .v { font-size: 20px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.funnel .stage .m { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.funnel .stage.ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.funnel .stage.danger { background: var(--danger-bg); border-color: var(--danger-bd); }
.funnel .stage.warn { background: var(--warn-bg); border-color: var(--warn-bd); }
.bar { height: 8px; background: var(--neutral-bg); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.bar.ok > span { background: var(--ok); } .bar.danger > span { background: var(--danger); } .bar.warn > span { background: #f59e0b; }
.list-rows > div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #eef1f5; align-items: center; }
.list-rows > div:last-child { border-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 7px 0; }
.timeline li::before { content: ""; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--border-strong); }

/* ------------------------------------------------------------ upload (legacy + new) */
.drop, label.drop {
  display: block; border: 2px dashed var(--border-strong); border-radius: 10px; padding: 26px;
  text-align: center; background: var(--surface-2); cursor: pointer; transition: background .15s;
}
.drop:hover { background: var(--brand-50); border-color: var(--brand); }
.drop input[type=file] { display: block; margin: 0 auto 10px; }
.upload-form { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.upload-section { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); position: relative; }
.upload-section .stat { position: absolute; top: 16px; right: 18px; font-size: 12px; color: var(--text-3); }
.progress { height: 10px; border-radius: 6px; background: var(--neutral-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.progress.ok > span { background: var(--ok); }

/* ------------------------------------------------------------ auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0b1324 0%, #13234a 100%); padding: 20px; }
.auth-card { width: min(400px, 100%); background: #fff; border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card .brand { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; font-weight: 750; font-size: 16px; }
.auth-card .brand .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.auth-card input { width: 100%; height: 40px; }
.auth-card .btn { width: 100%; height: 40px; }
.error-page { max-width: 520px; margin: 10vh auto; text-align: center; }
.error-page .code { font-size: 54px; font-weight: 800; color: var(--border-strong); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-grid; }
  .user-btn .who { display: none; }
  .content { padding: 16px 14px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  dl.kv { grid-template-columns: 110px 1fr; }
  .table-toolbar input[type=search] { width: 100%; }
  .funnel .stage { min-width: 50%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .topbar .btn span { display: none; }          /* icon-only Upload: room for search */
  .page-header .actions { width: 100%; }
}
@media print {
  .sidebar, .topbar, .table-toolbar, .table-foot, .bulk-bar, .actions { display: none !important; }
  .main { margin: 0; }
}

/* ------------------------------------------------------------ language */
html[lang=hi] body { line-height: 1.55; }           /* Devanagari needs more leading */
html[lang=hi] .nav-section > .label, html[lang=hi] .section-title,
html[lang=hi] .funnel .stage .t { letter-spacing: 0; text-transform: none; }
.lang-switch { display: flex; gap: 4px; padding: 6px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 4px 0; }
.lang-switch a { flex: 1; text-align: center; padding: 5px 8px; border-radius: 6px; color: var(--text-2); font-size: 13px; }
.lang-switch a.active { background: var(--brand); color: #fff; }
.lang-switch a:hover { text-decoration: none; background: var(--neutral-bg); }
.lang-switch a.active:hover { background: var(--brand-600); }
.lang-switch.login { border: 0; padding: 0 0 14px; justify-content: flex-end; }
.lang-switch.login a { flex: 0 0 auto; border: 1px solid var(--border); }
