/*
 * Admin dashboard theme — AgentKart v2.0 on its dark ground.
 *
 * The same palette as the website and the app (BRAND.md), in the guidelines'
 * "on emerald" usage: the website's `night` green as the base, emerald panels,
 * warm ivory text, and gold as the accent. Dark because this is a utility
 * surface an operator stares at for hours, not a consumer moment — that
 * reasoning is unchanged; only the colours it is expressed in moved off navy
 * and electric blue.
 *
 * Gold is #D4AF37 here and nothing darker: on this ground it clears 8:1, so it
 * can carry links and labels. What it cannot do is sit UNDER white text (under
 * 2:1), so every fill in the accent carries `--on-accent` emerald type.
 */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #051d15;
  --panel: #0a2c21;
  --panel-2: #0e3528;
  --panel-border: rgba(170, 200, 185, 0.12);
  --panel-border-strong: rgba(170, 200, 185, 0.22);
  --text: #f2f4ef;
  --text-muted: #a9b8b0;
  --text-dim: #7c8c84;
  /* The accent. Named `electric` still, so no rule needed rewriting. */
  --electric: #d4af37;
  --electric-hi: #e6c45a;
  --electric-dim: rgba(212, 175, 55, 0.14);
  --on-accent: #072a1f;
  --danger: #f2646b;
  --danger-dim: rgba(242, 100, 107, 0.14);
  --success: #5fbf8f;
  --success-dim: rgba(95, 191, 143, 0.14);
  /* Pending/attention. Kept warmer and more orange than the gold accent, so
     "this needs you" does not read as "this is branding". */
  --amber: #e0913a;
  --amber-dim: rgba(224, 145, 58, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Headings in the brand's editorial serif; everything else stays in the sans. */
h1, h2, .topbar .brand, .sidebar-brand { font-family: var(--font-display); letter-spacing: -0.01em; }

/* Digits that sit in columns must line up, everywhere. */
table, .stat-value, .tab-count, .mono, time { font-variant-numeric: tabular-nums; }

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--panel-border);
}
.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }
.topbar .brand span { color: var(--electric); }

/*
 * App shell: a fixed-width left sidebar (nav + account) and a scrollable
 * content area.
 *
 * The shell is exactly one viewport tall and clips, so only `.content`
 * scrolls. It used to be min-height, which let the whole document grow with a
 * long page — the sidebar scrolled away with it, and a reviewer working down a
 * queue lost the navigation entirely. The sidebar scrolls on its own only if
 * the nav itself outgrows the screen.
 */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  height: 100%;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 12px;
}
.sidebar-brand span { color: var(--electric); }
.sidebar-logo { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }

.sidebar-nav { margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav li { margin: 2px 10px; }

/*
 * Collapsible groups. Seventeen flat rows gave the queues an admin works every
 * day the same weight as settings touched once a month; grouping lets the work
 * sit at the top and the rest fold away.
 */
.nav-group { border: 0; }
.nav-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 10px 22px 6px;
  color: var(--text-muted, #a9b8b0);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--text, #f2f4ef); }
.nav-group-label { flex: 1; }

/*
 * The role badge on a group heading — CFO, CTO and so on.
 *
 * Deliberately quiet: it says who owns the section, and the section's own name
 * is what an operator actually scans for. Set at the same weight as the count
 * chips so the sidebar keeps one visual language rather than gaining a second.
 */
.nav-group-role {
  display: inline-block;
  min-width: 2.4em;
  margin-right: 0.4em;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  opacity: 0.9;
}
.nav-group[open] .nav-group-role,
.nav-group:hover .nav-group-role { opacity: 1; }
.nav-group-caret { transition: transform 0.15s ease; font-size: 14px; line-height: 1; }
.nav-group[open] .nav-group-caret { transform: rotate(90deg); }

/*
 * What is waiting, on the row itself. Counted in one request per page — see
 * the middleware in server.ts — so an admin can see there is work without
 * opening every section to find out.
 */
.nav-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--electric, #d4af37);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* On a collapsed group the number is the only thing saying "look in here". */
.nav-count-group { background: rgba(212, 175, 55, 0.28); color: var(--electric-hi); }
.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.04); text-decoration: none; color: var(--text); }
.sidebar-nav a.active { background: var(--electric-dim); color: var(--electric-hi); }
/* Nav rows are label-only now; an active row is marked by a rail, not an icon. */
.sidebar-nav a.active { position: relative; }
.sidebar-nav a.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--electric);
}

