/* Gastro Modern theme tokens. The existing light palette remains the default. */
:root{
  --theme-page:#f7f4ef;--theme-surface:#fff;--theme-soft:#faf7f4;
  --theme-raised:#fcfaf8;--theme-input:#fff;--theme-hover:#fffdfb;
  --theme-text:#342a25;--theme-heading:#30251f;--theme-muted:#6f625a;
  --theme-border:#e3d8ce;--theme-field-border:#dcd1c8;
  --theme-sidebar:#2f2926;--theme-sidebar-text:#f8f5f1;
  --theme-sidebar-muted:#bfb5ae;--theme-sidebar-active:#443a35;
  --theme-accent:#a84f2d;--theme-accent-text:#fff;
  --theme-chart-grid:#e9e1db;--theme-chart-axis:#766a63;
  --theme-chart-track:#eee5de;--theme-tooltip:#342a25;
  --theme-success-bg:#eaf7ee;--theme-success-text:#26633f;
  --theme-warning-bg:#fff3d9;--theme-warning-text:#765520;
  --theme-danger-bg:#fff1ee;--theme-danger-text:#8f271f;
  --theme-info-bg:#e5f5f3;--theme-info-text:#216f6a;
  --theme-shadow:rgba(52,42,37,.08);
}
html[data-theme="light"]{color-scheme:light}
html[data-theme="dark"]{
  color-scheme:dark;
  --theme-page:#171b1e;--theme-surface:#242a2e;--theme-soft:#2b3236;
  --theme-raised:#30383d;--theme-input:#1d2428;--theme-hover:#353d41;
  --theme-text:#f0ede8;--theme-heading:#fff9f2;--theme-muted:#bdafa5;
  --theme-border:#475159;--theme-field-border:#667079;
  --theme-sidebar:#1a1d20;--theme-sidebar-text:#f4eee8;
  --theme-sidebar-muted:#c4b8af;--theme-sidebar-active:#3b3432;
  --theme-accent:#e18a65;--theme-accent-text:#211a17;
  --theme-chart-grid:#49535a;--theme-chart-axis:#c9bbb1;
  --theme-chart-track:#414a50;--theme-tooltip:#eef0ed;
  --theme-chart-terracotta:#ef956d;--theme-chart-teal:#79c9bc;
  --theme-chart-gold:#f2c573;--theme-chart-brown:#cfaa98;
  --theme-chart-green:#a5c891;--theme-chart-purple:#c3a4dd;
  --theme-chart-negative:#f2a39b;
  --theme-success-bg:#193c2e;--theme-success-text:#b8ecc9;
  --theme-warning-bg:#493720;--theme-warning-text:#ffe0a0;
  --theme-danger-bg:#452927;--theme-danger-text:#ffc1bb;
  --theme-info-bg:#1e4147;--theme-info-text:#b2e7ed;
  --theme-shadow:rgba(0,0,0,.24);
  --brand-dark:#352c27;--brand-primary:#ed9870;--brand-accent:#f3ac77;
  --brand-soft:#51382d;--brand-background:#302924;
  --blue:#90c8ee;--green:#9bd8b0;--amber:#f0c278;--red:#f2a39b;
  --border:var(--theme-border);--muted:var(--theme-muted);
  --text:var(--theme-text);--surface-soft:var(--theme-soft);--sidebar:var(--theme-sidebar);
}

