/**
 * ═══════════════════════════════════════════════════════════
 * XFLANE Container Dispatch System — v2.0 Dark Theme
 * Left Sidebar Layout · Commercial Grade
 * Optimized for Night-Shift Operations (护眼深色模式)
 * ═══════════════════════════════════════════════════════════
 */

/* ========== Dark Theme Variables ========= */
:root,
[data-theme="default"] {
  /* Core dark palette */
  --bg-app:        #0f1021;       /* Deepest background */
  --bg-sidebar:    #161728;       /* Sidebar */
  --bg-sidebar-hov:#1e1f38;
  --bg-sidebar-active: #232545;
  --bg-panel:      #1a1b30;       /* Content panels */
  --bg-panel-hov:  #222340;
  --bg-card:       #1e1f35;
  --bg-card-hov:   #262847;
  --bg-input:      #18192d;
  --bg-input-focus:#1e2040;

  /* Accent colors (vibrant on dark) — Default: Violet-Indigo */
  --accent:        #6c5ce7;
  --accent-light:  #a29bfe;
  --accent-glow:   rgba(108, 92, 231, 0.25);
  --blue:          #0984e3;
  --blue-light:    #74b9ff;
  --blue-glow:     rgba(9, 132, 227, 0.2);
  --cyan:          #00cec9;
  --green:         #00b894;
  --green-light:   #55efc4;
  --yellow:        #fdcb6e;
  --orange:        #e17055;
  --red:           #d63031;
  --red-light:     #ff7675;
  --pink:          #fd79a8;

  /* Text */
  --text-primary:  #eaeaff;
  --text-secondary:#9999bb;
  --text-muted:    #666688;
  --text-accent:   var(--accent-light);
  --text-on-accent:#fff;

  /* Borders & shadows */
  --border:        rgba(255,255,255,0.06);
  --border-light:  rgba(255,255,255,0.10);
  --border-accent: var(--accent);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.45);
  --glow-blue:     0 0 20px rgba(9,132,227,0.15);
  --glow-accent:   0 0 20px rgba(108,92,231,0.15);

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  --topbar-height:  52px;
  --radius:        8px;
  --radius-lg:     12px;

  /* Font */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Section header backgrounds (作业页面表头) */
  --sec-pickup-bg:   rgba(0,184,148,0.12);
  --sec-delivery-bg: rgba(9,132,227,0.12);
  --sec-return-bg:   rgba(253,121,168,0.12);
}

/* ═══════════ THEME 1: Ocean Blue (深海蓝) ═══════════ */
[data-theme="ocean"] {
  --bg-app:        #0a1628;
  --bg-sidebar:    #0f1f38;
  --bg-sidebar-hov:#162d4e;
  --bg-sidebar-active: #1a3a5c;
  --bg-panel:      #12243d;
  --bg-panel-hov:  #1a3055;
  --bg-card:       #162d4e;
  --bg-card-hov:   #1e3a5f;
  --bg-input:      #0e1c32;
  --bg-input-focus:#142842;

  --accent:        #0077b6;
  --accent-light:  #48cae4;
  --accent-glow:   rgba(0, 119, 182, 0.25);
  --blue:          #0096c7;
  --blue-light:    #90e0ef;
  --blue-glow:     rgba(0, 150, 199, 0.2);
  --green:         #2ec4b6;
  --green-light:   #80ffdb;
  --yellow:        #ffd166;
  --orange:        #f77f00;
  --red:           #ef476f;
  --red-light:     #ff8fa3;
  --pink:          #d62828;

  --text-primary:  #caf0f8;
  --text-secondary:#90a4ae;
  --text-muted:    #607082;
  --text-accent:   var(--accent-light);
  --glow-accent:   0 0 20px rgba(0,119,182,0.18);
}

[data-theme="neon"] {
  --bg-app:        #10081c;
  --bg-sidebar:    #180e26;
  --bg-sidebar-hov:#24163a;
  --bg-sidebar-active: #2e1e48;
  --bg-panel:      #1c1230;
  --bg-panel-hov:  #281a42;
  --bg-card:       #24163a;
  --bg-card-hov:   #302052;
  --bg-input:      #160e24;
  --bg-input-focus:#1e1536;

  --accent:        #b829d1;
  --accent-light:  #e88dff;
  --accent-glow:   rgba(184, 41, 209, 0.3);
  --blue:          #7209b7;
  --blue-light:    #c77dff;
  --blue-glow:     rgba(114, 9, 183, 0.25);
  --green:         #38b000;
  --green-light:   #70e000;
  --yellow:        #ffea00;
  --orange:        #ff5400;
  --red:           #ff0054;
  --red-light:     #ff7096;
  --pink:          #ff006e;

  --text-primary:  #f0e6ff;
  --text-secondary:#b39ddb;
  --text-muted:    #7e57c2;
  --text-accent:   var(--accent-light);
  --glow-accent:   0 0 20px rgba(184,41,209,0.25);
}

[data-theme="steel"] {
  --bg-app:        #111118;
  --bg-sidebar:    #191a22;
  --bg-sidebar-hov:#232430;
  --bg-sidebar-active: #2d2e3c;
  --bg-panel:      #1a1b24;
  --bg-panel-hov:  #242532;
  --bg-card:       #222330;
  --bg-card-hov:   #2e3040;
  --bg-input:      #15161e;
  --bg-input-focus:#1e1f2a;

  --accent:        #475569;
  --accent-light:  #94a3b8;
  --accent-glow:   rgba(71, 85, 105, 0.2);
  --blue:          #2563eb;
  --blue-light:    #93c5fd;
  --blue-glow:     rgba(37, 99, 235, 0.2);
  --green:         #059669;
  --green-light:   #6ee7b7;
  --yellow:        #eab308;
  --orange:        #ea580c;
  --red:           #dc2626;
  --red-light:     #fca5a5;
  --pink:          #a78bfa;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --text-accent:   var(--accent-light);
  --glow-accent:   0 0 20px rgba(71,85,105,0.15);
}

