/* ═══════════════════════════════════════════════════════════════════════════
   SHELL — Design tokens, reset, sidebar, topbar, search, layout, PDF drawer
   Modern Professional · trust-blue (#2563EB) · Swiss-inspired · 4px rhythm
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  --color-primary-light: #DBEAFE;
  --color-primary-subtle: #EFF6FF;
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted: #94A3B8;
  --color-success: #16A34A;
  --color-success-bg: #DCFCE7;
  --color-warning: #D97706;
  --color-warning-bg: #FEF3C7;
  --color-danger: #EF4444;
  --color-danger-bg: #FEE2E2;
  --color-purple: #9333EA;
  --color-purple-bg: #F3E8FF;
  --color-teal: #0891B2;
  --color-teal-bg: #CFFAFE;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Consolas', monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-modal: 0 24px 80px rgba(0,0,0,0.15);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --sidebar-width: 220px;
  --topbar-height: 52px;
}

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

body {
  font-family: var(--font-family);
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: 350;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-logo > i {
  font-size: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-secondary { padding: 4px 0 16px; }

.sidebar-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0 16px 6px;
  white-space: nowrap;
}

/* Sidebar tab overrides */
.sidebar .tab {
  border-radius: 6px;
  margin: 2px 10px;
  padding: 10px 10px;
  width: auto;
  justify-content: flex-start;
  gap: 10px;
  white-space: nowrap;
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.sidebar .tab i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--color-text-muted);
}
.sidebar .tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
  border-left-color: var(--color-border);
}
.sidebar .tab:hover i {
  color: var(--color-text-secondary);
}
.sidebar .tab.active {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  font-weight: 600;
  border-left-color: var(--color-primary);
}
.sidebar .tab.active i {
  color: var(--color-primary);
}

/* Sidebar backdrop (mobile/tablet overlay) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 349;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible { display: block; }

/* ── Main area (topbar + content) ──────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--color-surface);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), inset 0 -1px 0 rgba(37,99,235,0.08);
  position: sticky;
  top: 0;
  z-index: 300;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

/* ── Hamburger button (hidden on desktop) ──────────────────────────────── */
.hamburger-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 15px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.hamburger-btn:hover {
  background: var(--color-primary-subtle);
  border-color: #93C5FD;
  color: var(--color-primary);
}

/* ── Search ────────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 480px;
}
.search-wrap input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}
.search-wrap input:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.search-wrap input::placeholder { color: var(--color-text-muted); }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--color-text-muted);
  pointer-events: none;
}
.clear-btn {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: none;
}
.clear-btn:hover { color: var(--color-text); }

/* ── Global search overlay ─────────────────────────────────────────────── */
#global-search-overlay {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 1000;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 13px;
}
.gso-group {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}
.gso-group:last-child { border-bottom: none; }
.gso-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.gso-count {
  background: var(--color-border);
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
  line-height: 18px;
}
.gso-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.gso-row:hover { background: var(--color-hover); }
.gso-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gso-row-sub { color: var(--color-text-muted); white-space: nowrap; font-size: 12px; }
.gso-showall {
  padding: 5px 14px;
  font-size: 12px;
  color: var(--color-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
}
.gso-showall:hover { color: var(--color-primary-hover, #1d4ed8); }

/* ── Layout with drawer ────────────────────────────────────────────────── */
.layout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  align-items: flex-start;
}
.content-col { flex: 1; min-width: 0; }

/* ── PDF Drawer ────────────────────────────────────────────────────────── */
.pdf-drawer {
  width: 520px;
  flex-shrink: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: none;
  flex-direction: column;
  position: sticky;
  top: 64px;
  max-height: calc(100dvh - 76px);
  box-shadow: var(--shadow-lg);
}
.pdf-drawer.open { display: flex; }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--color-text);
  color: var(--color-surface);
  flex-shrink: 0;
}
.drawer-header span {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}
.drawer-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.drawer-close:hover { color: var(--color-surface); }

.drawer-download {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.drawer-download:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.35);
}
.pdf-drawer iframe {
  flex: 1;
  border: none;
  width: 100%;
  min-height: 600px;
}

/* ── PDF backdrop (all breakpoints, shown only at ≤1024px via JS) ──────── */
#pdf-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 499;
  backdrop-filter: blur(2px);
}
#pdf-backdrop.visible { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet & mobile breakpoints
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  .pdf-drawer { width: 340px; }
  .layout { padding: 10px 14px; gap: 10px; }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 500;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.15);
  }
  .main-area { margin-left: 0; }
  .hamburger-btn { display: flex; }

  .layout { padding: var(--space-3); gap: 0; }

  /* PDF Drawer → slide-in overlay from right */
  .pdf-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(480px, 92vw);
    border-radius: 0;
    z-index: 500;
    transform: translateX(110%);
    transition: transform 0.25s ease;
    display: flex;
    box-shadow: -4px 0 32px rgba(0,0,0,0.15);
  }
  .pdf-drawer.open { transform: translateX(0); }
}

@media (max-width: 640px) {
  .layout {
    padding: var(--space-2) var(--space-2) 0 var(--space-2);
    gap: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
  .topbar-actions { flex: 1; gap: 6px; }
  .search-wrap { flex: 1; min-width: 0; }
  .search-wrap input { width: 100% !important; box-sizing: border-box; }
}
/* ═══════════════════════════════════════════════════════════════════════════
   Tables Module — tables, cards, tabs, badges, action buttons, expand rows
   Design: Modern Professional (trust-blue #2563EB)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tabs ── */
.tab {
  padding: 7px 10px; cursor: pointer; font-weight: 500; font-size: 13px;
  color: var(--color-text-secondary); background: transparent; border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  user-select: none; transition: color var(--transition-fast), background var(--transition-fast);
  border: none; font-family: var(--font-family);
}
.tab:hover { color: #1e293b; background: var(--color-bg); }
.tab.active { color: var(--color-primary); background: var(--color-primary-subtle); font-weight: 600; }

/* ── Card ── */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden; margin-top: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition-normal);
}
.card:hover {
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}
.table-wrap { overflow-x: auto; }

/* ── Table ── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead { background: #f1f5f9; }
th {
  padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: #475569;
  border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
th.r { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--color-primary); }
th.sortable .si { margin-left: 4px; font-style: normal; opacity: 0.3; }
th.sortable.asc  .si::after { content: '▲'; opacity: 1; color: var(--color-primary); }
th.sortable.desc .si::after { content: '▼'; opacity: 1; color: var(--color-primary); }
th.sortable:not(.asc):not(.desc) .si::after { content: '⇅'; }
td { padding: 10px 12px; border-bottom: 1px solid var(--color-border-light); vertical-align: middle; }

tr.data-row:nth-child(even) td { background: #f8fafc; }
tr.data-row:hover td { background: #eef2ff; cursor: pointer; }
tr.data-row.expanded td { background: var(--color-primary-subtle); }

/* ── Column utilities ── */
.col-trunc {
  max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.col-sup { max-width: 120px; }
.col-date { width: 76px; white-space: nowrap; }
.sup-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desc-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
tr.data-row.expanded .desc-text { white-space: normal; overflow: visible; text-overflow: clip; }
.col-m-hide { display: revert; }
.col-lg-hide { display: revert; }

/* ── Action-buttons cell ── */
.td-actions { white-space: nowrap; }

/* ── Expand row ── */
.li-detail { display: none; }
tr.exp-row td { padding: 0; }
.exp-inner {
  padding: 16px 20px 20px 48px;
  background: var(--color-primary-subtle);
  border-bottom: 1px solid var(--color-primary-light);
}
.exp-section {
  margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 8px;
  align-items: flex-start; overflow: hidden;
}
.exp-section:last-child { margin-bottom: 0; }
.exp-section > :not(.field-group) { flex: 1 1 100%; min-width: 0; }
.exp-section > .field-group { flex: 0 1 auto; margin-bottom: 0; min-width: 0; }
.exp-section .table-wrap {
  width: 100%; margin-top: 4px; border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-md); background: var(--color-surface);
}
.exp-section table { font-size: 12.5px; }

