/* ══════════════════════════════════════════════════════════════════════════
   QC Review — Star Nutrasciences
   Design system: shared with the Procurement portal — slate neutrals, one
   blue accent (#2563eb), blueprint grid background, hairline borders.
   Color is reserved for status (green/amber/red); everything else is neutral.
══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Backgrounds — same tokens as the Procurement portal */
  --bg:        #f8fafc;
  --surface:   #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;

  /* Borders */
  --border:       rgba(226, 232, 240, 0.8);
  --border-mid:   rgba(203, 213, 225, 0.9);
  --border-light: #eef2f6;

  /* Text */
  --text:       #0f172a;
  --text-muted: #475569;
  --text-dim:   #94a3b8;

  /* Accent — blue, shared across portals (matches inline blues in app.js) */
  --accent:        #2563eb;
  --accent-soft:   rgba(37, 99, 235, 0.06);
  --accent-border: rgba(37, 99, 235, 0.15);
  --accent-hover:  #1d4ed8;
  --accent-light:  #eff6ff;

  /* Status — green */
  --green:        #16a34a;
  --green-soft:   #f0fdf4;
  --green-border: #cdeed9;
  --green-text:   #15803d;

  /* Status — amber */
  --amber:        #d97706;
  --amber-soft:   #fffbeb;
  --amber-border: #f4e4b5;
  --amber-text:   #92400e;

  /* Status — red */
  --red:        #dc2626;
  --red-soft:   #fef2f2;
  --red-border: #f6d5d5;
  --red-text:   #b91c1c;

  /* Secondary hues (kept for JS-generated chips, used sparingly) */
  --purple:        #7c3aed;
  --purple-soft:   #f5f3ff;
  --purple-border: #e4dcf7;
  --purple-text:   #6d28d9;

  --teal:        #0891b2;
  --teal-soft:   #ecfeff;
  --teal-border: #c8eef5;
  --teal-text:   #0e7490;

  --orange:        #ea580c;
  --orange-soft:   #fff7ed;
  --orange-border: #f7ddc3;
  --orange-text:   #c2410c;

  /* Radius, shadow, timing */
  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow:    0 2px 8px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 2px 8px rgba(15, 23, 42, .05);
  --t:         160ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Subtle blueprint grid — shared visual signature with the Procurement portal */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(37,99,235,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none; z-index: 0;
}

.mono, .meta-mono {
  font-family: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════
   AUTH OVERLAY
══════════════════════════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-overlay.hidden { display: none; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
}

.auth-logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1d4ed8, #58a6ff);
  box-shadow: 0 0 18px rgba(88, 166, 255, .35);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-app-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}
.auth-app-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-bottom: 26px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.auth-input {
  padding: 10px 13px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: inherit;
  width: 100%;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--t), box-shadow var(--t);
}
.auth-input::placeholder { color: var(--text-dim); }
.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
  font-size: .76rem;
  color: var(--red);
  min-height: 1em;
}

.auth-btn {
  padding: 11px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t);
}
.auth-btn:hover { background: #1e293b; }

/* ══════════════════════════════════════════════════════════════════════════
   APP SHELL / HEADER
══════════════════════════════════════════════════════════════════════════ */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-shell.hidden { display: none; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1d4ed8, #58a6ff);
  box-shadow: 0 0 14px rgba(88, 166, 255, .35);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}

.header-title {
  font-size: .93rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.header-sub {
  font-size: .7rem;
  color: var(--text-dim);
  margin-top: 1px;
}

#user-button { display: flex; align-items: center; }

.stat-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  font-size: .74rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
}
.stat-pill #totalPendingCount { color: var(--text); font-weight: 700; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.stat-dot.amber {
  background: var(--amber);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .3; }
}