.sidebar-footer { padding: 12px 16px 0; border-top: 1px solid var(--panel-border); margin-top: 12px; }
.sidebar-email { font-size: 12px; color: var(--text-muted); padding: 0 4px 10px; word-break: break-all; }

.content { flex: 1; min-width: 0; height: 100%; overflow-y: auto; }

.container { max-width: 1040px; margin: 0 auto; padding: 32px 28px 64px; }

.centered-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; font-weight: 680; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.subtitle { color: var(--text-muted); margin: 0 0 24px; }

label { display: block; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
/*
 * Every text-like input, not a list of the three that happened to exist when
 * this was written. A `type="search"` box fell through and rendered as the
 * browser's own light-mode control on a dark page — visibly not part of the
 * product. `date`, `number` and the rest would have done the same.
 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input:not([type]),
select,
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }
/* Safari paints its own rounded box and clear button on search fields. */
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: var(--text-muted, #a9b8b0); opacity: 0.7; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--electric, #d4af37);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}
.field { margin-bottom: 16px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--electric);
  /* Emerald on gold: white on #D4AF37 is under 2:1. */
  color: var(--on-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover, .btn:hover { background: var(--electric-hi); text-decoration: none; }
button:active, .btn:active { transform: translateY(0.5px); }

/*
 * A disabled button has to LOOK disabled.
 *
 * Nothing styled the state, so a Save that was correctly refusing to submit
 * was indistinguishable from one that would — which is worse than no button:
 * it reads as a click that did nothing. Faded, and the cursor says so before
 * the click rather than after.
 */
button:disabled,
button:disabled:hover,
.btn:disabled,
.btn:disabled:hover {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  background: var(--electric);
}
.btn-ghost { background: transparent; border-color: var(--panel-border-strong); color: var(--text); }
.btn-ghost:hover { background: rgba(170, 200, 185, 0.08); border-color: var(--panel-border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff7b81; }
.btn-success { background: var(--success); color: var(--on-accent); }
.btn-success:hover { background: #74cc9f; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.error-banner {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  color: #ffb3b3;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.hint-banner {
  background: var(--electric-dim);
  border: 1px solid var(--electric);
  color: var(--electric-hi);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--panel-border); vertical-align: middle; }
tbody tr { transition: background 100ms ease; }
tbody tr:hover { background: rgba(170, 200, 185, 0.04); }
tbody tr:last-child td { border-bottom: none; }
th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; margin-left: 6px; }

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.chip.payment { background: rgba(79, 124, 255, 0.15); color: #9db8ff; }
.chip.email { background: var(--amber-dim); color: #f0ad63; }
.chip.sms { background: var(--success-dim); color: #8fd6b1; }
.chip.storage { background: rgba(180, 100, 220, 0.15); color: #d2a3ef; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--text-muted); }

.reveal-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 4px 8px;
  word-break: break-all;
}

.empty-state { text-align: center; padding: 48px 0; color: var(--text-muted); }

.add-form { margin-top: 28px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.chip.other { background: rgba(255, 255, 255, 0.1); color: var(--text); }

.review-card { margin-bottom: 20px; }
.review-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.review-applicant { font-weight: 600; font-size: 15px; }
.review-doc-image { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: 8px; margin-top: 12px; background: rgba(255, 255, 255, 0.05); }
.review-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--panel-border); }
.confidence-row { display: flex; gap: 10px; }
.radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.radio-pill input { margin: 0; }
.review-actions { display: flex; gap: 10px; margin-top: 16px; }

.audit-detail {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 360px;
}

.chip.status-draft { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }
.chip.status-pending_review { background: var(--amber-dim); color: #f0ad63; }
.chip.status-approved { background: var(--success-dim); color: #8fd6b1; }
.chip.status-edit_pending { background: var(--amber-dim); color: #f0ad63; }
.chip.status-paused { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }
.chip.status-suspended { background: var(--danger-dim); color: #ffb3b3; }
.chip.status-terminated { background: var(--danger-dim); color: #ffb3b3; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--panel-border); }

/*
 * A grid rather than a row, for pages with more than four numbers. Flex made
 * eight tiles a single unreadable line on a laptop; this wraps into columns
 * that stay wide enough to read a label.
 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
/* The quiet note under a figure — what it counts, or what it does not. */
.stat-note { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; line-height: 1.35; }
/* A figure that is fine at zero and wants attention above it. */
.stat-value.stat-warn { color: var(--danger); }

.stat-row { display: flex; gap: 16px; }
.stat-card { flex: 1; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }

.row-active { background: var(--electric-dim); }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 4px; }

/*
 * ---------------------------------------------------------------------------
 * APPROVALS — three queues, one decision surface
 * ---------------------------------------------------------------------------
 * The tab strip's counter is the point of the whole screen: it tells an admin
 * how much work is waiting in each track without opening any of them, so it
 * stays legible (tabular digits) and goes quiet at zero rather than shouting a
 * bright "0" badge at someone whose queue is clear.
 */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 120ms ease, color 120ms ease;
}
.tab:hover { background: rgba(170, 200, 185, 0.06); color: var(--text); text-decoration: none; }
.tab.active { background: var(--electric-dim); color: var(--electric-hi); }
.tab-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--amber-dim);
  color: var(--amber);
}
.tab-count.zero { background: rgba(170, 200, 185, 0.1); color: var(--text-dim); }
.tab.active .tab-count { background: rgba(212, 175, 55, 0.25); color: var(--electric-hi); }

.row-name { font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

/* A second attempt is worth flagging — it is not a fresh applicant. */
.chip.resubmitted { background: var(--amber-dim); color: var(--amber); }

.waiting { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

/*
 * Detail view: the reviewer reads top-down and decides at the bottom, so the
 * decision bar is the last thing on the page rather than floating over it.
 */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.detail-name { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.detail-meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--panel-border);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.detail-cell { background: var(--panel); padding: 12px 14px; }
.detail-key {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.detail-value { font-size: 13.5px; word-break: break-word; }
.detail-value.empty { color: var(--text-dim); }

.section { margin-top: 24px; }
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}

.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.doc-item {
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.doc-type { font-weight: 600; font-size: 13px; }
.doc-status { font-size: 12px; margin-top: 2px; }

/* Decision bar — the end of the page, and the end of the reviewer's read. */
.decide-bar {
  margin-top: 28px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-border-strong);
  border-radius: var(--radius);
}
.decide-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.decide-actions form { display: contents; }

/* Reject needs a reason, so the field is part of the same form, not a prompt. */
.reject-block { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--panel-border); }

.banner-success {
  background: var(--success-dim);
  border: 1px solid rgba(95, 191, 143, 0.4);
  color: #8fe0bb;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.prior-reject {
  background: var(--danger-dim);
  border: 1px solid rgba(242, 100, 107, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}
.prior-reject strong { color: #ffb3b6; }

/* ---------------------------------------------------------------- Lightbox
   Documents and photos open over the profile rather than in a new tab, so a
   reviewer working a queue never loses their place. */
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.lightbox-panel {
  position: relative;
  width: min(920px, 92vw);
  height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--panel, #0a2c21);
  border: 1px solid var(--panel-border-strong, rgba(170, 200, 185, 0.22));
  border-radius: 14px;
  overflow: hidden;
}
.lightbox-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--panel-border-strong, rgba(170, 200, 185, 0.22));
}
.lightbox-title { font-size: 13px; color: var(--text-muted, #a9b8b0); }
.lightbox-body { flex: 1; min-height: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.lightbox-body img,
.lightbox-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* Shown when the browser refuses a video format we accepted on upload. */
.lightbox-fallback { color: var(--text-muted, #a9b8b0); text-align: center; padding: 32px; max-width: 46ch; }
.lightbox-fallback p { margin: 0 0 14px; line-height: 1.6; }