.exp-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px; margin-top: 6px;
}
.exp-detail-item {
  background: var(--color-surface); border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-lg); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.exp-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: #93C5FD;
}
.exp-detail-item > span:last-child {
  font-size: 13px; color: #1e293b; word-break: break-all;
}
.exp-detail-item > .pdf-btn {
  align-self: flex-start; font-size: 12px; word-break: break-all;
  white-space: normal; text-align: left;
}

/* ── Field groups ── */
.field-groups-wrap {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
}
.field-groups-wrap > :not(.field-group) { flex: 0 0 100%; }
.field-groups-wrap > .field-group { flex: 1 1 auto; margin-bottom: 0; min-width: 0; }
.field-group { margin-bottom: 10px; }
.field-group-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 5px; padding-left: 10px;
}
.field-group-inner {
  border-left: 3px solid; border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 10px 10px 10px 11px;
}
.field-group-inner .exp-detail-grid {
  margin-top: 0; display: flex; flex-direction: column; gap: 0;
}
.field-group-inner .exp-detail-item {
  background: transparent; border: none;
  border-bottom: 1px solid rgba(0,0,0,0.05); border-radius: 0;
  padding: 5px 2px; flex-direction: row; align-items: baseline; gap: 8px;
}
.field-group-inner .exp-detail-item:last-child { border-bottom: none; }
.field-group-inner .exp-label {
  white-space: nowrap; flex-shrink: 0; font-size: 11px;
  color: var(--color-text-muted); text-transform: none; letter-spacing: 0; font-weight: 500;
}
.field-group-inner .exp-detail-item > span:last-child {
  font-size: 13px; color: #1e293b; word-break: break-word; flex: 1; min-width: 0;
}