.btn-refresh {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
}
.btn-refresh:hover {
  color: var(--text);
  border-color: var(--border-mid);
  background: var(--surface-2);
}
.btn-refresh.spinning svg { animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════
   TAB BAR
══════════════════════════════════════════════════════════════════════════ */
.tab-bar {
  display: flex;
  align-items: stretch;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;
  z-index: 10;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-divider {
  width: 1px;
  background: var(--border);
  margin: 13px 10px;
  flex-shrink: 0;
}

.tab {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: .82rem; font-weight: 500;
  padding: 0 12px;
  height: 46px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t);
  font-family: inherit; white-space: nowrap;
}

.tab-icon { opacity: .55; transition: opacity var(--t); }
.tab:hover { color: var(--text); }
.tab:hover .tab-icon { opacity: .85; }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab.active .tab-icon { opacity: 1; color: var(--accent); }
.tab.tab-secondary { font-size: .8rem; }

.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-light); color: var(--accent);
  border: 1px solid var(--accent-border);
  font-size: .62rem; font-weight: 700;
  min-width: 17px; height: 17px;
  border-radius: 999px; padding: 0 5px;
}
.tab-badge.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN LAYOUT / TOOLBAR
══════════════════════════════════════════════════════════════════════════ */
.main {
  padding: 26px 28px 48px;
  max-width: 1480px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}

.panel { display: block; }
.panel.hidden { display: none; }

.panel-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.toolbar-left  { display: flex; align-items: baseline; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.panel-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.015em;
}
.panel-count {
  font-size: .74rem;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

/* Filter pills — segmented control */
.filter-pills {
  display: flex; gap: 2px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.filter-pill {
  background: none; border: none;
  color: var(--text-muted);
  font-size: .74rem; font-weight: 500;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--t);
  font-family: inherit; white-space: nowrap;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Search */
.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  transition: border-color var(--t), box-shadow var(--t);
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box svg { color: var(--text-dim); flex-shrink: 0; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: .8rem;
  font-family: inherit; width: 170px;
}
.search-box input::placeholder { color: var(--text-dim); }

/* ══════════════════════════════════════════════════════════════════════════
   STATE MESSAGES
══════════════════════════════════════════════════════════════════════════ */
.state-message {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px;
  min-height: 240px;
  color: var(--text-muted);
  font-size: .88rem;
  background: var(--surface);
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius-lg);
}
.state-message.hidden { display: none; }

.empty-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.green-icon {
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  color: var(--green);
}

.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ══════════════════════════════════════════════════════════════════════════
   APPROVAL LIST — one calm row per item, details on demand
══════════════════════════════════════════════════════════════════════════ */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.batch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: row; align-items: stretch;
  transition: border-color var(--t), box-shadow var(--t);
  animation: cardIn .2s ease both;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.batch-card:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow);
}

/* Vendor rows dropped into the approvals list get the same card chrome */
.card-grid > .vendor-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  padding: 14px 20px 14px 23px;
  animation: cardIn .2s ease both;
}
.card-grid > .vendor-row:hover {
  background: var(--surface);
  border-color: var(--border-mid);
  box-shadow: var(--shadow);
}

/* Left rail — type indicator (JS toggles card-type-* / card-* variants) */
.batch-card::before,
.card-grid > .vendor-row::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 0; width: 3px;
  background: transparent;
}
.card-type-batch::before,
.batch-card.card-bpr::before         { background: var(--accent); }
.card-type-vendor::before,
.batch-card.card-vendor::before      { background: var(--teal); }
.card-type-formulation::before,
.batch-card.card-formulation::before { background: var(--amber); }
.card-type-bpr::before,
.batch-card.card-product::before     { background: var(--purple); }
.card-type-rm::before                { background: var(--green); }
.card-type-mmr::before               { background: var(--orange); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.batch-card.removing { animation: cardOut .25s ease forwards; }
@keyframes cardOut {
  to { opacity: 0; transform: scale(.98); }
}

.card-body {
  padding: 13px 20px 13px 23px;
  display: flex; flex-direction: row; flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px; flex: 1;
  min-width: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  /* fixed width so the facts column lines up across all rows */
  flex: 0 0 280px;
  min-width: 0;
}
.card-title-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-item-name  {
  font-size: .92rem; font-weight: 650;
  color: var(--text); line-height: 1.35;
  letter-spacing: -.01em;
}
.card-lot {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .7rem; color: var(--text-dim); margin-top: 1px;
}

/* Category chips — one quiet neutral style; color no longer encodes category */
.card-category-chip,
.chip-raw, .chip-herb, .chip-vitamin, .chip-mineral, .chip-oil,
.chip-packaging, .chip-default, .chip-excipient, .chip-active,
.chip-sweetener, .chip-flavor, .chip-acid, .chip-hydrocolloid, .chip-color-cat {
  display: inline-flex; align-items: center;
  font-size: .64rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; margin-top: 4px;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-muted);
  width: fit-content;
}

