body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #0a0c14; color: #e0e0e0; overflow: hidden; height: 100vh; }

/* Sidebar buttons (theme-aware) */
.sb-btn { padding: 2px 6px; background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 4px; color: #aaa; cursor: pointer; font-size: 8px; white-space: nowrap; transition: all .15s; }
.sb-btn:hover { border-color: #4f9cf7; color: #ccc; }
.sb-btn-primary { background: #4f9cf7; border-color: #4f9cf7; color: #fff; font-weight: 600; font-size: 9px; }
.sb-btn-primary:hover { background: #3b82f6; }
.sb-btn-green { background: #22c55e; border-color: #22c55e; color: #fff; }
.sb-btn-green:hover { background: #16a34a; }
body.light .sb-btn { background: #f0f2f8; border-color: #dde1ea; color: #555; }
body.light .sb-btn:hover { border-color: #4f9cf7; color: #333; }
body.light .sb-btn-primary { background: #4f9cf7; border-color: #4f9cf7; color: #fff; }
body.light .sb-btn-green { background: #22c55e; border-color: #22c55e; color: #fff; }

/* Layout */
.app { display: grid; grid-template-columns: 340px 1fr 340px; grid-template-rows: 52px 1fr 32px; height: 100vh; }
header { grid-column: 1/-1; background: linear-gradient(135deg, #12141e 0%, #1a1d2e 100%); border-bottom: 1px solid #2a2d3a; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 10; }
.sidebar-left { grid-row: 2; background: #0e1019; border-right: 1px solid #1e2130; overflow-y: auto; display: flex; flex-direction: column; }
.main-view { grid-row: 2; position: relative; background: #0a0c14; }
.sidebar-right { grid-row: 2; background: #0e1019; border-left: 1px solid #1e2130; overflow-y: auto; }
footer { grid-column: 1/-1; background: #12141e; border-top: 1px solid #1e2130; display: flex; align-items: center; padding: 0 16px; font-size: 11px; color: #555; justify-content: space-between; }

/* Header */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; }
.logo .icon { width: 30px; height: 30px; background: linear-gradient(135deg, #4f9cf7, #6366f1); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.logo .accent { color: #4f9cf7; }
.header-tabs { display: flex; gap: 2px; background: #0a0c14; border-radius: 8px; padding: 3px; }
.header-tabs button { background: none; border: none; color: #666; padding: 6px 16px; cursor: pointer; font-size: 12px; border-radius: 6px; transition: all .2s; font-weight: 500; }
.header-tabs button.active { background: #4f9cf7; color: #fff; }
.header-tabs button:hover:not(.active) { color: #aaa; background: #1a1d2e; }
.header-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.header-actions button { background: #1a1d2e; border: 1px solid #2a2d3a; color: #bbb; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 11px; transition: all .2s; font-weight: 500; }
.header-actions button:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.header-actions button.primary { background: linear-gradient(135deg, #4f9cf7, #6366f1); color: #fff; border-color: transparent; }
.header-actions button.success { background: #22c55e; color: #fff; border-color: #22c55e; }

/* Sidebar sections */
.section { padding: 12px; border-bottom: 1px solid #1e2130; }
.section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #555; margin-bottom: 8px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.section-title .action { color: #4f9cf7; cursor: pointer; font-size: 9px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.section-title .action:hover { color: #6db3ff; }

/* Container selector */
.container-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; border: 1px solid #1e2130; transition: all .2s; background: #12141e; }
.container-card:hover { border-color: #4f9cf7; }
.container-card.selected { border-color: #4f9cf7; background: rgba(79,156,247,.08); box-shadow: 0 0 12px rgba(79,156,247,0.1); }
.container-icon { width: 36px; display: flex; align-items: center; justify-content: center; color: #4f9cf7; }
.container-info { flex: 1; }
.container-name { font-size: 12px; font-weight: 600; }
.container-dims { font-size: 10px; color: #666; margin-top: 1px; }
.container-badge { font-size: 9px; background: #4f9cf7; color: #fff; padding: 1px 6px; border-radius: 10px; font-weight: 600; }

/* Product items */
.product-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; margin-bottom: 3px; transition: all .15s; border: 1px solid transparent; background: #12141e; }
.product-item:hover { border-color: #2a2d3a; background: #1a1d2e; }
.product-item.in-container { border-left: 3px solid #4ade80; }
.product-swatch { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.product-info { flex: 1; min-width: 0; }
.product-name { font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-dims { font-size: 9px; color: #555; margin-top: 1px; }
.product-vol { font-size: 9px; color: #4f9cf7; }
.product-qty { display: flex; align-items: center; gap: 4px; }
.product-qty button { width: 20px; height: 20px; border-radius: 4px; border: 1px solid #2a2d3a; background: #1a1d2e; color: #ccc; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.product-qty button:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.product-qty span { font-size: 12px; font-weight: 600; min-width: 18px; text-align: center; }

/* Stats */
.stat-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; }
.stat-label { color: #666; }
.stat-value { font-weight: 600; }
.stat-value.good { color: #4ade80; }
.stat-value.warn { color: #fbbf24; }
.stat-value.danger { color: #f87171; }
.progress-bar { height: 5px; background: #1a1d2e; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .4s ease, background .4s; }

/* Margin controls */
.margin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.margin-input { display: flex; align-items: center; gap: 4px; }
.margin-input label { font-size: 10px; color: #666; min-width: 40px; }
.margin-input input { width: 100%; padding: 4px 6px; background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 4px; color: #e0e0e0; font-size: 11px; outline: none; text-align: center; }
.margin-input input:focus { border-color: #4f9cf7; }

/* Toggle switch */
.toggle { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.toggle-track { width: 32px; height: 18px; border-radius: 9px; background: #2a2d3a; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-track.on { background: #4f9cf7; }
.toggle-track .toggle-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: left .2s; }
.toggle-track.on .toggle-thumb { left: 16px; }
.toggle-label { font-size: 11px; color: #aaa; }

/* View tabs */
.view-tabs { position: absolute; top: 10px; left: 10px; display: flex; gap: 2px; z-index: 5; background: rgba(14,16,25,.9); backdrop-filter: blur(8px); border-radius: 8px; padding: 3px; border: 1px solid #1e2130; }
.view-tabs button { background: none; border: none; color: #666; padding: 5px 12px; cursor: pointer; font-size: 11px; border-radius: 5px; transition: all .2s; }
.view-tabs button.active { background: #4f9cf7; color: #fff; }

/* 3D Canvas */
#canvas3d { width: 100%; height: 100%; display: block; }

/* Overlay Panels */
.overlay-panel { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #0a0c14; display: none; z-index: 50; }
.overlay-panel.active { display: flex; }

/* Route panel */
.route-layout { display: flex; width: 100%; height: 100%; }
.route-map { flex: 1; position: relative; }
#leafletMap { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }
.route-sidebar { width: 340px; background: #0e1019; border-left: 1px solid #1e2130; overflow-y: auto; padding: 14px; flex-shrink: 0; }

/* All containers overview */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 16px; padding: 20px; overflow-y: auto; height: 100%; }
.overview-card { background: #12141e; border: 1px solid #1e2130; border-radius: 12px; overflow: hidden; transition: border-color .2s; cursor: pointer; }
.overview-card:hover { border-color: #4f9cf7; }
.overview-card-header { padding: 12px 16px; background: #1a1d2e; display: flex; align-items: center; justify-content: space-between; }
.overview-card canvas { width: 100%; height: 240px; display: block; }
.overview-card-stats { padding: 10px 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.overview-stat { text-align: center; }
.overview-stat-val { font-size: 14px; font-weight: 700; color: #4f9cf7; }
.overview-stat-label { font-size: 9px; color: #555; }

/* Settings modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 400; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #12141e; border: 1px solid #2a2d3a; border-radius: 16px; width: 600px; max-height: 85vh; overflow-y: auto; padding: 24px; }
.modal h2 { font-size: 18px; margin-bottom: 16px; color: #fff; display: flex; align-items: center; gap: 8px; }
.modal-section { margin-bottom: 16px; }
.modal-section h3 { font-size: 12px; color: #4f9cf7; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.form-row label { font-size: 12px; color: #aaa; min-width: 140px; }
.form-row input, .form-row select { flex: 1; padding: 6px 10px; background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 6px; color: #e0e0e0; font-size: 12px; outline: none; }
.form-row input:focus, .form-row select:focus { border-color: #4f9cf7; }
.form-row select { cursor: pointer; }

/* Stop items */
.stop-item { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; background: #12141e; border: 1px solid #1e2130; transition: border-color .2s; }
.stop-item:hover { border-color: #2a2d3a; }
.stop-number { width: 22px; height: 22px; border-radius: 50%; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.stop-details { flex: 1; min-width: 0; }
.stop-name { font-size: 12px; font-weight: 500; }
.stop-addr { font-size: 10px; color: #555; margin-top: 1px; }
.stop-meta { font-size: 10px; color: #4f9cf7; margin-top: 3px; }
.stop-actions button { background: none; border: none; color: #555; cursor: pointer; font-size: 12px; padding: 2px 4px; }
.stop-actions button:hover { color: #f87171; }

/* Route summary */
.summary-card { background: #12141e; border: 1px solid #1e2130; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.summary-card h3 { font-size: 12px; margin-bottom: 8px; color: #4f9cf7; }

/* Constraint */
.constraint { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 11px; }
.constraint-icon { font-size: 12px; }
.constraint.ok .constraint-icon { color: #4ade80; }
.constraint.warn .constraint-icon { color: #fbbf24; }
.constraint.fail .constraint-icon { color: #f87171; }

/* Controls hint */
.controls-hint { position: absolute; bottom: 10px; left: 10px; background: rgba(14,16,25,.9); backdrop-filter: blur(8px); padding: 6px 12px; border-radius: 6px; font-size: 10px; color: #555; border: 1px solid #1e2130; z-index: 5; }
.controls-hint kbd { background: #1a1d2e; padding: 1px 4px; border-radius: 2px; border: 1px solid #2a2d3a; color: #888; margin: 0 1px; font-size: 9px; }

/* Container number badge */
.container-num { position: absolute; top: 10px; right: 10px; background: linear-gradient(135deg, #4f9cf7, #6366f1); color: #fff; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; z-index: 5; box-shadow: 0 2px 8px rgba(79,156,247,.3); }

/* Leaflet overrides */
.leaflet-popup-content-wrapper { background: #12141e; color: #e0e0e0; border: 1px solid #2a2d3a; border-radius: 8px; }
.leaflet-popup-tip { background: #12141e; }
.leaflet-popup-content { font-size: 12px; }
.leaflet-popup-content b { color: #4f9cf7; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #252838; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3d4a; }

/* Suggestion banner */
.suggestion-banner { background: linear-gradient(135deg, rgba(79,156,247,.1), rgba(99,102,241,.1)); border: 1px solid rgba(79,156,247,.2); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.suggestion-banner h4 { font-size: 11px; color: #4f9cf7; margin-bottom: 4px; }
.suggestion-banner p { font-size: 10px; color: #888; line-height: 1.4; }
.suggestion-banner button { margin-top: 6px; padding: 4px 10px; background: #4f9cf7; border: none; border-radius: 4px; color: #fff; font-size: 10px; cursor: pointer; font-weight: 600; }

/* Add form */
.add-form input, .add-form select { width: 100%; padding: 6px 8px; background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 6px; color: #e0e0e0; font-size: 11px; margin-bottom: 4px; outline: none; }
.add-form input:focus { border-color: #4f9cf7; }
.add-form button { width: 100%; padding: 6px; background: #4f9cf7; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 11px; font-weight: 600; }

/* Weight distribution */
.weight-dist { display: flex; height: 20px; border-radius: 4px; overflow: hidden; background: #1a1d2e; }
.weight-dist div { transition: width .4s; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 600; color: #fff; }

/* Loaded items list */
.loaded-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px; font-size: 11px; border-radius: 4px; margin-bottom: 2px; background: #12141e; border: 1px solid #1e2130; }
.loaded-item .num { width: 16px; height: 16px; border-radius: 50%; font-size: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.loaded-item .remove { margin-left: auto; cursor: pointer; color: #555; font-size: 10px; }
.loaded-item .remove:hover { color: #f87171; }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Mini container tabs */
.mini-tabs { display: flex; gap: 2px; margin-bottom: 8px; flex-wrap: wrap; }
.mini-tab { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; cursor: pointer; background: #1a1d2e; color: #666; border: 1px solid #2a2d3a; transition: all .2s; }
.mini-tab.active { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.mini-tab:hover:not(.active) { border-color: #4f9cf7; color: #aaa; }

/* Packing suggestion */
.pack-suggestion { background: #12141e; border: 1px solid #1e2130; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.pack-suggestion .container-label { font-size: 11px; font-weight: 600; color: #4f9cf7; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.pack-suggestion .items-list { font-size: 10px; color: #888; line-height: 1.5; }

/* Order card */
.order-card { padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; border: 1px solid #1e2130; background: #12141e; transition: all .2s; cursor: pointer; }
.order-card:hover { border-color: #4f9cf7; }
.order-card.selected { border-color: #4f9cf7; background: rgba(79,156,247,.08); box-shadow: 0 0 12px rgba(79,156,247,0.1); }
.order-card.packed { border-color: #4ade80; background: rgba(74,222,128,.06); }
.order-card .order-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.order-card .order-num { font-size: 11px; font-weight: 700; color: #4f9cf7; }
.order-card .order-customer { font-size: 12px; font-weight: 600; }
.order-card .order-addr { font-size: 9px; color: #555; }
.order-card .order-items-summary { font-size: 9px; color: #888; margin-top: 4px; line-height: 1.4; }

/* Container type group label */
.ct-group-label { font-size: 9px; color: #4f9cf7; text-transform: uppercase; letter-spacing: 1px; padding: 6px 0 3px 0; font-weight: 700; border-top: 1px solid #1e2130; margin-top: 6px; }
.ct-group-label:first-child { border-top: none; margin-top: 0; }

/* Start modal */
.start-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); z-index: 300; display: flex; align-items: center; justify-content: center; }
.start-modal { background: #12141e; border: 1px solid #2a2d3a; border-radius: 20px; width: 900px; max-width: 95vw; max-height: 92vh; overflow-y: auto; padding: 32px; text-align: center; }
.start-modal h1 { font-size: 24px; color: #fff; margin-bottom: 6px; }
.start-modal p { font-size: 13px; color: #888; margin-bottom: 20px; }
.start-modal .ct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; margin-bottom: 16px; }
.start-modal .ct-option { padding: 10px 12px; border-radius: 10px; border: 1px solid #2a2d3a; background: #1a1d2e; cursor: pointer; transition: all .2s; }
.start-modal .ct-option:hover { border-color: #4f9cf7; background: rgba(79,156,247,.08); }
.start-modal .ct-option.selected { border-color: #4f9cf7; box-shadow: 0 0 12px rgba(79,156,247,.15); }
.start-modal .ct-option .ct-opt-name { font-size: 12px; font-weight: 600; }
.start-modal .ct-option .ct-opt-dims { font-size: 10px; color: #666; }
.start-modal .start-btn { display: inline-block; padding: 12px 40px; background: linear-gradient(135deg, #4f9cf7, #6366f1); color: #fff; border: none; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; transition: transform .15s; }
.start-modal .start-btn:hover { transform: scale(1.03); }
.start-modal .skip-btn { display: inline-block; padding: 8px 20px; background: none; border: 1px solid #2a2d3a; color: #888; border-radius: 8px; font-size: 12px; cursor: pointer; margin-top: 8px; margin-left: 8px; }

/* Theme toggle button */
.theme-toggle { background: none; border: 1px solid #2a2d3a; color: #888; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all .2s; }
.theme-toggle:hover { border-color: #4f9cf7; color: #ccc; }

/* ============================================================
   LIGHT THEME
   ============================================================ */
body.light { background: #f5f6fa; color: #1a1a2e; }
body.light .app { background: #f5f6fa; }
body.light header { background: linear-gradient(135deg, #fff 0%, #f0f2f8 100%); border-bottom-color: #dde1ea; }
body.light .header-row:first-child { border-bottom-color: #e8ebf2; }
body.light .logo { color: #1a1a2e; }
body.light .header-tabs { background: #e8ebf2; }
body.light .header-tabs button { color: #444; }
body.light .header-tabs button:hover:not(.active) { color: #555; background: #dde1ea; }
body.light .header-actions button { background: #fff; border-color: #dde1ea; color: #555; }
body.light .header-actions button:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
body.light .header-actions-btn { background: #fff; border-color: #dde1ea; color: #555; }
body.light .header-actions-btn:hover { background: #4f9cf7; color: #fff; }
body.light .sidebar-left, body.light .sidebar-right { background: #fff; border-color: #dde1ea; }
body.light .sidebar-left details summary { color: #777; }
body.light .sidebar-left #leftTab_orders,
body.light .sidebar-left #leftTab_products { color: #888; }
body.light .sidebar-left button[id^="leftTab_"] { border-bottom-color: transparent; }
body.light .section { border-bottom-color: #e8ebf2; }
body.light .section-title { color: #777; }
body.light footer { background: #fff; border-top-color: #dde1ea; color: #888; }
body.light .main-view { background: #eef1f6; }

body.light .container-card { background: #fff !important; border-color: #dde1ea !important; color: #333; }
body.light .container-card:hover { border-color: #4f9cf7 !important; }
body.light .container-card.selected { background: #eef4ff !important; border-color: #4f9cf7 !important; }
body.light .container-dims { color: #777; }
body.light .container-icon { color: #4f9cf7; }

body.light .product-item { background: #fff !important; border-color: #e8ebf2 !important; color: #333; }
body.light .product-item:hover { background: #f0f4ff !important; border-color: #c5d5f0 !important; }
body.light .product-dims { color: #777; }
body.light .product-qty button { background: #fff; border-color: #dde1ea; color: #333; }
body.light .product-qty span { color: #333; }

body.light .stat-label { color: #777; }
body.light .stat-value { color: #1a1a2e; }
body.light .progress-bar { background: #e8ebf2; }
body.light .weight-dist { background: #e8ebf2; }

body.light .loaded-item { background: #fff !important; border-color: #e8ebf2 !important; color: #333; }
body.light .loaded-item .num { color: #fff; }
body.light .loaded-item .remove { color: #aaa; }
body.light .loaded-item .remove:hover { color: #f87171; }
body.light .order-card { background: #fff !important; border-color: #dde1ea !important; color: #333; }
body.light .order-card:hover { border-color: #4f9cf7 !important; }
body.light .order-card.selected { background: #eef4ff !important; border-color: #4f9cf7 !important; box-shadow: 0 0 8px rgba(79,156,247,.12); }
body.light .order-card .order-num { color: #2563eb; }
body.light .order-card .order-customer { color: #1a1a2e; }
body.light .order-card .order-addr { color: #777; }
body.light .order-card .order-items-summary { color: #888; }

/* Light theme: global overrides for dynamic dark inline styles */
body.light select { background: #fff !important; border-color: #dde1ea !important; color: #333 !important; }
body.light input[type="text"],
body.light input[type="number"],
body.light input[type="password"] { background: #fff !important; border-color: #dde1ea !important; color: #333 !important; }
body.light .capacity-dialog { background: #fff !important; border-color: #dde1ea !important; color: #333; }
body.light .capacity-dialog h3 { color: #2563eb; }
body.light .capacity-dialog table { color: #333; }
body.light .capacity-dialog table th { color: #555; background: #f8f9fc !important; border-bottom-color: #e8ebf2 !important; }
body.light .capacity-dialog table td { border-bottom-color: #f0f2f8; }
body.light .capacity-dialog table input { background: #f8f9fc !important; border-color: #dde1ea !important; color: #333 !important; }
body.light .capacity-dialog table button { color: #fff; }
body.light .capacity-dialog button:not([style*="background:#4f9cf7"]):not([style*="background:#22c55e"]):not([style*="background:#a855f7"]):not([style*="background:linear"]) { color: #555; background: #f0f2f8; border-color: #dde1ea; }

body.light .modal { background: #fff; border-color: #dde1ea; }
body.light .modal h2 { color: #1a1a2e; }
body.light .form-row label { color: #333; }
body.light .form-row input, body.light .form-row select { background: #f8f9fc; border-color: #dde1ea; color: #1a1a2e; }
body.light .modal-overlay { background: rgba(0,0,0,.3); }

body.light .view-tabs { background: rgba(255,255,255,.9); border-color: #dde1ea; }
body.light .view-tabs button { color: #555; }
body.light .controls-hint { background: rgba(255,255,255,.95); border-color: #dde1ea; color: #666; }
body.light .controls-hint kbd { background: #e8ebf2; border-color: #d0d5e0; color: #333; }
body.light .controls-hint button { background: #fff !important; border-color: #dde1ea !important; color: #555 !important; }
body.light .controls-hint select { background: #fff !important; border-color: #dde1ea !important; color: #333 !important; }

body.light .overlay-panel { background: #f5f6fa; }
body.light .route-sidebar { background: #fff; border-color: #dde1ea; }
body.light .summary-card { background: #f8f9fc; border-color: #e8ebf2; }
body.light .stop-item { background: #f8f9fc; border-color: #e8ebf2; }
body.light .stop-addr { color: #555; }
body.light .add-form input { background: #f8f9fc; border-color: #dde1ea; color: #1a1a2e; }

body.light .overview-card { background: #fff; border-color: #dde1ea; }
body.light .overview-card-header { background: #f8f9fc; }

body.light .start-modal-overlay { background: rgba(0,0,0,.3); }
body.light .start-modal { background: #fff; border-color: #dde1ea; }
body.light .start-modal h1 { color: #1a1a2e; }
body.light .start-modal .ct-option { background: #f8f9fc; border-color: #dde1ea; }
body.light .start-modal .ct-option:hover { background: rgba(79,156,247,.06); }
body.light .start-modal .skip-btn { border-color: #dde1ea; color: #555; }

body.light .margin-input input { background: #f8f9fc; border-color: #dde1ea; color: #1a1a2e; }
body.light .margin-input label { color: #555; }
body.light .toggle-track { background: #dde1ea; }
body.light .toggle-label { color: #333; }
body.light .suggestion-banner { background: rgba(79,156,247,.06); border-color: rgba(79,156,247,.15); }
body.light .suggestion-banner p { color: #333; }
body.light .pack-suggestion { background: #f8f9fc; border-color: #e8ebf2; }
body.light .pack-suggestion .items-list { color: #333; }
body.light .ct-group-label { border-top-color: #e8ebf2; }
body.light .theme-toggle { border-color: #dde1ea; color: #444; }
body.light .add-form input { color: #1a1a2e; }
body.light .add-form select { color: #1a1a2e; }
body.light .leaflet-popup-content-wrapper { background: #fff; color: #1a1a2e; border-color: #dde1ea; }
body.light .leaflet-popup-tip { background: #fff; }
body.light ::-webkit-scrollbar-thumb { background: #ccc; }
body.light ::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ============================================================
   DELIVERY LIFECYCLE - Cards & State Badges
   ============================================================ */

/* Start modal redesigned */
.start-modal { width: 900px; max-width: 95vw; max-height: 92vh; text-align: left; }
.start-modal h1 { text-align: center; }
.start-modal > p { text-align: center; }

.start-new-btn { display: block; width: 100%; padding: 14px 24px; background: linear-gradient(135deg, #4f9cf7, #6366f1); color: #fff; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; margin-bottom: 20px; transition: transform .15s, box-shadow .15s; text-align: center; }
.start-new-btn:hover { transform: scale(1.02); box-shadow: 0 4px 20px rgba(79,156,247,.3); }

.start-sample-btn { display: block; width: 100%; padding: 10px 20px; background: none; border: 1px solid #2a2d3a; color: #888; border-radius: 10px; font-size: 12px; cursor: pointer; margin-bottom: 20px; text-align: center; }
.start-sample-btn:hover { border-color: #4f9cf7; color: #ccc; }

.delivery-section { margin-bottom: 16px; }
.delivery-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #555; margin-bottom: 8px; font-weight: 700; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.delivery-section-title .count-badge { font-size: 10px; background: #2a2d3a; color: #888; padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.delivery-section-title .toggle-arrow { font-size: 10px; color: #555; transition: transform .2s; }
.delivery-section-title .toggle-arrow.collapsed { transform: rotate(-90deg); }

.delivery-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.delivery-card { padding: 12px 14px; border-radius: 10px; border: 1px solid #1e2130; background: #12141e; cursor: pointer; transition: all .2s; position: relative; }
.delivery-card:hover { border-color: #4f9cf7; background: rgba(79,156,247,.04); }

.delivery-card .dc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #e0e0e0; }
.delivery-card .dc-date { font-size: 10px; color: #555; margin-bottom: 6px; }
.delivery-card .dc-stats { font-size: 10px; color: #888; display: flex; gap: 10px; margin-bottom: 6px; }
.delivery-card .dc-badges { display: flex; gap: 4px; flex-wrap: wrap; }

.state-badge { display: inline-block; font-size: 9px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.state-badge.drafting { background: rgba(79,156,247,.15); color: #4f9cf7; }
.state-badge.packed { background: rgba(34,197,94,.15); color: #22c55e; }
.state-badge.delivered { background: rgba(251,191,36,.15); color: #fbbf24; }
.state-badge.archived { background: rgba(107,114,128,.15); color: #6b7280; }

.date-badge { display: inline-block; font-size: 9px; padding: 2px 8px; border-radius: 10px; background: #1a1d2e; color: #888; }

.delivery-card .dc-actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.delivery-card .dc-actions button { padding: 4px 10px; border-radius: 6px; border: 1px solid #2a2d3a; background: #1a1d2e; color: #bbb; font-size: 10px; cursor: pointer; font-weight: 500; transition: all .15s; }
.delivery-card .dc-actions button:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.delivery-card .dc-actions button.btn-green { background: rgba(34,197,94,.15); color: #22c55e; border-color: rgba(34,197,94,.3); }
.delivery-card .dc-actions button.btn-green:hover { background: #22c55e; color: #fff; }
.delivery-card .dc-actions button.btn-orange { background: rgba(249,115,22,.15); color: #f97316; border-color: rgba(249,115,22,.3); }
.delivery-card .dc-actions button.btn-orange:hover { background: #f97316; color: #fff; }
.delivery-card .dc-actions button.btn-red { background: rgba(248,113,113,.1); color: #f87171; border-color: rgba(248,113,113,.2); }
.delivery-card .dc-actions button.btn-red:hover { background: #f87171; color: #fff; }

/* Container type picker dropdown */
.ct-picker-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); z-index: 350; display: flex; align-items: center; justify-content: center; }
.ct-picker { background: #12141e; border: 1px solid #2a2d3a; border-radius: 16px; width: 560px; max-height: 70vh; overflow-y: auto; padding: 20px; }
.ct-picker h3 { font-size: 14px; color: #fff; margin-bottom: 12px; text-align: center; }
.ct-picker .ct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ct-picker .ct-option { padding: 8px 10px; border-radius: 8px; border: 1px solid #2a2d3a; background: #1a1d2e; cursor: pointer; transition: all .2s; }
.ct-picker .ct-option:hover { border-color: #4f9cf7; background: rgba(79,156,247,.08); }
.ct-picker .ct-option .ct-opt-name { font-size: 11px; font-weight: 600; }
.ct-picker .ct-option .ct-opt-dims { font-size: 9px; color: #666; }

/* Header back button */
.header-back { background: none; border: 1px solid #2a2d3a; color: #bbb; padding: 3px 8px; border-radius: 5px; cursor: pointer; font-size: 10px; font-weight: 500; transition: all .2s; margin-right: 4px; }
.header-back:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.header-delivery-name { font-size: 10px; color: #4f9cf7; font-weight: 600; margin-right: 6px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Approve packing button */
.btn-approve { background: #22c55e !important; color: #fff !important; border-color: #22c55e !important; font-weight: 700 !important; font-size: 13px !important; padding: 7px 18px !important; box-shadow: 0 2px 10px rgba(34,197,94,.3); }
.btn-approve:hover { background: #16a34a !important; box-shadow: 0 4px 16px rgba(34,197,94,.4); }

/* Light theme overrides */
body.light .delivery-card { background: #f8f9fc; border-color: #dde1ea; }
body.light .delivery-card:hover { border-color: #4f9cf7; background: rgba(79,156,247,.04); }
body.light .delivery-card .dc-name { color: #1a1a2e; }
body.light .delivery-card .dc-date { color: #555; }
body.light .delivery-card .dc-stats { color: #444; }
body.light .delivery-card .dc-actions button { background: #fff; border-color: #dde1ea; color: #555; }
body.light .delivery-section-title .count-badge { background: #e8ebf2; color: #444; }
body.light .date-badge { background: #e8ebf2; color: #444; }
body.light .start-new-btn { box-shadow: 0 2px 12px rgba(79,156,247,.2); }
body.light .start-sample-btn { border-color: #dde1ea; color: #555; }
body.light .ct-picker { background: #fff; border-color: #dde1ea; }
body.light .ct-picker .ct-option { background: #f8f9fc; border-color: #dde1ea; }
body.light .header-back { border-color: #dde1ea; color: #555; }
body.light .header-delivery-name { color: #4f9cf7; }

/* Help modal */
#helpModal .modal-section { border-bottom: 1px solid #1e2130; padding-bottom: 12px; }
#helpModal .modal-section:last-of-type { border-bottom: none; }
#helpModal .modal-section h3 { font-size: 13px; color: #4f9cf7; margin-bottom: 6px; text-transform: none; letter-spacing: 0; }
#helpModal .modal-section p { margin: 0; }
body.light #helpModal .modal-section { border-bottom-color: #e8ebf2; }
body.light #helpModal .modal-section p { color: #333; }

/* ============================================================
   USER PICKER
   ============================================================ */
.user-picker-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(8px); z-index: 400; display: flex; align-items: center; justify-content: center; }
.user-picker { background: #12141e; border: 1px solid #2a2d3a; border-radius: 20px; width: 480px; max-width: 90vw; padding: 32px; text-align: center; }
.user-picker h2 { font-size: 20px; color: #fff; margin-bottom: 4px; }
.user-picker-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.user-picker-card { padding: 16px 12px; border-radius: 12px; border: 1px solid #2a2d3a; background: #1a1d2e; cursor: pointer; transition: all .2s; text-align: center; }
.user-picker-card:hover { border-color: #4f9cf7; background: rgba(79,156,247,.08); transform: scale(1.02); }
.user-picker-card .up-name { font-size: 14px; font-weight: 600; color: #e0e0e0; margin-bottom: 4px; }
.user-picker-card .up-role { font-size: 11px; color: #4f9cf7; font-weight: 500; }
.user-picker-card .up-avatar { font-size: 28px; margin-bottom: 6px; }

body.light .user-picker { background: #fff; border-color: #dde1ea; }
body.light .user-picker h2 { color: #1a1a2e; }
body.light .user-picker-card { background: #f8f9fc; border-color: #dde1ea; }
body.light .user-picker-card:hover { background: rgba(79,156,247,.06); }
body.light .user-picker-card .up-name { color: #1a1a2e; }

/* ============================================================
   DELIVERY TABLE ROWS
   ============================================================ */
.delivery-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.delivery-table th { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #555; font-weight: 700; padding: 4px 8px; text-align: left; }
.delivery-table td { padding: 8px; font-size: 12px; background: #12141e; border-top: 1px solid #1e2130; border-bottom: 1px solid #1e2130; }
.delivery-table tr td:first-child { border-left: 1px solid #1e2130; border-radius: 8px 0 0 8px; }
.delivery-table tr td:last-child { border-right: 1px solid #1e2130; border-radius: 0 8px 8px 0; }
.delivery-table tr:hover td { background: rgba(79,156,247,.04); }
.delivery-table .dt-name { font-weight: 600; color: #e0e0e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.delivery-table .dt-date { font-size: 10px; color: #888; white-space: nowrap; }
.delivery-table .dt-stat { font-size: 11px; color: #888; text-align: center; }
.delivery-table .dt-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.delivery-table .dt-actions button { padding: 3px 8px; border-radius: 5px; border: 1px solid #2a2d3a; background: #1a1d2e; color: #bbb; font-size: 10px; cursor: pointer; font-weight: 500; transition: all .15s; white-space: nowrap; }
.delivery-table .dt-actions button:hover { background: #4f9cf7; color: #fff; border-color: #4f9cf7; }
.delivery-table .dt-actions button.btn-green { background: rgba(34,197,94,.15); color: #22c55e; border-color: rgba(34,197,94,.3); }
.delivery-table .dt-actions button.btn-green:hover { background: #22c55e; color: #fff; }
.delivery-table .dt-actions button.btn-orange { background: rgba(249,115,22,.15); color: #f97316; border-color: rgba(249,115,22,.3); }
.delivery-table .dt-actions button.btn-orange:hover { background: #f97316; color: #fff; }
.delivery-table .dt-actions button.btn-red { background: rgba(248,113,113,.1); color: #f87171; border-color: rgba(248,113,113,.2); }
.delivery-table .dt-actions button.btn-red:hover { background: #f87171; color: #fff; }

.show-more-btn { display: block; width: 100%; padding: 8px; background: #1a1d2e; border: 1px solid #2a2d3a; border-radius: 8px; color: #4f9cf7; font-size: 11px; font-weight: 600; cursor: pointer; text-align: center; margin-top: 8px; transition: all .2s; }
.show-more-btn:hover { background: rgba(79,156,247,.1); border-color: #4f9cf7; }

body.light .delivery-table td { background: #f8f9fc; border-color: #e8ebf2; }
body.light .delivery-table tr:hover td { background: rgba(79,156,247,.04); }
body.light .delivery-table .dt-name { color: #1a1a2e; }
body.light .delivery-table .dt-actions button { background: #fff; border-color: #dde1ea; color: #555; }
body.light .show-more-btn { background: #f8f9fc; border-color: #dde1ea; }

/* Lock indicator on delivery rows */
.dt-lock-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 9px; color: #fbbf24; background: rgba(251,191,36,.1); padding: 1px 6px; border-radius: 8px; margin-left: 4px; }
body.light .dt-lock-badge { background: rgba(251,191,36,.08); }

/* Capacity dialog */
.capacity-dialog-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 350; display: flex; align-items: center; justify-content: center; }
.capacity-dialog { background: #12141e; border: 1px solid #2a2d3a; border-radius: 16px; padding: 24px; width: 520px; max-width: 95vw; max-height: 85vh; overflow-y: auto; }
.capacity-dialog h3 { font-size: 16px; color: #f87171; margin-bottom: 4px; }
.cd-subtitle { font-size: 12px; color: #888; margin-bottom: 16px; }
.cd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.cd-stat { background: #1a1d2e; border-radius: 8px; padding: 10px; text-align: center; }
.cd-stat-label { font-size: 9px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
.cd-stat-val { font-size: 16px; font-weight: 700; color: #4f9cf7; margin-top: 4px; }
.cd-stat-val.cd-red { color: #f87171; }
.cd-current { font-size: 11px; color: #888; text-align: center; margin-bottom: 16px; padding: 6px; background: #1a1d2e; border-radius: 6px; }
.cd-options { display: flex; flex-direction: column; gap: 8px; }
.cd-option { padding: 12px 14px; border: 1px solid #2a2d3a; border-radius: 10px; cursor: pointer; transition: all .2s; background: #1a1d2e; }
.cd-option:hover { border-color: #4f9cf7; background: rgba(79,156,247,.08); }
.cd-opt-title { font-size: 13px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 8px; }
.cd-opt-desc { font-size: 10px; color: #888; margin-top: 3px; }
.cd-cancel { display: block; width: 100%; margin-top: 12px; padding: 8px; background: none; border: 1px solid #2a2d3a; border-radius: 8px; color: #888; cursor: pointer; font-size: 12px; }
.cd-cancel:hover { border-color: #4f9cf7; color: #ccc; }
.cd-split-items { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.cd-split-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #1a1d2e; border-radius: 8px; }
.cd-split-name { flex: 1; font-size: 12px; font-weight: 500; }
.cd-split-qty { font-size: 10px; color: #666; min-width: 80px; }
.cd-split-input { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.cd-split-input label { color: #888; font-size: 10px; }

/* Light theme */
body.light .capacity-dialog { background: #fff; border-color: #dde1ea; }
body.light .cd-subtitle { color: #666; }
body.light .cd-stat { background: #f8f9fc; }
body.light .cd-stat-label { color: #999; }
body.light .cd-current { background: #f8f9fc; color: #666; }
body.light .cd-option { background: #f8f9fc; border-color: #dde1ea; }
body.light .cd-option:hover { background: rgba(79,156,247,.06); }
body.light .cd-opt-title { color: #1a1a2e; }
body.light .cd-opt-desc { color: #666; }
body.light .cd-cancel { border-color: #dde1ea; color: #555; background: #f8f9fc; }
body.light .cd-cancel:hover { border-color: #4f9cf7; color: #333; }
body.light .capacity-dialog .form-row label { color: #555; }
body.light .capacity-dialog .cd-subtitle { color: #666; }

/* Delivery stops section in right sidebar */
.stop-delivery-group:hover { border-color: #4f9cf7 !important; background: #1a1d2e !important; }
body.light .stop-delivery-group { background: #f8f9fc !important; border-color: #e8ebf2 !important; }
body.light .stop-delivery-group:hover { background: #edf0f7 !important; border-color: #4f9cf7 !important; }

/* Orientation badge */
.orient-badge { display: inline-block; font-size: 7px; padding: 0 3px; border-radius: 3px; color: #fff; font-weight: 700; vertical-align: middle; }
.orient-badge.orient-k { background: #4f9cf7; }
.orient-badge.orient-p { background: #a855f7; }
body.light .cd-split-row { background: #f8f9fc; }
body.light .cd-split-input input { background: #fff; border-color: #dde1ea; color: #1a1a2e; }

/* ============================================================
   WIZARD (guided tour)
   ============================================================ */
.wizard-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); z-index: 500; }
.wizard-popup { background: #12141e; border: 2px solid #4f9cf7; border-radius: 16px; padding: 20px; width: 360px; max-width: 90vw; box-shadow: 0 8px 32px rgba(79,156,247,.3); z-index: 501; }
.wizard-popup h3 { font-size: 16px; color: #4f9cf7; margin-bottom: 6px; }
.wizard-popup p { font-size: 12px; color: #ccc; line-height: 1.6; margin-bottom: 12px; }
.wz-step { font-size: 10px; color: #888; margin-bottom: 4px; }
.wz-progress { height: 3px; background: #2a2d3a; border-radius: 2px; margin-bottom: 10px; overflow: hidden; }
.wz-progress-fill { height: 100%; background: #4f9cf7; width: 0%; transition: width .1s linear; border-radius: 2px; }
.wz-buttons { display: flex; gap: 6px; }
.wz-buttons button { padding: 6px 14px; border-radius: 6px; border: 1px solid #2a2d3a; background: #1a1d2e; color: #aaa; cursor: pointer; font-size: 11px; }
.wz-buttons .wz-primary { background: #4f9cf7; color: #fff; border-color: #4f9cf7; font-weight: 600; }
.wz-buttons .wz-skip { background: none; border: none; color: #666; font-size: 10px; margin-left: auto; }
.wizard-highlight { box-shadow: 0 0 0 3px #4f9cf7, 0 0 20px rgba(79,156,247,.4) !important; border-radius: 8px; z-index: 499; position: relative; }
body.light .wizard-popup { background: #fff; border-color: #4f9cf7; }
body.light .wizard-popup p { color: #555; }
body.light .wz-buttons button { background: #f8f9fc; border-color: #dde1ea; color: #555; }
body.light .wz-buttons .wz-primary { background: #4f9cf7; color: #fff; }
body.light .wz-progress { background: #e8ebf2; }

/* ============================================================
   DASHBOARD SEARCH/FILTER BAR
   ============================================================ */
body.light #dashSearchText,
body.light #dashDateFrom,
body.light #dashDateTo { background: #f8f9fc; border-color: #dde1ea; color: #1a1a2e; }
body.light #dashSearchText::placeholder { color: #999; }