/* ═══════════ THEME 6: White Light (白色亮色) ═══════════ */
[data-theme="white"] {
  --bg-app:        #f0f2f5;
  --bg-sidebar:    #ffffff;
  --bg-sidebar-hov:#f5f7fa;
  --bg-sidebar-active: #e8ecf2;
  --bg-panel:      #ffffff;
  --bg-panel-hov:  #f8f9fc;
  --bg-card:       #ffffff;
  --bg-card-hov:   #f5f7fa;
  --bg-input:      #f0f2f5;
  --bg-input-focus:#ffffff;

  --accent:        #4f46e5;
  --accent-light:  #818cf8;
  --accent-glow:   rgba(79, 70, 229, 0.15);
  --blue:          #2563eb;
  --blue-light:    #3b82f6;
  --blue-glow:     rgba(37, 99, 235, 0.12);
  --green:         #059669;
  --green-light:   #10b981;
  --yellow:        #d97706;
  --orange:        #ea580c;
  --red:           #dc2626;
  --red-light:     #ef4444;
  --pink:          #ec4899;

  --text-primary:  #1e293b;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;
  --text-accent:   var(--accent-light);
  --border:        rgba(0,0,0,0.08);
  --border-light:  rgba(0,0,0,0.12);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.12);
  --glow-blue:     0 0 16px rgba(37,99,235,0.10);
  --glow-accent:   0 0 16px rgba(79,70,229,0.10);
}

/* ═══════════ WHITE THEME ONLY — force legible (dark) text on light surfaces ═══════════
   These override hardcoded #fff that sits on white/light backgrounds in white mode.
   Scoped to [data-theme="white"] so dark themes are never touched. */
[data-theme="white"] .sb-logo,
[data-theme="white"] .sb-logo-text,
[data-theme="white"] .page-title,
[data-theme="white"] .stat-card .stat-value,
[data-theme="white"] .panel-title,
[data-theme="white"] .modal-title,
[data-theme="white"] .cl-row .cl-ctnr,
[data-theme="white"] .kcard .ctnr,
[data-theme="white"] .emodal-toolbar .et-title,
[data-theme="white"] .sp-title,
[data-theme="white"] .panel-header h3 { color: #1e293b; }

[data-theme="white"] .sb-item.active { color: #1e293b; }
[data-theme="white"] .panel-title i { color: var(--accent); }

[data-theme="white"] .sb-toggle:hover,
[data-theme="white"] .btn-icon:hover,
[data-theme="white"] .modal-close:hover,
[data-theme="white"] .et-tool-icon:hover,
[data-theme="white"] .sb-item:hover { color: var(--text-primary); }

/* 白色主题：表格条纹和悬停使用浅色 */
[data-theme="white"] .excel-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
[data-theme="white"] .excel-table tbody tr:hover { background: rgba(79,70,229,0.06); }
[data-theme="white"] .excel-table tbody tr.selected { background: rgba(79,70,229,0.10); }

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

html { font-size: 14px; scroll-behavior: smooth; }

body.xflane-dark {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-app);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-light); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-light); text-decoration: none; }

img { max-width: 100%; display: block; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transition: width 0.25s cubic-bezier(.4,0,.2,1), transform 0.25s;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sb-logo-text,
.sidebar.collapsed .sb-item span,
.sidebar.collapsed .sb-search-wrap input::placeholder,
.sidebar.collapsed .sb-user-details,
.sidebar.collapsed .sb-footer-actions { opacity: 0; visibility: hidden; }

/* Sidebar Header / Logo */
.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}
.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  white-space: nowrap;
}
.sb-logo:hover { color: var(--accent-light); }
.sb-logo-img {
  max-height: 32px;
  max-width: 170px;
  object-fit: contain;
  display: block;
}
.sidebar.collapsed .sb-logo-img { max-width: 32px; }
.sb-logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(108,92,231,0.5));
}
.sb-toggle {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text-secondary);
  cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.sb-toggle:hover { background: var(--bg-sidebar-hov); color: var(--text-primary); }

/* Sidebar Navigation */
.sb-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .15s;
  position: relative;
  cursor: pointer;
}
.sb-item i {
  width: 20px; text-align: center;
  font-size: 15px; flex-shrink: 0;
}
.sb-item:hover {
  background: var(--bg-sidebar-hov);
  color: var(--text-primary);
}
.sb-item.active {
  background: linear-gradient(135deg, rgba(108,92,231,0.20), rgba(9,132,227,0.12));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(108,92,231,0.2);
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* LFD warning badge on the Dispatch nav item (v2.2.46) */
.lfd-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e03131; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  border-radius: 10px;
  box-shadow: 0 0 6px rgba(224,49,49,.6);
  animation: lfdPulse 1.6s ease-in-out infinite;
}
@keyframes lfdPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.sidebar.collapsed .lfd-badge {
  position: absolute; top: 6px; right: 10px; margin: 0;
}

/* Sidebar Bottom */
.sb-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Sidebar Search */
.sb-search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 12px;
  transition: border-color .15s;
}
.sb-search-wrap:focus-within { border-color: var(--accent); }
.sb-search-wrap > i { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.sb-search {
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 13px;
  width: 100%; min-width: 120px;
}
.sb-search::placeholder { color: var(--text-muted); }

/* User Info */
.sb-user-info {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.sb-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: uppercase;
}
.sb-user-details { display: flex; flex-direction: column; min-width: 80px; }
.sb-user-name { font-weight: 600; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 11px; color: var(--text-muted); }

/* Footer actions in sidebar */
.sb-footer-actions {
  display: flex; align-items: center; gap: 6px;
}
.sb-lang {
  padding: 4px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  transition: all .12s;
}
.sb-lang:hover, .sb-lang.active { color: var(--accent-light); background: var(--bg-sidebar-hov); }
.sb-logout {
  margin-left: auto; padding: 6px 10px;
  color: var(--text-muted); border-radius: var(--radius);
  transition: all .12s;
}
.sb-logout:hover { color: var(--red-light); background: rgba(214,48,49,0.1); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,0.5); z-index: 1050;
}
.sidebar-overlay.show { display: block; }