/* Field group color accents */
.field-group--id  .field-group-label { color: #93C5FD; }
.field-group--id  .field-group-inner { border-color: #93C5FD; background: var(--color-primary-subtle); }
.field-group--sup .field-group-label { color: var(--color-text-secondary); }
.field-group--sup .field-group-inner { border-color: var(--color-text-muted); background: var(--color-bg); }
.field-group--fin .field-group-label { color: var(--color-success); }
.field-group--fin .field-group-inner { border-color: #4ade80; background: var(--color-success-bg); }
.field-group--sta .field-group-label { color: #b45309; }
.field-group--sta .field-group-inner { border-color: #fbbf24; background: var(--color-warning-bg); }
.field-group--sco .field-group-label { color: var(--color-purple); }
.field-group--sco .field-group-inner { border-color: #D8B4FE; background: var(--color-purple-bg); }

/* ── Amount columns ── */
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total { font-weight: 600; }
.fin-paid { color: var(--color-success); }
.fin-owed { color: var(--color-danger); }
.fin-zero { color: var(--color-text-secondary); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap; letter-spacing: 0.01em;
}
.badge-transfer      { background: var(--color-primary-light); color: var(--color-primary-hover); }
.badge-prepayment    { background: var(--color-warning-bg); color: #92400e; }
.badge-check         { background: #ede9fe; color: #5b21b6; }
.badge-check-pending { background: #fef3c7; color: #92400e; }
.badge-paid-off      { background: var(--color-success-bg); color: #166534; }
.badge-pending       { background: var(--color-warning-bg); color: #92400e; }

/* ── Sub-text ── */
.sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }

/* ── Mono ── */
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Arrow cell ── */
.arrow { width: 24px; color: #cbd5e1; font-size: 11px; user-select: none; }

/* ── Utility ── */
.text-center { text-align: center; }

/* ── Summary bar ── */
.summary {
  padding: 8px 18px; background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: 12px; color: var(--color-text-secondary);
  display: flex; gap: 0; align-items: stretch;
}
.summary strong { color: var(--color-text); font-weight: 600; }
.sum-block {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px 18px; border-right: 1px solid var(--color-border);
}
.sum-block:first-child { padding-left: 0; }
.sum-block:last-child  { border-right: none; }
.sum-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted); font-weight: 600; white-space: nowrap;
}
.sum-value {
  font-size: 13px; font-weight: 700; color: var(--color-text); white-space: nowrap;
}
.sum-value .sub-unit { font-size: 10px; font-weight: 500; color: var(--color-text-muted); margin-left: 2px; }
.sum-block.sum-paid  .sum-value { color: var(--color-success); }
.sum-block.sum-semi  .sum-value { color: #EA580C; }
.sum-block.sum-unpaid .sum-value { color: var(--color-warning); }

/* ── Payment status ── */
.pay-status { font-size: 15px; flex-shrink: 0; line-height: 1; }
.pay-paid     { color: var(--color-success); }
.pay-semi     { color: #EA580C; }
.pay-partial  { color: var(--color-purple); }
.pay-unpaid   { color: var(--color-warning); }
.pay-issue    { color: var(--color-warning); }

/* ── Filter pill ── */
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--color-warning); color: var(--color-warning);
  background: transparent; cursor: pointer; font-family: var(--font-family);
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
  white-space: nowrap; flex-shrink: 0;
}
.filter-pill:hover { background: var(--color-warning-bg); }
.filter-pill.active { background: var(--color-warning); color: white; border-color: var(--color-warning); }
.pill-count {
  background: var(--color-warning-bg); border-radius: 999px;
  padding: 1px 7px; font-size: 11px;
}
.filter-pill.active .pill-count { background: rgba(255,255,255,0.25); }

/* ── Selection bar ── */
.sel-bar {
  display: none; align-items: center; gap: 14px;
  padding: 9px 18px; background: var(--color-primary-subtle);
  border-bottom: 1px solid #BFDBFE;
  font-size: 13px; color: var(--color-primary-hover); font-weight: 500;
}
.sel-bar.visible { display: flex; }
.sel-cb {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary);
  margin: 0; flex-shrink: 0;
}
.sel-bar .sel-count { font-weight: 700; }
.sel-bar .sel-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-primary); color: white; border: none;
  border-radius: var(--radius-sm); padding: 6px 14px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; font-family: var(--font-family);
  transition: background var(--transition-fast);
}
.sel-bar .sel-download:hover { background: var(--color-primary-hover); }
.sel-bar .sel-download:disabled { background: #93C5FD; cursor: wait; }
.sel-bar .sel-delete {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-danger); color: white; border: none;
  border-radius: var(--radius-sm); padding: 6px 14px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; font-family: var(--font-family);
  transition: background var(--transition-fast);
}
.sel-bar .sel-delete:hover { background: #dc2626; }
.sel-bar .sel-delete:disabled { background: #fca5a5; cursor: wait; }
.sel-bar .sel-clear {
  background: none; border: none; color: #3B82F6; cursor: pointer;
  font-size: 12px; font-family: var(--font-family); text-decoration: underline;
  transition: color var(--transition-fast);
}
.sel-bar .sel-clear:hover { color: var(--color-primary-hover); }

/* ── Action buttons ── */

/* PDF button */
.pdf-btn {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 8px; color: var(--color-text-secondary);
  line-height: 1.4; transition: all var(--transition-fast);
  font-family: var(--font-family);
}
.pdf-btn:hover {
  background: var(--color-primary-subtle); border-color: #93C5FD;
  color: var(--color-primary);
}
.pdf-btn.active {
  background: var(--color-primary-light); border-color: #3B82F6;
  color: var(--color-primary-hover);
}

/* Edit button */
.edit-btn {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 7px; color: var(--color-text-secondary);
  line-height: 1.4; transition: all var(--transition-fast);
  margin-right: 4px; font-family: var(--font-family);
}
.edit-btn:hover {
  background: var(--color-warning-bg); border-color: #fbbf24; color: #92400e;
}
.edit-btn.danger:hover {
  background: var(--color-danger-bg); border-color: #fca5a5; color: #991b1b;
}

/* Delete button */
.delete-btn {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 7px; color: var(--color-text-secondary);
  line-height: 1.4; transition: all var(--transition-fast);
  margin-right: 4px; font-family: var(--font-family);
}
.delete-btn:hover {
  background: var(--color-danger-bg); border-color: #fca5a5; color: #991b1b;
}

/* Archive button */
.archive-btn {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 7px; color: var(--color-text-secondary);
  line-height: 1.4; transition: all var(--transition-fast);
  margin-right: 4px; font-family: var(--font-family);
}
.archive-btn:hover {
  background: var(--color-border-light); border-color: var(--color-text-muted);
  color: #475569;
}

/* Unarchive button */
.unarchive-btn {
  background: var(--color-success-bg); border: 1px solid #86efac;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 8px; color: #166534; line-height: 1.4;
  transition: all var(--transition-fast); font-family: var(--font-family);
  font-weight: 500;
}
.unarchive-btn:hover { background: #bbf7d0; border-color: #4ade80; }

/* Unlink button */
.unlink-btn {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 7px; color: var(--color-text-secondary);
  line-height: 1.4; transition: all var(--transition-fast);
  font-family: var(--font-family);
}
.unlink-btn:hover {
  background: var(--color-danger-bg); border-color: #fca5a5; color: #991b1b;
}

/* Restore button */
.restore-btn {
  background: var(--color-success-bg); border: 1px solid #86efac;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  padding: 3px 9px; color: #166534; line-height: 1.4;
  transition: all var(--transition-fast); font-family: var(--font-family);
  font-weight: 500; white-space: nowrap;
}
.restore-btn:hover { background: #bbf7d0; border-color: #4ade80; }
.restore-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Archive section headers ── */
.archive-section-hdr {
  padding: 12px 18px; background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: 13px; font-weight: 600; color: #475569;
  display: flex; align-items: center; gap: 8px;
}
.archive-section-hdr + .table-wrap { border-top: none; }
.archive-section-hdr:not(:first-child) { border-top: 2px solid var(--color-border); }

/* ── States ── */
.state { text-align: center; padding: 56px 24px; color: var(--color-text-muted); }
.state.error { color: var(--color-danger); }

/* ── Transfer detail sections ── */
.exp-section h4 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--color-primary-hover);
  margin-bottom: 10px; padding: 5px 10px;
  background: var(--color-primary-subtle); border-radius: var(--radius-sm);
  border-left: 3px solid #3B82F6; display: flex; align-items: center; gap: 6px;
}
.exp-section thead { background: var(--color-primary-subtle); }
.exp-section th {
  color: var(--color-primary-hover);
  border-bottom: 1px solid var(--color-primary-light);
}
.exp-section td { border-bottom: 1px solid var(--color-primary-subtle); }
.exp-section tbody tr:last-child td { border-bottom: none; }
.exp-section tbody tr:nth-child(even) td { background: rgba(37,99,235,0.04); }
.no-links {
  color: var(--color-text-muted); font-style: italic; font-size: 13px; padding: 6px 0;
}
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--color-primary-subtle) !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* 1400px — hide description and non-essential columns */
@media (max-width: 1400px) {
  .col-desc { display: none; }
  .col-lg-hide { display: none !important; }

  .table-wrap thead th:last-child,
  .table-wrap tbody td.td-actions {
    position: sticky; right: 0; z-index: 2;
    background: inherit;
    box-shadow: -3px 0 6px -3px rgba(0,0,0,0.12);
  }
  .table-wrap thead th:last-child {
    z-index: 3; background: var(--color-bg);
  }
  .table-wrap tbody tr:nth-child(4n+1) td.td-actions { background: var(--color-bg); }
  .table-wrap tbody tr:hover td.td-actions { background: var(--color-border-light); }
  .table-wrap tbody tr.data-row.expanded td.td-actions { background: var(--color-primary-subtle); }
  .td-actions { white-space: nowrap; }
}

/* 1280px — wrap summary blocks */
@media (max-width: 1280px) {
  .summary { flex-wrap: wrap; }
  .sum-block {
    flex: 1 1 calc(33.33% - 1px); min-width: 0;
    padding-left: 12px; padding-right: 12px;
    border-right: 1px solid var(--color-border);
  }
  .sum-block:first-child { padding-left: 12px; }
  .sum-block:nth-child(3n) { border-right: none; }
  .sum-block:last-child:nth-child(3n+1) { flex: 1 1 100%; border-right: none; }
  .sum-block:last-child { border-bottom: 1px solid var(--color-border); }
}

/* 1024px — expand row padding tighter, summary wraps */
@media (max-width: 1024px) {
  .exp-inner { padding: 14px 16px 18px 24px; }
  .summary { flex-wrap: wrap; padding: 4px 14px; }
  .sum-block { padding: 4px 8px; }
  .sum-block:first-child { padding-left: 8px; }
  .sum-label { white-space: normal; line-height: 1.3; }
}

/* 640px — mobile layout */
@media (max-width: 640px) {
  /* Column hiding */
  .col-m-hide { display: none !important; }

  /* Disable sticky action column */
  .table-wrap thead th:last-child,
  .table-wrap tbody td.td-actions {
    position: static !important;
    box-shadow: none !important;
  }

  /* Allow action buttons to wrap */
  .td-actions { white-space: normal; }

  /* Taller rows for touch */
  td { padding: 10px 8px; }
  th { padding: 7px 8px; font-size: 12px; }

  /* Supplier column */
  .col-sup { max-width: 110px; }
  .sup-name { white-space: normal; font-size: 12px; }

  /* Emphasise total */
  td.r.total { font-size: 14px; font-weight: 700; }

  /* Summary bar — 2-column wrap grid */
  .summary {
    overflow-x: unset; flex-wrap: wrap; padding: 0;
    scrollbar-width: auto;
  }
  .summary::-webkit-scrollbar { display: revert; }
  .sum-block {
    flex: 1 1 calc(50% - 1px); min-width: 0;
    padding: 7px 12px; border-right: none;
    border-bottom: 1px solid var(--color-border-light);
  }
  .sum-block:nth-child(odd)  { border-right: 1px solid var(--color-border-light); }
  .sum-block:last-child:nth-child(odd) { flex: 1 1 100%; border-right: none; }
  .sum-block:last-child { border-bottom: none; }
  .sum-block:first-child { padding-left: 12px; }
  .sum-label { font-size: 10px; white-space: normal; line-height: 1.3; }
  .sum-value { font-size: 13px; white-space: normal; line-height: 1.3; }

  /* Selection bar */
  .sel-bar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .sel-bar > span { flex: 0 0 100%; }
  .sel-bar .sel-download,
  .sel-bar .sel-delete { flex: 1; justify-content: center; padding: 10px 8px; font-size: 12px; }
  .sel-bar .sel-clear  { flex: 0 0 100%; text-align: center; padding: 4px; }

  /* Touch targets for action buttons */
  .edit-btn, .delete-btn, .archive-btn, .pdf-btn,
  .unarchive-btn, .restore-btn, .unlink-btn {
    padding: 10px 12px; min-height: 44px; min-width: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 2px;
  }

  /* Card */
  .card { border-radius: var(--radius-md); }

  /* Expand inner */
  .exp-inner { padding: 12px 12px 16px 16px; }
  .exp-detail-grid { grid-template-columns: 1fr; }
  .exp-label { font-size: 11px; }
  .field-group-label { font-size: 10px; }

  /* Expand section tables */
  .exp-section { gap: 12px; }
  .exp-section table { font-size: 12px; }
  .exp-section th, .exp-section td { padding: 6px 8px; }

  /* Archive section headers */
  .archive-section-hdr { font-size: 12px; padding: 10px 12px; }

  /* Filter pill — hide label text on mobile */
  .pill-label { display: none; }
  .filter-pill { padding: 6px 10px; }
}
/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS — Edit Modal, Buttons, Import Panel, Combobox, Batch Review,
   Queue Sidebar, Restore Button, Cash Payment Modal
   Design tokens from shell.css — modern professional theme (trust-blue)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Edit Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  width: 700px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
}
.modal-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.modal-header h3 {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.modal-warn {
  font-size: 11px;
  color: var(--color-warning);
  font-weight: 500;
}
.modal-x {
  background: var(--color-bg);
  border: none;
  font-size: 17px;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.modal-x:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.modal-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.modal-field.full {
  grid-column: 1 / -1;
}
.modal-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}
.modal-field select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--color-surface);
  transition: var(--transition-fast);
  cursor: pointer;
  color: var(--color-text);
}
.modal-field select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.modal-field input,
.modal-field textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
  color: var(--color-text);
}
.modal-field input:focus,
.modal-field textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.modal-field textarea {
  resize: vertical;
  min-height: 72px;
}
.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.modal-error {
  flex: 1;
  font-size: 12px;
  color: var(--color-danger);
  min-height: 16px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
  font-family: inherit;
}
.btn-cancel {
  background: var(--color-bg);
  color: var(--color-text-secondary);
}
.btn-cancel:hover {
  background: var(--color-border);
}
.btn-save {
  background: var(--color-primary);
  color: white;
}
.btn-save:hover {
  background: var(--color-primary-hover);
}
.btn-save:disabled {
  background: #93C5FD;
  cursor: not-allowed;
}
.btn-save.unpaid-active {
  background: var(--color-warning);
  border-color: var(--color-warning);
}
.btn-danger {
  background: var(--color-danger-bg);
  color: #991b1b;
}
.btn-danger:hover {
  background: #fca5a5;
}

/* ── Import Panel ───────────────────────────────────────────────────────── */
#import-panel {
  margin-top: var(--space-2);
}
.import-panel-flex {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  flex-direction: row;
}
.import-main-content {
  flex: 1;
  min-width: 0;
}

.import-drop-zone {
  background: var(--color-surface);
  border: 2px dashed #CBD5E1;
  border-radius: var(--radius-lg);
  padding: 80px var(--space-7);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-normal);
  color: var(--color-text-muted);
  box-shadow: var(--shadow-sm);
}
.import-drop-zone:hover,
.import-drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}
.import-drop-zone .drop-icon {
  font-size: 52px;
  margin-bottom: var(--space-3);
  display: block;
}
.import-drop-zone .drop-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: inherit;
}
.import-drop-zone .drop-sub {
  font-size: 13px;
  color: var(--color-text-muted);
}

