:root {
  /* Customs / shipping-portal palette (navy + gold) */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --navy: #0b2e4e;
  --navy-deep: #072038;
  --navy-mid: #13406a;
  --gold: #c9a227;
  --gold-soft: #f7efd0;
  --primary: #0b4f7a;
  --primary-hover: #083d5e;
  --primary-soft: #e3eef5;
  --text: #1a2433;
  --text-muted: #5a6b7d;
  --border: #d5dde6;
  --border-strong: #b8c4d1;
  --success: #1a6b3c;
  --success-soft: #e6f4ec;
  --danger: #a32020;
  --danger-soft: #fceaea;
  --warning: #9a5b00;
  --warning-soft: #fff4e0;
  --shadow: 0 1px 3px rgba(11, 46, 78, 0.08);
  --radius: 4px;
  --sidebar-w-expanded: 210px;
  --sidebar-w-collapsed: 56px;
  --sidebar-w: var(--sidebar-w-expanded);
  --sticky-col-1-w: 4.5rem;
  --sticky-col-2-left: 4.5rem;
  --content-max: 100%;
  --content-pad-x: clamp(0.75rem, 2vw, 1.75rem);
  --content-pad-y: clamp(0.75rem, 1.5vw, 1.5rem);
  --table-max-h: min(70dvh, 720px);
  --panel-ease: cubic-bezier(.2, .8, .2, 1);
  --panel-ms: .16s;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(11, 46, 78, 0.04) 0%, transparent 12rem);
  color: var(--text);
  line-height: 1.4;
  font-size: clamp(12.5px, 0.85vw + 10px, 14px);
  min-height: 100dvh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* App shell */
.app-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(7, 32, 56, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  align-items: center;
  gap: .65rem;
  padding: .65rem var(--content-pad-x);
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--gold);
}

.mobile-topbar-title {
  font-weight: 700;
  font-size: .95rem;
}

.mobile-menu-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.mobile-menu-btn:hover { background: rgba(255, 255, 255, 0.16); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  width: var(--sidebar-w);
  height: 100dvh;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-right: none;
  box-shadow: 2px 0 8px rgba(7, 32, 56, 0.25);
  display: flex;
  flex-direction: column;
  transition: width var(--panel-ms) var(--panel-ease), transform var(--panel-ms) var(--panel-ease);
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--gold) 0%, #a8841a 100%);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .85rem .7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 52px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.12);
}

.sidebar-brand-mark {
  font-weight: 800;
  font-size: .8rem;
  letter-spacing: 0.02em;
  color: var(--navy-deep);
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sidebar-brand-text {
  font-weight: 650;
  font-size: .88rem;
  color: #f0f5fa;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: 0.01em;
}

.sidebar-collapse-btn {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
  padding: 0;
}

.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: .65rem .45rem;
  overflow: hidden;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .55rem;
  border-radius: 3px;
  color: rgba(232, 240, 248, 0.78);
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(201, 162, 39, 0.22);
  color: #ffe9a0;
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-link-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.sidebar-link-label { overflow: hidden; }

html.sidebar-collapsed {
  --sidebar-w: var(--sidebar-w-collapsed);
}

html.sidebar-collapsed .sidebar-brand-text,
html.sidebar-collapsed .sidebar-link-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

html.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  width: 100%;
  transition: margin-left var(--panel-ms) var(--panel-ease);
}

