/* ═══════════════════════════════════════════════════════════════════
   Distributor Inventory Dashboard — Enterprise Premium Stylesheet
   Primary: #0F4C81 (Royal Blue) | Background: #F0F4FF | White cards
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  --primary:       #0F4C81;
  --primary-dark:  #0a3560;
  --primary-light: #1565C0;
  --accent:        #2196F3;
  --accent-light:  #E3F2FD;
  --success:       #00897B;
  --success-bg:    #E0F2F1;
  --warning:       #F57C00;
  --warning-bg:    #FFF3E0;
  --danger:        #C62828;
  --danger-bg:     #FFEBEE;
  --info:          #0277BD;
  --info-bg:       #E1F5FE;
  --bg:            #EEF2FB;
  --surface:       #FFFFFF;
  --border:        #DDE3EF;
  --text:          #1A2340;
  --text-muted:    #64748B;
  --text-light:    #94A3B8;
  --shadow-sm:     0 1px 3px rgba(15,76,129,.06), 0 1px 2px rgba(15,76,129,.04);
  --shadow:        0 4px 16px rgba(15,76,129,.10), 0 1px 4px rgba(15,76,129,.06);
  --shadow-lg:     0 12px 40px rgba(15,76,129,.18), 0 4px 12px rgba(15,76,129,.08);
  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     20px;
  --radius-xl:     28px;
  --header-h:      68px;
  --tabnav-h:      52px;
  --font:          'DM Sans', 'Inter', system-ui, sans-serif;
  --font-mono:     'DM Mono', 'Fira Code', monospace;
  --transition:    0.22s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Loading Overlay ────────────────────────────────────────────────── */
#pageLoader {
  position: fixed; inset: 0;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 9999;
  transition: opacity .4s, visibility .4s;
}
#pageLoader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-logo { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; }
.loader-logo svg { width: 32px; height: 32px; fill: #fff; }
.loader-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loader-text { color: rgba(255,255,255,.8); font-size: .88rem; letter-spacing: .04em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────────── */
#toastContainer {
  position: fixed; top: 80px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 8000; pointer-events: none;
}
.toast {
  min-width: 280px; max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  pointer-events: auto;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  border-left: 4px solid var(--accent);
}
.toast.toast-success { border-color: var(--success); }
.toast.toast-error   { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }
.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: .88rem; color: var(--text); }
.toast-msg   { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; padding: 0; line-height: 1; flex-shrink: 0;
  transition: color var(--transition);
}
.toast-close:hover { color: var(--text); }
.toast.removing { animation: toastOut .25s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: none; } }
@keyframes toastOut { to   { opacity:0; transform: translateX(40px); } }

/* ── Header ──────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 500;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  box-shadow: var(--shadow-sm);
}
.header-left  { display: flex; align-items: center; gap: 14px; }
.header-logo  { height: 38px; width: 38px; object-fit: contain; border-radius: 8px; }
.header-title h1 { font-size: 1.08rem; font-weight: 700; color: var(--primary); letter-spacing: -.01em; }
.header-title p  { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 100px;
  padding: 5px 12px 5px 5px; border: 1px solid var(--border);
}
.header-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
.header-user-name { font-size: .82rem; font-weight: 500; }

/* ── Tab Navigation ──────────────────────────────────────────────────── */
.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-end;
  padding: 0 28px;
  height: var(--tabnav-h);
  gap: 4px;
  overflow-x: auto;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  height: 40px; padding: 0 18px;
  background: none; border: none;
  border-bottom: 3px solid transparent;
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  display: flex; align-items: center; gap: 7px;
  position: relative; top: 1px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn .tab-badge {
  background: var(--danger); color: #fff;
  border-radius: 100px; font-size: .7rem;
  padding: 1px 6px; font-weight: 700; line-height: 1.5;
}