.import-spinner-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 80px var(--space-7);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.import-spinner-wrap i {
  font-size: 40px;
  color: var(--color-primary);
  margin-bottom: var(--space-3);
  display: block;
}
.import-spinner-wrap p {
  font-size: 15px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.import-results-grid {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 45%);
  gap: var(--space-3);
  align-items: start;
}
.import-analysis-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.import-pdf-pane {
  position: sticky;
  top: 64px;
}
.import-pdf-pane iframe {
  width: 100%;
  height: calc(100dvh - 180px);
  min-height: 400px;
  border: none;
  border-radius: var(--radius-lg);
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
}

#import-batch-pdf-frame {
  width: 100%;
  height: calc(100dvh - 180px);
  min-height: 400px;
  border: none;
  border-radius: var(--radius-lg);
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
}

#import-batch-list {
  padding: var(--space-6);
  max-height: calc(100dvh - 280px);
  overflow-y: auto;
}

#import-batch-review {
  padding: var(--space-6);
}

#import-imp-batch-stats,
#imp-batch-stats {
  font-size: 13px;
  color: var(--color-text-secondary);
}

#imp-pdf-toggle-row {
  display: none;
}

.import-sec {
  padding: 14px var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}
.import-sec:last-child {
  border-bottom: none;
}
.import-sec-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.import-fld-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.import-fld {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.import-fld.span2 {
  grid-column: 1 / -1;
}
.import-fld label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
}
.import-fld input,
.import-fld textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  color: var(--color-text);
  transition: var(--transition-fast);
}
.import-fld input:focus,
.import-fld textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.import-fld textarea {
  resize: vertical;
  min-height: 60px;
}
.import-fld .ro-val {
  font-size: 12.5px;
  color: #475569;
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  line-height: 1.5;
}
.ro-val.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.ro-val.empty {
  color: var(--color-text-muted);
  font-style: italic;
}

.import-done-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow-sm);
  max-width: 700px;
  margin: 0 auto;
}

/* ── Doc Type Badges ── */
.dtb {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.dtb-invoice {
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
}
.dtb-transfer {
  background: var(--color-success-bg);
  color: #166534;
}
.dtb-prepayment {
  background: var(--color-warning-bg);
  color: #92400e;
}
.dtb-delivery_note {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}
.dtb-agreement {
  background: #fce7f3;
  color: #9d174d;
}

/* ── Import Alerts ── */
.imp-alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.imp-alert + .imp-alert {
  margin-top: var(--space-1);
}
.imp-warn {
  background: var(--color-warning-bg);
  border: 1px solid #fcd34d;
  color: #92400e;
}
.imp-orange {
  background: #fff7ed;
  border: 1px solid #fb923c;
  color: #9a3412;
}
.imp-err {
  background: var(--color-danger-bg);
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.imp-ok {
  background: var(--color-success-bg);
  border: 1px solid #86efac;
  color: #166534;
}

/* ── Link Rows ── */
.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-border-light);
}
.link-row:last-child {
  border-bottom: none;
}
.link-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}
.link-row label {
  flex: 1;
  cursor: pointer;
  font-size: 13px;
}
.link-exact {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-success);
}
.link-approx {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-warning);
}