.main-content {
  padding: var(--content-pad-y) var(--content-pad-x) clamp(1.25rem, 3vw, 2.5rem);
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* Page toolbar */
.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.page-toolbar > div:first-child {
  min-width: min(100%, 16rem);
  flex: 1 1 14rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.05rem, 1.2vw + 0.7rem, 1.35rem);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.page-subtitle {
  margin: .25rem 0 0;
  color: var(--text-muted);
  font-size: .82rem;
}

.page-toolbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Panels */
.portal-main-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.portal-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem 1rem;
  padding: .75rem clamp(.75rem, 1.5vw, 1rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
  flex-wrap: wrap;
}

.portal-panel-title {
  margin: 0;
  font-size: .92rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.portal-panel-sub {
  margin: .25rem 0 0;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.portal-panel-body {
  padding: clamp(.75rem, 1.5vw, 1rem);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .42rem .85rem;
  border-radius: 3px;
  border: 1px solid transparent;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  text-decoration: none;
  background: var(--primary-soft);
  border-color: #8eb4cb;
  color: var(--primary);
}

.btn:hover:not(:disabled) {
  background: #d4e6f0;
  color: var(--primary-hover);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  border-color: var(--navy-deep);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-mid);
  border-color: var(--navy);
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--navy-mid);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--navy);
  border-color: var(--navy-mid);
}

.btn-sm {
  padding: .25rem .55rem;
  font-size: .78rem;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* Form bits */
.file-btn {
  display: inline-flex;
  align-items: center;
  padding: .45rem .9rem;
  border: 1px dashed var(--navy-mid);
  background: var(--primary-soft);
  border-radius: 3px;
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
}

.file-btn:hover { background: #d4e6f0; border-style: solid; }

.check {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  color: var(--text-muted);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: .85rem;
  flex-wrap: wrap;
}

.muted { color: var(--text-muted); }

/* Status / progress */
.status-line {
  margin: .75rem 0 0;
  min-height: 1.2em;
  color: var(--text-muted);
}

.progress-box {
  margin-top: .85rem;
  display: none;
}

.progress-box.visible { display: block; }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-mid) 60%, var(--gold) 100%);
  border-radius: 3px;
  animation: progress-indeterminate 1.8s infinite ease-in-out;
  transition: width .25s ease;
}

.progress-bar.determinate {
  animation: none;
  width: 0%;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(80%); }
  100% { transform: translateX(250%); }
}

.result {
  margin-top: .85rem;
  padding: .75rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  line-height: 1.5;
}

.result.ok { border-left: 3px solid var(--success); background: var(--success-soft); }
.result.err { border-left: 3px solid var(--danger); background: var(--danger-soft); }
.result.partial { border-left: 3px solid var(--warning); background: var(--warning-soft); }