/* Floating mobile menu button (hidden on desktop) */
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  margin-right: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--text); font-size: 16px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mobile-menu-btn:hover { border-color: var(--border-light); background: var(--bg-sidebar-hov); }

/* ===================== APP WRAPPER + MAIN ===================== */
.app-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
}
.sidebar.collapsed ~ .app-wrapper,
.sidebar.collapsed + .app-wrapper { margin-left: var(--sidebar-collapsed); }

.main-content {
  min-height: 100vh;
  padding: 24px 28px;
  max-width: 1600px;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 22px; font-weight: 800; color: var(--text-primary);
  display: flex; align-items: baseline; gap: 10px;
  letter-spacing: -0.02em;
}
.page-title span {
  font-size: 13px; font-weight: 400; color: var(--text-muted);
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.page-subtitle { margin: 0; font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.page-info { color: var(--text-secondary); font-size: 13px; font-weight: 500; padding: 0 8px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s ease;
  white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 13px 26px; font-size: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; border: none;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow); }

.btn-success {
  background: linear-gradient(135deg, #059669, var(--green)); color: #fff;
  box-shadow: 0 2px 10px rgba(0,184,148,0.2);
}
.btn-success:hover { transform: translateY(-1px); }

.btn-warning {
  background: linear-gradient(135deg, #d97706, var(--orange)); color: #fff;
}
.btn-danger {
  background: linear-gradient(135deg, #b91c1c, var(--red)); color: #fff;
}
.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover { background: var(--bg-card-hov); border-color: var(--border-light); }
.btn-icon {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: none; background: var(--bg-card);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 14px;
}
.btn-icon:hover { background: var(--bg-card-hov); color: var(--text-primary); }

/* ===================== STATS CARDS GRID ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px 22px;
  display: flex; align-items: center; gap: 16px;
  transition: all .2s; position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  opacity: 0; transition: opacity .2s;
}
.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--glow-accent);
}
.stat-card:hover::before { opacity: 1; }

.stat-link { text-decoration: none; color: inherit; cursor: pointer; }
.stat-link:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-card .stat-icon.blue   { background: rgba(9,132,227,0.15); color: var(--blue-light); }
.stat-card .stat-icon.green  { background: rgba(0,184,148,0.15); color: var(--green-light); }
.stat-card .stat-icon.orange{ background: rgba(225,112,85,0.15); color: var(--orange); }
.stat-card .stat-icon.red    { background: rgba(214,48,49,0.15); color: var(--red-light); }
.stat-card .stat-icon.purple { background: rgba(108,92,231,0.15); color: var(--accent-light); }
.stat-card .stat-icon.gray   { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.stat-card .stat-icon.cyan   { background: rgba(0,206,201,0.15); color: var(--cyan); }

.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-value {
  font-size: 28px; font-weight: 800; color: #fff;
  line-height: 1.2; letter-spacing: -0.03em;
}
.stat-card .stat-label {
  font-size: 12px; color: var(--text-secondary); margin-top: 3px;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;
}

/* ===================== DASHBOARD PANELS ===================== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px; margin-bottom: 20px;
}
.dash-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px; margin-bottom: 20px;
}
.dash-full { grid-column: 1 / -1; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: border-color .2s;
}
.panel:hover { border-color: var(--border-light); }
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.panel-title {
  font-size: 15px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.panel-title i { color: var(--accent-light); font-size: 14px; }
.panel-action {
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; transition: color .12s;
  padding: 4px 8px; border-radius: 4px;
}
.panel-action:hover { color: var(--accent-light); background: var(--bg-sidebar-hov); }

/* Chart containers */
.chart-wrap {
  position: relative; width: 100%; height: 280px;
}
.chart-wrap.tall { height: 320px; }
.chart-wrap.short { height: 220px; }

/* ===================== DASHBOARD PANEL SIZING ===================== */
.dash-panel {
  grid-column: span var(--span-w, 1);
  position: relative;
  transition: box-shadow .2s, border-color .2s;
}
.dash-panel:hover { border-color: var(--border-light); }

/* Panel header tools row (flex container for selects + actions) */
.panel-header-tools {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; flex-shrink: 0;
}

/* Size selector dropdown (1-4 columns) */
.dash-size-select {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
  min-width: 42px;
  text-align: center;
  transition: all .15s;
}
.dash-size-select:hover { border-color: var(--accent); color: var(--text); }
.dash-size-select:focus { border-color: var(--accent-light); }

/* Span sizes (width only) */
.dash-panel[data-w="2"] { --span-w: 2; }
.dash-panel[data-w="3"] { --span-w: 3; }
.dash-panel[data-w="4"] { --span-w: 4; }

/* Range selector in trend panel header */
.dash-range-select {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  transition: all .15s;
}
.dash-range-select:hover { border-color: var(--accent-light); color: var(--text); }
.dash-range-select:focus { border-color: var(--accent); }

/* ===================== EXCEL-LIKE DATA TABLE (Dark) ===================== */
.data-grid-container {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.excel-table-wrapper {
  overflow-x: auto; overflow-y: auto;
  max-height: calc(100vh - 200px); position: relative;
}
.excel-table {
  border-collapse: collapse; width: 100%; font-size: 12.5px;
  table-layout: fixed; min-width: 900px;
}
.excel-table th,
.excel-table td {
  border: 1px solid var(--border);
  padding: 6px 10px; text-align: left;
  vertical-align: middle; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4; height: 34px;
  color: var(--text-primary);
}
.excel-table thead { position: sticky; top: 0; z-index: 10; }

/* Flash message banner */
.flash-banner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-sm); border: 1px solid transparent; }
.flash-error   { background: rgba(255,107,107,.15); color: #ff8787; border-color: rgba(255,107,107,.4); }
.flash-success { background: rgba(81,207,102,.15);  color: #69db7c; border-color: rgba(81,207,102,.4); }
.flash-info    { background: rgba(77,171,247,.15);  color: #74c0fc; border-color: rgba(77,171,247,.4); }

/* Collapsible finance line-item detail row (Tier 2 #6) */
.detail-row { background: var(--bg-sidebar-hov); }
.detail-row td { white-space: normal !important; overflow: visible !important; height: auto !important; }
.detail-row td table td { border: none; padding: 2px 0; white-space: nowrap; }

/* Header Row 1 - Section headers */
.excel-table .header-row-1 th {
  background: var(--bg-sidebar-active); color: var(--text-primary);
  font-weight: 700; font-size: 11.5px; text-align: center;
  padding: 8px 8px; border: 1px solid var(--border-light);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.excel-table .section-basic   { background: var(--bg-panel-hov) !important; }
.excel-table .section-pickup  { background: rgba(0,184,148,0.15) !important; color: var(--green-light) !important; }
.excel-table .section-delivery{ background: rgba(9,132,227,0.15) !important; color: var(--blue-light) !important; }
.excel-table .section-return  { background: rgba(253,121,168,0.15) !important; color: var(--pink) !important; }
.excel-table .section-bill    { background: rgba(253,203,110,0.15) !important; color: var(--yellow) !important; }

/* Header Row 2 - Column names */
.excel-table .header-row-2 th {
  background: var(--bg-card); color: var(--text-secondary);
  font-weight: 650; font-size: 11.5px; padding: 6px 10px;
  border: 1px solid var(--border);
}
.excel-table .header-row-2 th:hover { background: var(--bg-card-hov); cursor: pointer; }

/* Data rows */
.excel-table tbody tr { background: transparent; transition: background .15s ease; }
.excel-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.excel-table tbody tr:hover { background: rgba(108,92,231,0.08); }
.excel-table tbody tr.selected { background: rgba(108,92,231,0.15); }

/* Status cell */
.status-cell { font-weight: 700; text-align: center; font-size: 11.5px; }

/* ── Table Density Modes (v2.2.43) ── */
.excel-table.table-compact { font-size: 11px; }
.excel-table.table-compact th,
.excel-table.table-compact td { padding: 3px 6px !important; height: 28px !important; font-size: 11px !important; }
.excel-table.table-compact .header-row-1 th { padding: 5px 4px !important; font-size: 10.5px !important; }
.excel-table.table-compact .header-row-2 th { padding: 4px 5px !important; font-size: 10.5px !important; }

.excel-table.table-wide { font-size: 14px; }
.excel-table.table-wide th,
.excel-table.table-wide td { padding: 10px 14px !important; height: 42px !important; font-size: 13px !important; }
.excel-table.table-wide .header-row-1 th { padding: 10px 12px !important; font-size: 12.5px !important; }
.excel-table.table-wide .header-row-2 th { padding: 8px 12px !important; font-size: 12.5px !important; }

/* Default = normal (no extra class needed, matches current) */

/* ── Density Toolbar (v2.2.43) ── */
.density-toolbar {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; margin-left: 8px;
}
.density-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 28px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-muted);
  font-size: 11px; cursor: pointer; transition: all .15s;
  line-height: 1;
}
.density-btn:hover { background: rgba(255,255,255,.06); color: var(--text-primary); }
.density-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(139,92,246,.35); }

/* ── Font Selector (v2.2.43) ── */
.font-option {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); transition: all .15s;
  margin-bottom: 6px;
}
.font-option:hover { border-color: var(--accent); background: rgba(139,92,246,.06); }
.font-option.active { border-color: var(--accent); background: rgba(139,92,246,.12); }
.font-preview {
  flex: 1; font-size: 16px; letter-spacing: .3px;
}
.font-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.font-check { color: var(--accent); font-size: 16px; opacity: 0; transition: opacity .15s; }
.font-option.active .font-check { opacity: 1; }

/* Row coloring */
.row-red td      { background: rgba(214,48,49,0.15) !important; color: var(--red-light) !important; }
.row-red td a    { color: var(--red-light) !important; font-weight: 700; }
.row-green td    { background: rgba(0,184,148,0.12) !important; }
.row-yellow td   { background: rgba(253,203,110,0.12) !important; }
.row-gray td     { background: rgba(255,255,255,0.04) !important; }
.row-blue td     { background: rgba(9,132,227,0.10) !important; }

/* Section cells */
.cell-pickup  { background: rgba(0,184,148,0.06); }
.cell-delivery { background: rgba(9,132,227,0.06); }
.cell-return  { background: rgba(225,112,85,0.06); }
.cell-bill    { background: rgba(253,203,110,0.06); }
.cell-warn    { color: var(--red-light) !important; font-weight: 700; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
}
.badge-blue    { background: rgba(9,132,227,0.2); color: var(--blue-light); }
.badge-green   { background: rgba(0,184,148,0.2); color: var(--green-light); }
.badge-red     { background: rgba(214,48,49,0.2); color: var(--red-light); }
.badge-yellow  { background: rgba(253,203,110,0.2); color: var(--yellow); }
.badge-purple  { background: rgba(108,92,231,0.2); color: var(--accent-light); }
.badge-gray    { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.badge-dark    { background: rgba(255,255,255,0.1); color: #fff; }

/* ===================== FORMS ===================== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 18px; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 10px; line-height: 1.5; }
.profile-theme-dots, .profile-font-row { margin-top: 4px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px; font-weight: 650; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.form-group label.required::after { content: ' *'; color: var(--red); }
.form-control {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--bg-input);
  color: var(--text-primary);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-input-focus);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: auto; padding-right: 8px; }
textarea.form-control { resize: vertical; min-height: 72px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); }

/* ===================== MODAL (Dark) ===================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 2000; display: flex;
  align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .2s, visibility .2s;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-panel);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 94%; max-width: 640px;
  max-height: 90vh; display: flex; flex-direction: column;
  transform: translateY(-16px) scale(0.97);
  transition: transform .25s;
  border: 1px solid var(--border-light);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1140px; }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; color: #fff; }

.modal-close {
  background: none; border: none; font-size: 19px;
  cursor: pointer; color: var(--text-muted);
  width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-sidebar-hov); color: #fff; }

.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
/* Filter modal: give each field group breathing room */
.filter-modal .modal-body { display: flex; flex-direction: column; gap: 18px; }
.filter-modal .form-group { gap: 8px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ===================== FILTER CHIPS (PORT multi-select) ===================== */
.fchip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.fchip {
  display: inline-flex; align-items: center;
  padding: 7px 18px; border-radius: 18px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-light);
  background: rgba(255,255,255,.06);
  color: var(--text-secondary);
  user-select: none; transition: .15s;
}
.fchip:hover { border-color: var(--accent); color: var(--text-primary); }
.fchip.on {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(108,92,231,.35);
}

/* ===================== ALERTS & TOASTS ===================== */
.alert {
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; border: 1px solid transparent; font-weight: 500;
}
.alert-success { background: rgba(0,184,148,0.12); color: var(--green-light); border-color: rgba(0,184,148,0.2); }
.alert-error   { background: rgba(214,48,49,0.12); color: var(--red-light); border-color: rgba(214,48,49,0.2); }
.alert-warning { background: rgba(253,203,110,0.12); color: var(--yellow); border-color: rgba(253,203,110,0.2); }
.alert-info    { background: rgba(9,132,227,0.12); color: var(--blue-light); border-color: rgba(9,132,227,0.2); }

.toast-container {
  position: fixed; top: 70px; right: 24px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-size: 13px; min-width: 300px;
  display: flex; align-items: center; gap: 10px;
  animation: slideInRight .25s ease;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 500;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--orange); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===================== PAGINATION ===================== */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: center;
}
.pagination a, .pagination span {
  padding: 6px 13px; border-radius: var(--radius); font-size: 12px;
  color: var(--text-primary);
  border: 1px solid var(--border);
  min-width: 36px; text-align: center;
  font-weight: 500;
}
.pagination a:hover { background: var(--bg-panel-hov); border-color: var(--border-light); text-decoration: none; }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { color: var(--text-muted); cursor: not-allowed; opacity: 0.5; }

/* ===================== TABS ===================== */
.tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 18px; overflow-x: auto;
}
.tab {
  padding: 11px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }

/* ===================== FILTER PANEL ===================== */
.filter-panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  display: none; box-shadow: var(--shadow-sm);
}
.filter-panel.show { display: block; }
.filter-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 10px; }

.excel-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.filter-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; background: rgba(108,92,231,0.15);
  color: var(--accent-light); border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.filter-tag .remove { cursor: pointer; opacity: 0.65; }
.filter-tag .remove:hover { opacity: 1; }

/* ===================== LOADING / EMPTY STATES ===================== */
.loading-overlay {
  position: absolute; inset: 0; background: rgba(15,16,33,0.8);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border-light);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.35; }