/* ── Supplier Combobox ──────────────────────────────────────────────────── */
.sup-combo {
  position: relative;
}
.sup-combo-input {
  width: 100%;
  padding: var(--space-1) var(--space-7) var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--color-surface);
  cursor: pointer;
  outline: none;
}
.sup-combo-input:focus {
  border-color: #93C5FD;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.sup-combo-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--color-text-muted);
  pointer-events: none;
}
.sup-combo-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
}
.sup-combo-list.open {
  display: block;
}
.sup-combo-item {
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-bg);
}
.sup-combo-item:hover,
.sup-combo-item.highlighted {
  background: var(--color-bg);
}
.sup-combo-item.selected {
  background: var(--color-primary-subtle);
}
.sc-name {
  font-weight: 600;
  flex: 1;
}
.sc-company {
  color: var(--color-text-secondary);
  font-size: 12px;
  flex: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-score {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.sc-score-high {
  background: var(--color-success-bg);
  color: #166534;
}
.sc-score-med {
  background: var(--color-warning-bg);
  color: #92400e;
}
.sc-score-low {
  background: var(--color-border-light);
  color: var(--color-text-muted);
}
.sup-combo-new {
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.sup-combo-new:hover {
  background: var(--color-primary-subtle);
}

/* ── New Supplier Dialog ────────────────────────────────────────────────── */
dialog.ns-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 520px;
  width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}
dialog.ns-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}
.ns-dialog-inner {
  padding: var(--space-6);
}
.ns-dialog-inner h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}
.ns-dialog-inner .import-fld-grid {
  gap: 10px;
}
.ns-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ── Batch Review UI ────────────────────────────────────────────────────── */
.import-batch-grid {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 45%);
  gap: var(--space-3);
  align-items: start;
}

.batch-header {
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.batch-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.batch-header-title i {
  color: var(--color-primary);
  font-size: 18px;
}
.batch-header-title h3 {
  margin: 0;
  font-size: 16px;
}

.batch-doc-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: var(--transition-normal);
}
.batch-doc-row:hover {
  border-color: #CBD5E1;
  background: var(--color-surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.batch-num {
  background: var(--color-primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
  font-size: 13px;
}

.batch-fields {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: var(--space-2);
  min-width: 0;
}

.batch-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}
.batch-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
}
.batch-field input,
.batch-field select {
  padding: 6px var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--color-surface);
  transition: var(--transition-fast);
}
.batch-field input:focus,
.batch-field select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.batch-delete {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-danger);
  cursor: pointer;
  padding: var(--space-1);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.batch-delete:hover {
  background: var(--color-danger-bg);
  border-color: #fca5a5;
}

.batch-add-btn {
  background: var(--color-primary-subtle);
  color: var(--color-primary-hover);
  border: 1px solid #BFDBFE;
}

.batch-footer {
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}
.batch-footer-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Import Queue Sidebar ───────────────────────────────────────────────── */
.import-queue-section {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
}
#imp-queue-list {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
}

.imp-progress-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
}
#imp-progress-text {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
#imp-progress-percent {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
#imp-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

.q-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px var(--space-1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}
.q-row.active {
  background: var(--color-primary-subtle);
  border-left-color: var(--color-primary);
}
.q-row:hover {
  background: var(--color-bg);
}
.q-status {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.q-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 12px;
}
.q-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-border);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.q-row.q-committed {
  opacity: 0.55;
}
.q-row.q-skipped {
  opacity: 0.55;
  font-style: italic;
}
.q-done {
  font-size: 11px;
  color: var(--color-success);
  font-weight: 500;
  flex-shrink: 0;
}
.q-row.q-error {
  background: var(--color-danger-bg);
}
.q-err-text {
  font-size: 11px;
  color: var(--color-danger);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.q-retry-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  line-height: 1;
  border-radius: 4px;
}
.q-retry-btn:hover {
  background: var(--color-primary-subtle);
}
.q-row.q-analyzing {
  opacity: 0.6;
}
.q-row.q-uploading {
  opacity: 0.4;
}
.q-row.q-ready {
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
}
.q-row.q-ready:hover {
  background: #dcfce7;
}

/* ── Restore Button ─────────────────────────────────────────────────────── */
.restore-btn {
  background: var(--color-success-bg);
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 9px;
  color: #166534;
  line-height: 1.4;
  transition: var(--transition-fast);
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
}
.restore-btn:hover {
  background: #dcfce7;
  border-color: #4ade80;
}
.restore-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Import Panel & Queue Sidebar
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1450px — shrink queue sidebar ── */
@media (max-width: 1450px) {
  .import-queue-section {
    width: 200px;
  }
  .q-label {
    display: none;
  }
  .q-name {
    max-width: 130px;
  }
  .imp-progress-card {
    padding: 10px;
  }
}

/* ── 1400px — fluid PDF panes ── */
@media (max-width: 1400px) {
  .import-batch-grid {
    grid-template-columns: 1fr minmax(280px, 380px);
  }
  .import-results-grid {
    grid-template-columns: 1fr minmax(280px, 380px);
  }
}

/* ── 1350px — queue sidebar → horizontal top strip ── */
@media (max-width: 1350px) {
  .import-panel-flex {
    flex-direction: column;
    gap: var(--space-2);
  }

  .import-queue-section {
    width: 100%;
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
  }

  .imp-progress-card {
    flex-shrink: 0;
    width: 200px;
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  #imp-queue-list {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    align-items: center;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
  }

  .q-row {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    border-left: none;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg);
    margin-bottom: 0;
    max-width: 160px;
    gap: 5px;
    font-size: 12px;
  }
  .q-row.active {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
  }
  .q-row.q-ready {
    border-color: #86efac;
  }
  .q-row.q-error {
    background: var(--color-danger-bg);
    border-color: #fca5a5;
  }

  .q-name {
    flex: 0 1 auto;
    max-width: 100px;
  }

  .q-label {
    display: none;
  }

  .import-batch-grid {
    grid-template-columns: 1fr minmax(220px, 300px);
    gap: var(--space-3);
  }
  .import-results-grid {
    grid-template-columns: 1fr minmax(220px, 300px);
    gap: var(--space-3);
  }

  .import-pdf-pane iframe {
    height: calc(100dvh - 200px);
  }

  #imp-batch-review {
    padding: var(--space-2);
  }

  .batch-doc-row {
    gap: 10px;
    padding: var(--space-2);
  }

  #imp-batch-review > .import-batch-grid > div > div:first-child {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .batch-footer {
    padding: var(--space-2) var(--space-3);
    flex-wrap: wrap;
    gap: var(--space-1);
  }
  .batch-footer-actions {
    gap: var(--space-1);
  }
  .batch-footer .btn,
  .batch-footer-actions .btn {
    font-size: 12px;
    padding: 7px 10px;
  }
}