.result ul {
  margin: .4rem 0 0;
  padding-left: 1.1rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .45rem;
  border-radius: 2px;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-done, .badge-ok { background: var(--success-soft); color: var(--success); border: 1px solid #b7dcc6; }
.badge-failed, .badge-err { background: var(--danger-soft); color: var(--danger); border: 1px solid #e8b4b4; }
.badge-partial, .badge-processing, .badge-pending {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid #efd39a;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
}

.stat-card:nth-child(2) { border-left-color: var(--navy-mid); }
.stat-card:nth-child(3) { border-left-color: var(--gold); }

.stat-label {
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  margin: 0 0 .35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
  color: var(--navy);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Tables */
.table-scroll,
.excel-table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: var(--table-max-h);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: clamp(11.5px, 0.2vw + 11px, 13px);
}

.data-table th,
.data-table td {
  text-align: left;
  padding: .45rem .55rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--navy);
  color: #e8f0f7;
  font-weight: 650;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--gold);
  padding: .5rem .55rem;
}

.data-table tbody tr:nth-child(even) td { background: #f7fafc; }
.data-table tbody tr:hover td { background: #eaf2f8; }

.data-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: var(--sticky-col-1-w);
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

.data-table th.sticky-col { z-index: 4; background: var(--navy); color: #e8f0f7; }

.data-table .sticky-col-2 {
  position: sticky;
  left: var(--sticky-col-2-left);
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

.data-table th.sticky-col-2 { z-index: 4; background: var(--navy); color: #e8f0f7; }

.data-table tbody tr:nth-child(even) .sticky-col,
.data-table tbody tr:nth-child(even) .sticky-col-2 { background: #f7fafc; }
.data-table tbody tr:hover .sticky-col,
.data-table tbody tr:hover .sticky-col-2 { background: #eaf2f8; }

.data-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .col-desc {
  max-width: clamp(8rem, 18vw, 16rem);
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-panel-body { padding: 0; }
.table-panel-body .excel-table-wrap { border: none; border-radius: 0 0 var(--radius) var(--radius); }

.batches-table { min-width: 40rem; }
.excel-table { min-width: 58rem; }

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination-info { color: var(--text-muted); font-size: .8rem; }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 .4rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 4px;
  cursor: pointer;
  font-size: .78rem;
  color: var(--text);
  font-family: inherit;
}

.page-btn:hover:not(:disabled) { background: var(--surface-2); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-btn.active {
  background: var(--navy);
  border-color: var(--navy-deep);
  color: #fff;
  font-weight: 650;
}

.per-page-select {
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: .25rem .4rem;
  font-size: .78rem;
  font-family: inherit;
  background: var(--surface);
}

.batch-chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding-top: .75rem !important;
  padding-bottom: .75rem !important;
}

.batch-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--navy);
  border-radius: 3px;
  padding: .35rem .65rem;
  font-size: .78rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.2;
}

.batch-chip:hover {
  background: var(--primary-soft);
  border-color: var(--navy-mid);
}

.batch-chip.active {
  background: var(--navy);
  border-color: var(--navy-deep);
  color: #fff;
}

.records-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  flex: 1;
  min-width: 0;
}

.filter-input {
  flex: 1 1 16rem;
  min-width: 12rem;
  max-width: 28rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: .4rem .55rem;
  font-size: .85rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.filter-input:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--navy-mid);
}

.filter-select {
  min-width: 10rem;
  padding: .4rem .45rem;
}

/* Batch meta */
.batch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: .35rem;
}

.batch-meta strong { color: var(--text); font-weight: 650; }

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Dashboard */
.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.1rem;
  padding: 1.15rem 1.25rem;
  background:
    linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 55%, #1a5a8a 100%);
  border-radius: var(--radius);
  border-bottom: 3px solid var(--gold);
  color: #e8f0f7;
  box-shadow: var(--shadow);
}

.dash-hero .page-title { color: #fff; }
.dash-hero .page-subtitle { color: rgba(232, 240, 248, 0.78); }

.dash-hero-actions {
  display: flex;
  gap: .45rem;
  flex-shrink: 0;
}

.dash-hero-actions .btn-primary {
  background: var(--gold);
  border-color: #a8841a;
  color: var(--navy-deep);
}

.dash-hero-actions .btn-primary:hover:not(:disabled) {
  background: #e0b93a;
  border-color: var(--gold);
  color: var(--navy-deep);
}

.dash-hero-actions .btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.dash-hero-actions .btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.dash-kpi {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem;
}

.dash-kpi.accent-gold { border-top-color: var(--gold); }

.dash-kpi .stat-value { font-size: 1.4rem; }

.dash-kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 3px;
  background: var(--primary-soft);
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.dash-kpi-meta {
  margin: .25rem 0 0;
  font-size: .75rem;
  color: var(--text-muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.dash-panel { margin-bottom: 0; }

.dash-health-body {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.dash-ring-wrap { flex-shrink: 0; }

.dash-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(#d5dde6 0% 100%);
  display: grid;
  place-items: center;
  position: relative;
}

.dash-ring::before {
  content: '';
  position: absolute;
  inset: 14px;
  background: var(--surface);
  border-radius: 50%;
}

.dash-ring-center {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.dash-ring-center strong {
  font-size: 1.35rem;
  color: var(--navy);
}

.dash-ring-center span {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  flex: 1;
  min-width: 140px;
}

.dash-legend li {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .85rem;
}

.dash-legend strong {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch.done { background: #1a6b3c; }
.swatch.partial { background: #c9a227; }
.swatch.failed { background: #a32020; }

.value-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.value-row-top {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .3rem;
  font-size: .82rem;
  color: var(--text-muted);
}

.value-row-top strong {
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.value-track,
.rank-track {
  height: 8px;
  background: #e8eef3;
  border-radius: 2px;
  overflow: hidden;
}

.value-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width .4s ease;
}

.value-fill.fob { background: var(--navy); }
.value-fill.dbk { background: var(--navy-mid); }
.value-fill.rodtep { background: var(--gold); }

.rank-row {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  margin-bottom: .75rem;
}

.rank-row:last-child { margin-bottom: 0; }

.rank-idx {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

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

.rank-top {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .82rem;
  margin-bottom: .25rem;
}

.rank-top span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.rank-top strong {
  color: var(--text-muted);
  font-weight: 650;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.rank-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-mid), var(--gold));
  border-radius: 2px;
  transition: width .4s ease;
}

.activity-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr));
  gap: .65rem;
}

.activity-card {
  display: block;
  padding: .75rem .85rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy-mid);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.activity-card:hover {
  background: #fff;
  border-color: var(--navy-mid);
  box-shadow: var(--shadow);
  color: inherit;
}

.activity-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  margin-bottom: .4rem;
}

.activity-batch {
  font-size: .75rem;
  font-weight: 700;
  color: var(--navy);
}

.activity-folder {
  display: block;
  font-size: .9rem;
  margin-bottom: .45rem;
  color: var(--text);
}

.activity-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}

.activity-when {
  font-size: .7rem;
  color: var(--text-muted);
}

.port-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: 1rem;
  padding-top: .85rem;
  border-top: 1px dashed var(--border);
}

.port-chips-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: .25rem;
}

.port-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .5rem;
  background: var(--primary-soft);
  border: 1px solid #b7c9d6;
  border-radius: 2px;
  font-size: .75rem;
  color: var(--navy);
  font-weight: 600;
}

.port-chip em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 650;
}

.dash-empty-cta {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
}

.dash-empty-cta .btn { margin-top: .5rem; }

/* Large desktops: use full width comfortably */
@media (min-width: 1400px) {
  :root {
    --content-max: 1680px;
    --table-max-h: min(72dvh, 860px);
  }
}

@media (min-width: 1800px) {
  :root {
    --content-max: 1920px;
    --content-pad-x: 2rem;
  }
}

/* Tablets */
@media (max-width: 1024px) {
  :root {
    --table-max-h: min(65dvh, 640px);
  }

  .dash-hero {
    flex-wrap: wrap;
    align-items: stretch;
  }
}

/* Phones / small tablets — drawer nav */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
    --table-max-h: min(60dvh, 520px);
    --sticky-col-1-w: 3.75rem;
    --sticky-col-2-left: 3.75rem;
  }

  .mobile-topbar { display: flex; }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--panel-ms) var(--panel-ease);
  }

  html.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    width: min(16.5rem, 86vw);
    transform: translateX(-105%);
    --sidebar-w: min(16.5rem, 86vw);
  }

  html.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Collapse control unused on mobile drawer */
  .sidebar-collapse-btn { display: none; }
  html.sidebar-collapsed .sidebar-brand-text,
  html.sidebar-collapsed .sidebar-link-label {
    opacity: 1;
    width: auto;
  }

  .main-wrap { margin-left: 0; }

  .dash-hero {
    flex-direction: column;
    align-items: stretch;
    padding: .9rem 1rem;
  }

  .dash-hero-actions { width: 100%; }
  .dash-hero-actions .btn { flex: 1; }

  .page-toolbar-actions { width: 100%; }
  .page-toolbar-actions .btn { flex: 1 1 auto; justify-content: center; }

  .portal-panel-title { font-size: .82rem; }

  .data-table .sticky-col-2 { left: var(--sticky-col-2-left); }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  body.sidebar-lock { overflow: hidden; }
}