.empty-state p { font-size: 14px; }

/* ===================== LOGIN PAGE ===================== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,92,231,0.15), transparent 70%),
              linear-gradient(135deg, #0f1021 0%, #161728 50%, #0f1021 100%);
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 420px; padding: 40px 36px;
  background: var(--bg-panel); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}
.login-box .logo { text-align: center; margin-bottom: 28px; color: var(--text-primary); }
.login-box .logo h1 {
  font-size: 28px; font-weight: 900; letter-spacing: 3px; margin-bottom: 4px;
}
.login-box .logo p { font-size: 13px; color: var(--text-muted); }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-group label {
  display: block; font-size: 12.5px; font-weight: 650;
  margin-bottom: 7px; color: var(--text-secondary);
}
.login-form .control { width: 100%; padding: 12px 14px; font-size: 14.5px; }
.login-form .btn { width: 100%; padding: 13px; font-size: 15px; margin-top: 8px; }

/* ===================== INLINE EDITING (Dark) ===================== */
.editable-cell { cursor: pointer; position: relative; transition: background-color .15s; min-height: 32px; }
.editable-cell:hover {
  background: rgba(108,92,231,0.1);
  box-shadow: inset 0 0 0 1px rgba(108,92,231,0.3);
}
.editable-cell.editing { padding: 0 !important; background: var(--bg-input) !important; box-shadow: inset 0 0 0 2px var(--accent) !important; }
.editable-cell .inline-input {
  width: 100%; height: 100%; min-height: 32px;
  border: none; outline: none; padding: 6px 10px;
  font-size: inherit; font-family: inherit;
  background: transparent; color: inherit; box-sizing: border-box;
}
.editable-cell.saving { opacity: 0.65; pointer-events: none; }
.editable-cell .edit-icon { font-size: 11px; opacity: 0; color: var(--accent-light); margin-left: 4px; }
.editable-cell:hover .edit-icon { opacity: 1; }

