/* DocuSense — Design System
   Colour palette derived from the DocuSense brain logo:
   indigo → purple gradient (brain) + blue → teal (wordmark).
   Vibrant, modern. Variable names preserved for backward compatibility —
   values remapped from the old steel-navy palette to the brand palette.
*/

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand core — straight from the logo */
  --brand-indigo:      #5B5FE9;   /* brain top */
  --brand-purple:      #9B6DD6;   /* brain bottom */
  --brand-blue:        #2E6FF2;   /* "Sense" start */
  --brand-teal:        #14B8A6;   /* "Sense" end — accent */
  --brand-teal-light:  #CCFBF1;
  --brand-gradient:    linear-gradient(135deg, #5B5FE9 0%, #9B6DD6 100%);
  --sidebar-gradient:  linear-gradient(180deg, #4338CA 0%, #6D28D9 100%);
  --panel-slate:       #1E293B;   /* dark slate — contrasts the indigo sidebar */

  /* Legacy variable names → remapped to vibrant brand values.
     Everything in the app that used these now picks up the new palette. */
  --blue-dark:   #4338CA;   /* indigo-700 — page titles, dark buttons */
  --blue-mid:    #4F46E5;   /* indigo-600 — primary buttons, links, focus */
  --blue-light:  #818CF8;   /* indigo-400 — active borders, light accents */
  --blue-pale:   #E0E7FF;   /* indigo-100 */
  --blue-bg:     #EEF0FF;   /* indigo-50  — subtle tinted backgrounds */
  --white:       #FFFFFF;
  --gray-100:    #F6F7FB;
  --gray-200:    #EAECF3;
  --gray-400:    #AEB4C7;
  --gray-600:    #66708A;
  --gray-700:    #475067;
  --gray-900:    #1A2238;
  --green:       #16A34A;   /* brighter success green */
  --green-light: #DCFCE7;
  --amber:       #B45309;   /* warmer amber */
  --amber-light: #FEF3C7;
  --red:         #DC2626;   /* brighter red */
  --red-light:   #FEE2E2;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(67,56,202,.07), 0 4px 18px rgba(67,56,202,.08);
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.55;
  min-height: 100vh;
}

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

/* ── Layout ──────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--sidebar-gradient);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;   /* hamburger button must never bleed past the sidebar boundary */
}
.sidebar-brand {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.sidebar-brand-link:hover { text-decoration: none; }
.sidebar-wordmark {
  object-fit: contain;
  max-width: 140px;
  height: 36px;
}
.sidebar-footer {
  padding: 14px 16px;
  font-size: .82rem;
  color: rgba(255,255,255,.5);
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user  { color: rgba(255,255,255,.8); font-weight: 500; font-size: .82rem; }
.sidebar-role  { color: rgba(255,255,255,.4); font-size: .74rem; }
.sidebar-manifest-icon {
  opacity: .75;
  transition: opacity .15s;
}
.sidebar-manifest-icon:hover { opacity: 1; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.8);
  font-size: .92rem;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.10);
  color: var(--white);
  text-decoration: none;
}
.sidebar-nav a.active {
  /* Vibrant on-brand selection: indigo→teal gradient, brighter than the page,
     thick teal accent rail. Reads clearly as "you are here". */
  color: var(--white);
  font-weight: 600;
  text-decoration: none;
  border-left: 4px solid var(--brand-teal);
  background: linear-gradient(90deg,
              rgba(20,184,166,.34) 0%,
              rgba(91,95,233,.30) 100%);
  box-shadow: inset 0 0 0 1px rgba(20,184,166,.30);
}
.sidebar-nav-group-label {
  padding: 12px 20px 4px;
  font-size: .70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
}
.sidebar-nav-sub { padding-left: 32px !important; font-size: .86rem !important; }
.sidebar-nav-placeholder { opacity: .5; cursor: default; pointer-events: none; }
.sidebar-footer {
  padding: 16px 20px;
  font-size: .82rem;
  color: rgba(255,255,255,.5);
  border-top: 1px solid rgba(255,255,255,.1);
}