/* Status badges — the only colorful element in a card header */
.qc-badge {
  font-size: .62rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; border: 1px solid;
  white-space: nowrap; flex-shrink: 0; letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-pending  { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-text); }
.badge-approved { background: var(--green-soft);  border-color: var(--green-border);  color: var(--green-text); }
.badge-rejected { background: var(--red-soft);    border-color: var(--red-border);    color: var(--red-text); }
.badge-product  { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple-text); }
.badge-fm       { background: var(--amber-soft);  border-color: var(--amber-border);  color: var(--amber-text); }
.badge-bpr      { background: var(--teal-soft);   border-color: var(--teal-border);   color: var(--teal-text); }

/* Meta — inline facts, no box */
.card-meta {
  display: flex; flex-wrap: wrap;
  gap: 4px 26px;
  padding: 0;
  border: none;
  flex: 1 1 340px;
  min-width: 0;
}
.meta-item   { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.meta-label  {
  font-size: .62rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.meta-value  {
  font-size: .84rem; font-weight: 550; color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
}
.meta-mono   { font-size: .76rem; }

/* COA strip — compact pill in list rows */
.coa-strip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; border: 1px solid;
  flex: 0 0 auto;
  white-space: nowrap;
}
.coa-strip.coa-ok   { background: var(--green-soft); border-color: var(--green-border); color: var(--green-text); }
.coa-strip.coa-miss { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber-text); }
.coa-strip.coa-no   { background: var(--surface-2);  border-color: var(--border);       color: var(--text-muted); }

/* Check pills */
.checks { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; }
.check-pill {
  font-size: .7rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; border: 1px solid;
  white-space: nowrap;
}
.check-pass { background: var(--green-soft); border-color: var(--green-border); color: var(--green-text); }
.check-fail { background: var(--red-soft);   border-color: var(--red-border);   color: var(--red-text); }
.check-na   { background: var(--surface-2);  border-color: var(--border);       color: var(--text-dim); }

/* Notes — one quiet truncated line in list rows */
.card-notes {
  font-size: .76rem; color: var(--text-muted);
  padding: 5px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  line-height: 1.5;
  flex-basis: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Expanded detail area spans the full row */
.batch-detail-wrap, .bpr-detail-wrap { flex-basis: 100%; min-width: 0; }

/* Decision banner */
.card-status-banner {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600; line-height: 1.45;
  border: 1px solid;
  flex: 1 1 260px;
  min-width: 0;
}
.banner-approved { background: var(--green-soft); border-color: var(--green-border); color: var(--green-text); }
.banner-rejected { background: var(--red-soft);   border-color: var(--red-border);   color: var(--red-text); }
.card-status-banner svg { flex-shrink: 0; margin-top: 1px; }

/* Card actions — quiet pill buttons on the right edge of the row */
.card-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-left: 1px solid var(--border-light);
  flex: 0 0 auto;
}

.btn-outline-sm {
  padding: 7px 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: .76rem;
  font-weight: 550;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: all var(--t);
  white-space: nowrap;
  flex: 0 0 auto;
}
.btn-outline-sm:hover { background: var(--surface-2); color: var(--text); }

.btn-approve,
.btn-reject {
  flex: 0 0 auto;
  padding: 7px 15px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: .78rem; font-weight: 650;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--t);
  white-space: nowrap;
}

