/* ============================================================
   CARGOSYNC — ENTERPRISE CARGO OPERATIONS PORTAL
   Precision Design System, Responsive Architecture & Print Engine
   ============================================================ */

:root {
  /* Surfaces - Pure neutral dark-mode palette */
  --bg:              #09090B;
  --bg-grid:         #0F0F11;
  --bg-elevated:     #141416;
  --surface:         #18181A;
  --surface-2:       #222225;
  --surface-hover:   #2A2A2E;
  --border:          #2E2E33;
  --border-strong:   #3F3F46;
  --border-hairline: rgba(255, 255, 255, 0.08);

  /* Text colors */
  --text-primary:   #F4F4F5;
  --text-secondary: #A1A1AA;
  --text-tertiary:  #71717A;
  --text-on-accent: #09090B;

  /* Status accents */
  --status-green:       #22C55E;
  --status-green-soft:  rgba(34, 197, 94, 0.12);
  --status-amber:       #F59E0B;
  --status-amber-soft:  rgba(245, 158, 11, 0.12);
  --status-red:         #EF4444;
  --status-red-soft:    rgba(239, 68, 68, 0.12);
  --status-blue:        #3B82F6;
  --status-blue-soft:   rgba(59, 130, 246, 0.12);

  /* Typography - Unified Single Font Family: Inter */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Border radius */
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   18px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.65);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, 0.85);

  /* Transition timing */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   BASE & RESET
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse 900px 500px at 14% -10%, rgba(255, 255, 255, 0.025), transparent 60%),
    radial-gradient(ellipse 700px 500px at 85% 0%, rgba(255, 255, 255, 0.02), transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
  width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

:focus-visible {
  outline: 2px solid #F4F4F5;
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Sleek Scrollbars */
html, body, .slideover, .modal-body, .nav, .table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: #52525B;
}

/* Icon Alignment */
i, i.fa-solid, i.fa-regular, .fa-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  vertical-align: 0 !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  text-align: center !important;
}

/* ============================================================
   APP LAYOUT & NAVIGATION
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
}

/* ---------- Mobile Header ---------- */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky;
  top: 0;
  z-index: 160;
  padding-top: max(10px, env(safe-area-inset-top));
  width: 100%;
}

.mobile-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.system-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}
.system-status-chip .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.mobile-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
}
.mobile-menu-btn:active {
  background: var(--surface-hover);
}

.mobile-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.mobile-sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
}
.mobile-sidebar-close:hover, .mobile-sidebar-close:active {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ---------- Sidebar Navigation ---------- */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 240;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease);
}
.sidebar-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  background: linear-gradient(180deg, var(--bg-elevated) 0%, #0A0A0C 100%);
  border-right: 1px solid var(--border-hairline);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 120;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 4px;
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
  padding: 14px 10px 6px;
}
.nav-label:first-child {
  padding-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  min-height: 38px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 13.4px;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s var(--ease);
}

.nav-item i {
  width: 16px;
  height: 16px;
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}
.nav-item.is-active i {
  opacity: 1;
  color: #FFFFFF;
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}
.nav-item.is-active .nav-count {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 14px;
  margin-top: auto;
}

.system-sync-card {
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.system-sync-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  flex-shrink: 0;
}

.system-sync-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.system-sync-desc {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* ---------- Main Content Container ---------- */
.main {
  padding: 28px 34px 60px;
  max-width: 1440px;
  width: 100%;
  min-width: 0; /* Critical for grid child overflow isolation */
}

.view {
  display: none;
  min-width: 0;
}
.view.is-active {
  display: block;
  animation: fade-in 0.22s var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.view-head h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.view-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.view-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  min-height: 38px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn i {
  font-size: 12.5px;
  width: 13px;
  height: 13px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: #F4F4F5;
  color: #09090B;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: #E4E4E7;
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #52525B;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface);
}

.btn-sm {
  padding: 6px 11px;
  min-height: 32px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #FEF2F2;
  transform: translateY(-1px);
}

.btn-ghost-danger {
  background: transparent;
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.2);
}
.btn-ghost-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
}