/* ── Main Content ─────────────────────────────────────────────────────── */
.main-content { padding: 28px; max-width: 1600px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── KPI Cards ───────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 120px; height: 120px;
  border-radius: 50%;
  transform: translate(30%, -30%);
  opacity: .07;
}
.kpi-card.kpi-blue::before   { background: var(--primary); }
.kpi-card.kpi-teal::before   { background: var(--success); }
.kpi-card.kpi-orange::before { background: var(--warning); }
.kpi-card.kpi-purple::before { background: #7C3AED; }

.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.kpi-blue   .kpi-icon { background: rgba(15,76,129,.1);   color: var(--primary); }
.kpi-teal   .kpi-icon { background: var(--success-bg);    color: var(--success); }
.kpi-orange .kpi-icon { background: var(--warning-bg);    color: var(--warning); }
.kpi-purple .kpi-icon { background: rgba(124,58,237,.1);  color: #7C3AED; }

.kpi-trend { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 100px; }
.kpi-trend.up   { background: var(--success-bg); color: var(--success); }
.kpi-trend.down { background: var(--danger-bg);  color: var(--danger); }
.kpi-trend.flat { background: var(--bg);          color: var(--text-muted); }

.kpi-number {
  font-size: 2.4rem; font-weight: 700; color: var(--text);
  letter-spacing: -.03em; line-height: 1;
}
.kpi-label  { font-size: .82rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

/* ── Section Header ──────────────────────────────────────────────────── */
.section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.section-hdr h2 { font-size: 1.08rem; font-weight: 700; color: var(--text); }
.section-hdr p  { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── Filter Bar ──────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.filter-input, .filter-select {
  height: 38px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg);
  color: var(--text); font-size: .85rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-input { width: 100%; padding: 0 12px 0 36px; }
.filter-select { padding: 0 10px; min-width: 150px; }
.filter-input:focus, .filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,76,129,.1);
  background: #fff;
}
.filter-date-group { display: flex; align-items: center; gap: 6px; }
.filter-date-group span { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.date-input {
  height: 38px; padding: 0 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: .85rem;
  outline: none; transition: border-color var(--transition);
}
.date-input:focus { border-color: var(--primary); background: #fff; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: 100px;
  background: var(--bg); color: var(--text-muted);
  font-size: .8rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.chip:hover, .chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-clear-filter {
  height: 38px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-muted);
  font-size: .82rem; font-weight: 500;
  display: flex; align-items: center; gap: 5px;
  transition: all var(--transition);
}
.btn-clear-filter:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* ── Export Bar ──────────────────────────────────────────────────────── */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.export-btns { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); font-size: .84rem;
  font-weight: 600; border: none; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(15,76,129,.3); transform: translateY(-1px); }
.btn-outline  { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover  { background: var(--accent-light); }
.btn-ghost    { background: var(--bg); color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover    { background: var(--surface); color: var(--text); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { opacity: .9; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: .8rem; }
.btn-icon { width: 38px; padding: 0; justify-content: center; }
.result-count { font-size: .85rem; color: var(--text-muted); }
.result-count strong { color: var(--text); }

/* ── Table ───────────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
thead { background: var(--bg); position: sticky; top: 0; z-index: 2; }
thead th {
  padding: 12px 16px; text-align: left;
  font-size: .78rem; font-weight: 700;
  color: var(--text-muted); letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
  transition: color var(--transition);
}
thead th:hover { color: var(--primary); }
thead th.sorted { color: var(--primary); }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(15,76,129,.03); }
tbody td {
  padding: 13px 16px; vertical-align: middle;
  color: var(--text);
}
td.muted { color: var(--text-muted); }

/* Product cell */
.prod-cell { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.prod-img {
  width: 40px; height: 40px; border-radius: 8px;
  object-fit: cover; background: var(--bg); flex-shrink: 0;
  border: 1px solid var(--border);
}
.prod-img-placeholder {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--accent-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; border: 1px solid var(--border);
}
.prod-name   { font-weight: 600; font-size: .875rem; }
.prod-brand  { font-size: .76rem; color: var(--text-muted); }
.prod-dist   { font-size: .76rem; color: var(--text-light); margin-top: 1px; }

/* Qty cells */
.qty-value { font-family: var(--font-mono); font-weight: 600; font-size: .92rem; }
.qty-sent     { color: var(--primary); }
.qty-returned { color: var(--warning); }
.qty-remaining-wrap {
  display: flex; align-items: center; gap: 6px;
}
.qty-remaining {
  font-family: var(--font-mono); font-weight: 700; font-size: 1rem;
}

/* Status badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: .75rem; font-weight: 700;
  white-space: nowrap;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-success::before { background: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-warning::before { background: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-danger::before  { background: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-info::before    { background: var(--info); }
.badge-pending { background: #F3F4F6; color: #6B7280; }
.badge-pending::before { background: #9CA3AF; }
.badge-lg { padding: 6px 16px; font-size: .88rem; }

/* Batch number */
.batch-tag {
  font-family: var(--font-mono); font-size: .8rem;
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px; color: var(--text-muted);
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--bg); gap: 12px; flex-wrap: wrap;
}
.page-info { font-size: .82rem; color: var(--text-muted); }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: .82rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.page-btn:hover    { border-color: var(--primary); color: var(--primary); }
.page-btn.active   { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; pointer-events: none; }

/* ── Notifications Panel ─────────────────────────────────────────────── */
.notif-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.notif-hdr {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-hdr h3 { font-size: 1rem; font-weight: 700; }
.notif-count {
  background: var(--danger-bg); color: var(--danger);
  border-radius: 100px; font-size: .78rem; font-weight: 700;
  padding: 2px 10px;
}
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.notif-dot.danger  { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.notif-dot.warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.notif-dot.info    { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.notif-text    { font-size: .86rem; color: var(--text); flex: 1; line-height: 1.5; }
.notif-time    { font-size: .76rem; color: var(--text-light); white-space: nowrap; }
.notif-empty   { padding: 40px 22px; text-align: center; color: var(--text-muted); font-size: .88rem; }

/* ── Stats Grid (overview lower section) ─────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin-top: 24px;
}

/* ── Drawer ──────────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 700;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 560px; max-width: 95vw;
  background: var(--surface);
  z-index: 800;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: none; }

.drawer-hdr {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.drawer-hdr h2 { font-size: 1.05rem; font-weight: 700; }
.drawer-close {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 18px; line-height: 1;
  cursor: pointer; transition: all var(--transition);
}
.drawer-close:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-body::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-track { background: var(--bg); }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Drawer product info */
.drawer-product-hdr {
  display: flex; gap: 18px; align-items: flex-start;
  padding: 20px; background: var(--bg);
  border-radius: var(--radius); margin-bottom: 22px;
  border: 1px solid var(--border);
}
.drawer-prod-img {
  width: 80px; height: 80px; border-radius: 12px;
  object-fit: cover; border: 2px solid var(--border);
  background: #fff; flex-shrink: 0;
}
.drawer-prod-placeholder {
  width: 80px; height: 80px; border-radius: 12px;
  background: var(--accent-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; flex-shrink: 0; border: 2px solid var(--border);
}
.drawer-prod-info h3  { font-size: 1.02rem; font-weight: 700; }
.drawer-prod-info p   { font-size: .82rem; color: var(--text-muted); margin-top: 3px; }
.drawer-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.drawer-meta-item label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); font-weight: 600; }
.drawer-meta-item span  { font-size: .84rem; color: var(--text); font-weight: 500; }

/* Inventory summary cards (drawer) */
.inv-summary-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 22px;
}
.inv-summary-card {
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 14px 16px; text-align: center;
}
.inv-summary-card .label { font-size: .74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.inv-summary-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; font-family: var(--font-mono); }
.inv-summary-card.sent     .value { color: var(--primary); }
.inv-summary-card.returned .value { color: var(--warning); }
.inv-summary-card.remaining .value { color: var(--success); }

/* Drawer sections */
.drawer-section { margin-bottom: 28px; }
.drawer-section h4 {
  font-size: .88rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.drawer-section h4::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.mini-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.mini-table th {
  padding: 8px 10px; text-align: left;
  background: var(--bg); color: var(--text-muted);
  font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; border-bottom: 1px solid var(--border);
}
.mini-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table tr:hover td { background: var(--bg); }

/* Final summary */
.final-summary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius); padding: 22px;
  color: #fff; margin-top: 8px;
}
.final-summary h4 { font-size: .78rem; opacity: .7; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 16px; }
.final-flow { display: flex; align-items: center; justify-content: space-around; gap: 12px; }
.final-step { text-align: center; }
.final-step .num { font-size: 1.6rem; font-weight: 700; font-family: var(--font-mono); }
.final-step .lbl { font-size: .76rem; opacity: .75; margin-top: 4px; }
.final-arrow { font-size: 1.2rem; opacity: .5; }
.final-remaining-badge {
  background: rgba(255,255,255,.15);
  border-radius: 100px; padding: 4px 14px;
  font-size: .78rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,.25);
  display: inline-block; margin-top: 6px;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(20px);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: none; }
.modal-hdr {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-hdr h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.modal-hdr h2 .modal-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.modal-hdr h2 .modal-icon.blue   { background: var(--accent-light); }
.modal-hdr h2 .modal-icon.orange { background: var(--warning-bg); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Form */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-col-2  { grid-column: 1 / -1; }
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.form-group label span.req { color: var(--danger); margin-left: 2px; }
.form-control {
  height: 40px; padding: 0 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-size: .875rem;
  outline: none; transition: all var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,76,129,.1);
  background: #fff;
}
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; min-height: 70px; }
.form-control.error { border-color: var(--danger); }
.form-error { font-size: .76rem; color: var(--danger); }
.form-hint  { font-size: .76rem; color: var(--text-light); }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  padding: 60px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 4px;
}
.empty-state h3   { font-size: 1.02rem; font-weight: 700; }
.empty-state p    { font-size: .86rem; color: var(--text-muted); max-width: 340px; }

/* ── Skeleton ────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #EEF2FB 25%, #E2E8F4 50%, #EEF2FB 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-kpi { height: 120px; border-radius: var(--radius-lg); }
.skel-row { height: 54px; margin-bottom: 8px; border-radius: 8px; }

/* ── Dispatch/Return row actions ─────────────────────────────────────── */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Progress bar (for drawer remaining%) ────────────────────────────── */
.progress-bar-wrap { background: var(--bg); border-radius: 100px; height: 6px; overflow: hidden; margin-top: 8px; }
.progress-bar-fill { height: 100%; border-radius: 100px; transition: width .5s ease; }
.progress-bar-fill.good    { background: var(--success); }
.progress-bar-fill.caution { background: var(--warning); }
.progress-bar-fill.bad     { background: var(--danger); }

/* ── Divider ─────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .header { padding: 0 16px; }
  .tab-nav { padding: 0 8px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi-number { font-size: 1.8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-date-group { flex-direction: column; align-items: stretch; }
  .action-bar { flex-direction: column; align-items: flex-start; }
  .export-btns { flex-wrap: wrap; }
  .drawer { width: 100%; }
  .inv-summary-cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tab-btn  { padding: 0 12px; font-size: .82rem; }
}

/* ── Print ───────────────────────────────────────────────────────────── */
@media print {
  .header, .tab-nav, .filter-bar, .action-bar,
  .pagination-bar, .row-actions, #toastContainer,
  .btn, .drawer, .modal-overlay { display: none !important; }
  .table-card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
  .tab-panel { display: block !important; }
}