/* Dashboard Search (Dark) */
.dashboard-search {
  margin-bottom: 24px;
  background: var(--bg-panel); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  padding: 16px 20px; display: flex; align-items: center; gap: 12px;
}
.dashboard-search .ds-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  transition: border-color .15s, box-shadow .15s; position: relative;
}
.dashboard-search .ds-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.dashboard-search .ds-icon { font-size: 17px; color: var(--text-muted); flex-shrink: 0; }
.dashboard-search .ds-input { flex: 1; border: none; outline: none; background: transparent; font-size: 14.5px; color: var(--text-primary); min-width: 200px; }
.dashboard-search .ds-input::placeholder { color: var(--text-muted); }
.dashboard-search .ds-hints { display: flex; gap: 6px; flex-shrink: 0; }
.dashboard-search .ds-hint {
  font-size: 11.5px; padding: 5px 14px; background: var(--bg-card);
  border-radius: 999px; color: var(--text-secondary); cursor: pointer;
  white-space: nowrap; font-weight: 500; transition: all .12s;
  border: 1px solid transparent;
}
.dashboard-search .ds-hint:hover { background: var(--bg-sidebar-hov); color: var(--accent-light); border-color: var(--border-light); }

/* Search dropdown (Dark) */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 380px; overflow-y: auto; z-index: 100; display: none;
}
.search-dropdown.show { display: block; }
.search-dropdown .sd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .1s; font-size: 13px;
}
.search-dropdown .sd-item:last-child { border-bottom: none; }
.search-dropdown .sd-item:hover { background: var(--bg-sidebar-hov); }
.search-dropdown .sd-ctnr { font-weight: 700; color: var(--accent-light); }
.search-dropdown .sd-meta { font-size: 11.5px; color: var(--text-secondary); }
.search-dropdown .sd-empty { padding: 28px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* View switcher */
.view-switch {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 14px 0 6px; padding: 10px 14px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.view-switch .vs-label { font-size: 13px; color: var(--text-muted); margin-right: 2px; font-weight: 600; }
.view-switch .vs-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; font-size: 13px; line-height: 1.2;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-secondary); background: transparent; cursor: pointer;
  transition: all .12s; font-weight: 500;
}
.view-switch .vs-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.view-switch .vs-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.view-switch .vs-save {
  margin-left: auto; padding: 7px 16px; font-size: 13px;
  border: none; border-radius: 999px; background: var(--green); color: #fff;
  cursor: pointer; font-weight: 600; transition: background .12s;
}
.view-switch .vs-save:hover { background: #059669; }

/* List view */
.container-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cl-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .15s;
}
.cl-row:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); transform: translateX(3px); }
.cl-row .cl-dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; }
.cl-row .cl-main { flex: 1 1 auto; min-width: 0; }
.cl-row .cl-ctnr { font-weight: 700; font-size: 14.5px; color: #fff; }
.cl-row .cl-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-row .cl-info { flex: 0 0 auto; text-align: right; font-size: 12px; color: var(--text-secondary); }
.cl-row .cl-sub { line-height: 1.5; }
.cl-row .cl-warn { color: var(--red-light); font-weight: 700; }
.cl-row .cl-driver { flex: 0 0 auto; font-size: 12px; color: var(--text-secondary); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-row .cl-cb { display: flex; align-items: center; flex: 0 0 auto; }
.cl-row .cl-cb input { width: 19px; height: 19px; cursor: pointer; accent-color: var(--accent); }
.cl-row.cl-red { border-color: var(--red); background: rgba(239,68,68,0.08); }
.cl-row.cl-red .cl-ctnr { color: var(--red-light); }

/* Kanban board (Dark) */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; margin-top: 14px; }
.kanban-col {
  flex: 0 0 250px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 240px);
}
.kanban-col-head {
  padding: 10px 14px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between;
}
.kanban-col-head .count {
  background: rgba(255,255,255,0.1); border-radius: 999px; padding: 2px 10px; font-size: 12px;
}
.kanban-col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-col.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcard {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; cursor: grab; transition: all .15s;
}
.kcard:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard .ctnr { font-weight: 650; font-size: 13.5px; color: #fff; }
.kcard .meta { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }
.kcard .sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.kcard .lfd-warn { color: var(--red-light); font-weight: 600; }
.kanban-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 20px 0; }