.btn-count {
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s var(--ease);
}
.icon-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  padding: 16px 18px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 14px;
  flex-shrink: 0;
}
.stat-icon i {
  line-height: 1;
  display: inline-flex;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-foot {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   PANEL / TOOLBAR / TABLE
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  min-width: 0;
  width: 100%;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  flex-wrap: wrap;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  min-width: 260px;
  flex: 1;
  max-width: 420px;
  color: var(--text-tertiary);
  transition: border-color 0.15s;
}
.search-field:focus-within {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.search-field input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
}
.search-field input::placeholder {
  color: var(--text-tertiary);
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Custom Dropdowns */
.select-field {
  position: relative;
  display: inline-block;
}
.select-field-full {
  width: 100%;
  display: block;
}

.select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 13px;
  min-height: 36px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.15s var(--ease);
  user-select: none;
}
.select-btn-full {
  width: 100%;
  padding: 9px 11px;
}
.select-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface-hover);
}
.select-btn.is-open {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.select-btn i {
  font-size: 10.5px;
  opacity: 0.75;
  transition: transform 0.2s var(--ease);
}
.select-btn.is-open i {
  transform: rotate(180deg);
  opacity: 1;
}

.select-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 140;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  min-width: 200px;
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.select-menu-full {
  left: 0;
  right: 0;
  width: 100%;
}
.select-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.select-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.12s var(--ease);
  cursor: pointer;
}
.select-opt:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.select-opt.is-active {
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
}
.select-opt .select-check {
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.12s;
}
.select-opt.is-active .select-check {
  opacity: 1;
}

/* ---------- Table Container ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom-left-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-xl);
  width: 100%;
  min-width: 0;
}

.cargo-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.cargo-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.cargo-table thead th.num {
  text-align: right;
}
.cargo-table thead th.col-check {
  width: 42px;
  text-align: center;
}
.cargo-table thead th.col-end {
  width: 40px;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}
.sortable-th:hover {
  color: var(--text-primary);
}
.sortable-th .sort-icon {
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.3;
  transition: opacity 0.15s, transform 0.15s;
}
.sortable-th.is-sorted .sort-icon {
  opacity: 1;
  color: var(--text-primary);
}
.sortable-th.is-sorted.desc .sort-icon {
  transform: rotate(180deg);
}

.cargo-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-hairline);
  font-size: 13px;
  color: var(--text-secondary);
  vertical-align: middle;
  white-space: nowrap;
}

.cargo-table tbody td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
}

.cargo-table tbody tr {
  transition: background 0.12s;
}
.cargo-table tbody tr:hover {
  background: var(--surface-hover);
  cursor: pointer;
}
.cargo-table tbody tr.is-selected {
  background: var(--surface-2);
}
.cargo-table tbody tr:last-child td {
  border-bottom: none;
}

.cell-mark {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  font-weight: 600;
}
.cell-primary {
  color: var(--text-primary);
  font-weight: 500;
}

.cell-item {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-primary);
  font-weight: 500;
  max-width: 220px;
}
.cell-item-swatch {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}
.cell-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.cell-date {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.row-check {
  text-align: center;
  padding: 12px 10px;
}
.row-chevron {
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: right;
}

/* Checkbox Custom */
.checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}
.checkbox i {
  font-size: 10px;
  color: #09090B;
  opacity: 0;
  transition: opacity 0.1s;
}
.checkbox.is-checked {
  background: #F4F4F5;
  border-color: #F4F4F5;
}
.checkbox.is-checked i {
  opacity: 1;
}

/* Badges & Chips */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.4;
  white-space: nowrap;
}
.pill i {
  font-size: 11.5px;
  flex-shrink: 0;
}
.pill-warehouse {
  background: var(--surface-2);
  color: #F4F4F5;
  border: 1px solid var(--border);
}

