/* =========================================================================
   Invoice Admin — restyled on the Entirely design system
   Same selectors/classes/CSS custom-property NAMES as the original file
   (app.js reads var(--c-ing)/--c-ok/--c-fail directly) — only values,
   type, radii and shadows changed to match Entirely tokens.
   ========================================================================= */

@font-face{font-family:'Bagoss Standard';font-style:normal;font-weight:300;font-display:swap;src:url('assets/fonts/BagossStandard-Light.woff2') format('woff2');}
@font-face{font-family:'Bagoss Standard';font-style:normal;font-weight:400;font-display:swap;src:url('assets/fonts/BagossStandard-Regular.woff2') format('woff2');}
@font-face{font-family:'Bagoss Standard';font-style:normal;font-weight:500;font-display:swap;src:url('assets/fonts/BagossStandard-Medium.woff2') format('woff2');}
@font-face{font-family:'Bagoss Standard';font-style:normal;font-weight:600;font-display:swap;src:url('assets/fonts/BagossStandard-SemiBold.woff2') format('woff2');}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* surfaces — Entirely primary palette */
  --bg: #f2ebe3;           /* Sand */
  --surface: #ffffff;      /* White */
  --surface-2: #ede4d7;    /* Sand, one step down */
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.18);

  /* text */
  --text: #000000;         /* Black */
  --muted: #2e2e2e;        /* Slate */
  --faint: #9b9b9a;        /* Cement */

  /* brand + accents — Moss is the interactive/brand accent, Neon reserved for the one highest-emphasis action */
  --primary: #003e26;      /* Moss */
  --primary-2: #002a1a;    /* Moss, darker — hover */
  --primary-soft: #e3ebc2; /* Sage */
  --accent: #c7f100;       /* Neon — single highest-emphasis action only */
  --accent-2: #42dd41;     /* Lime — Neon hover */

  /* status */
  --green: #003e26;        /* Moss on Sage = "approved/ok" */
  --green-soft: #e3ebc2;
  --red: #60036b;          /* Plum on Petal = "rejected/fail" */
  --red-soft: #ffd1de;
  --amber: #733326;        /* Bark on Cream = "pending" */
  --amber-soft: #f1f5c2;
  --violet: #60036b;
  --violet-soft: #ffd1de;

  /* chart series */
  --c-ing: #9b9b9a;   /* Cement — ingested (neutral baseline) */
  --c-ok: #003e26;    /* Moss — completed */
  --c-fail: #60036b;  /* Plum — failed */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --sidebar-w: 264px;
  --font: 'Outfit', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  --font-display: 'Bagoss Standard', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
  font-weight: 500;
}

a {
  color: var(--primary);
}
a:hover {
  color: var(--primary-2);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12.5px;
}
.hidden {
  display: none !important;
}

/* ----------------------------- Boot gate ------------------------------ */
.boot-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
}
.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}
.boot-text {
  font-size: 14px;
}

/* ----------------------------- Spinner -------------------------------- */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------ Shell --------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----------------------------- Sidebar -------------------------------- */
.sidebar {
  background: #000000;
  color: #cdd5e4;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 6px 22px;
}
.brand-logo {
  height: 24px;
  width: auto;
  display: block;
}
.brand-tagline {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.5);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
  font-family: inherit;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(199, 241, 0, 0.14);
  color: #fff;
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.nav-ico {
  font-size: 15px;
  width: 18px;
  text-align: center;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 2px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ------------------------------- Main --------------------------------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  background: rgba(242, 235, 227, 0.86);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  font-size: 20px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #000;
  background: var(--accent);
}
.user-email {
  font-size: 13px;
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:hover {
  background: var(--surface-2);
}
#nav-toggle {
  display: none;
}

.content {
  padding: 28px 22px 48px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.view {
  display: grid;
  gap: 20px;
}

/* ----------------------------- Buttons -------------------------------- */
.button {
  padding: 11px 20px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font);
  transition: filter 0.12s, background 0.12s, transform 0.06s, color 0.12s, border-color 0.12s;
}
.button:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}
.button:active {
  transform: translateY(1px);
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.button.secondary:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}
.button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.button.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.button.small {
  padding: 7px 14px;
  font-size: 11px;
}
.button.danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}
.button.danger:hover {
  background: #ffc0d4;
}