/* ═══════ THEME SWITCHER (Sidebar) ═══════ */
.sb-theme-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0 4px; border-top: 1px solid var(--border);
  margin-top: 4px;
}
.sb-theme-label { color: var(--text-muted); font-size: 13px; }
.sb-theme-dots {
  display: flex; gap: 5px; flex: 1; justify-content: center;
}
.theme-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.theme-dot:hover { transform: scale(1.2); }
.theme-dot.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.3);
  transform: scale(1.15);
}

/* Font Size Switcher */
.sb-font-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 4px; border-top: 1px solid var(--border);
  margin-top: 4px;
}
.sb-font-btns {
  display: flex; gap: 4px; flex: 1; justify-content: center;
}
.font-btn {
  min-width: 30px; height: 26px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all .15s; line-height: 1;
}
.font-btn:hover { border-color: var(--accent); color: var(--text); }
.font-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 0 8px rgba(124,92,231,0.4);
}

/* ═══════ eMODAL-STYLE CONTAINER TABLE ═══════ */

/* Toolbar bar (eModal-style) */
.emodal-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-wrap: wrap;
}
.emodal-toolbar .et-title {
  font-size: 17px; font-weight: 800; color: #fff;
  letter-spacing: -0.02em; margin-right: 8px;
}
.et-actions-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-light); font-size: 12.5px;
  font-weight: 600; cursor: pointer; transition: all .12s;
}
.et-actions-btn:hover { background: var(--bg-card-hov); border-color: var(--accent); }
.et-actions-dropdown { position: relative; display: inline-block; }
.et-actions-menu {
  position: absolute; top: 100%; left: 0; min-width: 180px;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 100; display: none; padding: 4px 0;
}
.et-actions-menu.show { display: block; }
.et-actions-menu a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-size: 13px; color: var(--text-primary);
  transition: background .1s;
}
.et-actions-menu a:hover { background: var(--bg-sidebar-hov); }
.et-add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #fff; border: none; font-size: 13px;
  font-weight: 700; cursor: pointer; transition: all .15s;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.et-add-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow); }

/* Toolbar right icons */
.et-tools { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.et-tool-icon {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-card);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 14px; transition: all .12s;
}
.et-tool-icon:hover { background: var(--bg-card-hov); color: #fff; border-color: var(--border-light); }
.et-tool-icon.active { background: rgba(108,92,231,0.18); color: #8b5cf6; border-color: #8b5cf6; }
.et-saved-view {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: var(--radius);
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); font-size: 12px;
  cursor: pointer; transition: all .12s;
}
.et-saved-view:hover { border-color: var(--accent); color: var(--text-accent); }

/* Data Grid Container */
.emodal-grid-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow-x: auto; overflow-y: hidden;
}