/* Main content */
.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 6px; }
.topbar-title { font-weight: 600; font-size: 1rem; color: var(--gray-900); }
.topbar-user  { font-size: .86rem; color: var(--gray-600); }
.topbar-user a { color: var(--blue-mid); margin-left: 12px; }

/* Topbar hamburger — standard location used by every web app.
   Kept in the topbar so it never overlaps the thumbnail strip below it. */
.topbar-hamburger {
  background: none;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--gray-600);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--gray-200); color: var(--gray-900); }

.page-body { padding: 28px; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-title   { font-size: 1.45rem; font-weight: 700; color: var(--blue-dark); }
.page-subtitle{ font-size: .88rem; color: var(--gray-600); margin-top: 2px; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-200);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--blue-dark); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.93); transform: translateY(-1px); text-decoration: none; }
.btn:active{ transform: translateY(0); }
.btn-primary  { background: var(--brand-gradient); color: var(--white);
                box-shadow: 0 2px 8px rgba(91,95,233,.28); }
.btn-dark     { background: var(--blue-dark); color: var(--white); }
.btn-success  { background: var(--green);     color: var(--white); }
.btn-danger   { background: var(--red);       color: var(--white); }
.btn-outline  { background: transparent; color: var(--brand-indigo); border: 1.5px solid var(--brand-indigo); }
.btn-ghost    { background: var(--gray-200);  color: var(--gray-600); }
.btn-teal     { background: var(--brand-teal); color: var(--white); }
.btn-reject   { background: var(--red);  color: var(--white); }
.btn-draft    { background: var(--brand-teal); color: var(--white); }
/* Equal-width primary action buttons on the preview action bar */
#action-bar .btn-lg { min-width: 200px; justify-content: center; }
.btn-sm       { padding: 5px 12px; font-size: .82rem; }
.btn-lg       { padding: 12px 28px; font-size: 1rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-weight: 500; margin-bottom: 6px; color: var(--gray-900); font-size: .9rem; }
.form-input, select.form-input, textarea.form-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .92rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--blue-mid); }
.form-input.error { border-color: #dc3545; }
.form-hint { font-size: .8rem; color: var(--gray-600); margin-top: 4px; }

/* ── Alerts / Flash ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--green-light);  color: var(--green); }
.alert-error   { background: var(--red-light);    color: var(--red); }
.alert-warning { background: var(--amber-light);  color: var(--amber); }
.alert-info    { background: var(--blue-bg);      color: var(--blue-dark); }

/* ── Duplicate Detection Banner ──────────────────────────── */
.duplicate-banner {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  background: #FFFBF0;
  border: 1px solid #F0AD00;
  border-left: 4px solid #F0AD00;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.duplicate-banner-icon {
  font-size: 1.5rem;
  line-height: 1;
  padding-top: 1px;
  color: #856404;
  flex-shrink: 0;
}
.duplicate-banner-content { flex: 1; }
.duplicate-banner-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
  line-height: 1.45;
}
.duplicate-banner-heading {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #856404;
  margin-bottom: 4px;
}
.duplicate-banner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: .88rem;
  color: var(--gray-900);
  margin-bottom: 12px;
}
.duplicate-banner-sub {
  font-size: .88rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.duplicate-banner-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Credit Estimate Box ─────────────────────────────────── */
.estimate-box {
  background: var(--blue-bg);
  border: 1.5px solid var(--blue-pale);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.estimate-box h3 { color: var(--blue-dark); margin-bottom: 12px; font-size: 1rem; }
.estimate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.estimate-stat { text-align: center; }
.estimate-stat .num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--blue-dark);
  line-height: 1;
}
.estimate-stat .lbl { font-size: .78rem; color: var(--gray-600); margin-top: 2px; }
.estimate-stat.highlight .num { color: #d97706; }

/* ── Drop Zone ───────────────────────────────────────────── */
.drop-zone {
  border: 2.5px dashed var(--blue-pale);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--gray-100);
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--blue-mid);
  background: var(--blue-bg);
}
.drop-zone .icon   { font-size: 2.4rem; margin-bottom: 10px; }
.drop-zone p       { color: var(--gray-600); font-size: .92rem; }
.drop-zone .browse { color: var(--blue-mid); font-weight: 600; cursor: pointer; }