.btn-approve { color: var(--green-text); border-color: var(--green-border); }
.btn-approve:hover { background: var(--green); border-color: var(--green); color: #fff; }

.btn-reject { color: var(--red-text); border-color: var(--red-border); }
.btn-reject:hover { background: var(--red); border-color: var(--red); color: #fff; }

.btn-approve:disabled,
.btn-reject:disabled { opacity: .35; cursor: not-allowed; }

/* Type tag — sits above the item name inside the title block */
.apv-type-tag {
  font-size: .58rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid; white-space: nowrap; pointer-events: none;
  width: fit-content;
  margin-bottom: 3px;
  align-self: flex-start;
  flex: 0 0 auto;
}
/* If the tag lands as a direct child of the row (fallback path), pin it to the
   corner instead of letting the flex row stretch it into a blob */
.batch-card > .apv-type-tag,
.vendor-row > .apv-type-tag {
  position: absolute; top: 10px; right: 14px; margin: 0;
}
.apv-type-batch       { background: var(--accent-light); border-color: var(--accent-border); color: var(--accent); }
.apv-type-vendor      { background: var(--teal-soft);    border-color: var(--teal-border);   color: var(--teal-text); }
.apv-type-formulation { background: var(--amber-soft);   border-color: var(--amber-border);  color: var(--amber-text); }
.apv-type-bpr         { background: var(--purple-soft);  border-color: var(--purple-border); color: var(--purple-text); }
.apv-type-rm          { background: var(--green-soft);   border-color: var(--green-border);  color: var(--green-text); }
.apv-type-mmr         { background: var(--orange-soft);  border-color: var(--orange-border); color: var(--orange-text); }

/* ══════════════════════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(23, 27, 35, 0.4);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease both;
}
.modal-backdrop.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s cubic-bezier(.2,.8,.4,1) both;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-action-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; border: 1px solid;
}
.icon-approve { background: var(--green-soft); border-color: var(--green-border); color: var(--green-text); }
.icon-reject  { background: var(--red-soft);   border-color: var(--red-border);   color: var(--red-text); }

.modal-header-text { flex: 1; }
.modal-title { font-size: .96rem; font-weight: 700; color: var(--text); }
.modal-lot   {
  font-size: .72rem; color: var(--text-muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1rem; cursor: pointer; padding: 5px; border-radius: 6px;
  transition: color var(--t), background var(--t); line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--surface-3); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-reviewer-info {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .82rem; font-weight: 600; color: var(--text);
}
.modal-reviewer-info svg { flex-shrink: 0; color: var(--text-muted); }
.modal-reviewer-role {
  font-size: .7rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 500;
  margin-left: auto;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: .72rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.form-group.hidden { display: none; }
.optional { font-weight: 400; color: var(--text-dim); text-transform: none; letter-spacing: 0; }
.required { color: var(--red); }

.form-group textarea {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: .87rem;
  padding: 9px 12px; outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  resize: vertical;
  line-height: 1.5;
}
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-error {
  margin: 0 20px;
  background: var(--red-soft); border: 1px solid var(--red-border);
  color: var(--red-text); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: .8rem; font-weight: 600;
}
.modal-error.hidden { display: none; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.btn-cancel {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
  font-family: inherit; font-size: .84rem; font-weight: 600;
  padding: 9px 18px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--t);
}
.btn-cancel:hover { color: var(--text); background: var(--surface-2); }

.btn-confirm {
  border: none; font-family: inherit;
  font-size: .86rem; font-weight: 650;
  padding: 9px 24px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--t);
  color: #fff;
}
.btn-confirm.confirm-approve { background: var(--green); }
.btn-confirm.confirm-approve:hover { background: #15803d; }
.btn-confirm.confirm-reject { background: var(--red); }
.btn-confirm.confirm-reject:hover { background: #b91c1c; }
.btn-confirm:disabled { opacity: .45; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════════════
   HISTORY TABLE
══════════════════════════════════════════════════════════════════════════ */
.history-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.history-wrap.hidden { display: none; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px; text-align: left;
  font-size: .68rem; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border-light);
  font-size: .8rem; color: var(--text); vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

/* ══════════════════════════════════════════════════════════════════════════
   TOAST — inverted dark, bottom right
══════════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: #0f172a;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: .83rem; font-weight: 550; color: #f5f6f8;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.2,.8,.4,1) both;
  pointer-events: all; max-width: 340px;
}
.toast.out { animation: toastOut .22s ease forwards; }
.toast-icon {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; flex-shrink: 0;
}
.toast-success .toast-icon { background: rgba(34,197,94,.2); color: #4ade80; }
.toast-error   .toast-icon { background: rgba(239,68,68,.22); color: #f87171; }

@keyframes toastIn  {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px); }
}

/* ══════════════════════════════════════════════════════════════════════════
   VENDOR LIST
══════════════════════════════════════════════════════════════════════════ */
.vendor-list {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.vendor-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  animation: cardIn .2s ease both;
  transition: background var(--t);
}
.vendor-row:last-child { border-bottom: none; }
.vendor-row:hover { background: var(--surface-2); }

.vendor-row-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 20px;
  cursor: pointer; padding: 2px 0;
}
.vendor-row-main:hover .vendor-row-name { color: var(--accent); }

.vendor-row-info {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 200px;
}
.vendor-row-name { font-size: .88rem; font-weight: 650; color: var(--text); transition: color var(--t); }
.vendor-row-code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .68rem; color: var(--text-dim); }