/* Table */
.emodal-table {
  width: auto; border-collapse: collapse; font-size: 12.5px;
  table-layout: fixed;
}
.emodal-table thead th {
  background: var(--bg-sidebar-hov);
  color: var(--text-secondary); font-weight: 700;
  font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.4px; padding: 10px 12px;
  text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border-light);
  position: sticky; top: 0; z-index: 10;
}
.emodal-table thead th:hover { color: var(--text-accent); }
.emodal-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.emodal-table tbody tr:hover { background: rgba(108,92,231,0.05); }
.emodal-table tbody tr.selected-row { background: rgba(108,92,231,0.12); }
.emodal-table td {
  padding: 9px 12px; vertical-align: middle;
  color: var(--text-primary); white-space: nowrap;
  height: 42px; overflow: hidden; text-overflow: ellipsis;
}

/* Checkbox column */
.et-cb-col { width: 38px; text-align: center !important; }
.et-cb-col input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Expand column */
.et-expand-col { width: 28px; text-align: center !important; }
.et-expand-arrow {
  display: inline-block; width: 0; height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .2s; cursor: pointer;
  vertical-align: middle;
}
.tr-expanded > td .et-expand-arrow { transform: rotate(90deg); }

/* Container number cell */
.et-ctnr-cell { font-weight: 700; color: var(--accent-light); }
.et-ctnr-cell a { color: inherit; text-decoration: none; }
.et-ctnr-cell a:hover { text-decoration: underline; }
.et-info-icon { color: var(--blue-light); font-size: 11px; margin-left: 3px; opacity: 0.6; cursor: help; }
.remark-flag { color: #e74c3c; font-weight: 800; margin-left: 2px; cursor: help; }

/* ── Rich-text editor (shared: notepad + container remark) ── */
.sp-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 6px 8px; border: 1px solid var(--border); border-bottom: none;
  border-radius: 8px 8px 0 0; background: var(--bg-card-alt);
}
.sp-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-input); color: var(--text-secondary);
  border-radius: 6px; cursor: pointer; font-size: 13px; transition: .15s;
}
.sp-btn:hover { border-color: var(--accent); color: var(--accent); }
.sp-btn.active { background: var(--accent-light); color: #fff; border-color: var(--accent-light); }
.sp-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.sp-select {
  height: 30px; border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-primary); border-radius: 6px; padding: 0 6px; font-size: 12px;
}
.sp-color {
  width: 30px; height: 30px; border: 1px solid var(--border); background: var(--bg-input);
  border-radius: 6px; cursor: pointer; padding: 2px;
}
.sp-hint { margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.scratchpad-content {
  min-height: 120px; max-height: 460px; overflow: auto;
  border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  background: var(--bg-input); color: var(--text-primary);
  padding: 12px; font-size: 13px; line-height: 1.6; outline: none;
}
.scratchpad-content:focus { border-color: var(--accent); }
.scratchpad-content.is-empty:before {
  content: attr(data-placeholder); color: var(--text-muted); pointer-events: none;
}
.scratchpad-content table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.scratchpad-content table td,
.scratchpad-content table th { border: 1px solid var(--border); padding: 4px 8px; min-width: 64px; }
.scratchpad-content ul,
.scratchpad-content ol { margin: 6px 0; padding-left: 22px; }
.sp-table-dialog {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .45);
}
.sp-table-dialog[hidden] { display: none; }
.sp-table-box {
  width: 260px; background: var(--bg-card, #fff); color: var(--text-primary);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  border: 1px solid var(--border);
}
.sp-table-box h4 { margin: 0 0 14px; font-size: 15px; }
.sp-table-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sp-table-row label { font-size: 13px; color: var(--text-secondary); }
.sp-table-row input {
  width: 84px; padding: 6px 8px; font-size: 14px; text-align: center;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-input); color: var(--text-primary);
}
.sp-table-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.sp-table-actions button {
  padding: 7px 16px; font-size: 13px; border-radius: 7px; cursor: pointer; border: 1px solid var(--border);
}
.sp-table-cancel { background: transparent; color: var(--text-secondary); }
.sp-table-ok { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Status badge cells */
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.status-badge.s-onvessel   { background: rgba(253,203,110,0.20); color: var(--yellow); }
.status-badge.s-gatein     { background: rgba(9,132,227,0.20); color: var(--blue-light); }
.status-badge.s-inyard     { background: rgba(0,184,148,0.20); color: var(--green-light); }
.status-badge.s-import     { background: rgba(108,92,231,0.20); color: var(--accent-light); }
.status-badge.s-export     { background: rgba(0,206,201,0.20); color: var(--cyan); }
.status-badge.s-hold       { background: rgba(214,48,49,0.20); color: var(--red-light); }
.status-badge.s-default    { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

/* Holds indicator */
.holds-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
}
.holds-yes { color: var(--orange); }
.holds-no  { color: var(--green-light); }
.holds-icon {
  width: 16px; height: 16px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 9px;
}
.holds-yes .holds-icon { background: rgba(225,112,85,0.2); }
.holds-no  .holds-icon { background: rgba(0,184,148,0.2); }

/* Detail expand row */
.detail-expand-row {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.detail-expand-inner {
  padding: 20px 24px;
  display: grid; grid-template-columns: 1fr 280px; gap: 24px;
  animation: detailSlideIn .25s ease;
}
@keyframes detailSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Detail sections */
.detail-section {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  margin-bottom: 12px;
}
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title {
  font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.detail-field {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 4px 12px; margin-bottom: 6px; font-size: 12.5px;
}
.detail-field-label { color: var(--text-muted); font-weight: 500; }
.detail-field-value { color: var(--text-primary); font-weight: 600; word-break: break-all; }
.detail-field-value.link { color: var(--blue-light); cursor: pointer; }
.detail-field-value.link:hover { text-decoration: underline; }

/* Timeline on the right side of detail row */
.detail-timeline { position: relative; padding-left: 20px; }
.timeline-line {
  position: absolute; left: 7px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot {
  position: absolute; left: -15px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--bg-app);
}
.timeline-dot.done { background: var(--green); border-color: var(--green); }
.timeline-dot.active { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 6px var(--blue-glow); }
.timeline-dot.pending { background: var(--bg-card); border-color: var(--text-muted); }
.timeline-text { font-size: 12px; color: var(--text-secondary); }
.timeline-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Filter panel for containers page (eModal style) */
.emodal-filter-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--bg-card);
  border: 1px solid var(--border); border-top: none;
  flex-wrap: wrap;
}
.emodal-filter-bar .ef-input {
  padding: 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-primary); font-size: 12.5px;
  outline: none; transition: border-color .12s;
}
.emodal-filter-bar .ef-input:focus { border-color: var(--accent); }
.emodal-filter-bar select.ef-input { min-width: 130px; }
.emodal-filter-bar input.ef-input[type="text"] { min-width: 140px; }