/* ------------------------------ Banner -------------------------------- */
.banner {
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 500;
}
.banner.error {
  background: var(--red-soft);
  color: var(--red);
  border: none;
}

/* ------------------------------- Panel -------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}
.panel.no-pad {
  padding: 0;
  overflow: hidden;
}
.panel.narrow {
  max-width: 620px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: 1.15rem;
}
.panel-head p {
  margin: 4px 0 0;
  font-size: 13px;
  font-family: var(--font);
}
.panel-title {
  font-weight: 600;
  font-size: 0.66rem;
  color: var(--faint);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font);
}

/* ------------------------------- KPIs --------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: none;
}
.kpi-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
.kpi-value {
  font-size: 2rem;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-skel {
  display: inline-block;
  width: 56px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(90deg, #ede4d7, #e3d9c9, #ede4d7);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ------------------------------ Chart --------------------------------- */
.chart-wrap {
  width: 100%;
  overflow-x: auto;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}
.grid-line {
  stroke: var(--border);
  stroke-width: 1;
}
.axis-label {
  fill: var(--faint);
  font-size: 11px;
  font-family: var(--font);
}
.chart-svg rect {
  transition: opacity 0.1s;
}
.chart-svg rect:hover {
  opacity: 0.78;
}
.legend {
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.lg {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.lg + .lg::before {
  content: "/";
  color: var(--faint);
  margin-right: 10px;
}
.sw {
  display: none;
}

/* --------------------------- Recent failures -------------------------- */
.failures {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.failure-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.failure-row:last-child {
  border-bottom: none;
}
.failure-main {
  min-width: 0;
  flex: 1;
}
.failure-subject {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.failure-sub {
  font-size: 12.5px;
  margin-top: 1px;
}
.failure-error {
  font-size: 12.5px;
  color: var(--red);
  margin-top: 4px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------- Empty -------------------------------- */
.empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
}

/* ------------------------------ Toolbar ------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1 1 320px;
  min-width: 220px;
}
.search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 15px;
}
.search-box input {
  width: 100%;
  padding: 11px 14px 11px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.select {
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.count-pill {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------- Table -------------------------------- */
.table-scroll {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  padding: 13px 16px;
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table th.num,
.table td.num {
  text-align: right;
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.row-click {
  cursor: pointer;
  transition: background 0.1s;
}
.row-click:hover {
  background: var(--primary-soft);
}
.cell-strong {
  font-weight: 600;
}

/* Email grouping: one collapsed summary line per multi-invoice message. */
.table tbody tr.email-summary td {
  background: var(--surface-2);
}
.email-caret {
  display: inline-block;
  width: 12px;
  color: var(--muted);
  font-size: 10px;
}
/* Secondary line under a vendor name: attachment counts and group summaries. */
.row-attachments {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}
/* Left rule ties an attachment row visually to the email above it. */
.table tbody tr.grouped td:first-child {
  box-shadow: inset 3px 0 0 var(--border-strong);
  padding-left: 24px;
}
.table-foot {
  padding: 16px;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
}

/* ------------------------------ Badges -------------------------------- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.ok {
  background: var(--green-soft);
  color: var(--green);
}
.badge.fail {
  background: var(--red-soft);
  color: var(--red);
}
.badge.pending {
  background: var(--amber-soft);
  color: var(--amber);
}
/* Supporting documents: deliberately muted — they need no action, so they
   shouldn't read as urgently as anything awaiting review. */
.badge.neutral {
  background: var(--surface-2);
  color: var(--muted);
}
.conf {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.conf.good {
  color: var(--green);
}
.conf.medium {
  color: var(--amber);
}
.conf.low {
  color: var(--red);
}
.flag-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.flag {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}
.flag.info {
  background: var(--primary-soft);
  color: var(--primary);
}
.flag.warning {
  background: var(--amber-soft);
  color: var(--amber);
}
.flag.blocker {
  background: var(--red-soft);
  color: var(--red);
}

/* Collapsed advisory notes on an invoice that's already posted to NetSuite. */
.flag-details > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
  user-select: none;
}
.flag-details > summary:hover {
  color: var(--text);
}
.flag-details[open] > summary {
  margin-bottom: 5px;
}

/* Reference documents attached to an invoice (same email, not payable). */
.reference-doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.reference-doc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.reference-doc-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.reference-doc-name {
  font-size: 12.5px;
  word-break: break-word;
}
.reference-doc-type {
  font-size: 11px;
  color: var(--muted);
}

/* Shared shape for an in-panel action: state the blocker, then the control
   directly beneath it — used by both the department picker and the vendor-
   creation button, so a held invoice presents its fixes the same way
   wherever they appear instead of each panel inventing its own layout. */
.panel-action {
  margin-top: 10px;
}
.panel-action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.panel-action-row select {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}
.panel-action-row select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.panel-action-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* ------------------------------ Upload -------------------------------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color 0.14s, background 0.14s;
}
.dropzone.drag {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone p {
  margin: 12px 0 0;
}
.file-input {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 9px;
  font-size: 13.5px;
}
.file-input::file-selector-button {
  margin-right: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.file-input::file-selector-button:hover {
  background: var(--primary-soft);
}
.upload-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.status-row {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 20px;
}
.status-text {
  color: var(--muted);
  font-size: 13.5px;
}

/* --------------------------- Configuration ---------------------------- */
.config-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.config-envs {
  display: grid;
  gap: 20px;
}
.config-env {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.config-env:first-child {
  border-top: none;
  padding-top: 0;
}
.config-env-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.config-env-head h3 {
  font-size: 1.02rem;
}
.config-env-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.env-badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}
.inline-field {
  min-width: 150px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text);
}
.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
.config-status-row {
  margin-top: 16px;
}

/* ------------------------------ Drawer -------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: min(640px, 100%);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 {
  font-size: 1.2rem;
}
.drawer-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.meta-label {
  font-size: 0.66rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.meta-value {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.drawer-section {
  margin-top: 8px;
}
.duplicate-review-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 0 0 20px;
  background: var(--surface-2);
}
.duplicate-review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.duplicate-review-status,
.duplicate-review-message {
  color: var(--muted);
  font-size: 12.5px;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex-shrink: 0;
}
.segmented button {
  min-height: 34px;
  padding: 7px 12px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button:last-child {
  border-right: 0;
}
.segmented button.active {
  background: var(--primary);
  color: #fff;
}
.segmented button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.duplicate-match-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.duplicate-match {
  display: grid;
  grid-template-columns:
    minmax(90px, 1fr)
    minmax(110px, 1.2fr)
    minmax(80px, 0.8fr)
    minmax(110px, 1fr);
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.json-box {
  margin: 0;
  background: #000000;
  color: #e3ebc2;
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow: auto;
  max-height: 50vh;
  font-size: 12.5px;
  line-height: 1.5;
  font-family: var(--mono);
}
.drawer-foot {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.drawer-foot .button.danger {
  margin-right: auto;
}

/* ------------------------------ Toasts -------------------------------- */
.toast-host {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: #000000;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 340px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.success {
  background: var(--green);
}
.toast.error {
  background: var(--red);
}

/* ---------------------------- Responsive ------------------------------ */
@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar {
    transform: translateX(0);
  }
  #nav-toggle {
    display: grid;
  }
  .user-email {
    display: none;
  }
  .content {
    padding: 18px 14px 40px;
  }
  .topbar {
    padding: 12px 14px;
  }
}

@media (max-width: 520px) {
  .kpi-value {
    font-size: 1.7rem;
  }
  .duplicate-review-head {
    flex-direction: column;
  }
  .segmented {
    width: 100%;
  }
  .segmented button {
    flex: 1;
  }
  .duplicate-match {
    grid-template-columns: 1fr;
  }
  .drawer-foot .button.danger {
    margin-right: 0;
  }
  .drawer-foot {
    flex-wrap: wrap;
  }
}