.vendor-row-contact {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  font-size: .77rem; color: var(--text-muted);
}
.vendor-row-contact span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vendor-row-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.vendor-row-approve,
.vendor-row-reject {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 13px;
  border: 1px solid; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .75rem; font-weight: 600;
  cursor: pointer; transition: all var(--t); white-space: nowrap;
  background: var(--surface);
}
.vendor-row-approve { color: var(--green-text); border-color: var(--green-border); }
.vendor-row-approve:hover { background: var(--green); border-color: var(--green); color: #fff; }
.vendor-row-reject { color: var(--red-text); border-color: var(--red-border); }
.vendor-row-reject:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   VENDOR DETAIL DIALOG
══════════════════════════════════════════════════════════════════════════ */
.vdialog-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .15s ease both;
}
.vdialog-backdrop.hidden { display: none; }

.vdialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 700px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s cubic-bezier(.2,.8,.4,1) both;
  overflow: hidden;
}

.vdialog-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.vdialog-title-wrap { flex: 1; }
.vdialog-name { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.vdialog-code {
  display: flex; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .7rem; color: var(--text-muted); margin-top: 4px;
}

.vdialog-body { flex: 1; overflow-y: auto; }

.vdialog-section { padding: 18px 22px; border-bottom: 1px solid var(--border-light); }
.vdialog-section:last-child { border-bottom: none; }

.vdialog-section-label {
  font-size: .66rem; font-weight: 650;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px;
}

.vdialog-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.vdialog-meta-full { grid-column: 1 / -1; }
.vdialog-meta-item { display: flex; flex-direction: column; gap: 3px; }
.vdialog-meta-label { font-size: .62rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.vdialog-meta-value { font-size: .84rem; font-weight: 550; color: var(--text); }

.vdialog-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.vdialog-footer .btn-approve,
.vdialog-footer .btn-reject {
  flex: 0; padding: 9px 18px;
  border: 1px solid; border-radius: var(--radius-sm);
  font-size: .84rem;
  background: var(--surface);
}
.vdialog-footer .btn-approve { border-color: var(--green-border); color: var(--green-text); }
.vdialog-footer .btn-approve:hover { background: var(--green); border-color: var(--green); color: #fff; }
.vdialog-footer .btn-reject { border-color: var(--red-border); color: var(--red-text); }
.vdialog-footer .btn-reject:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* JS-generated sub-lists inside the dialog */
.cert-list { font-size: .8rem; }
.vendor-items-list { font-size: .8rem; color: var(--text-muted); }
.cert-cancel-btn { font-family: inherit; }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .header { padding: 10px 16px; height: auto; min-height: 58px; }
  .main { padding: 18px 16px 40px; }
  .toolbar-right { width: 100%; }
  .search-box { flex: 1 1 100%; }
  /* Rows stack: title/facts above, actions bar below */
  .batch-card { flex-direction: column; }
  .card-header { flex-basis: auto; min-width: 0; }
  .card-actions {
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding: 10px 20px;
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .header-right { gap: 8px; }
  .main { padding: 14px 12px 36px; }
  .tab-bar { padding-left: 12px; padding-right: 12px; }
  .panel-heading { font-size: 1.05rem; }
  .toolbar-right { flex-direction: column; align-items: stretch; }
  .filter-pills { width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .filter-pills::-webkit-scrollbar { display: none; }
  .search-box { width: 100%; }
  .history-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .history-wrap .table { min-width: 640px; }
  .modal { max-width: 100%; }
  .modal-backdrop { padding: 12px; }
  .vendor-row { flex-wrap: wrap; }
  .vendor-row-main { flex-direction: column; align-items: flex-start; gap: 6px; }
  .vendor-row-info { min-width: 0; }
  .vendor-row-end { width: 100%; justify-content: flex-end; }
  .vdialog-backdrop { padding: 12px; }
  .vdialog-meta-grid { grid-template-columns: 1fr; }
}
