:root{--bg:#f4f6f8;--card:#fff;--text:#17202a;--muted:#667085;--line:#d9dee7;--primary:#087443;--primary2:#065c35;--danger:#b42318;--warning:#f79009;--manual:#fff4cc;--calc:#eef1f5;--sidebar:#111827;--sidebar2:#1f2937}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Inter,Segoe UI,Arial,sans-serif;color:var(--text);background:var(--bg)}button,input,select,textarea{font:inherit}.hidden{display:none!important}
.login-screen{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#0f172a,#065f46)}.login-card{width:min(430px,100%);background:white;border-radius:18px;padding:30px;box-shadow:0 25px 80px #0005}.login-card h1{margin:0 0 5px}.login-card p{color:var(--muted)}.field{display:grid;gap:6px;margin:14px 0}.field input,.field select,.field textarea{width:100%;padding:11px;border:1px solid var(--line);border-radius:9px}.primary{background:var(--primary);color:#fff;border:0;border-radius:9px;padding:11px 15px;font-weight:700;cursor:pointer}.primary:hover{background:var(--primary2)}
.app-shell{display:flex;min-height:100vh}.sidebar{width:288px;position:fixed;inset:0 auto 0 0;background:var(--sidebar);color:#fff;display:flex;flex-direction:column;z-index:20;transition:.2s}.sidebar.collapsed{width:76px}.brand{display:flex;gap:10px;align-items:center;padding:18px 14px}.brand-mark{width:42px;height:42px;border-radius:10px;background:var(--primary);display:grid;place-items:center;font-weight:900}.brand small{display:block;color:#aeb8c7;font-size:11px;margin-top:3px}.collapsed .brand>div:last-child,.collapsed .nav-label,.collapsed .group-title,.collapsed .sidebar-footer{display:none}.icon-btn{border:0;background:transparent;color:inherit;font-size:23px;cursor:pointer}.sidebar>#sidebarToggle{position:absolute;right:8px;top:55px}.nav-group{border-top:1px solid #ffffff15}.group-title{width:100%;padding:11px 15px;background:transparent;border:0;color:#c9d2df;text-align:left;font-size:12px;text-transform:uppercase;letter-spacing:.07em;cursor:pointer}.nav-items{display:grid}.nav-items.closed{display:none}.nav-link{display:flex;align-items:center;gap:10px;color:#e5e7eb;background:transparent;border:0;padding:10px 15px;text-align:left;cursor:pointer}.nav-link:hover,.nav-link.active{background:var(--sidebar2);border-left:3px solid #36c98a}.nav-icon{width:22px;text-align:center}.sidebar-footer{margin-top:auto;padding:12px;display:grid;gap:7px}.sidebar-footer button,.file-button{border:1px solid #ffffff25;background:#ffffff0d;color:#fff;padding:9px;border-radius:7px;text-align:center;cursor:pointer}.file-button input{display:none}.danger{background:#7f1d1d!important}.main{margin-left:288px;width:calc(100% - 288px);transition:.2s}.sidebar.collapsed~.main{margin-left:76px;width:calc(100% - 76px)}.topbar{height:76px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:15px;padding:10px 22px;position:sticky;top:0;z-index:10}.topbar h1{margin:0;font-size:22px}.topbar p{margin:3px 0 0;color:var(--muted);font-size:13px}.user-chip{margin-left:auto;display:grid;text-align:right}.user-chip small{color:var(--muted)}#mobileMenu{display:none}.content{padding:20px}.toolbar{display:flex;gap:9px;align-items:center;flex-wrap:wrap;margin-bottom:15px}.toolbar button,.toolbar label,.toolbar select,.toolbar input{border:1px solid var(--line);background:#fff;padding:9px 11px;border-radius:8px}.toolbar button{cursor:pointer}.toolbar .primary{border:0;background:var(--primary);color:#fff}.toolbar .danger{color:#fff;border:0}.toolbar .spacer{margin-left:auto}.file-button.light{color:var(--text);background:white;border:1px solid var(--line)}
.kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(180px,1fr));gap:14px;margin-bottom:18px}.kpi{background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px}.kpi small{color:var(--muted)}.kpi strong{display:block;font-size:25px;margin-top:8px}.panel{background:#fff;border:1px solid var(--line);border-radius:12px;padding:15px;margin-bottom:16px}.panel h2,.panel h3{margin-top:0}.table-wrap{overflow:auto;max-height:calc(100vh - 200px);border:1px solid var(--line);border-radius:10px;background:white}.data-table{border-collapse:separate;border-spacing:0;width:max-content;min-width:100%;font-size:12px}.data-table th{position:sticky;top:0;z-index:2;background:#17202a;color:#fff;padding:9px;border-right:1px solid #ffffff22;white-space:nowrap}.data-table td{padding:5px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);min-width:105px;vertical-align:top}.data-table td.name-cell{min-width:290px;max-width:420px;white-space:normal}.data-table td.manual{background:var(--manual)}.data-table td.calculated{background:var(--calc)}.cell-input,.cell-select{border:0;background:transparent;width:100%;min-width:90px;padding:5px}.cell-input:focus,.cell-select:focus{outline:2px solid #54bd8a;border-radius:4px;background:#fff}.add-inline{display:flex;gap:4px}.add-inline button{border:1px solid var(--line);border-radius:5px;background:white;cursor:pointer}.badge{display:inline-block;padding:3px 7px;border-radius:99px;font-weight:700;font-size:11px}.badge.green{background:#d1fadf;color:#05603a}.badge.orange{background:#ffead5;color:#93370d}.badge.red{background:#fee4e2;color:#912018}.badge.gray{background:#eaecf0;color:#344054}.notice{padding:12px;border-radius:8px;background:#eff8ff;border:1px solid #b2ddff;margin:10px 0}.warning{background:#fffaeb;border-color:#fedf89}.error{background:#fef3f2;border-color:#fecdca}.upload-box{border:2px dashed #aab4c4;border-radius:12px;padding:22px;text-align:center;background:#fafbfc}.preview-table{max-height:250px;overflow:auto;margin-top:12px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.form-grid .full{grid-column:1/-1}dialog{border:0;border-radius:14px;width:min(780px,95vw);padding:0;box-shadow:0 25px 80px #0005}dialog::backdrop{background:#10182899}#modalForm{padding:22px}.modal-close{float:right;border:0;background:transparent;font-size:25px;cursor:pointer}.chart{display:flex;align-items:end;gap:6px;height:190px;padding:15px;border-bottom:1px solid var(--line)}.bar{flex:1;background:#52b788;border-radius:4px 4px 0 0;min-width:12px;position:relative}.bar span{position:absolute;bottom:-22px;left:50%;transform:translateX(-50%);font-size:10px}.toast{position:fixed;right:20px;bottom:20px;background:#111827;color:white;padding:12px 15px;border-radius:8px;opacity:0;pointer-events:none;transition:.2s;z-index:99}.toast.show{opacity:1}.mobile-overlay{display:none}
@media(max-width:1000px){.kpi-grid{grid-template-columns:repeat(2,1fr)}.sidebar{transform:translateX(-100%);width:288px}.sidebar.mobile-open{transform:translateX(0)}.main,.sidebar.collapsed~.main{margin-left:0;width:100%}#mobileMenu{display:block}.mobile-overlay.show{display:block;position:fixed;inset:0;background:#0007;z-index:15}.form-grid{grid-template-columns:1fr}}
@media(max-width:600px){.content{padding:12px}.topbar{padding:8px 12px}.kpi-grid{grid-template-columns:1fr}.user-chip{display:none}}

/* v12.2 navigation restoration and four complete themes */
#navigation{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--sidebar2) transparent}
.sidebar-footer{margin-top:0;flex:0 0 auto;border-top:1px solid color-mix(in srgb,var(--sidebar-text,#fff) 14%,transparent);background:var(--sidebar)}
.group-title{display:flex;align-items:center;justify-content:space-between;color:var(--sidebar-muted,#c9d2df)}
.group-chevron{font-size:15px;transition:transform .18s}.group-title[aria-expanded="false"] .group-chevron{transform:rotate(-90deg)}
.nav-link{color:var(--sidebar-text,#e5e7eb)}
.nav-link:hover,.nav-link.active{background:var(--sidebar2);border-left-color:var(--accent,#36c98a)}
.brand small{color:var(--sidebar-muted,#aeb8c7)}
.theme-cycle{display:flex;align-items:center;gap:8px;border:1px solid var(--line);border-radius:999px;background:var(--card);color:var(--text);padding:8px 12px;cursor:pointer;font-weight:700;box-shadow:0 2px 8px #0000000d}
.theme-cycle:hover{border-color:var(--primary);transform:translateY(-1px)}.theme-icon{font-size:16px;color:var(--accent)}
.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:14px}.modal-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:18px}.modal-actions button{border:1px solid var(--line);border-radius:8px;padding:9px 14px;cursor:pointer}.modal-actions .primary{border:0}.modal-actions .danger{color:#fff;border:0}.error{color:var(--danger)}

/* Arctic Minimalist */
html[data-theme="arctic"]{--bg:#f7fbff;--card:#ffffff;--text:#102a43;--muted:#61758a;--line:#d7e5ef;--primary:#157bb8;--primary2:#0d5e91;--accent:#52b9e9;--danger:#c23b4a;--warning:#d78b14;--manual:#fff8dc;--calc:#edf5fa;--sidebar:#eaf6fc;--sidebar2:#d5edf8;--sidebar-text:#12364d;--sidebar-muted:#53758a}
/* Cyberpunk / Synthwave */
html[data-theme="cyberpunk"]{--bg:#070710;--card:#11111d;--text:#f7f7ff;--muted:#aaa6c6;--line:#2c2942;--primary:#00d8c8;--primary2:#00aa9d;--accent:#00f0dc;--danger:#ff3cac;--warning:#ffb000;--manual:#2b2440;--calc:#16162a;--sidebar:#05050c;--sidebar2:#19152c;--sidebar-text:#f4f1ff;--sidebar-muted:#b7add0}
/* Slate & Emerald */
html[data-theme="slate"]{--bg:#172129;--card:#202d36;--text:#f3f7f7;--muted:#a9bbc0;--line:#3b4b54;--primary:#37c990;--primary2:#22a874;--accent:#6fe5b4;--danger:#ef6b73;--warning:#e9b949;--manual:#403b27;--calc:#273842;--sidebar:#111a20;--sidebar2:#263740;--sidebar-text:#f7fbfb;--sidebar-muted:#9eb2b8}
/* Solarized Dark */
html[data-theme="solarized"]{--bg:#002b36;--card:#073642;--text:#eee8d5;--muted:#93a1a1;--line:#31545d;--primary:#268bd2;--primary2:#1c6fa8;--accent:#2aa198;--danger:#dc322f;--warning:#b58900;--manual:#4a4322;--calc:#0c4553;--sidebar:#00212a;--sidebar2:#0b414d;--sidebar-text:#eee8d5;--sidebar-muted:#93a1a1}

html[data-theme] body,html[data-theme] .topbar,html[data-theme] .panel,html[data-theme] .kpi,html[data-theme] .table-wrap,html[data-theme] .toolbar button,html[data-theme] .toolbar label,html[data-theme] .toolbar select,html[data-theme] .toolbar input,html[data-theme] .file-button.light,html[data-theme] dialog,html[data-theme] .login-card{background:var(--card);color:var(--text)}
html[data-theme] .sidebar{background:var(--sidebar);color:var(--sidebar-text)}
html[data-theme] .sidebar-footer button,html[data-theme] .sidebar-footer .file-button{background:var(--sidebar2);color:var(--sidebar-text);border-color:var(--line)}
html[data-theme] .cell-input,html[data-theme] .cell-select{color:var(--text)}
html[data-theme] .cell-input:focus,html[data-theme] .cell-select:focus{background:var(--card)}
html[data-theme] .upload-box{background:color-mix(in srgb,var(--card) 88%,var(--accent) 12%)}
html[data-theme] .data-table th{background:var(--sidebar);color:var(--sidebar-text)}
html[data-theme] .bar{background:var(--accent)}
html[data-theme="cyberpunk"] .sidebar,html[data-theme="cyberpunk"] .topbar{box-shadow:0 0 22px #00f0dc18}
html[data-theme="cyberpunk"] .nav-link.active{box-shadow:inset 3px 0 0 #ff3cac,0 0 12px #00f0dc20;border-left-color:#ff3cac}
html[data-theme="cyberpunk"] .primary{box-shadow:0 0 12px #00f0dc40}
html[data-theme="arctic"] .sidebar{border-right:1px solid #c7e5f2}
html[data-theme="slate"] .nav-link.active{box-shadow:inset 3px 0 0 var(--accent)}
html[data-theme="solarized"] .nav-link.active{border-left-color:#b58900}

@media(max-width:600px){.theme-cycle #themeName{display:none}.theme-cycle{padding:8px 10px}.topbar-actions{margin-left:auto}}

/* V12.3 functional controls */
.permission-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.55rem;padding:.75rem;border:1px solid var(--border);border-radius:10px;background:var(--panel-2)}
.permission-item{display:flex;align-items:center;gap:.5rem;padding:.45rem .55rem;border-radius:8px;background:var(--panel)}
.permission-item input{width:auto;margin:0}
textarea{min-height:88px;resize:vertical}
.category-filter{min-width:190px}
.modal-actions{display:flex;justify-content:flex-end;gap:.65rem;margin-top:1rem;flex-wrap:wrap}

/* V12.4 theme legibility and complete component color coverage */
:root{
  --input-bg:#ffffff;--input-text:#17202a;--placeholder:#7b8794;
  --notice-bg:#eff8ff;--notice-text:#16324f;--notice-line:#b2ddff;
  --success-bg:#e9f9f0;--success-text:#075e3b;--success-line:#9dd9b9;
  --table-head:#17202a;--table-head-text:#ffffff;
}
html[data-theme="arctic"]{--input-bg:#ffffff;--input-text:#102a43;--placeholder:#6d8395;--notice-bg:#eef8fd;--notice-text:#163c55;--notice-line:#b9ddeb;--success-bg:#e8f8f3;--success-text:#075e4b;--success-line:#a8daca;--table-head:#12364d;--table-head-text:#ffffff}
html[data-theme="cyberpunk"]{--input-bg:#171725;--input-text:#f7f7ff;--placeholder:#8f8aa8;--notice-bg:#121c28;--notice-text:#d8fffb;--notice-line:#00d8c8;--success-bg:#0b2624;--success-text:#8ffff4;--success-line:#00d8c8;--table-head:#080811;--table-head-text:#f7f7ff}
html[data-theme="slate"]{--input-bg:#25343d;--input-text:#f3f7f7;--placeholder:#99adb3;--notice-bg:#243944;--notice-text:#e8f7f2;--notice-line:#4e776a;--success-bg:#1d4537;--success-text:#c7ffe9;--success-line:#37c990;--table-head:#111a20;--table-head-text:#ffffff}
html[data-theme="solarized"]{--input-bg:#0b3b46;--input-text:#eee8d5;--placeholder:#93a1a1;--notice-bg:#0b414d;--notice-text:#eee8d5;--notice-line:#2aa198;--success-bg:#164a45;--success-text:#d8f3dc;--success-line:#2aa198;--table-head:#00212a;--table-head-text:#eee8d5}
html[data-theme] body,html[data-theme] .main,html[data-theme] .content{color:var(--text);background:var(--bg)}
html[data-theme] h1,html[data-theme] h2,html[data-theme] h3,html[data-theme] h4,html[data-theme] p,html[data-theme] label,html[data-theme] strong,html[data-theme] small,html[data-theme] span{color:inherit}
html[data-theme] input,html[data-theme] select,html[data-theme] textarea,html[data-theme] option{background:var(--input-bg);color:var(--input-text);border-color:var(--line)}
html[data-theme] input::placeholder,html[data-theme] textarea::placeholder{color:var(--placeholder);opacity:1}
html[data-theme] .cell-input,html[data-theme] .cell-select{color:var(--input-text);background:transparent}
html[data-theme] .data-table td.manual .cell-input,html[data-theme] .data-table td.manual .cell-select{color:var(--input-text)}
html[data-theme] .data-table th{background:var(--table-head);color:var(--table-head-text)}
html[data-theme] .notice{background:var(--notice-bg);color:var(--notice-text);border-color:var(--notice-line)}
html[data-theme] .success-notice{background:var(--success-bg);color:var(--success-text);border-color:var(--success-line)}
html[data-theme] .toolbar button:not(.primary):not(.danger),html[data-theme] .modal-actions button:not(.primary):not(.danger){background:var(--input-bg);color:var(--input-text);border-color:var(--line)}
html[data-theme] dialog #modalBody,html[data-theme] dialog #modalForm{background:var(--card);color:var(--text)}
html[data-theme] .sidebar .nav-link,html[data-theme] .sidebar .group-title,html[data-theme] .sidebar .brand,html[data-theme] .sidebar .sidebar-footer{color:var(--sidebar-text)}
html[data-theme] .sidebar-footer button,html[data-theme] .sidebar-footer label{color:var(--sidebar-text)!important}
html[data-theme] a{color:var(--accent)}

/* V13 maintenance and modal refinements */
.action-grid{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0}.check-line{display:flex;gap:10px;align-items:center;margin:12px 0}.check-line input{width:auto}.notice.error{border-color:var(--danger,#d14343);background:color-mix(in srgb,var(--danger,#d14343) 12%,var(--panel));}.danger{background:var(--danger,#b42318)!important;color:#fff!important}.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:18px}.field.full{grid-column:1/-1}

/* V13.2 dashboard-level maintenance controls */
.dashboard-maintenance{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;margin:0 0 14px;border:1px solid var(--border);border-radius:12px;background:var(--panel);color:var(--text)}
.dashboard-maintenance>div:first-child{display:flex;flex-direction:column;gap:2px}.dashboard-maintenance small{color:var(--muted)}
.dashboard-maintenance-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.dashboard-maintenance .file-button{margin:0}
@media(max-width:760px){.dashboard-maintenance{align-items:flex-start;flex-direction:column}.dashboard-maintenance-actions{width:100%}.dashboard-maintenance-actions>*{flex:1 1 auto;text-align:center}}

/* V13.4 Strict: requested status sections only */
.workflow-section{margin:0 0 22px}.workflow-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 8px}.workflow-heading h2{margin:0}.status-count{display:inline-flex;min-width:30px;height:30px;align-items:center;justify-content:center;border-radius:999px;background:var(--accent,#1f6f8b);color:var(--accent-text,#fff);font-weight:700}

/* V13.4.1 stability fixes */
dialog.receipt-modal{width:96vw;max-width:1600px;max-height:94vh}
dialog.receipt-modal #modalForm{padding:18px}
dialog.receipt-modal .table-wrap{max-height:62vh;overflow:auto}
dialog.receipt-modal .data-table{width:100%;min-width:1050px}
.route-summary{display:flex;gap:18px;flex-wrap:wrap;margin-top:10px}
.batch-panel{border:1px solid var(--line);border-radius:12px;padding:14px;margin:14px 0;background:var(--card)}
.batch-panel>h3{margin:16px 0 8px}.batch-summary{margin-bottom:10px}
.success-notice{border-color:var(--success);background:color-mix(in srgb,var(--success) 12%,var(--card))}

/* V13.4.2 invoice and payment UI */
.invoice-modal{width:min(1180px,96vw);max-width:none;max-height:94vh}
.invoice-preview-actions{display:flex;justify-content:flex-end;gap:10px;position:sticky;top:0;padding:10px;background:var(--panel,#fff);z-index:3;border-bottom:1px solid var(--border,#ccc)}
.invoice-document{background:#fff;color:#111;padding:28px;border-radius:12px}
.invoice-head,.invoice-parties{display:flex;justify-content:space-between;gap:32px}
.invoice-title{text-align:right}.invoice-parties{margin:24px 0}.invoice-parties>div{width:48%;border:1px solid #ccc;padding:14px;border-radius:8px}
.invoice-table{width:100%;border-collapse:collapse;margin:16px 0}.invoice-table th,.invoice-table td{border:1px solid #bbb;padding:8px;text-align:left;color:#111;background:#fff}
.invoice-table th{background:#eef2f5}.invoice-totals{width:min(420px,100%);margin-left:auto}.invoice-totals div{display:flex;justify-content:space-between;padding:6px 4px}.invoice-totals .grand{font-size:18px;border-top:2px solid #111;border-bottom:2px solid #111}
.invoice-order-picker{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px;max-height:300px;overflow:auto;padding:10px;border:1px solid var(--border,#ccc);border-radius:8px}
.invoice-order-picker label{display:flex;align-items:center;gap:8px}
@media(max-width:720px){.invoice-head,.invoice-parties{display:block}.invoice-title{text-align:left;margin-top:20px}.invoice-parties>div{width:auto;margin-bottom:10px}.invoice-document{padding:14px}}

/* V13.4.3 focused controls */
.inline-control{display:grid;grid-template-columns:minmax(0,1fr) 42px;gap:8px;align-items:center}
.inline-control button{min-width:42px;padding:8px 10px}
/* V13.5 targeted UI support */
#modal:has([data-rec-good]), #modal:has(#receiptSave){width:min(96vw,1500px);max-width:1500px;}
#modal:has([data-rec-good]) .table-wrap, #modal:has(#receiptSave) .table-wrap{overflow:visible;max-height:none;}
#modal:has([data-rec-good]) .data-table, #modal:has(#receiptSave) .data-table{min-width:0;width:100%;table-layout:fixed;}
#modal:has([data-rec-good]) .data-table input, #modal:has(#receiptSave) .data-table input{width:100%;min-width:70px;}

/* V13.5.2: keep the active product/item identity visible while details scroll. */
.data-table .sticky-identity{
  position:sticky;
  left:0;
  z-index:5;
  min-width:240px;
  max-width:340px;
  white-space:normal;
  overflow-wrap:anywhere;
  box-shadow:2px 0 0 var(--border, #d8dee9);
}
.data-table thead .sticky-identity{z-index:8;background:var(--table-head-bg, var(--surface-strong, #eaf0f6));}
.data-table tbody .sticky-identity{background:var(--surface, #fff);}
.data-table tbody tr:hover .sticky-identity{background:var(--surface-hover, #f4f7fa);}

/* V13.5.3 focused patch */
.receipt-modal{width:min(96vw,1500px);max-width:1500px;}
.receipt-modal .form-grid{grid-template-columns:repeat(4,minmax(180px,1fr));}
@media(max-width:900px){.receipt-modal .form-grid{grid-template-columns:1fr 1fr;}}
@media(max-width:600px){.receipt-modal .form-grid{grid-template-columns:1fr;}}

/* V13.5.5 STRICT — text contrast only; no layout or component redesign */
html[data-theme] .content,
html[data-theme] .panel,
html[data-theme] .workflow-section,
html[data-theme] .batch-card,
html[data-theme] dialog,
html[data-theme] .modal-body,
html[data-theme] .data-table td,
html[data-theme] .data-table td span,
html[data-theme] .data-table td strong,
html[data-theme] .data-table td small,
html[data-theme] label,
html[data-theme] p,
html[data-theme] h1,
html[data-theme] h2,
html[data-theme] h3{color:var(--text)!important}
html[data-theme] .muted,
html[data-theme] .hint,
html[data-theme] .subtitle,
html[data-theme] .kpi-label,
html[data-theme] .status-count{color:var(--muted)!important}
html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea,
html[data-theme] option{color:var(--input-text)!important;background:var(--input-bg)!important}
html[data-theme] .nav-link:not(.active),
html[data-theme] .group-title,
html[data-theme] .brand-subtitle{color:var(--sidebar-text)!important}
html[data-theme] .nav-link.active{color:var(--sidebar-text)!important}
.route-receipt-modal{width:min(96vw,1500px);max-width:1500px}
.route-receipt-modal #modalBody{max-height:90vh;overflow:auto}
.route-receipt-modal .table-wrap{max-height:55vh;overflow:auto}

/* V13.5.6 route patch — full theme readability and route receipt clarity */
html[data-theme] .data-table td,
html[data-theme] .data-table td *,
html[data-theme] .panel,
html[data-theme] .panel *,
html[data-theme] .workflow-section,
html[data-theme] .workflow-section *,
html[data-theme] .batch-panel,
html[data-theme] .batch-panel *,
html[data-theme] dialog,
html[data-theme] dialog *{color:var(--text)!important}
html[data-theme] .data-table th,
html[data-theme] .data-table th *{color:var(--table-head-text)!important}
html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea,
html[data-theme] option{color:var(--input-text)!important;background:var(--input-bg)!important}
html[data-theme] .notice,
html[data-theme] .notice *{color:var(--notice-text)!important}
html[data-theme] .sidebar,
html[data-theme] .sidebar *{color:var(--sidebar-text)!important}
html[data-theme] .primary{color:#fff!important}
html[data-theme="arctic"] .primary{color:#fff!important}
.route-receipt-modal{width:min(98vw,1650px)!important;max-width:1650px!important}
.route-receipt-modal .data-table{width:100%;min-width:0;table-layout:fixed}
.route-receipt-modal .data-table input{width:100%;min-width:62px}

/* V13.5.7 THEME TOKENS — visual patch only. Authoritative contrast layer. */
html[data-theme="arctic"]{
  color-scheme:light;
  --surface:#ffffff;--surface-alt:#f1f7fb;--surface-hover:#e8f3f9;--surface-strong:#12364d;
  --surface-manual:#fff5cf;--surface-calc:#eaf3f8;--surface-disabled:#e8eef2;
  --on-surface:#102a43;--on-surface-muted:#526b7a;--on-strong:#ffffff;--on-manual:#3c3100;--on-calc:#16384e;
  --button-secondary-bg:#eaf3f8;--button-secondary-text:#12364d;--button-border:#9fc5d8;
  --focus-ring:#157bb8;--link:#075f93;
}
html[data-theme="cyberpunk"]{
  color-scheme:dark;
  --surface:#11111d;--surface-alt:#171725;--surface-hover:#24203a;--surface-strong:#080811;
  --surface-manual:#2b2440;--surface-calc:#16162a;--surface-disabled:#252339;
  --on-surface:#f7f7ff;--on-surface-muted:#c3bdd8;--on-strong:#ffffff;--on-manual:#fff4c7;--on-calc:#dcfaff;
  --button-secondary-bg:#1c1930;--button-secondary-text:#f7f7ff;--button-border:#514a71;
  --focus-ring:#00f0dc;--link:#69fff2;
}
html[data-theme="slate"]{
  color-scheme:dark;
  --surface:#202d36;--surface-alt:#25343d;--surface-hover:#30434d;--surface-strong:#111a20;
  --surface-manual:#403b27;--surface-calc:#273842;--surface-disabled:#34434b;
  --on-surface:#f3f7f7;--on-surface-muted:#c0ced1;--on-strong:#ffffff;--on-manual:#fff3b0;--on-calc:#e7fbf6;
  --button-secondary-bg:#2b3d46;--button-secondary-text:#f3f7f7;--button-border:#59707a;
  --focus-ring:#6fe5b4;--link:#8cf0c7;
}
html[data-theme="solarized"]{
  color-scheme:dark;
  --surface:#073642;--surface-alt:#0b3b46;--surface-hover:#124956;--surface-strong:#00212a;
  --surface-manual:#4a4322;--surface-calc:#0c4553;--surface-disabled:#244b55;
  --on-surface:#eee8d5;--on-surface-muted:#c5c3b6;--on-strong:#fffdf4;--on-manual:#fff3b0;--on-calc:#e9f5f5;
  --button-secondary-bg:#0b414d;--button-secondary-text:#eee8d5;--button-border:#52727a;
  --focus-ring:#2aa198;--link:#5ecfc4;
}

/* Page surfaces and typography */
html[data-theme] body,
html[data-theme] .main,
html[data-theme] .content{background:var(--bg)!important;color:var(--on-surface)!important}
html[data-theme] .topbar,
html[data-theme] .panel,
html[data-theme] .kpi,
html[data-theme] .batch-panel,
html[data-theme] dialog,
html[data-theme] #modalForm,
html[data-theme] #modalBody{background:var(--surface)!important;color:var(--on-surface)!important;border-color:var(--line)!important}
html[data-theme] .muted,
html[data-theme] .hint,
html[data-theme] .subtitle,
html[data-theme] .kpi small,
html[data-theme] .topbar p,
html[data-theme] .user-chip small{color:var(--on-surface-muted)!important}
html[data-theme] a{color:var(--link)!important}

/* Tables: never inherit a conflicting global text color. */
html[data-theme] .table-wrap,
html[data-theme] .preview-table{background:var(--surface)!important;border-color:var(--line)!important}
html[data-theme] .data-table th,
html[data-theme] .data-table th *{background:var(--surface-strong)!important;color:var(--on-strong)!important;border-color:var(--line)!important}
html[data-theme] .data-table td,
html[data-theme] .data-table td > span,
html[data-theme] .data-table td > strong,
html[data-theme] .data-table td > small{background:var(--surface)!important;color:var(--on-surface)!important;border-color:var(--line)!important}
html[data-theme] .data-table tbody tr:hover td{background:var(--surface-hover)!important;color:var(--on-surface)!important}
html[data-theme] .data-table td.manual,
html[data-theme] .data-table td.manual > *{background:var(--surface-manual)!important;color:var(--on-manual)!important}
html[data-theme] .data-table td.calculated,
html[data-theme] .data-table td.calculated > *{background:var(--surface-calc)!important;color:var(--on-calc)!important}
html[data-theme] .data-table .sticky-identity,
html[data-theme] .data-table tbody .sticky-identity,
html[data-theme] .data-table tbody .sticky-identity *{background:var(--surface)!important;color:var(--on-surface)!important}
html[data-theme] .data-table tbody tr:hover .sticky-identity,
html[data-theme] .data-table tbody tr:hover .sticky-identity *{background:var(--surface-hover)!important;color:var(--on-surface)!important}
html[data-theme] .data-table thead .sticky-identity,
html[data-theme] .data-table thead .sticky-identity *{background:var(--surface-strong)!important;color:var(--on-strong)!important}

/* Inputs and selects inside every surface, including table cells. */
html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea,
html[data-theme] .cell-input,
html[data-theme] .cell-select,
html[data-theme] .data-table td input,
html[data-theme] .data-table td select,
html[data-theme] .data-table td textarea{background:var(--input-bg)!important;color:var(--input-text)!important;border-color:var(--line)!important;-webkit-text-fill-color:var(--input-text)!important}
html[data-theme] .data-table td.manual input,
html[data-theme] .data-table td.manual select,
html[data-theme] .data-table td.manual textarea{background:transparent!important;color:var(--on-manual)!important;-webkit-text-fill-color:var(--on-manual)!important}
html[data-theme] .data-table td.calculated input,
html[data-theme] .data-table td.calculated select,
html[data-theme] .data-table td.calculated textarea{background:transparent!important;color:var(--on-calc)!important;-webkit-text-fill-color:var(--on-calc)!important}
html[data-theme] input::placeholder,
html[data-theme] textarea::placeholder{color:var(--placeholder)!important;opacity:1}
html[data-theme] input:disabled,
html[data-theme] select:disabled,
html[data-theme] textarea:disabled,
html[data-theme] button:disabled{background:var(--surface-disabled)!important;color:var(--on-surface-muted)!important;opacity:.85!important}
html[data-theme] input:focus,
html[data-theme] select:focus,
html[data-theme] textarea:focus,
html[data-theme] button:focus-visible{outline:3px solid color-mix(in srgb,var(--focus-ring) 55%,transparent)!important;outline-offset:1px}

/* Buttons and controls */
html[data-theme] button,
html[data-theme] .file-button,
html[data-theme] .toolbar button,
html[data-theme] .modal-actions button,
html[data-theme] .add-inline button{background:var(--button-secondary-bg)!important;color:var(--button-secondary-text)!important;border-color:var(--button-border)!important}
html[data-theme] button.primary,
html[data-theme] .primary,
html[data-theme] .toolbar .primary{background:var(--primary)!important;color:#ffffff!important;border-color:var(--primary)!important;-webkit-text-fill-color:#ffffff!important}
html[data-theme] button.danger,
html[data-theme] .danger{background:var(--danger)!important;color:#ffffff!important;border-color:var(--danger)!important;-webkit-text-fill-color:#ffffff!important}
html[data-theme] .icon-btn,
html[data-theme] .modal-close{background:transparent!important;color:inherit!important;border-color:transparent!important}
html[data-theme] .theme-cycle{background:var(--surface)!important;color:var(--on-surface)!important;border-color:var(--line)!important}

/* Badges and notices */
html[data-theme] .badge.green{background:#d1fadf!important;color:#05603a!important}
html[data-theme] .badge.orange{background:#ffead5!important;color:#7a2e0e!important}
html[data-theme] .badge.red{background:#fee4e2!important;color:#912018!important}
html[data-theme] .badge.gray{background:#eaecf0!important;color:#344054!important}
html[data-theme] .notice,
html[data-theme] .notice *{background:var(--notice-bg)!important;color:var(--notice-text)!important;border-color:var(--notice-line)!important}
html[data-theme] .toast,
html[data-theme] .toast *{background:var(--surface-strong)!important;color:var(--on-strong)!important}

/* Sidebar and navigation use their own readable token pair. */
html[data-theme] .sidebar,
html[data-theme] .sidebar-footer{background:var(--sidebar)!important;color:var(--sidebar-text)!important}
html[data-theme] .sidebar .brand,
html[data-theme] .sidebar .brand *,
html[data-theme] .sidebar .group-title,
html[data-theme] .sidebar .group-title *,
html[data-theme] .sidebar .nav-link,
html[data-theme] .sidebar .nav-link *,
html[data-theme] .sidebar-footer button,
html[data-theme] .sidebar-footer label{color:var(--sidebar-text)!important;-webkit-text-fill-color:var(--sidebar-text)!important}
html[data-theme] .sidebar .brand small{color:var(--sidebar-muted)!important;-webkit-text-fill-color:var(--sidebar-muted)!important}
html[data-theme] .sidebar .nav-link:hover,
html[data-theme] .sidebar .nav-link.active{background:var(--sidebar2)!important;color:var(--sidebar-text)!important}

/* Native dropdown menu palette where supported. */
html[data-theme] option{background:var(--input-bg)!important;color:var(--input-text)!important}

/* V13.5.10 route-specific receipt dialog */
dialog.receipt-modal-large{width:min(96vw,1500px);max-width:1500px;max-height:94vh}
dialog.receipt-modal-large .table-wrap{max-height:54vh;overflow:auto}
dialog.receipt-modal-large .data-table{min-width:1050px}

/* V13.5.12 strict operations patch */
.v13512-maintenance{position:sticky;top:0;z-index:8;background:var(--page-bg);border-bottom:1px solid var(--border);padding-block:8px}

/* Printed/generated invoices are independent of application themes. */
.invoice-document,.invoice-document *{color:#111827!important;-webkit-text-fill-color:#111827!important;text-shadow:none!important}
.invoice-document{background:#fff!important;border-color:#cbd5e1!important}
.invoice-document .invoice-head,.invoice-document .invoice-parties,.invoice-document section,.invoice-document footer{background:#fff!important;color:#111827!important}
.invoice-document .invoice-table{background:#fff!important;color:#111827!important;border-collapse:collapse!important}
.invoice-document .invoice-table th{background:#e5e7eb!important;color:#111827!important;border:1px solid #64748b!important}
.invoice-document .invoice-table td{background:#fff!important;color:#111827!important;border:1px solid #94a3b8!important}
.invoice-document .invoice-totals,.invoice-document .invoice-totals div{background:#fff!important;color:#111827!important}
.invoice-document .grand{border-color:#111827!important}
@media print{
  html,body{background:#fff!important;color:#111!important}
  body *{visibility:hidden!important}
  .invoice-document,.invoice-document *{visibility:visible!important}
  .invoice-document{position:absolute!important;left:0!important;top:0!important;width:100%!important;margin:0!important;padding:0!important;box-shadow:none!important}
  .invoice-preview-actions,.v13512-maintenance{display:none!important}
}

/* V13.5.15 permanent maintenance toolbar */
.v13515-permanent-maintenance{
  display:flex !important;
  flex-wrap:wrap;
  align-items:center;
  gap:.65rem;
  margin:0 0 1rem 0;
  padding:.75rem;
  border:1px solid var(--border-color, rgba(148,163,184,.35));
  border-radius:12px;
  background:var(--panel-bg, var(--card-bg, rgba(255,255,255,.04)));
}
.v13515-permanent-maintenance .file-button{display:inline-flex;align-items:center;cursor:pointer}
.v13515-permanent-maintenance input[type=file]{display:none}

/* V13.5.16 permanent maintenance controls outside dynamic dashboard content */
.dashboard-maintenance-static{display:flex;gap:.65rem;align-items:center;flex-wrap:wrap;padding:.75rem 1.25rem;border-bottom:1px solid var(--border-color,var(--line,#d7dee8));background:var(--bg-secondary,var(--panel,#fff));position:sticky;top:0;z-index:35}
.dashboard-maintenance-static.hidden{display:none!important}
.dashboard-maintenance-static .file-button{display:inline-flex;align-items:center;justify-content:center}
.dashboard-maintenance-static button,.dashboard-maintenance-static .file-button{min-height:38px}

/* V13.5.17 permanent dashboard maintenance bar */
#dashboardMaintenance.dashboard-maintenance-static{
  display:none;
  gap:.65rem;
  align-items:center;
  flex-wrap:wrap;
  padding:.8rem 1.25rem;
  border-bottom:2px solid var(--border-color,var(--line,#d7dee8));
  background:var(--bg-secondary,var(--panel,#fff));
  color:var(--text-primary,var(--text,#111827));
  position:sticky;
  top:0;
  z-index:999;
  min-height:56px;
}
#dashboardMaintenance.dashboard-maintenance-static strong{margin-right:auto;color:inherit}
#dashboardMaintenance.dashboard-maintenance-static button,
#dashboardMaintenance.dashboard-maintenance-static .file-button{
  display:inline-flex!important;
  visibility:visible!important;
  opacity:1!important;
  min-height:38px;
  align-items:center;
  justify-content:center;
}

/* V14.0 Phase 1 — additive read-only intelligence dashboards only */
.intelligence-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:16px}
.intelligence-grid .panel{margin-bottom:0;min-width:0}
.compact-table{max-height:360px}
.executive-kpis{grid-template-columns:repeat(4,minmax(170px,1fr))}
@media(max-width:1200px){.executive-kpis{grid-template-columns:repeat(3,minmax(160px,1fr))}}
@media(max-width:900px){.intelligence-grid{grid-template-columns:1fr}.executive-kpis{grid-template-columns:repeat(2,minmax(150px,1fr))}}
@media(max-width:600px){.executive-kpis{grid-template-columns:1fr}}