/* ── Data Table ──────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
  background: var(--blue-dark);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
.data-table tr:nth-child(even) td { background: var(--gray-100); }
.data-table tr:hover td { background: var(--blue-bg); }
.data-table input.form-input {
  padding: 4px 8px;
  font-size: .86rem;
  margin: 0;
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-ocr      { background: var(--green-light);  color: var(--green); }
.badge-vision   { background: var(--amber-light);  color: var(--amber); }
.badge-mock     { background: var(--gray-200);     color: var(--gray-600); }
.badge-unmatched{ background: var(--red-light);    color: var(--red); }
.badge-doctype  { background: var(--blue-bg);      color: var(--blue-dark);
                  font-size: .72rem; letter-spacing: .02em; }

/* ── Tier indicator ──────────────────────────────────────── */
.tier-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.tier-free   { background: var(--green-light); color: var(--green); }
.tier-ai     { background: var(--amber-light); color: var(--amber); }
.tier-mock   { background: var(--gray-200);    color: var(--gray-600); }

/* ── Splash / loading screen ─────────────────────────────── */
.ds-splash {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ds-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  user-select: none;
}
.ds-splash-by {
  font-size: .82rem;
  color: var(--gray-400);
  margin: 0;
}

/* ── Brain loader (upload / processing) ──────────────────── */
/* The DocuSense brain logo with a breathing glow + a shine streak that sweeps
   across it. The shine is confined to the brain shape via a CSS mask so it never
   appears in the transparent background around the logo. */
.brain-loader {
  position: relative;
  width: 110px;
  height: 110px;
  animation: brainBreathe 2.6s ease-in-out infinite;
  filter: drop-shadow(0 0 0 transparent);
}
.brain-loader img {
  width: 100%;
  height: 100%;
  display: block;
  animation: brainGlow 2.6s ease-in-out infinite;
}
/* Shine sweep — a moving white band, masked to the brain silhouette */
.brain-loader::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
              transparent 38%, rgba(255,255,255,.85) 50%, transparent 62%);
  background-size: 250% 250%;
  -webkit-mask: url('../images/fav%20icon.png') center / contain no-repeat;
          mask: url('../images/fav%20icon.png') center / contain no-repeat;
  mix-blend-mode: screen;
  animation: brainShine 2.4s linear infinite;
  pointer-events: none;
}
@keyframes brainBreathe {
  0%, 100% { transform: scale(1);    }
  50%      { transform: scale(1.06); }
}
@keyframes brainGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(91,95,233,.55)); }
  50%      { filter: drop-shadow(0 0 16px rgba(20,184,166,.75)); }
}
@keyframes brainShine {
  0%   { background-position: 180% 0; }
  100% { background-position: -80% 0; }
}

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: linear-gradient(135deg, #4338CA 0%, #6D28D9 55%, #14B8A6 140%);
}
.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-img {
  max-width: 240px;
  height: auto;
  display: block;
  margin: 0 auto 8px;
}
.login-logo .tagline {
  font-size: .8rem;
  color: var(--gray-600);
  margin-top: 4px;
}
.login-manifest-footer {
  padding-bottom: 8px;
  opacity: .85;
}

/* ── Confidence badges ───────────────────────────────────────── */
.conf-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
  cursor: help;
  white-space: nowrap;
}
.conf-locked    { background: var(--green-light);  color: var(--green); }
.conf-uncertain { background: var(--amber-light);  color: var(--amber); }
.conf-disputed  { background: var(--red-light);    color: var(--red); }
.conf-empty     { background: var(--gray-200);     color: var(--gray-600); }