/* ── 640px — mobile: single-column, hide PDF panes, sheet modals ── */
@media (max-width: 640px) {
  /* Import panel: column-reverse (queue at bottom) */
  .import-panel-flex {
    flex-direction: column-reverse;
    gap: var(--space-3);
  }
  .import-queue-section {
    width: 100% !important;
    position: static !important;
  }

  .import-results-grid {
    grid-template-columns: 1fr;
  }

  /* PDF pane hidden by default on mobile */
  .import-pdf-pane {
    position: static;
    display: none;
  }
  .import-pdf-pane.mob-pdf-open {
    display: block;
  }
  .import-pdf-pane iframe {
    height: 70dvh;
    min-height: unset;
    border-radius: var(--radius-md);
  }

  #imp-pdf-toggle-row {
    display: flex;
  }

  .import-drop-zone {
    padding: 48px var(--space-6);
  }
  .import-drop-zone .drop-icon {
    font-size: 36px;
  }

  .import-fld-grid {
    grid-template-columns: 1fr;
  }
  .import-fld.span2 {
    grid-column: 1;
  }

  .import-batch-grid {
    grid-template-columns: 1fr;
  }

  .batch-doc-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-2);
  }
  .batch-fields {
    grid-template-columns: 1fr;
  }
  .batch-num {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  .batch-delete {
    align-self: flex-end;
  }

  .batch-footer {
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
  }
  .batch-footer-actions {
    gap: var(--space-1);
  }
  .batch-footer .btn,
  .batch-footer-actions .btn {
    font-size: 12px;
    padding: var(--space-1) 10px;
  }

  dialog.ns-dialog {
    max-height: 90dvh;
  }
  .ns-dialog-inner {
    overflow-y: auto;
    max-height: calc(90dvh - 40px);
  }

  /* Modal: sheet from bottom on mobile */
  .modal-overlay {
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    margin: 0;
  }
  .modal-grid {
    grid-template-columns: 1fr;
  }
  .modal-field.full {
    grid-column: 1;
  }
  .modal-header {
    padding: var(--space-3) 18px;
  }
  .modal-warn {
    display: none;
  }
  .modal-body {
    padding: var(--space-3) 18px;
  }
  .modal-footer {
    padding: 14px 18px;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .modal-error {
    flex: 0 0 100%;
  }
  #modal-reextract {
    flex: 1;
    justify-content: center;
  }
  .modal-footer .btn-cancel,
  .modal-footer .btn-save {
    flex: 1;
    text-align: center;
    padding: var(--space-2) var(--space-3);
    justify-content: center;
  }
}
/* ==========================================================================
   panels.css — Dashboard, Reports, Matchmaking & All Responsive Breakpoints
   Design tokens: shell.css  |  Primary accent: trust-blue (#2563EB)
   ========================================================================== */

/* ==========================================================================
   PART 1: DASHBOARD
   ========================================================================== */

/* ── Panel container ── */
#dashboard-panel {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── KPI row ── */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.dash-kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.dash-kpi:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.dash-kpi-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.dash-kpi-body { flex: 1; min-width: 0; }

.dash-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
}

.dash-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

.dash-kpi-icon { display: none; }

/* ── Charts ── */
.dash-charts-row {
  display: grid;
  gap: var(--space-3);
}

.dash-charts-row.row1 { grid-template-columns: 3fr 2fr; }
.dash-charts-row.row2 { grid-template-columns: 3fr 2fr; }

.dash-chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dash-chart-hdr {
  padding: 13px 18px 10px;
  border-bottom: 1px solid var(--color-bg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dash-chart-hdr h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  margin: 0;
}

.dash-chart-hdr > i { color: var(--color-text-muted); }

.dash-chart-body {
  padding: var(--space-4);
  position: relative;
}

.dash-chart-body canvas { display: block; }

/* ── Stats table ── */
.dash-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dash-stats-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-bg);
}

.dash-stats-table tr:last-child td { border-bottom: none; }

.dash-stats-table .dst-label { color: var(--color-text-secondary); }

.dash-stats-table .dst-count {
  text-align: right;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.dash-stats-table .dst-icon {
  width: 28px;
  text-align: center;
}

/* ── Alerts row ── */
.dash-alerts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ── Skeleton loading ── */
.dash-skeleton {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.skel-line {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-border) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  margin-bottom: 10px;
}

.skel-line.tall { height: 28px; }
.skel-line.short { width: 60%; }

@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Refresh bar ── */
.dash-refresh-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  color: var(--color-text-muted);
}

.dash-refresh-bar i { font-size: 12px; }


/* ==========================================================================
   PART 2: REPORTS & BACKUP
   ========================================================================== */

#reports-panel { margin-top: var(--space-3); }

.reports-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  max-width: 640px;
}

.reports-card-hdr {
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-bg);
  display: flex;
  align-items: center;
  gap: 10px;
}

.reports-card-hdr i {
  font-size: 18px;
  color: var(--color-primary);
}

