/*
 * ARFA Authorization Command Center — light teal/navy theme.
 * Palette matches the RBT note checker (accent teal #00d4b4, navy #0f172a).
 * Dark navy sidebar + light main area, per the reference mockup.
 */

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

:root {
  --bg:          #f5f7fa;
  --bg-soft:     #eef2f7;
  --card:        #ffffff;
  --border:      #e6eaf0;
  --border-soft: #eef0f4;
  --text:        #0f172a;
  --text-soft:   #334155;
  --text-muted:  #64748b;
  --text-faint:  #94a3b8;
  --teal:        #00d4b4;
  --teal-deep:   #00b8a0;
  --navy:        #0f172a;
  --navy-soft:   #1e293b;
  --navy-deep:   #0b1220;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 3px rgba(15,23,42,.05), 0 4px 20px rgba(15,23,42,.04);
  --sidebar-w:   256px;
}

html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--navy-deep);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width .18s ease;
  overflow: hidden;
}
body.sidebar-collapsed .sidebar { width: 68px; }
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-head,
body.sidebar-collapsed .nav-lock,
body.sidebar-collapsed .stale,
body.sidebar-collapsed .upload-btn .lbl,
body.sidebar-collapsed .user-meta,
body.sidebar-collapsed .user .chev-dn { display: none; }
body.sidebar-collapsed .collapse-btn { transform: rotate(180deg); }
body.sidebar-collapsed .upload-btn { font-size: 0; padding: 12px 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  position: relative;
}
.brand-mark { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-weight: 900; font-size: 20px; color: #fff; letter-spacing: .5px; line-height: 1; }
.brand-tag { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-top: 4px; line-height: 1.25; }
.collapse-btn {
  position: absolute; right: 12px; top: 22px;
  background: var(--navy-soft); color: #94a3b8; border: none;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center; transition: transform .18s;
}
.collapse-btn:hover { color: #fff; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-section { margin-bottom: 18px; }
.nav-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.1px;
  color: #475569; padding: 8px 10px 6px; font-weight: 700;
}
.nav-head-tag { color: #334155; font-weight: 500; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px; color: #94a3b8;
  text-decoration: none; font-weight: 500; font-size: 13.5px; margin-bottom: 2px;
  white-space: nowrap; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--navy-soft); color: #e2e8f0; }
.nav-item.active { background: rgba(0,212,180,.12); color: #fff; }
.nav-item.active .nav-ico { color: var(--teal); }
.nav-ico { display: flex; width: 20px; flex-shrink: 0; }
.nav-text { flex: 1; }
.nav-locked { color: #475569; }
.nav-locked:hover { background: var(--navy-soft); color: #64748b; }
.nav-lock { font-size: 10px; opacity: .6; }

.sidebar-foot { padding: 14px 16px 16px; border-top: 1px solid rgba(255,255,255,.05); }
.stale {
  background: var(--navy-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.stale-head { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: #64748b; }
.stale-date { font-size: 12.5px; color: #e2e8f0; font-weight: 600; margin-top: 2px; }
.stale-days { font-size: 15px; color: var(--warning); font-weight: 800; margin-top: 6px; }
.stale-note { font-size: 10.5px; color: #475569; margin-top: 2px; }
.upload-btn {
  width: 100%; background: var(--teal); color: var(--navy); border: none;
  padding: 12px; border-radius: 10px; font-weight: 700; font-size: 13.5px; cursor: pointer;
  font-family: inherit; transition: background .12s;
}
.upload-btn:hover { background: var(--teal-deep); }
.user { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--teal);
  color: var(--navy); font-weight: 800; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; flex: 1; }
.user-name { font-size: 13px; color: #e2e8f0; font-weight: 600; }
.user-role { font-size: 11px; color: #64748b; }
.chev-dn { color: #475569; font-size: 11px; }

/* ============ MAIN ============ */
.main { flex: 1; height: 100vh; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.view { padding: 26px 30px 60px; max-width: 1500px; }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.view-head h1 { font-size: 27px; font-weight: 800; color: var(--navy); letter-spacing: -.3px; }
.view-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; max-width: 760px; }
.unit-filter {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-weight: 600; color: var(--text-soft); font-size: 13.5px;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); white-space: nowrap;
}
.unit-filter svg { color: var(--text-muted); }
.chev-dn { font-size: 10px; }

/* ---- search + tier filter (live, no re-render) ---- */
.q-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.q-search-wrap { position: relative; display: flex; align-items: center; }
.q-search-wrap svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.q-search {
  width: 300px; max-width: 60vw; padding: 9px 12px 9px 34px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card);
  font-family: inherit; font-size: 13.5px; color: var(--text); box-shadow: var(--shadow);
}
.q-search::placeholder { color: var(--text-faint); }
.q-search:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,212,180,.15); }
.q-filter {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card);
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-soft); cursor: pointer; box-shadow: var(--shadow);
}
.q-filter:focus { outline: none; border-color: var(--teal); }
.q-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.q-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13.5px; }
tr[hidden] { display: none; }
.up-skip { color: var(--warning); font-size: 11.5px; }

/* ---- toast ---- */
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 400; max-width: 390px;
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border-radius: 12px; background: var(--navy-deep); color: #e2e8f0;
  box-shadow: 0 12px 44px rgba(0,0,0,.32); font-size: 13px; line-height: 1.5;
  border-left: 4px solid var(--teal);
  transform: translateY(-12px); opacity: 0; transition: transform .25s, opacity .25s;
}
.toast.in { transform: translateY(0); opacity: 1; }
.toast.err { border-left-color: var(--danger); }
.toast .t-ico { flex-shrink: 0; color: var(--teal); }
.toast.err .t-ico { color: var(--danger); }
.toast .t-ico svg { width: 20px; height: 20px; }
.toast > div { flex: 1; }
.toast .t-x { background: none; border: none; color: #8b949e; cursor: pointer; font-size: 17px; line-height: 1; padding: 0 2px; }
.toast .t-x:hover { color: #fff; }

/* ---- KPI row ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: flex-start;
}
.kpi-label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.kpi-note { color: var(--text-faint); font-weight: 500; font-size: 11.5px; }
.kpi-value { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 8px 0 4px; color: var(--navy); }
.kpi-value.kpi-danger { color: var(--danger); }
.kpi-value.kpi-warning { color: var(--warning); }
.kpi-value.kpi-success { color: var(--success); }
.kpi-value.kpi-teal { color: var(--navy); }
.kpi-sub { font-size: 12px; color: var(--text-muted); }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon-teal { background: rgba(0,212,180,.10); color: var(--teal-deep); }
.kpi-icon-danger { background: rgba(239,68,68,.10); color: var(--danger); }
.kpi-icon-warning { background: rgba(245,158,11,.12); color: var(--warning); }
.kpi-icon-success { background: rgba(16,185,129,.10); color: var(--success); }

/* ---- 2-col grid ---- */
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 18px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 18px; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-title { font-size: 15px; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 7px; }
.panel-title.sm { font-size: 13.5px; margin-bottom: 14px; }
.panel-note { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.info { color: var(--text-faint); font-size: 13px; }
.panel-actions { display: flex; gap: 8px; }
.btn-ghost, .btn-dark {
  border: 1px solid var(--border); background: var(--card); color: var(--text-soft);
  padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-deep); }

/* ---- queue table ---- */
.table-scroll { overflow-x: auto; margin: 0 -2px; }
.queue { width: 100%; border-collapse: collapse; min-width: 720px; }
.queue th, .queue td { white-space: nowrap; }
.queue th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); font-weight: 700; padding: 0 12px 12px; border-bottom: 1px solid var(--border);
}
.queue th .th-sub { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 9.5px; }
.queue td { padding: 14px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; font-size: 13px; }
.queue tbody tr:last-child td { border-bottom: none; }
.queue tbody tr:hover { background: #fafbfc; }
.c-rank { font-weight: 800; color: var(--navy); font-size: 16px; width: 44px; }
.c-auth { font-weight: 700; color: var(--navy); }
.c-name { color: var(--text-soft); font-size: 12.5px; }
.c-dob { color: var(--text-faint); font-size: 11px; margin-top: 2px; }
.c-payer { color: var(--text-soft); font-weight: 500; }
.c-dry div:first-child { color: var(--navy); font-weight: 600; }
.c-sub, .c-pace { color: var(--text-faint); font-size: 11px; }
.c-pace { margin-top: 3px; }
.d-neg { color: var(--danger); font-weight: 700; }
.d-warn { color: var(--warning); font-weight: 700; }
.d-ok { color: var(--text-soft); font-weight: 700; }
.d-sub { display: block; color: var(--text-faint); font-size: 11px; }
.u-num { font-weight: 700; color: var(--navy); font-size: 15px; }
.u-pct { color: var(--text-muted); font-size: 11.5px; }
.c-chev { color: var(--text-faint); font-size: 18px; text-align: center; width: 30px; }
.badge { display: inline-block; padding: 5px 11px; border-radius: 7px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.badge-high { background: rgba(239,68,68,.12); color: #dc2626; }
.badge-medium { background: rgba(245,158,11,.14); color: #d97706; }
.badge-low { background: rgba(16,185,129,.12); color: #059669; }
/* ---- clickable rows open a docked panel ---- */
.queue tr[data-auth] { cursor: pointer; }
.queue tr[data-auth]:hover { background: #fafbfc; }
.queue tr.open { background: #f1f7f6; box-shadow: inset 3px 0 0 var(--teal); }
.queue tr.open .c-chev { color: var(--teal-deep); }

/* ---- Gmail-compose-style docked auth panels (stacked bottom-right) ---- */
.auth-tabs { position: fixed; bottom: 0; right: 24px; display: flex; align-items: flex-end; gap: 14px; z-index: 200; pointer-events: none; }
.auth-tab {
  pointer-events: auto; width: 360px; max-width: calc(100vw - 48px);
  background: var(--navy-deep); color: #cbd5e1;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(0,212,180,.18);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(36px); opacity: 0;
  transition: transform .28s cubic-bezier(.2,.85,.3,1.1), opacity .22s, box-shadow .3s;
}
.auth-tab.in { transform: translateY(0); opacity: 1; }
.auth-tab.pulse { animation: tabPulse .7s ease; }
@keyframes tabPulse {
  0%,100% { box-shadow: 0 -10px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(0,212,180,.18); }
  50%     { box-shadow: 0 -10px 40px rgba(0,0,0,.35), 0 0 0 3px rgba(0,212,180,.6); }
}
.tab-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; cursor: pointer; user-select: none;
  background: linear-gradient(180deg, rgba(0,212,180,.12), rgba(0,212,180,.03));
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.tab-name { font-size: 13px; font-weight: 700; color: #fff; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-name small { color: #8b949e; font-weight: 500; margin-left: 4px; }
.tab-controls { display: flex; gap: 4px; }
.tab-btn { width: 24px; height: 24px; border-radius: 6px; background: transparent; border: none; color: #8b949e; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background .12s, color .12s; }
.tab-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.tab-btn-close:hover { background: rgba(239,68,68,.18); color: #ef4444; }
.tab-body { padding: 16px 18px; max-height: 62vh; overflow-y: auto; }
.auth-tab.collapsed .tab-body { display: none; }

/* the reused auth-card, themed for the dark docked panel + single column */
.auth-card { padding: 0; }
.ac-grid { display: flex; flex-direction: column; gap: 16px; }
.ac-h { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #64748b; font-weight: 700; margin-bottom: 8px; }
.ac-kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 3px 0; }
.ac-kv span { color: #8b949e; }
.ac-kv b { color: #e2e8f0; font-weight: 600; text-align: right; }
.ac-bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; margin: 2px 0 10px; }
.ac-bar > i { display: block; height: 100%; background: var(--teal); }
.ac-action { margin-top: 4px; padding: 12px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 500; line-height: 1.5; }
.ac-action-h { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-bottom: 4px; opacity: .85; }
.ac-action-high { background: rgba(239,68,68,.16); color: #fca5a5; border: 1px solid rgba(239,68,68,.32); }
.ac-action-medium { background: rgba(245,158,11,.16); color: #fcd34d; border: 1px solid rgba(245,158,11,.32); }
.ac-action-low { background: rgba(16,185,129,.16); color: #6ee7b7; border: 1px solid rgba(16,185,129,.32); }
@media (max-width: 480px) { .auth-tabs { right: 0; left: 0; justify-content: center; } }

.queue-foot { text-align: center; padding-top: 14px; }
.btn-pill { background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-soft); padding: 9px 20px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit; }
.btn-pill:hover { border-color: var(--teal); color: var(--teal-deep); }

/* ---- donut ---- */
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-num { font-size: 22px; font-weight: 800; color: var(--navy); }
.donut-lbl { font-size: 11px; color: var(--text-muted); }
.legend { flex: 1; }
.lg-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.lg-label { color: var(--text-soft); flex: 1; }
.lg-val { font-weight: 700; color: var(--navy); }
.lg-pct { color: var(--text-muted); font-weight: 500; font-size: 11.5px; }

/* ---- tier summary ---- */
.tier-summary { }
.ts-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--border-soft); }
.ts-lbl { flex: 1; color: var(--text-soft); }
.ts-val { font-weight: 700; color: var(--navy); }
.ts-pct { color: var(--text-muted); font-weight: 500; font-size: 11.5px; }
.ts-total { display: flex; justify-content: space-between; padding-top: 11px; font-weight: 800; color: var(--navy); font-size: 14px; }

/* ---- pace ---- */
.pace-box {
  background: rgba(0,212,180,.06); border: 1px solid rgba(0,212,180,.18); border-radius: 9px;
  padding: 12px 14px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-soft);
  white-space: pre-wrap; line-height: 1.6;
}
.pace-note { font-size: 11.5px; color: var(--text-muted); margin-top: 10px; }

/* ---- trust banner ---- */
.trust-banner {
  margin-top: 18px; background: rgba(0,212,180,.06); border: 1px solid rgba(0,212,180,.2);
  border-radius: var(--radius); padding: 15px 20px; display: flex; align-items: center; gap: 14px;
  font-size: 13px; color: var(--text-soft);
}
.trust-banner svg { color: var(--teal-deep); flex-shrink: 0; width: 24px; height: 24px; }
.trust-banner > div { flex: 1; }
.trust-link { color: var(--teal-deep); font-weight: 600; text-decoration: none; white-space: nowrap; }
.trust-link:hover { text-decoration: underline; }

/* ---- detail / locked / settings ---- */
.queue.detail th, .queue.detail td { padding: 11px 10px; font-size: 12.5px; }
.empty-note, .locked-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 12px; }
.locked-panel { display: flex; align-items: center; gap: 16px; }
.locked-panel svg { color: var(--text-faint); width: 30px; height: 30px; flex-shrink: 0; }
.lock-big { font-size: 18px; }
.set h3 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.set { margin-bottom: 14px; }
.set p { color: var(--text-soft); font-size: 13px; }

@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