.field-uncertain { background: #fffbeb !important; }
.field-disputed  { background: #fff5f5 !important; }
.field-uncertain .form-input { border-color: var(--amber) !important; }
.field-disputed  .form-input { border-color: #dc3545 !important; }
/* Once the user verifies (ticks) a flagged field/row, the amber normalises to green */
.field-verified  { background: #f0fdf4 !important; }
.field-verified .form-input, .field-verified .sku-input { border-color: var(--green) !important; }

.field-saved {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 2px rgba(30,126,52,.18) !important;
  transition: border-color .3s, box-shadow .3s;
}

.header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}
.hfield       { padding: 8px; border-radius: var(--radius); }
.hfield-label {
  font-size: .82rem; font-weight: 500; color: var(--gray-600);
  margin-bottom: 4px; display: flex; align-items: center; gap: 2px;
}

.extraction-summary {
  display: flex; gap: 24px; align-items: center;
  flex-wrap: wrap; padding: 16px 24px; margin-bottom: 20px;
}
.summary-stat { text-align: center; }
.summary-num  { font-size: 1.5rem; font-weight: 700; color: var(--blue-dark); line-height: 1; }
.summary-lbl  { font-size: .72rem; color: var(--gray-600); margin-top: 2px; }

.field-flag { font-size: .70rem; color: var(--amber); font-weight: 600; margin-top: 2px; }

/* ── SKU Bridge ──────────────────────────────────────────── */
.sku-cell-td    { min-width: 190px; }
.sku-cell       { display: flex; flex-direction: column; gap: 4px; }
.sku-row        { display: flex; align-items: center; gap: 4px; }
.sku-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.sku-l1 { background: var(--green-light);  color: var(--green); }
.sku-l2 { background: var(--amber-light);  color: var(--amber); }
.sku-l3 { background: var(--gray-200);     color: var(--gray-600); }
.sku-input { flex: 1; min-width: 120px; }
.sku-confirm-label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: .78rem;
  color: var(--gray-600);
  flex-shrink: 0;
  white-space: nowrap;
}
/* SKU-confirm checkbox: indigo accent so it is visually distinct from the
   amber row-verify checkbox (the two do different jobs — see preview legend). */
.sku-confirm-label input[type=checkbox] {
  cursor: pointer;
  width: 15px; height: 15px;
  accent-color: var(--brand-indigo);
}
.sku-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.sku-suggestion-btn {
  background: var(--blue-bg);
  border: 1px solid var(--blue-pale);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: .72rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--blue-dark);
  transition: background .12s;
}
.sku-suggestion-btn:hover { background: var(--blue-pale); }
.sku-score { color: var(--gray-600); margin-left: 2px; }

/* Step 3 — SKU action row (Copy extracted name / Not in catalog) */
.sku-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.sku-action-btn {
  font-size: .72rem;
  padding: 2px 7px;
  border: 1px solid var(--gray-400);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  color: var(--gray-600);
  white-space: nowrap;
}
.sku-action-btn:hover { background: var(--gray-200); color: var(--gray-900); }
.sku-action-btn.sku-skip  { color: var(--gray-500); }
.sku-action-btn.sku-copy  { color: var(--blue-mid);  border-color: var(--blue-pale); }
.sku-skipped-label {
  font-size: .72rem;
  color: var(--gray-500);
  font-style: italic;
}

/* ── Admin debug panel ───────────────────────────────────── */
.debug-panel {
  border: 1px dashed var(--gray-400);
  border-radius: var(--radius);
  margin-top: 16px;
  background: var(--white);
}
.debug-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--gray-100);
  border-radius: var(--radius);
  user-select: none;
}
.debug-header:hover { background: var(--gray-200); }
.debug-title  { font-size: .82rem; font-weight: 600; color: var(--gray-600); }
.debug-meta   { font-size: .75rem; color: var(--gray-400); flex: 1; }
.debug-arrow  { font-size: .75rem; color: var(--gray-400); }
.debug-section-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.debug-li-row { font-size: .82rem; color: var(--gray-900); }
.debug-badge  {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: .70rem;
  font-weight: 700;
}
.debug-locked    { background: var(--green-light);  color: var(--green); }
.debug-uncertain { background: var(--amber-light);  color: var(--amber); }
.debug-disputed  { background: var(--red-light);    color: var(--red); }
.debug-empty     { background: var(--gray-200);     color: var(--gray-600); }