.reports-card-hdr h3 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.reports-card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.reports-card-footer {
  padding: var(--space-4) 22px;
  border-top: 1px solid var(--color-bg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.reports-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reports-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

.reports-row { display: flex; gap: var(--space-3); }
.reports-row .reports-field { flex: 1; }

.reports-field input[type=date] {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.reports-field input[type=date]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.reports-field input[type=date]:disabled {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.reports-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.reports-toggle input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.btn-report {
  background: var(--color-primary);
  color: white;
  padding: 9px 22px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-report:hover { background: var(--color-primary-hover); }
.btn-report:disabled { background: #93C5FD; cursor: not-allowed; }

.reports-status { font-size: 13px; flex: 1; }
.reports-status.ok    { color: var(--color-success); }
.reports-status.error { color: var(--color-danger); }


/* ==========================================================================
   PART 3: MATCHMAKING CANVAS
   ========================================================================== */

.mm-node {
  position: absolute;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  padding: 10px;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.2s, border-color 0.2s;
  z-index: 20;
}

.mm-node:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: #cbd5e1;
}

.mm-node.dragging {
  cursor: grabbing;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  z-index: 100;
}

.mm-node-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.mm-node-invoice { border-left: 4px solid var(--color-primary); }
.mm-node-invoice .mm-node-type { color: var(--color-primary); }

.mm-node-transfer { border-left: 4px solid #10b981; }
.mm-node-transfer .mm-node-type { color: #10b981; }

.mm-node-delivery_note { border-left: 4px solid #f59e0b; }
.mm-node-delivery_note .mm-node-type { color: #f59e0b; }

.mm-node-receipt { border-left: 4px solid #ec4899; }
.mm-node-receipt .mm-node-type { color: #ec4899; }

.mm-node-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mm-node-date {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.mm-node-amount {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
}

.mm-node-port {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-border);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
  transition: transform 0.2s, background 0.2s;
}

.mm-node-port:hover {
  background: var(--color-primary);
  transform: translateY(-50%) scale(1.3);
}

.mm-node-port-left  { left: -6px; }
.mm-node-port-right { right: -6px; }

.mm-edge-suggested {
  stroke: var(--color-text-muted);
  stroke-width: 2;
  stroke-dasharray: 6,4;
  fill: none;
  cursor: pointer;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.mm-edge-suggested:hover {
  stroke: var(--color-primary);
  stroke-width: 4;
}

.mm-edge-confirmed {
  stroke: var(--color-primary);
  stroke-width: 3;
  fill: none;
}


/* ==========================================================================
   PART 4: RESPONSIVE BREAKPOINTS

   Every @media query from the original CSS, consolidated here.
   Rules are organized from widest → narrowest breakpoint.
   ========================================================================== */


/* ────────────────────────────────────────────────────────────────────────────
   1450px — Import queue sidebar shrink
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1450px) {
  .import-queue-section { width: 200px; }
  .q-label { display: none; }
  .q-name { max-width: 130px; }
  .imp-progress-card { padding: 10px; }
}


/* ────────────────────────────────────────────────────────────────────────────
   1400px — Column hiding, sticky actions
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1400px) {
  .col-desc { display: none; }
  .col-lg-hide { display: none !important; }

  /* Sticky action-column buttons */
  .table-wrap thead th:last-child,
  .table-wrap tbody td.td-actions {
    position: sticky;
    right: 0;
    z-index: 2;
    background: inherit;
    box-shadow: -3px 0 6px -3px rgba(0,0,0,0.12);
  }
  .table-wrap thead th:last-child {
    z-index: 3;
    background: var(--color-bg);
  }
  .table-wrap tbody tr:nth-child(4n+1) td.td-actions { background: var(--color-bg); }
  .table-wrap tbody tr:hover td.td-actions { background: var(--color-bg); }
  .table-wrap tbody tr.data-row.expanded td.td-actions { background: var(--color-primary-subtle); }
  .td-actions { white-space: nowrap; }

  /* Import grids: fluid right pane */
  .import-batch-grid   { grid-template-columns: 1fr minmax(280px, 380px); }
  .import-results-grid { grid-template-columns: 1fr minmax(280px, 380px); }
}


/* ────────────────────────────────────────────────────────────────────────────
   1350px — Import queue → horizontal top strip
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1350px) {
  .import-panel-flex {
    flex-direction: column;
    gap: var(--space-3);
  }

  .import-queue-section {
    width: 100%;
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
  }

  .imp-progress-card {
    flex-shrink: 0;
    width: 200px;
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  #imp-queue-list {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    align-items: center;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
  }

  .q-row {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    border-left: none;
    border: 1.5px solid var(--color-border);
    background: var(--color-bg);
    margin-bottom: 0;
    max-width: 160px;
    gap: 5px;
    font-size: 12px;
  }

  .q-row.active {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    border-left-color: var(--color-primary);
  }

  .q-row.q-ready { border-color: #86efac; }

  .q-row.q-error {
    background: #fef2f2;
    border-color: #fca5a5;
  }

  .q-name { flex: 0 1 auto; max-width: 100px; }
  .q-label { display: none; }

  .import-batch-grid   { grid-template-columns: 1fr minmax(220px, 300px); gap: var(--space-4); }
  .import-results-grid { grid-template-columns: 1fr minmax(220px, 300px); gap: var(--space-4); }

  .import-pdf-pane iframe { height: calc(100dvh - 200px); }
  #imp-batch-review { padding: var(--space-3); }

  .batch-doc-row { gap: 10px; padding: var(--space-3); }

  #imp-batch-review > .import-batch-grid > div > div:first-child {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .batch-footer {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .batch-footer-actions { gap: var(--space-2); }
  .batch-footer .btn,
  .batch-footer-actions .btn {
    font-size: 12px;
    padding: 7px 10px;
  }
}


/* ────────────────────────────────────────────────────────────────────────────
   1280px — PDF drawer shrink, layout padding, dashboard stack, summary wrap
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .pdf-drawer { width: 340px; }
  .layout { padding: 10px 14px; gap: 10px; }

  /* Summary bar: wrap into rows */
  .summary { flex-wrap: wrap; }
  .sum-block {
    flex: 1 1 calc(33.33% - 1px);
    min-width: 0;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    border-right: 1px solid var(--color-border);
  }
  .sum-block:first-child { padding-left: var(--space-3); }
  .sum-block:nth-child(3n) { border-right: none; }
  .sum-block:last-child:nth-child(3n+1) { flex: 1 1 100%; border-right: none; }
  .sum-block:last-child { border-bottom: 1px solid var(--color-border); }

  /* Dashboard: KPI 3-col, charts single-col, alerts single-col */
  .dash-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dash-charts-row.row1,
  .dash-charts-row.row2 { grid-template-columns: 1fr; }
  .dash-alerts-row { grid-template-columns: 1fr; }
}


/* ────────────────────────────────────────────────────────────────────────────
   1200px — Dash KPI 3-col (redundant with 1280 but kept from original)
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .dash-kpi-row { grid-template-columns: repeat(3, 1fr); }
}


/* ────────────────────────────────────────────────────────────────────────────
   1024px — Sidebar overlay, PDF drawer slide-in, layout, expand, summary wrap
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Sidebar → hidden off-screen, opens as overlay */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 500;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.15);
  }
  .main-area { margin-left: 0; }
  .hamburger-btn { display: flex; }

  .layout { padding: var(--space-3); gap: 0; }

  /* PDF Drawer → slide-in overlay from right */
  .pdf-drawer {
    position: fixed;
    top: 0; right: 0;
    height: 100dvh;
    width: min(480px, 92vw);
    border-radius: 0;
    z-index: 500;
    transform: translateX(110%);
    transition: transform 0.25s ease;
    display: flex;
    box-shadow: -4px 0 32px rgba(0,0,0,0.15);
  }
  .pdf-drawer.open { transform: translateX(0); }

  /* Summary bar: wrap into multiple rows */
  .summary { flex-wrap: wrap; padding: 4px 14px; }
  .sum-block { padding: 4px var(--space-2); }
  .sum-block:first-child { padding-left: var(--space-2); }
  .sum-label { white-space: normal; line-height: 1.3; }

  /* Expand inner: tighter padding */
  .exp-inner { padding: 14px var(--space-4) 18px 24px; }
}


/* ────────────────────────────────────────────────────────────────────────────
   768px — Dash KPI 2-col
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
}


/* ════════════════════════════════════════════════════════════════════════════
   640px — MOBILE (iPhone 13 and similar)
   
   All rules here are additive. Desktop layout is completely unaffected.
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

  /* ── Layout ───────────────────────────────────────────────────────────── */
  .layout {
    padding: var(--space-2) var(--space-2) 0 var(--space-2);
    gap: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  /* ── Topbar ───────────────────────────────────────────────────────────── */
  .topbar-actions { flex: 1; gap: 6px; }
  .search-wrap { flex: 1; min-width: 0; }
  .search-wrap input { width: 100% !important; box-sizing: border-box; }
  .pill-label { display: none; }
  .filter-pill { padding: 6px 10px; }

  /* ── Bottom Nav ────────────────────────────────────────────────────────── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 400;
    align-items: stretch;
  }

  .bn-tab, .bn-more-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-muted);
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast);
    border-radius: 0;
  }

  .bn-tab i, .bn-more-btn i { font-size: 20px; line-height: 1; }
  .bn-tab.active { color: var(--color-primary); }
  .bn-tab:active, .bn-more-btn:active { background: var(--color-bg); }

  /* ── More Sheet Backdrop ───────────────────────────────────────────────── */
  .more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 450;
    backdrop-filter: blur(2px);
  }
  .more-backdrop.visible { display: block; }

  /* ── More Sheet ────────────────────────────────────────────────────────── */
  .more-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--color-surface);
    border-radius: 20px 20px 0 0;
    z-index: 451;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgba(0,0,0,0.14);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    display: block;
  }
  .more-sheet.open { transform: translateY(0); }

  .more-sheet-handle {
    width: 36px; height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: var(--space-3) auto 4px;
  }

  .more-sheet-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: var(--space-2) var(--space-3) var(--space-2);
  }

  .more-sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px var(--space-2);
    border-radius: var(--radius-lg);
    font-size: 11px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    min-height: 44px;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    line-height: 1.3;
  }
  .more-sheet-item i { font-size: 22px; }
  .more-sheet-item:active { background: var(--color-bg); }
  .more-sheet-item.active {
    color: var(--color-primary);
    background: var(--color-primary-subtle);
  }

  /* ── Tables ────────────────────────────────────────────────────────────── */
  .col-m-hide { display: none !important; }

  /* Disable sticky action column */
  .table-wrap thead th:last-child,
  .table-wrap tbody td.td-actions {
    position: static !important;
    box-shadow: none !important;
  }

  .td-actions { white-space: normal; }

  td { padding: 10px var(--space-2); }
  th { padding: 7px var(--space-2); font-size: 12px; }

  .col-sup { max-width: 110px; }
  .sup-name { white-space: normal; font-size: 12px; }
  td.r.total { font-size: 14px; font-weight: 700; }

  /* ── Summary Bar — 2-column wrap ───────────────────────────────────────── */
  .summary {
    overflow-x: unset;
    flex-wrap: wrap;
    padding: 0;
    scrollbar-width: auto;
  }
  .summary::-webkit-scrollbar { display: revert; }
  .sum-block {
    flex: 1 1 calc(50% - 1px);
    min-width: 0;
    padding: 7px var(--space-3);
    border-right: none;
    border-bottom: 1px solid var(--color-bg);
  }
  .sum-block:nth-child(odd)  { border-right: 1px solid var(--color-bg); }
  .sum-block:last-child:nth-child(odd) { flex: 1 1 100%; border-right: none; }
  .sum-block:last-child { border-bottom: none; }
  .sum-block:first-child { padding-left: var(--space-3); }
  .sum-label { font-size: 10px; white-space: normal; line-height: 1.3; }
  .sum-value { font-size: 13px; white-space: normal; line-height: 1.3; }

  /* ── Selection Bar ─────────────────────────────────────────────────────── */
  .sel-bar { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .sel-bar > span { flex: 0 0 100%; }
  .sel-bar .sel-download,
  .sel-bar .sel-delete { flex: 1; justify-content: center; padding: 10px var(--space-2); font-size: 12px; }
  .sel-bar .sel-clear  { flex: 0 0 100%; text-align: center; padding: 4px; }

  /* ── Touch Targets for action buttons ──────────────────────────────────── */
  .edit-btn, .delete-btn, .archive-btn, .pdf-btn,
  .unarchive-btn, .restore-btn, .unlink-btn {
    padding: 10px var(--space-3);
    min-height: 44px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
  }

  /* ── Edit / Detail Modal — sheet from bottom ───────────────────────────── */
  .modal-overlay { align-items: flex-end; }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    margin: 0;
  }

  .modal-grid { grid-template-columns: 1fr; }
  .modal-field.full { grid-column: 1; }
  .modal-header { padding: var(--space-4) 18px; }
  .modal-warn { display: none; }
  .modal-body { padding: var(--space-4) 18px; }

  .modal-footer {
    padding: 14px 18px;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .modal-error { flex: 0 0 100%; }
  #modal-reextract { flex: 1; justify-content: center; }
  .modal-footer .btn-cancel,
  .modal-footer .btn-save {
    flex: 1;
    text-align: center;
    padding: var(--space-3) var(--space-4);
    justify-content: center;
  }

  /* ── Card ──────────────────────────────────────────────────────────────── */
  .card { border-radius: var(--radius-md); }

  /* ── Expand inner, detail grid, labels ─────────────────────────────────── */
  .exp-inner { padding: var(--space-3) var(--space-3) var(--space-4) var(--space-4); }
  .exp-detail-grid { grid-template-columns: 1fr; }
  .exp-section { gap: var(--space-3); }
  .exp-section table { font-size: 12px; }
  .exp-section th, .exp-section td { padding: 6px var(--space-2); }
  .exp-label { font-size: 11px; }
  .field-group-label { font-size: 10px; }

  /* ── Dashboard ─────────────────────────────────────────────────────────── */
  #dashboard-panel { gap: 10px; margin-top: var(--space-2); }
  .dash-kpi { padding: 14px var(--space-4); gap: var(--space-3); }
  .dash-kpi-icon-wrap { width: 36px; height: 36px; font-size: 15px; }
  .dash-kpi-value { font-size: 17px; }
  .dash-chart-body { padding: 10px; }
  .dash-refresh-bar { font-size: 10px; }

  /* ── Import Panel ──────────────────────────────────────────────────────── */
  .import-panel-flex { flex-direction: column-reverse; gap: var(--space-4); }
  .import-queue-section { width: 100% !important; position: static !important; }

  .import-results-grid { grid-template-columns: 1fr; }

  /* PDF pane hidden by default on mobile — toggled by JS */
  .import-pdf-pane { position: static; display: none; }
  .import-pdf-pane.mob-pdf-open { display: block; }
  .import-pdf-pane iframe { height: 70dvh; min-height: unset; border-radius: var(--radius-md); }

  #imp-pdf-toggle-row { display: flex; }

  .import-drop-zone { padding: 48px 24px; }
  .import-drop-zone .drop-icon { font-size: 36px; }

  .import-fld-grid { grid-template-columns: 1fr; }
  .import-fld.span2 { grid-column: 1; }

  .import-batch-grid { grid-template-columns: 1fr; }

  .batch-doc-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-3);
  }
  .batch-fields { grid-template-columns: 1fr; }
  .batch-num { width: 24px; height: 24px; font-size: 12px; }
  .batch-delete { align-self: flex-end; }

  .batch-footer { flex-wrap: wrap; padding: var(--space-3) var(--space-4); }
  .batch-footer-actions { gap: var(--space-2); }
  .batch-footer .btn,
  .batch-footer-actions .btn { font-size: 12px; padding: var(--space-2) 10px; }

  dialog.ns-dialog { max-height: 90dvh; }
  .ns-dialog-inner { overflow-y: auto; max-height: calc(90dvh - 40px); }

  /* ── Reports ───────────────────────────────────────────────────────────── */
  .reports-card { max-width: 100%; }

  /* ── Archive section headers ───────────────────────────────────────────── */
  .archive-section-hdr { font-size: 12px; padding: 10px var(--space-3); }
}


/* ────────────────────────────────────────────────────────────────────────────
   480px — Dash KPI single column (very narrow)
   ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dash-kpi-row { grid-template-columns: 1fr; }
}


/* ────────────────────────────────────────────────────────────────────────────
   Desktop only — hide bottom nav elements above 640px
   ──────────────────────────────────────────────────────────────────────────── */
@media (min-width: 641px) {
  .bottom-nav, .more-backdrop, .more-sheet { display: none !important; }
}