/* Bulk actions bar */
.bulk-action-bar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 18px; background: rgba(108,92,231,0.08);
  border: 1px solid rgba(108,92,231,0.2);
  border-top: none;
  font-size: 13px; font-weight: 600; color: var(--accent-light);
}
.bulk-action-bar.show { display: flex; }
.bulk-count { color: var(--text-secondary); font-weight: 400; }

/* Detail columns wrapper (left side of expand row) */
.detail-cols { display: flex; flex-direction: column; gap: 0; }

/* Container checkbox class */
.ctnr-cb { cursor: pointer; }

/* Ripple effect for table rows */
.ripple-row { position: relative; overflow: hidden; }

/* ==================== UTILITY CLASSES ==================== */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-muted  { color: var(--text-secondary); }
.text-success{ color: var(--green-light); }
.text-danger  { color: var(--red-light); }
.text-warning { color: var(--yellow); }
.font-mono   { font-family: var(--font-mono); }
.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11.5px; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: 8px; }
.gap-4       { gap: 16px; }
.mb-2        { margin-bottom: 8px; }
.mb-4        { margin-bottom: 16px; }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 16px; }
.p-2         { padding: 8px; }
.p-4         { padding: 16px; }
.rounded     { border-radius: var(--radius); }
.shadow      { box-shadow: var(--shadow-sm); }
.bg-white    { background: var(--bg-panel); }
.hidden      { display: none !important; }
.mobile-only { display: none !important; }
.w-full      { width: 100%; }
.text-nowrap { white-space: nowrap; }
.money { text-align: right; font-family: var(--font-mono); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); z-index: 1150; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.55); }
  .app-wrapper { margin-left: 0 !important; }
  .main-content { padding: 16px 18px; }
  .sb-toggle { display: inline-flex; }       /* visible inside open drawer as a close affordance */
  .mobile-menu-btn { display: inline-flex; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .page-title { font-size: 19px; }
}

@media (max-width: 768px) {
  .main-content { padding: 14px 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 22px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: stretch; }
  .page-actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  /* Mobile: keep table visible with horizontal scroll.
     Collapsed = narrow table fits screen; expanded = scroll to see all columns. */
  .excel-table-wrapper { display: block !important; overflow-x: auto; }
  .mobile-only { display: flex !important; }
  .container-list.mobile-only { margin-top: 12px; }
  .cl-row .cl-cb input { width: 22px; height: 22px; }
  .dashboard-search { flex-direction: column; align-items: stretch; }
  .dashboard-search .ds-hints { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .main-content { padding: 10px 8px; }
  .stats-grid { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .page-title { font-size: 17px; }
  .page-actions { gap: 6px; }
  .page-actions .btn { padding: 8px 12px; font-size: 12px; }
  .modal { width: 96%; max-width: none; border-radius: 10px; }
  .modal-body { padding: 14px 16px; }
  .modal-header { padding: 12px 16px; }
  .modal-footer { padding: 10px 16px; }
  .filter-modal .modal-body { gap: 14px; }
  .excel-table { font-size: 11px; min-width: 700px; }
  .excel-table th, .excel-table td { padding: 4px 6px; height: 30px; }
  .toast { min-width: auto; width: calc(100vw - 32px); font-size: 12px; }
  .toast-container { right: 16px; left: 16px; top: 60px; }
  .sb-theme-dots { flex-wrap: wrap; gap: 4px; }
  .theme-dot { width: 20px; height: 20px; }
  .sb-font-btns { flex-wrap: wrap; gap: 4px; }
  .font-btn { padding: 3px 6px; font-size: 11px; }
}

/* ==================== PRINT ==================== */
@media print {
  html { zoom: 1 !important; }
  .sidebar, .toast-container, .btn, .page-actions,
  .filter-panel, .pagination, .dashboard-search,
  /* eModal: hide toolbar, filters, actions — show data only */
  .emodal-toolbar, .emodal-filter-bar, .bulk-action-bar,
  .et-cb-col, .et-expand-col,
  .modal-overlay { display: none !important; }
  .app-wrapper { margin-left: 0 !important; }
  .main-content { padding: 0; max-width: none; background: #fff; color: #000; }
  .excel-table-wrapper { max-height: none; overflow: visible; }
  /* eModal table: full width, readable */
  .emodal-grid-wrap { overflow: visible; }
  .emodal-table { font-size: 9pt; border-collapse: collapse; width: 100%; }
  .emodal-table th, .emodal-table td { border: 1px solid #ccc !important; padding: 3px 5px !important; }
  .emodal-table th { background: #eee !important; color: #000 !important; }
  .emodal-table td { background: #fff !important; color: #000 !important; }
  .status-badge { border: 1px solid #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Expandable detail rows visible when printing */
  .detail-expand-row { display: table-row !important; }
  .detail-expand-inner { display: block !important; }
  .detail-section { break-inside: avoid; margin-bottom: 8px; border: 1px solid #ddd; padding: 6px; }
  .panel { border: 1px solid #ddd; page-break-inside: avoid; }
  body.xflane-dark { background: #fff; color: #000; }
  .stat-card { break-inside: avoid; border: 1px solid #ddd; }
}