/* Accessible day/night control. Its state is derived from the same theme tokens. */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.topbar{display:flex}
.header-controls{margin-left:auto;display:flex;align-items:center;gap:12px;min-width:0}
.header-controls .top-actions{margin-left:0;padding-left:12px;border-left:1px solid var(--theme-border)}
.header-profile{display:flex;align-items:center;gap:6px;min-height:44px;color:var(--theme-muted);font-size:12px;font-weight:700}
.header-profile span{display:block;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.header-profile:hover{color:var(--theme-accent)}
.theme-control{display:inline-flex;align-items:center;gap:5px;flex:none}
.theme-switch,.theme-system{appearance:none;-webkit-appearance:none;display:grid;place-items:center;min-height:44px;border:0;background:transparent;padding:0;cursor:pointer;flex:none}
.theme-switch{width:72px}
.theme-switch-track{position:relative;display:block;width:72px;height:40px;overflow:hidden;border-radius:22px;border:1px solid #e3b978;background:linear-gradient(135deg,#fff3cf,#eebd71);box-shadow:inset 0 2px 5px rgba(90,58,25,.12)}
.theme-switch-thumb{position:absolute;left:4px;top:3px;display:grid;place-items:center;width:32px;height:32px;border-radius:50%;background:#fffaf0;box-shadow:0 2px 6px rgba(79,51,26,.24);transform:translateX(0);z-index:2}
.theme-switch-thumb svg{position:absolute;width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.theme-sun{color:#a86a1d;opacity:1;transform:rotate(0) scale(1)}
.theme-moon{color:#52667e;opacity:0;transform:rotate(-70deg) scale(.65)}
.theme-rays{position:absolute;left:1px;top:1px;width:38px;height:38px;border-radius:50%;background:radial-gradient(circle,rgba(255,255,255,.55),rgba(255,255,255,0) 72%);opacity:1}
.theme-stars{position:absolute;inset:0;opacity:0}
.theme-stars i{position:absolute;width:3px;height:3px;border-radius:50%;background:#f4ead4;box-shadow:0 0 5px rgba(255,248,224,.8)}
.theme-stars i:nth-child(1){left:15px;top:11px}.theme-stars i:nth-child(2){left:24px;top:26px;width:2px;height:2px}.theme-stars i:nth-child(3){left:34px;top:8px;width:2px;height:2px}
html[data-theme="dark"] .theme-switch-track{border-color:#526178;background:linear-gradient(135deg,#1b2937,#33445b);box-shadow:inset 0 2px 6px rgba(0,0,0,.3)}
html[data-theme="dark"] .theme-switch-thumb{transform:translateX(30px);background:#eff0e7;box-shadow:0 2px 7px rgba(0,0,0,.35)}
html[data-theme="dark"] .theme-sun{opacity:0;transform:rotate(70deg) scale(.65)}
html[data-theme="dark"] .theme-moon{opacity:1;transform:rotate(0) scale(1)}
html[data-theme="dark"] .theme-rays{opacity:0}
html[data-theme="dark"] .theme-stars{opacity:1}
.theme-system{position:relative;width:44px;height:44px;border:1px solid var(--theme-border);border-radius:11px;background:var(--theme-surface);color:var(--theme-muted)}
.theme-system svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
html[data-theme-choice="system"] .theme-system{border-color:var(--theme-accent);color:var(--theme-accent);background:var(--theme-soft)}
html[data-theme-choice="system"] .theme-system::after{content:"";position:absolute;right:5px;top:5px;width:5px;height:5px;border-radius:50%;background:var(--theme-accent)}
.theme-switch:focus-visible,.theme-system:focus-visible,.header-profile:focus-visible{outline:3px solid var(--theme-accent);outline-offset:3px}
.login-theme{display:flex!important;align-items:center;justify-content:space-between;gap:12px;margin:18px 0 0!important;color:var(--theme-muted);font-size:12px;font-weight:700}
html.theme-changing :is(body,.sidebar,.topbar,.mobile-nav,.login-card,.stat,.panel,.data-panel,.form-panel,.report-visual-card,.report-kpis article,.table-card,.pending-card,.inventory-card,.payment-panel,.report-filter,.list-head,.list-row,table th,table td,input,select,textarea,.btn-primary,.btn-secondary,.status-badge,.flash,.theme-system){transition:background-color 270ms ease,color 270ms ease,border-color 270ms ease,box-shadow 270ms ease}
html.theme-changing .theme-switch-track{transition:background 300ms ease,border-color 300ms ease}
html.theme-changing .theme-switch-thumb{transition:transform 300ms cubic-bezier(.22,.68,.2,1.08),background-color 300ms ease}
html.theme-changing :is(.theme-sun,.theme-moon){transition:opacity 220ms ease,transform 300ms ease}
html.theme-changing :is(.theme-rays,.theme-stars){transition:opacity 260ms ease}
html.theme-changing .report-chart :is(path,circle,rect,text,line){transition:fill 270ms ease,stroke 270ms ease}
@media(max-width:900px){.header-controls .top-actions,.header-profile{display:none}.mobile-brand{min-width:0;flex:1}.mobile-brand>div{min-width:0}.mobile-brand strong,.mobile-brand small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
@media(max-width:480px){.mobile-brand .demo-environment{display:none}.topbar{padding-left:12px;padding-right:12px}.header-controls{gap:0}}
@media(prefers-reduced-motion:reduce){html.theme-changing :is(body,.sidebar,.topbar,.mobile-nav,.login-card,.stat,.panel,.data-panel,.form-panel,.report-visual-card,.report-kpis article,.table-card,.pending-card,.inventory-card,.payment-panel,.report-filter,.list-head,.list-row,table th,table td,input,select,textarea,.btn-primary,.btn-secondary,.status-badge,.flash,.theme-system),html.theme-changing .theme-switch-track,html.theme-changing .theme-switch-thumb,html.theme-changing :is(.theme-sun,.theme-moon,.theme-rays,.theme-stars),html.theme-changing .report-chart :is(path,circle,rect,text,line){transition-duration:0ms!important}}

/* Shared surfaces, typography and inputs cover every module. */
html[data-theme="dark"],html[data-theme="dark"] body{background:var(--theme-page);color:var(--theme-text)}
html[data-theme="dark"] :is(.sidebar,.sidebar .brand,.sidebar .sidebar-user){background:var(--theme-sidebar);color:var(--theme-sidebar-text)}
html[data-theme="dark"] .sidebar :is(.brand small,.user-meta small,.nav-label){color:var(--theme-sidebar-muted)}
html[data-theme="dark"] .sidebar .nav a{color:var(--theme-sidebar-text)}
html[data-theme="dark"] .sidebar .nav a:is(:hover,.active){background:var(--theme-sidebar-active)}
html[data-theme="dark"] :is(.topbar,.mobile-nav){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
html[data-theme="dark"] .mobile-nav :is(a,button){color:var(--theme-muted)}
html[data-theme="dark"] .mobile-nav .active{color:var(--theme-accent)}
html[data-theme="dark"] .login-page{background:linear-gradient(135deg,#171b1e,#2a211d)}
html[data-theme="dark"] :is(.stat,.panel,.login-card,.filter-bar,.data-panel,.form-panel,.operation-summary,.presentation-card,.inline-form,.inventory-card,.summary-cards article,.menu-admin-card,.table-card,.pending-card,.kpi-card,.dashboard-section,.dashboard-production-card,.production-metric,.cash-summary-grid article,.address-card,.order-group-card,.delivery-client-card,.delivery-dashboard-strip,.report-center-card,.report-filter,.report-kpis article,.receipt,.financial-grid article,.split-context>div,.split-preview>div,.merge-preview>div,.merge-account,.payment-panel,.mixed-methods section,.settings-tabs a,.document-option span,.payment-selector span,.cart-extras,.filter-tabs a.active,.report-tabs a.active,.quick-grid a,.waiter-actions a,.sell-card,.category-pill,.flow-back,.btn-secondary,.btn-icon,.pagination a){background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border);box-shadow:0 5px 20px var(--theme-shadow)}
html[data-theme="dark"] :is(.switch-card,.physical-distribution,.production-line,.production-stock-note,.purchase-line,.recipe-line,.pending-extras,.pending-line-actions details form,.client-data dl div,.address-card.is-inactive,.report-shipping div,.metric-pair>div,.physical-summary>span,.locked-settings>div,.settings-note,.logo-preview,.production-today-list>div,.inventory-overview-grid article,.production-result-summary>div,.production-yield,.production-live-metrics .cost-metric,.split-head,.payment-method,.report-definition code,.billing-data-panel .invoice-warning,.fiscal-status-note){background:var(--theme-soft);color:var(--theme-text);border-color:var(--theme-border)}
html[data-theme="dark"] .operational-card{background:linear-gradient(180deg,var(--theme-surface),var(--theme-soft));border-color:var(--theme-border)}
html[data-theme="dark"] :is(.filter-tabs,.report-tabs){background:var(--theme-soft)}
html[data-theme="dark"] :is(.account-total,.cash-summary-grid .cash-expected,.financial-grid .financial-net){background:#352c27;color:#fff2e8;border-color:var(--theme-border)}
html[data-theme="dark"] :is(.account-total strong,.cash-summary-grid .cash-expected strong,.financial-grid .financial-net strong){color:#fff2e8}
html[data-theme="dark"] .report-kpis .report-kpi-primary{background:#493328!important;border-color:#aa7159!important}
html[data-theme="dark"] .report-kpis .report-kpi-primary strong{color:#ffb48b}
html[data-theme="dark"] .cash-blocker{background:var(--theme-danger-bg);color:var(--theme-danger-text);border-color:#ad6963}
html[data-theme="dark"] .cash-blocker .btn-secondary{background:var(--theme-surface)}
html[data-theme="dark"] .payment-selector input:checked+span{background:#493328;color:#ffd0b7;border-color:var(--theme-accent)}
html[data-theme="dark"] :is(.payment-panel label,.mixed-methods label,.cost-chart-selector label){color:var(--theme-text)}
html[data-theme="dark"] :is(.cash-change,.payment-validation.valid){background:var(--theme-success-bg);color:var(--theme-success-text)}
html[data-theme="dark"] :is(.mixed-summary>div,.payment-validation){background:var(--theme-soft);color:var(--theme-text)}
html[data-theme="dark"] .payment-validation.invalid{background:var(--theme-danger-bg);color:var(--theme-danger-text)}
html[data-theme="dark"] .mixed-change{color:var(--theme-success-text)}
html[data-theme="dark"] :is(h1,h2,h3,h4,h5,.kpi-card strong,.operational-card strong,.empty-state strong,.production-live-metrics dd,.locked-settings strong){color:var(--theme-heading)}
html[data-theme="dark"] :is(.stat span,.stat small,.welcome p,.login-brand p,.login-help,.empty-state,.kpi-card span,.kpi-card small,.operational-card span,.operational-card small,.menu-admin-card p,.table-card p,.pending-card p,.pending-card time,.pending-line-main p,.delivery-client-card span,.delivery-client-card small,.delivery-address-option small,.delivery-address-option em,.delivery-summary small,.delivery-dashboard-strip span,.account-line small,.report-chart-note,.audit-note){color:var(--theme-muted)}
html[data-theme="dark"] :is(.main,.login-card) label{color:var(--theme-text)}
html[data-theme="dark"] :is(.top-actions,.topbar-context){color:var(--theme-muted)}
html[data-theme="dark"] .cash-turn-note{background:var(--theme-warning-bg);color:var(--theme-warning-text);border-color:#a87d42}
html[data-theme="dark"] :is(input,select,textarea){color-scheme:dark}
html[data-theme="dark"] :is(.main,.login-card) :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea),html[data-theme="dark"] :is(.filter-bar,.form-panel,.payment-panel,.mixed-methods,.report-filter,.production-line,.recipe-line,.delivery-step,.delivery-actions,.pending-line-actions,.login-card) :is(input,select,textarea){background:var(--theme-input);color:var(--theme-text);border-color:var(--theme-field-border)}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#adaba8;opacity:1}
html[data-theme="dark"] :is(input,select,textarea):disabled,html[data-theme="dark"] input[readonly]{background:var(--theme-soft)!important;color:var(--theme-muted);opacity:1}
html[data-theme="dark"] :is(input,select,textarea):focus-visible{outline:2px solid var(--theme-accent);outline-offset:1px}
html[data-theme="dark"] :is(.btn-primary,.category-pill.active,.settings-tabs a.active,.pagination a.active){background:var(--theme-accent);color:var(--theme-accent-text);border-color:var(--theme-accent)}
html[data-theme="dark"] :is(.btn-secondary,.btn-icon,.flow-back,.report-tabs a,.filter-tabs a){color:var(--theme-text)}
html[data-theme="dark"] :is(.list-head,.list-row,.report-table th,.report-table td,table th,table td,.account-line,.cart-line,.pending-line){border-color:var(--theme-border)}
html[data-theme="dark"] :is(.list-head,.report-table th,table th){background:var(--theme-soft);color:var(--theme-muted)}
html[data-theme="dark"] :is(.list-row:hover,table tbody tr:hover,.quick-grid a:hover,.sell-card:hover){background:var(--theme-hover)}
html[data-theme="dark"] :is(.mobile-nav,.topbar,.login-card,.form-panel,.report-visual-card) .brand-image img{filter:none}

/* Status tokens remain distinct and every badge retains its text label. */
html[data-theme="dark"] :is(.badge-success,.status-active,.status-success,.delivery-state-listo_para_entregar){background:var(--theme-success-bg);color:var(--theme-success-text)}
html[data-theme="dark"] :is(.badge-warning,.status-warning,.delivery-state-pendiente_preparacion,.operation-warning,.production-metric.metric-warning,.flash-warning){background:var(--theme-warning-bg);color:var(--theme-warning-text);border-color:#a87d42}
html[data-theme="dark"] :is(.badge-info,.status-info,.delivery-state-en_camino){background:var(--theme-info-bg);color:var(--theme-info-text)}
html[data-theme="dark"] :is(.badge-danger,.status-danger,.flash-error,.alert-error){background:var(--theme-danger-bg);color:var(--theme-danger-text);border-color:#ad6963}
html[data-theme="dark"] :is(.flash-success,.alert-ok){background:var(--theme-success-bg);color:var(--theme-success-text);border-color:#609b75}
html[data-theme="dark"] :is(.badge-muted,.status-neutral,.status-inactive,.delivery-state-entregado){background:var(--theme-soft);color:var(--theme-text)}
html[data-theme="dark"] :is(.status-primary,.delivery-snapshot-note){background:#493328;color:#ffd0b7}
html[data-theme="dark"] .demo-environment{background:var(--theme-warning-bg);color:var(--theme-warning-text);border-color:#a87d42}

/* Report SVG inherits CSS colors while series colors retain their identity. */
.chart-grid-line{stroke:var(--theme-chart-grid)}
.chart-axis-label,.chart-value-label,.chart-legend text{fill:var(--theme-chart-axis)}
.chart-category-label{fill:var(--theme-text)}
.chart-donut-caption{fill:var(--theme-muted)}
.chart-donut-total{fill:var(--theme-heading)}
.chart-donut-track{stroke:var(--theme-chart-track)}
.report-chart-tooltip{background:var(--theme-tooltip);color:var(--theme-page)}
html[data-theme="dark"] .chart-negative-note{color:#ffb5aa}
html[data-theme="dark"] .report-chart [stroke="#b6532f"]{stroke:var(--theme-chart-terracotta)}
html[data-theme="dark"] .report-chart [stroke="#2f766d"]{stroke:var(--theme-chart-teal)}
html[data-theme="dark"] .report-chart [stroke="#d39a36"]{stroke:var(--theme-chart-gold)}
html[data-theme="dark"] .report-chart [stroke="#6f5145"]{stroke:var(--theme-chart-brown)}
html[data-theme="dark"] .report-chart [stroke="#6e8b65"]{stroke:var(--theme-chart-green)}
html[data-theme="dark"] .report-chart [stroke="#8d6a9f"]{stroke:var(--theme-chart-purple)}
html[data-theme="dark"] .report-chart [stroke="#a64036"]{stroke:var(--theme-chart-negative)}
html[data-theme="dark"] .report-chart [fill="#b6532f"]{fill:var(--theme-chart-terracotta)}
html[data-theme="dark"] .report-chart [fill="#2f766d"]{fill:var(--theme-chart-teal)}
html[data-theme="dark"] .report-chart [fill="#d39a36"]{fill:var(--theme-chart-gold)}
html[data-theme="dark"] .report-chart [fill="#6f5145"]{fill:var(--theme-chart-brown)}
html[data-theme="dark"] .report-chart [fill="#6e8b65"]{fill:var(--theme-chart-green)}
html[data-theme="dark"] .report-chart [fill="#8d6a9f"]{fill:var(--theme-chart-purple)}
html[data-theme="dark"] .report-chart [fill="#a64036"]{fill:var(--theme-chart-negative)}

/* Printing is always paper white, including charts and receipts. */
@media print{
  :root,html[data-theme="dark"]{color-scheme:light;--theme-page:#fff;--theme-surface:#fff;--theme-soft:#fff;--theme-raised:#fff;--theme-input:#fff;--theme-text:#111;--theme-heading:#111;--theme-muted:#444;--theme-border:#ccc;--theme-chart-grid:#d8d8d8;--theme-chart-axis:#333;--theme-chart-track:#ddd;--theme-tooltip:#fff}
  html[data-theme="dark"],html[data-theme="dark"] body,html[data-theme="dark"] :is(.main,.content,.receipt,.report-visual-card,.report-kpis article,.data-panel,.form-panel,.stat,.panel,.report-table th,.report-table td,table th,table td){background:#fff!important;color:#111!important;box-shadow:none!important}
  html[data-theme="dark"] :is(h1,h2,h3,h4,h5,.kpi-card strong,.operational-card strong,.empty-state strong){color:#111!important}
  html[data-theme="dark"] body *{background-color:transparent!important;background-image:none!important;color:#111!important;border-color:#ccc!important;box-shadow:none!important}
  .theme-control,.login-theme{display:none!important}
}