.view-head-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.view-head-badge i {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.pill-partial {
  background: var(--status-amber-soft);
  color: var(--status-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.dwell-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
}
.dwell-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dwell-fresh {
  background: var(--status-green-soft);
  color: var(--status-green);
}
.dwell-fresh .dwell-dot {
  background: var(--status-green);
}
.dwell-aging {
  background: var(--status-amber-soft);
  color: var(--status-amber);
}
.dwell-aging .dwell-dot {
  background: var(--status-amber);
}
.dwell-stale {
  background: var(--status-red-soft);
  color: var(--status-red);
}
.dwell-stale .dwell-dot {
  background: var(--status-red);
}

.table-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 18px;
  text-align: center;
  gap: 6px;
}
.empty-state-icon {
  font-size: 30px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.empty-state p {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.empty-state span {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================================================
   FLOATING BULK ACTION BAR
   ============================================================ */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: calc(248px + (100vw - 248px) / 2);
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  padding: 7px 14px 7px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}
.bulk-bar.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.bulk-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bulk-count-badge {
  background: #F4F4F5;
  color: #09090B;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.bulk-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.bulk-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   OUTBOUND HISTORY VIEW
   ============================================================ */
.outbound-list {
  display: flex;
  flex-direction: column;
}

.outbound-item {
  border-bottom: 1px solid var(--border-hairline);
  transition: background 0.12s;
}
.outbound-item:last-child {
  border-bottom: none;
}

.outbound-item-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  user-select: none;
}
.outbound-item-head:hover {
  background: var(--surface-hover);
}

.ob-ref {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 85px;
}

.ob-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.ob-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ob-container {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13.5px;
}
.ob-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.ob-stats {
  display: flex;
  align-items: center;
  gap: 18px;
}
.ob-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.ob-stat span {
  font-size: 11px;
  color: var(--text-tertiary);
}
.ob-stat strong {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
}

.ob-chevron {
  color: var(--text-tertiary);
  font-size: 12px;
  transition: transform 0.2s var(--ease);
}
.outbound-item.is-open .ob-chevron {
  transform: rotate(180deg);
  color: var(--text-primary);
}

.outbound-item-body {
  display: none;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-hairline);
  padding: 12px 20px 18px;
}
.outbound-item.is-open .outbound-item-body {
  display: block;
}

.ob-lines-table {
  width: 100%;
  border-collapse: collapse;
}
.ob-lines-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-hairline);
}
.ob-lines-table th.num {
  text-align: right;
}
.ob-lines-table td {
  padding: 9px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-hairline);
}
.ob-lines-table td.num {
  text-align: right;
}
.ob-lines-table tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   CUSTOMERS DIRECTORY
   ============================================================ */
.customer-toolbar {
  margin-bottom: 18px;
}

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.customer-card {
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-xl);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease);
  cursor: pointer;
}
.customer-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.customer-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.customer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.customer-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.customer-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
}

.customer-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.customer-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.customer-meta-row i {
  font-size: 12px;
  width: 13px;
  color: var(--text-tertiary);
}

.customer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 8px 12px;
}
.customer-stat {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.customer-stat strong {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}
.customer-stat span {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.customer-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.customer-card-actions .btn {
  flex: 1;
}

/* ============================================================
   DOCUMENTS REPOSITORY
   ============================================================ */
.doc-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
}
.doc-type-badge i {
  font-size: 10px;
  color: var(--text-tertiary);
}

.doc-action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-left: 4px;
  transition: all 0.12s;
}
.doc-action-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* Drop Zone */
.drop-zone {
  margin-top: 8px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.15s ease;
}
.drop-zone:hover, .drop-zone.is-dragover {
  border-color: #F4F4F5;
  background: var(--surface-2);
}
.drop-zone-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-primary);
}
.drop-zone-content p {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.drop-zone-link {
  text-decoration: underline;
  color: #FFFFFF;
  font-weight: 600;
}
.drop-zone-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}
.file-chip-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-chip-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-primary);
}
.file-chip-text {
  display: flex;
  flex-direction: column;
}
.file-chip-text strong {
  font-size: 13px;
  color: var(--text-primary);
}
.file-chip-text span {
  font-size: 11px;
  color: var(--text-tertiary);
}
.file-chip-remove {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: color 0.12s;
}
.file-chip-remove:hover {
  color: #EF4444;
}

/* ============================================================
   CBM DIMENSION CALCULATOR WIDGET
   ============================================================ */
