/* Dark is the default; light uses the existing stylesheet unchanged. */
.theme-toggle { flex: 0 0 auto; border: 1px solid rgba(255,255,255,.28); border-radius: 7px; padding: 7px 10px; color: #fff; background: rgba(255,255,255,.12); white-space: nowrap; font-size: 13px; }
.theme-toggle:hover { background: rgba(255,255,255,.22); }
.login-theme-toggle { justify-self: end; width: auto; margin: -8px -8px 0 0; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --teal: #167d8a;
  --teal-dark: #6ed5df;
  --teal-soft: #173a42;
  --ink: #e7f0f2;
  --muted: #a7bdc4;
  --line: #35505a;
  --paper: #1b3038;
  --bg: #101d24;
  --red: #ff8181;
  --amber: #f4bd61;
  --shadow: 0 16px 40px rgba(0,0,0,.32);
}
:root[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
:root[data-theme="dark"] .topbar { background: linear-gradient(110deg,#102e43,#124453); box-shadow: 0 2px 14px rgba(0,0,0,.28); }
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .sale-toolbar,
:root[data-theme="dark"] .filterbar,
:root[data-theme="dark"] .grid-wrap,
:root[data-theme="dark"] .notes-block,
:root[data-theme="dark"] .total-card,
:root[data-theme="dark"] .summary-card,
:root[data-theme="dark"] .report-controls,
:root[data-theme="dark"] .report-card,
:root[data-theme="dark"] .report-panel,
:root[data-theme="dark"] .template-group,
:root[data-theme="dark"] .template-preview-head,
:root[data-theme="dark"] .account-profile,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .category-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .drawer,
:root[data-theme="dark"] .detail-dialog,
:root[data-theme="dark"] .print-dialog,
:root[data-theme="dark"] .suggestions,
:root[data-theme="dark"] .product-popover { background: #1b3038; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .workspace-tabs { background: #142630; border-bottom-color: var(--line); }
:root[data-theme="dark"] .workspace-tab { background: #213943; color: #bfd4da; border-color: #3d5d68; }
:root[data-theme="dark"] .workspace-tab.active { background: #29434d; color: #fff; }
:root[data-theme="dark"] .workspace-tab button { color: #bdced3; }
:root[data-theme="dark"] .workspace-tab.drop-before { box-shadow: inset 3px 0 0 #7be0e8; }
:root[data-theme="dark"] .workspace-tab.drop-after { box-shadow: inset -3px 0 0 #7be0e8; }
:root[data-theme="dark"] .side-link { color: #b7cbd1; }
:root[data-theme="dark"] .side-link span { color: #91b8c0; }
:root[data-theme="dark"] .side-link:hover,
:root[data-theme="dark"] .side-link.active { color: #e9fdff; background: #1e424a; }
:root[data-theme="dark"] .side-stats strong,
:root[data-theme="dark"] .bill-meta strong { color: var(--ink); }
:root[data-theme="dark"] .global-search { background: #18313b; border: 1px solid #42616b; }
:root[data-theme="dark"] .global-search input { color: #e7f0f2; background: transparent; border: 0; }
:root[data-theme="dark"] .global-search button { color: #bce2e7; }
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select { color: var(--ink); background: #11252e; border-color: #45616b; }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #9fb5bc; opacity: 1; }
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] select:focus { background: #17313a; border-color: #75d7df; box-shadow: 0 0 0 3px rgba(88,194,207,.22); }
:root[data-theme="dark"] .sale-order-grid input { color: var(--ink); background: transparent; border-color: transparent; }
:root[data-theme="dark"] .sale-order-grid input:focus { background: #18333c; border-color: #75d7df; }
:root[data-theme="dark"] .segmented,
:root[data-theme="dark"] .date-presets { background: #13262e; }
:root[data-theme="dark"] .segmented button,
:root[data-theme="dark"] .date-presets button { color: #b4c8ce; }
:root[data-theme="dark"] .segmented button.active,
:root[data-theme="dark"] .date-presets button.active,
:root[data-theme="dark"] .date-presets button:hover { background: #31515b; color: #fff; }
:root[data-theme="dark"] .customer-chip,
:root[data-theme="dark"] .history-summary { background: #193b43; color: #e1f1f3; }
:root[data-theme="dark"] .customer-chip strong,
:root[data-theme="dark"] .history-summary strong { color: #fff; }
:root[data-theme="dark"] .frequency-legend,
:root[data-theme="dark"] .auto-customer-note { color: #b9cdd3; }
:root[data-theme="dark"] .order-grid th,
:root[data-theme="dark"] .data-table th { background: #29444d; color: #e9f4f5; border-color: var(--line); }
:root[data-theme="dark"] .order-grid td,
:root[data-theme="dark"] .data-table td { border-bottom-color: #344e58; }
:root[data-theme="dark"] .sale-order-grid,
:root[data-theme="dark"] .sale-order-grid th,
:root[data-theme="dark"] .sale-order-grid td { border-color: #49636d; }
:root[data-theme="dark"] .order-grid tbody tr:hover,
:root[data-theme="dark"] .data-table tbody tr:hover,
:root[data-theme="dark"] .data-table .openable-row:hover { background: #26434d; }
:root[data-theme="dark"] .sortable-table th[data-sales-sort]:hover,
:root[data-theme="dark"] .sortable-table th[data-purchase-sort]:hover { background: #365762; color: #fff; }
:root[data-theme="dark"] .suggestion,
:root[data-theme="dark"] .product-option,
:root[data-theme="dark"] .history-item,
:root[data-theme="dark"] .category-list-item { border-bottom-color: #37535d; }
:root[data-theme="dark"] .suggestion:hover,
:root[data-theme="dark"] .product-option:hover,
:root[data-theme="dark"] .category-list-item:hover { background: #31515b; }
:root[data-theme="dark"] .product-option.frequency-red { background: #472a31; border-left-color: #ff7777; }
:root[data-theme="dark"] .product-option.frequency-yellow { background: #4a4027; border-left-color: #f5c35b; }
:root[data-theme="dark"] .product-option.frequency-blue { background: #283d59; border-left-color: #72aaff; }
:root[data-theme="dark"] .product-option small,
:root[data-theme="dark"] .product-option .history-note { color: #d1e1e5; }
:root[data-theme="dark"] .frequency-red .frequency-badge { color: #ffe5e5; background: #703840; }
:root[data-theme="dark"] .frequency-yellow .frequency-badge { color: #fff1bf; background: #705c2b; }
:root[data-theme="dark"] .frequency-blue .frequency-badge { color: #e0edff; background: #365a83; }
:root[data-theme="dark"] .price-history,
:root[data-theme="dark"] .report-card strong,
:root[data-theme="dark"] .report-drill-month,
:root[data-theme="dark"] .report-drill-customer,
:root[data-theme="dark"] .history-price,
:root[data-theme="dark"] .category-card strong,
:root[data-theme="dark"] .template-group h3 { color: #84dee5; }
:root[data-theme="dark"] .total-card .grand { border-color: var(--line); }
:root[data-theme="dark"] .total-card .grand strong,
:root[data-theme="dark"] .negative { color: #ff8585; }
:root[data-theme="dark"] .primary { background: #147b88; color: #fff; }
:root[data-theme="dark"] .primary:hover { background: #1b94a3; }
:root[data-theme="dark"] .primary.accent { background: #a66522; }
:root[data-theme="dark"] .primary.accent:hover { background: #bd792e; }
:root[data-theme="dark"] .secondary,
:root[data-theme="dark"] .ghost,
:root[data-theme="dark"] .add-row { color: #d5edf0; border-color: #63838b; background: #233d46; }
:root[data-theme="dark"] .secondary:hover,
:root[data-theme="dark"] .ghost:hover,
:root[data-theme="dark"] .add-row:hover { background: #315761; }
:root[data-theme="dark"] .delete-record { color: #ffaaa9; }
:root[data-theme="dark"] .delete-record.confirming { background: #b94141; color: #fff; }
:root[data-theme="dark"] .report-bar-track { background: #35505a; }
:root[data-theme="dark"] .report-bar-track i { background: linear-gradient(90deg,#44c2d0,#6bdce4); }
:root[data-theme="dark"] .template-preview-panel,
:root[data-theme="dark"] .print-sheet { background: #13262e; border-color: var(--line); }
:root[data-theme="dark"] .template-group label,
:root[data-theme="dark"] .edit-form label { color: #cedfe3; }
:root[data-theme="dark"] .file-label span { background: #233d46; color: #e4f6f7; }
:root[data-theme="dark"] .category-list { border-color: var(--line); }
:root[data-theme="dark"] .admin-tip { background: #233b52; color: #d5e8f7; border-left-color: #6aace4; }
:root[data-theme="dark"] .login-layer { background: radial-gradient(circle at 20% 30%,#183e65 0,transparent 40%),linear-gradient(125deg,#071321,#0b283e 60%,#0a3a4b); }
:root[data-theme="dark"] .login-card .eyebrow { color: #92d8e5; }
:root[data-theme="dark"] .login-card .primary { background: #167d8a; }
:root[data-theme="dark"] .login-theme-toggle { color: #e2f2f5; border-color: #52727b; background: #2d4a55; }
:root[data-theme="dark"] .login-theme-toggle:hover { background: #385b67; }
:root[data-theme="dark"] .actionbar { background: transparent; }
:root[data-theme="dark"] .print-count-badge { background: #244650; color: #c9f4f5; }
:root[data-theme="dark"] .operation-busy { background: rgba(1,12,17,.7); }
:root[data-theme="dark"] .operation-busy-card { background: #203941; color: #e8f4f5; border: 1px solid #4a6871; }
:root[data-theme="dark"] .operation-busy-card small { color: #aec6cb; }
:root[data-theme="dark"] .operation-spinner { border-color: #4e747e; border-top-color: #79dce4; }
:root[data-theme="dark"] .ndf-template,
:root[data-theme="dark"] .ndf-template * { color: #111; }
@media(max-width:640px) {
  .theme-toggle:not(.login-theme-toggle) { padding: 6px 7px; font-size: 12px; }
  :root[data-theme="dark"] .actionbar { background: rgba(16,29,36,.96); }
}
@media print {
  .operation-busy { display: none !important; }
  :root[data-theme="dark"] { color-scheme: light; }
  :root[data-theme="dark"] html,
  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .print-dialog,
  :root[data-theme="dark"] .print-sheet,
  :root[data-theme="dark"] .ndf-template { background: #fff !important; color: #111 !important; }
}