/* ── Invoice capsule selector ────────────────────────────── */
.invoice-capsules {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.invoice-capsule {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 16px;
  border-radius: 24px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-100);
  text-decoration: none;
  min-width: 110px;
  transition: border-color .15s, background .15s;
}
.invoice-capsule:hover { border-color: var(--blue-mid); background: var(--blue-bg); text-decoration: none; }
.invoice-capsule.active { border-color: var(--blue-mid); background: var(--blue-bg); }
.invoice-capsule-num  { font-size: .9rem; font-weight: 600; color: var(--blue-dark); }
.invoice-capsule-name { font-size: .75rem; color: var(--gray-600); }

/* ── Workspace selector ──────────────────────────────────── */
.workspace-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.workspace-header {
  margin-bottom: 20px;
  text-align: center;
}
.workspace-greeting {
  font-size: .88rem;
  color: var(--gray-600);
  font-weight: 500;
  margin-bottom: 4px;
}
.workspace-subtext {
  font-size: .82rem;
  color: var(--gray-400);
}
.workspace-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.workspace-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .15s, background .15s;
}
.workspace-item:hover:not(:disabled) {
  border-color: var(--blue-mid);
  background: var(--blue-bg);
}
.workspace-item:disabled { opacity: .6; cursor: default; }
.workspace-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--blue-dark);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.workspace-info { flex: 1; }
.workspace-name { font-weight: 600; color: var(--gray-900); font-size: .92rem; }
.workspace-role { font-size: .78rem; color: var(--gray-600); margin-top: 1px; }
.workspace-arrow { color: var(--gray-400); font-size: 1.3rem; }

/* ── Login Google button ─────────────────────────────────── */
.btn-google {
  background: var(--white);
  color: var(--gray-900);
  border: 1.5px solid var(--gray-200);
  gap: 10px;
}
.btn-google:hover { background: var(--gray-100); filter: none; }

/* ── Login divider ───────────────────────────────────────── */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--gray-400);
  font-size: .8rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ── Three-panel Preview layout ─────────────────────────── */