.cbm-calc-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.cbm-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.cbm-calc-icon {
  font-size: 11px;
  color: var(--text-tertiary);
  transition: transform 0.2s var(--ease);
}
.cbm-calc-head.is-open .cbm-calc-icon {
  transform: rotate(180deg);
}

.cbm-calc-body {
  display: none;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border-hairline);
}
.cbm-calc-body.is-open {
  display: block;
  animation: fade-in 0.2s var(--ease);
}

.cbm-calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* ============================================================
   REPORTS / AGING BAR
   ============================================================ */
.aging-summary-bar-wrap {
  padding: 14px 18px 8px;
}
.aging-bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  display: flex;
  overflow: hidden;
  margin-bottom: 10px;
}
.aging-bar-fresh {
  background: var(--status-green);
  height: 100%;
}
.aging-bar-aging {
  background: var(--status-amber);
  height: 100%;
}
.aging-bar-stale {
  background: var(--status-red);
  height: 100%;
}

.aging-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.aging-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.aging-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ============================================================
   MODALS, SCRIMS & SLIDEOVERS
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(0.97);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 210;
  width: 90%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
}
.modal.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 780px; }
.pdf-modal { max-width: 920px; width: 95%; height: 92vh; }

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-elevated);
  border-bottom-left-radius: var(--r-xl);
  border-bottom-right-radius: var(--r-xl);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.field-wide {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.field input, .field select, .field textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  min-height: 38px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-strong);
}

/* Custom Date Picker */
.datepicker-wrap {
  position: relative;
}
.datepicker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  min-height: 38px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
}
.datepicker-btn i {
  color: var(--text-tertiary);
}
.datepicker-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 120;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  width: 260px;
  display: none;
}
.datepicker-popover.is-open {
  display: block;
}
.datepicker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.datepicker-title {
  font-size: 13px;
  font-weight: 600;
}
.datepicker-nav {
  display: flex;
  gap: 4px;
}
.datepicker-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-secondary);
}
.datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.datepicker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.datepicker-day {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 4px;
  color: var(--text-secondary);
}
.datepicker-day:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.datepicker-day.is-selected {
  background: #F4F4F5;
  color: #09090B;
  font-weight: 700;
}
.datepicker-day.is-today {
  border: 1px solid var(--border-strong);
}
.datepicker-day.is-muted {
  opacity: 0.3;
}
.datepicker-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-hairline);
}
.datepicker-foot-btn {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Outbound Stepper Modal */
.ob-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 10px;
}
.ob-lines-count {
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.ob-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.ob-line {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ob-line-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ob-line-title strong {
  font-size: 13.5px;
  color: var(--text-primary);
  display: block;
}
.ob-line-title span {
  font-size: 12px;
  color: var(--text-tertiary);
}
.ob-line-avail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  padding: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.segmented button.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.ob-line-qty {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ob-line-qty label {
  font-size: 12px;
  color: var(--text-secondary);
}
.qty-stepper {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.qty-stepper-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}
.qty-stepper-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.qty-stepper-input {
  width: 60px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.ob-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.ob-summary div {
  display: flex;
  flex-direction: column;
}
.ob-summary span {
  font-size: 11px;
  color: var(--text-tertiary);
}
.ob-summary strong {
  font-size: 13.5px;
  color: var(--text-primary);
}

/* ---------- Slideover Drawers ---------- */
.slideover {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  z-index: 230;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s var(--ease);
}
.slideover.is-open {
  transform: translateX(0);
}

.slideover-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.slideover-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  display: block;
}
.slideover-head h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
}

.slideover-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.slideover-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-media {
  height: 84px;
  min-height: 84px;
  flex-shrink: 0;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: var(--text-primary);
  margin: 2px 0 6px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.detail-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-field span {
  font-size: 11px;
  color: var(--text-tertiary);
}
.detail-field strong {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.qty-tracker {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  display: flex;
  overflow: hidden;
}
.qty-tracker-fill {
  background: #F4F4F5;
  height: 100%;
}
.qty-tracker-released {
  background: var(--border-strong);
  height: 100%;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 9px 12px;
  min-height: 54px;
  max-height: 54px;
  box-sizing: border-box;
  transition: all var(--t-fast);
}
.doc-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}
.doc-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.doc-item-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.doc-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-item-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-item-sub > * {
  white-space: nowrap;
  flex-shrink: 0;
}
.doc-pill-tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  padding: 1.5px 6px;
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.doc-item-sep {
  color: var(--text-tertiary);
  opacity: 0.5;
  font-size: 8px;
  flex-shrink: 0;
}
.doc-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.doc-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--t-fast);
}
.doc-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* Document Repository: Customer Grouping Architecture */
.doc-groups-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.doc-customer-group {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: border-color var(--t-fast);
}
.doc-customer-group:hover {
  border-color: var(--border-subtle);
}
.doc-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-hairline);
  flex-wrap: wrap;
  gap: 10px;
}
.doc-group-customer-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-group-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
  flex-shrink: 0;
}
.doc-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.doc-group-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}
.doc-group-count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Customer Lifetime Box */
.lifetime-summary-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lifetime-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
}
.lifetime-stat span {
  font-size: 11px;
  color: var(--text-tertiary);
  display: block;
}
.lifetime-stat strong {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}
.lifetime-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lifetime-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.lifetime-progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.lifetime-progress-fill {
  background: #F4F4F5;
  height: 100%;
  transition: width 0.3s var(--ease);
}

/* ============================================================
   DOCUMENT PREVIEW SURFACE
   ============================================================ */
.doc-preview-surface {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 20px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}
.doc-preview-header {
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.doc-preview-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.doc-preview-meta {
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.doc-preview-body {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================================
   DATABASE BACKUP MODAL
   ============================================================ */
.backup-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.backup-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.backup-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.backup-card-head strong {
  font-size: 13.5px;
  color: var(--text-primary);
  display: block;
}
.backup-card-head p {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 300;
  transform: translateY(80px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   PUBLICATION-GRADE A4 PRINT & PDF PREVIEW
   ============================================================ */
.pdf-modal-body {
  padding: 20px;
  background: #101012;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.a4-sheet {
  background: #FFFFFF;
  color: #18181B;
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  padding: 18mm;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #18181B;
  padding-bottom: 12px;
}
.pdf-brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #09090B;
  margin: 0;
}
.pdf-brand span {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717A;
  font-weight: 600;
}

.pdf-doc-info {
  text-align: right;
}
.pdf-doc-title {
  font-size: 13px;
  font-weight: 700;
  color: #09090B;
}
.pdf-doc-meta {
  font-size: 10px;
  color: #52525B;
  font-family: var(--font-mono);
}

.pdf-client-banner {
  background: #F4F4F5;
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.pdf-client-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pdf-client-avatar {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #18181B;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}
.pdf-client-name {
  font-size: 14px;
  font-weight: 700;
  color: #09090B;
}
.pdf-client-mark {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #52525B;
}
.pdf-client-contact {
  text-align: right;
  font-size: 10.5px;
  color: #52525B;
}

.pdf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.pdf-kpi-card {
  border: 1px solid #E4E4E7;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pdf-kpi-label {
  font-size: 9.5px;
  text-transform: uppercase;
  color: #71717A;
  font-weight: 600;
}
.pdf-kpi-val {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #09090B;
}

.pdf-section-heading {
  font-size: 12px;
  font-weight: 700;
  color: #09090B;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
}
.pdf-table th {
  background: #F4F4F5;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #3F3F46;
  padding: 7px 8px;
  border-bottom: 1px solid #D4D4D8;
}
.pdf-table th.num, .pdf-table td.num {
  text-align: right;
}
.pdf-table td {
  padding: 7px 8px;
  font-size: 10.5px;
  color: #27272A;
  border-bottom: 1px solid #E4E4E7;
}

.pdf-footer {
  margin-top: auto;
  border-top: 1px solid #D4D4D8;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  color: #71717A;
}
.pdf-stamp-box {
  border: 1px dashed #A1A1AA;
  border-radius: 4px;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 9px;
  color: #3F3F46;
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-action-btn.btn-doc-delete:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #F87171 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* ============================================================
   MEDIA PRINT STYLES
   ============================================================ */
@media print {
  body * {
    visibility: hidden;
  }
  #a4StatementSheet, #a4StatementSheet *,
  #docViewerContent, #docViewerContent * {
    visibility: visible;
  }
  #a4StatementSheet, #docViewerContent {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 15mm;
    box-shadow: none;
    background: #FFFFFF !important;
    color: #09090B !important;
  }
  @page {
    size: A4 portrait;
    margin: 0;
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS (TABLETS & DESKTOP)
   ============================================================ */
@media (max-width: 1023px) {
  .app {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .mobile-header {
    display: flex;
  }
  .mobile-sidebar-close {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    z-index: 250;
    box-shadow: var(--shadow-lg);
    visibility: hidden;
  }
  .sidebar.is-mobile-open {
    transform: translateX(0);
    visibility: visible;
  }

  .main {
    padding: 20px 20px 60px;
  }

  .bulk-bar {
    left: 50%;
    width: calc(100% - 32px);
    max-width: 480px;
    justify-content: space-between;
  }

  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-row-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS (MOBILE VIEWPORTS <640px)
   ============================================================ */
@media (max-width: 639px) {
  .main {
    padding: 14px 12px 60px;
  }

  .view-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .view-head h1 {
    font-size: 20px;
  }
  .view-sub {
    font-size: 12px;
  }
  .view-head-actions {
    width: 100%;
  }
  .view-head-actions .btn {
    flex: 1;
    min-height: 40px;
    justify-content: center;
  }

  /* Stat Cards 2x2 Grid on Mobile for compact scannability */
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-row-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-row-3 .stat-card:last-child {
    grid-column: 1 / -1;
  }

  .stat-card {
    padding: 12px 14px 12px;
  }
  .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
    margin-bottom: 4px;
  }
  .stat-label {
    font-size: 11px;
  }
  .stat-value {
    font-size: 18px;
  }
  .stat-foot {
    font-size: 10px;
  }

  /* Panel & Toolbar */
  .panel-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .search-field {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
  .toolbar-filters {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .toolbar-filters .select-field {
    flex: 1;
  }
  .toolbar-filters .select-btn {
    width: 100%;
    justify-content: space-between;
  }

  .customer-grid {
    grid-template-columns: 1fr;
  }

  .customer-card {
    padding: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Full Width Slideovers on Mobile */
  .slideover {
    width: 100%;
    max-width: 100%;
  }

  /* Centered Mobile Modals */
  .modal {
    width: calc(100% - 20px);
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--r-lg);
  }
  .modal-head {
    padding: 14px 16px;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-foot {
    padding: 12px 16px;
    flex-direction: row;
    gap: 8px;
  }
  .modal-foot .btn {
    flex: 1;
    min-height: 42px;
    justify-content: center;
  }

  /* Floating Bulk Bar */
  .bulk-bar {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    transform: translateY(100px);
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 8px 12px;
    justify-content: space-between;
  }
  .bulk-bar.is-visible {
    transform: translateY(0);
  }

  /* Outbound Items */
  .outbound-item-head {
    padding: 14px 16px;
    gap: 12px;
  }
  .ob-stats {
    display: none;
  }

  /* Full Screen A4 PDF Preview Modal on Mobile */
  .pdf-modal {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }
  .pdf-modal.is-open {
    transform: none;
  }
  .pdf-modal-body {
    padding: 10px;
  }
  .a4-sheet {
    width: 100%;
    padding: 12px;
    box-shadow: none;
    min-height: auto;
  }
  .pdf-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pdf-client-contact {
    text-align: left;
  }

  .cbm-calc-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .cbm-calc-grid input {
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Very Small Mobile Screens (<360px) */
@media (max-width: 359px) {
  .stat-row, .stat-row-3 {
    grid-template-columns: 1fr;
  }
  .customer-stats {
    padding: 6px 8px;
  }
  .customer-card-actions {
    flex-direction: column;
  }
  .pdf-kpi-grid {
    grid-template-columns: 1fr;
  }
}