/* Shell fills the page-body (which is forced to zero-padding on preview page) */
.preview-shell {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* LEFT: thumbnail strip — absolutely fixed, never grows or shrinks.
   Dark SLATE (not indigo) so it clearly contrasts the indigo-purple sidebar to
   its left — two distinct dark panels, never confused as one. */
.preview-left {
  flex: 0 0 7%;
  max-width: 7%;
  min-width: 60px;
  padding-left: 14px;
  background: var(--panel-slate);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 2px solid var(--brand-teal);   /* teal seam separates the two panels */
}
.thumb-scroll-btn {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.55);
  text-align: center;
  padding: 5px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: .76rem;
  user-select: none;
  transition: background .15s;
  border: none;
  width: 100%;
}
.thumb-scroll-btn:hover { background: rgba(255,255,255,.14); }
.thumb-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.thumb-card {
  background: rgba(255,255,255,.06);
  border-radius: 5px;
  padding: 5px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .15s, border-color .15s;
  position: relative;
  flex-shrink: 0;
}
.thumb-card:hover { background: rgba(255,255,255,.11); }
.thumb-card.thumb-active {
  border-color: rgba(255,255,255,.35);
  background: rgba(255,255,255,.11);
}
/* 3-state thumbnail colours */
.thumb-card.thumb-state-review   { border-color: var(--amber); }
.thumb-card.thumb-state-ready    { border-color: var(--green); }
.thumb-card.thumb-state-rejected { border-color: var(--red); opacity: .65; }
.thumb-card.thumb-active.thumb-state-review   { box-shadow: 0 0 0 2px rgba(180,83,9,.4); }
.thumb-card.thumb-active.thumb-state-ready    { box-shadow: 0 0 0 2px rgba(22,163,74,.4); }
.thumb-card.thumb-active.thumb-state-rejected { box-shadow: 0 0 0 2px rgba(220,38,38,.4); }
/* State dot — top-right corner of each thumbnail */
.thumb-state-dot {
  position: absolute; top: 7px; right: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.7);
}
.thumb-state-review   .thumb-state-dot { background: var(--amber); }
.thumb-state-ready    .thumb-state-dot { background: var(--green); }
.thumb-state-rejected .thumb-state-dot { background: var(--red); }
.thumb-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  background: var(--white);
  min-height: 60px;
}
.thumb-info { margin-top: 4px; padding: 0 2px; }
.thumb-supplier {
  font-size: .70rem;
  color: rgba(255,255,255,.82);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb-inv {
  font-size: .66rem;
  color: rgba(255,255,255,.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb-active-arrow {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,.7);
  font-size: .68rem;
  pointer-events: none;
}

/* MIDDLE: PDF viewer — absolutely fixed outer shell.
   All three inner components (controls, viewer, drop strip) are absolutely
   positioned so the canvas growing inside .pdf-viewer can NEVER affect any
   sibling panel or the outer flex layout. */
.preview-mid {
  flex: 0 0 23%;
  max-width: 23%;
  min-width: 0;
  position: relative;   /* positioning context for all three inner components */
  background: #d8d8d8;
  border-right: 1px solid var(--gray-200);
  overflow: hidden;     /* hard clip — nothing escapes this box */
}

/* Controls toolbar: pinned to top of the mid panel */
/* (height: 34px already declared in the toolbar section below) */

/* PDF canvas viewport: fills the space between controls (34px) and drop strip (120px).
   Absolutely positioned = canvas size changes are completely isolated here. */
.pdf-viewer {
  position: absolute;
  top: 34px;  /* pdf-controls height */
  left: 0; right: 0; bottom: 0;
  overflow: auto;
  padding: 14px;
  scrollbar-width: thin;
  cursor: grab;
  user-select: none;
}
.pdf-viewer.panning { cursor: grabbing; }
.pdf-viewer canvas {
  display: block;
  margin: 0 auto;
  box-shadow: 0 3px 16px rgba(0,0,0,.28);
  border-radius: 2px;
  background: white;
}
.pdf-no-preview {
  color: var(--gray-600);
  font-size: .86rem;
  text-align: center;
  padding: 40px 20px;
}

/* Drop strip: pinned to bottom of the mid panel */
.pdf-drop-strip {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 120px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pdf-drop-label {
  font-size: .76rem;
  color: var(--gray-600);
  font-weight: 500;
}
.pdf-drop-boxes {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.pdf-drop-box {
  min-width: 56px;
  height: 62px;
  border: 1.5px dashed var(--gray-400);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .70rem;
  color: var(--gray-400);
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.pdf-drop-box.drag-over {
  border-color: var(--blue-mid);
  background: var(--blue-bg);
  color: var(--blue-dark);
}

/* RIGHT: invoice data — absolutely fixed, never grows or shrinks */
.preview-right {
  flex: 0 0 70%;
  max-width: 70%;
  overflow-y: auto;
  overflow-x: hidden;   /* line-items table overflow stays inside .scroll-x, never page-level */
  padding: 14px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

/* header-grid-3col canonical rule is defined below; no duplicate needed here */
.preview-right .hfield {
  padding: 4px;
}
.preview-right .hfield-label {
  font-size: .72rem;
  margin-bottom: 2px;
}
.preview-right .header-grid-3col .form-input {
  padding: 4px 8px;
  font-size: .84rem;
}

/* Compact line-items table — reduces cell breathing room so table fits without scrolling */
.preview-right .data-table td,
.preview-right .data-table th {
  padding: 5px 7px;
}
.preview-right .data-table input.form-input {
  padding: 3px 5px;
  font-size: .80rem;
}

/* Compact summary bar */
.preview-summary-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 14px;
  background: var(--blue-bg);
  border-radius: var(--radius);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.preview-summary-stat { display: flex; align-items: baseline; gap: 4px; }
.preview-summary-num  { font-size: 1.05rem; font-weight: 700; color: var(--blue-dark); line-height: 1; }
.preview-summary-lbl  { font-size: .70rem; color: var(--gray-600); }

/* Needs attention block */
.attention-block {
  border: 1px solid #d97706;
  border-radius: var(--radius);
  background: var(--amber-light);
  flex-shrink: 0;
}
.attention-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
}

/* Preview panel cards (compact variant of .card) */
.preview-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  flex-shrink: 0;
}
.preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}
.preview-card-title { font-size: .94rem; font-weight: 600; color: var(--blue-dark); }

/* Header grid — 2fr:1fr:1fr means Supplier Name column is 2× wider than the other two.
   Row 1: Supplier Name (50%) | Invoice Number (25%) | Invoice Date (25%)
   Row 2: GSTIN Supplier (50%) | GSTIN Buyer (25%) | Place of Supply (25%)
   Row 3: Grand Total (50%) | Total GST (25%) | Subtotal (25%)
   Row 4: Custom Label (50%) | Custom Value span-2 (50%) */
.header-grid-3col {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
}
.span-2 { grid-column: span 2; }

/* ── Sidebar collapse ────────────────────────────────────── */

/* Smooth transition for collapse/expand */
.sidebar      { transition: width .18s ease; }
.main-content { transition: margin-left .18s ease; }

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.sidebar-hamburger {
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: background .15s, color .15s;
}
.sidebar-hamburger:hover { background: rgba(255,255,255,.12); color: white; }

/* Collapsed state — 50px icon-only strip */
.sidebar-collapsed .sidebar         { width: 56px; }
.sidebar-collapsed .main-content    { margin-left: 56px; }
/* Keep the brain logo visible when collapsed — hide only the wordmark */
.sidebar-collapsed .sidebar-brand        { padding: 14px 0 12px; }
.sidebar-collapsed .sidebar-brand-link   { justify-content: center; gap: 0; }
.sidebar-collapsed .sidebar-wordmark     { display: none; }
.sidebar-collapsed .sidebar-nav-label    { display: none; }
.sidebar-collapsed .sidebar-footer-text  { display: none; }
.sidebar-collapsed .sidebar-nav a        { justify-content: center; padding: 12px 0; }
/* SETTINGS group label would overflow at 56px — replace with a thin divider */
.sidebar-collapsed .sidebar-nav-group-label {
  font-size: 0; padding: 8px 0; margin: 4px 12px 2px;
  border-top: 1px solid rgba(255,255,255,.18);
}
/* Centre the sub-nav icons (they normally have padding-left:32px) */
.sidebar-collapsed .sidebar-nav-sub { padding-left: 0 !important; justify-content: center; }
.sidebar-collapsed .sidebar-footer  { align-items: center; justify-content: center; padding: 12px 0; }
.sidebar-collapsed .sidebar-hamburger { width: 100%; text-align: center; }

/* ── PDF viewer controls toolbar — pinned to top of .preview-mid ─── */
.pdf-controls {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  height: 34px;
}
.pdf-ctrl-btn {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: .92rem;
  line-height: 1.2;
  color: var(--gray-900);
  transition: background .12s, border-color .12s;
  min-width: 26px;
  text-align: center;
}
.pdf-ctrl-btn:hover { background: var(--blue-bg); border-color: var(--blue-light); color: var(--blue-dark); }
.pdf-ctrl-sep   { width: 1px; height: 16px; background: var(--gray-200); margin: 0 2px; flex-shrink: 0; }
.pdf-zoom-label {
  font-size: .76rem;
  color: var(--gray-600);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

/* ── Utility ─────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.text-muted   { color: var(--gray-600); }
.text-small   { font-size: .82rem; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-bold    { font-weight: 700; }
.w-full       { width: 100%; }
.scroll-x     { overflow-x: auto; }
