:root { color-scheme: light; }
.mi-theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 9px;
  border: 1px solid var(--mi-line);
  border-radius: 10px;
  background: var(--mi-card);
  color: var(--mi-muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.mi-theme-switcher select {
  min-width: 106px;
  height: 36px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  outline: 0;
  background: transparent;
  color: var(--mi-ink);
  font: inherit;
  cursor: pointer;
}
.mi-theme-switcher select:focus-visible { box-shadow: 0 0 0 3px rgba(29,128,96,.23); }
.mi-login-card .mi-theme-switcher { margin: 0 0 10px; }
@media (max-width: 782px) {
  .mi-theme-switcher { flex: none; min-height: 44px; }
  .mi-login-card .mi-theme-switcher { width: 100%; justify-content: space-between; }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --mi-ink: #e8f0e9;
  --mi-muted: #a7b9ad;
  --mi-line: #33483b;
  --mi-bg: #111a16;
  --mi-card: #1c2a22;
  --mi-green: #196847;
  --mi-green-2: #58bf8d;
  --mi-red: #f18c8c;
  --mi-amber: #efc376;
  --mi-blue: #85bafa;
  --mi-shadow: 0 12px 34px rgba(0,0,0,.14);
  --mi-surface-2: #23342a;
  --mi-surface-3: #293e31;
  --mi-accent-text: #86ddad;
}
html[data-theme="dark"] body,
html[data-theme="dark"] .mi-app { background: var(--mi-bg); color: var(--mi-ink); }
html[data-theme="dark"] .mi-login-page {
  background: radial-gradient(circle at 20% 10%, #1a3829, transparent 40%), var(--mi-bg);
  color: var(--mi-ink);
}
html[data-theme="dark"] :is(.mi-card, .mi-kpi, .mi-sub-kpi, .mi-toolbar, .mi-login-card,
  .mi-admin-stats article, .mi-product-filters, .mi-fin-filters, .mi-bi-filters,
  .mi-detail-heading, .mi-detail-grid article, .mi-note, .mi-detail-table,
  .mi-action-bar, .mi-product-fields, .mi-variations, .mi-bulk-fields > label,
  .mi-customer-block, .mi-modal-card > header, .mi-order-totals > span,
  .mi-mobile-table tbody tr, .mi-settings-preview, .mi-install-dialog) {
  background: var(--mi-card);
  color: var(--mi-ink);
}
html[data-theme="dark"] :is(.mi-sync, .mi-logout, .mi-pager button,
  .mi-bi-filters button, .mi-fin-filters button, .mi-invoice-actions button,
  .mi-tabs button, .mi-mobile-table .mi-products-table thead th:first-child) {
  background: var(--mi-card);
  color: var(--mi-accent-text);
  border-color: var(--mi-line);
}
html[data-theme="dark"] :is(.mi-sync:hover, .mi-logout:hover, .mi-pager button:hover,
  .mi-bi-filters button:hover, .mi-fin-filters button:hover,
  .mi-invoice-actions button:hover, .mi-mini-order:hover, .mi-card tbody tr:hover) {
  background: var(--mi-surface-2);
}
html[data-theme="dark"] :is(.mi-date-field input, .mi-search input, .mi-login-card input,
  .mi-admin-form input:not([type=checkbox]), .mi-admin-form select,
  .mi-settings-form textarea, .mi-action-bar select, .mi-price-editor input,
  .mi-stock-editor input, .mi-stock-editor select, .mi-product-filters select,
  .mi-bi-filters select, .mi-fin-filters select, .mi-fin-filters input,
  .mi-quick-pair input, .mi-quick-stock input, .mi-quick-stock select,
  .mi-bulk-fields input, .mi-bulk-fields select) {
  background: var(--mi-surface-2);
  color: var(--mi-ink);
  border-color: var(--mi-line);
}
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #91a798; opacity: 1; }
html[data-theme="dark"] :is(.mi-date-field input, .mi-search input, .mi-login-card input,
  .mi-admin-form input, .mi-admin-form select, .mi-settings-form textarea,
  .mi-product-filters select, .mi-bi-filters select, .mi-fin-filters select,
  .mi-fin-filters input):focus { border-color: var(--mi-green-2); }
html[data-theme="dark"] :is(.mi-eyebrow, .mi-card-head > strong, .mi-link,
  .mi-change, .mi-rank > strong, .mi-card td a, .mi-text-button,
  .mi-customer-open, .mi-admin-stats strong, .mi-admin-row details summary,
  .mi-products-table .mi-view-price, .mi-bi-donut b, .mi-bi-bar-label strong,
  .mi-bi-frequency-row strong, .mi-bi-pair strong, .mi-fin-method strong,
  .mi-fin-ledger .mi-fin-amount, .mi-fin-guidance strong) {
  color: var(--mi-accent-text);
}
html[data-theme="dark"] :is(.mi-change.down, .mi-fin-ledger .mi-fin-amount.negative,
  .mi-fin-step.negative strong) { color: #f19a92; }
html[data-theme="dark"] :is(.mi-primary, .mi-save, .mi-search button,
  .mi-login-card form button, .mi-invoice-actions button:first-child,
  .mi-quick-save, .mi-tabs button.active) {
  background: #267a57;
  border-color: #267a57;
  color: #fff;
}
html[data-theme="dark"] :is(.mi-primary:hover, .mi-save:hover,
  .mi-login-card form button:hover, .mi-quick-save:hover) { background: #329467; }
html[data-theme="dark"] :is(.mi-quick button.active, .mi-quick button:hover,
  .mi-bi-toggle button.active, .mi-icon-btn, .mi-live, .mi-edit-button,
  .mi-bi-export, .mi-bi-donut > span, .mi-rank > span, .mi-order-icon,
  .mi-modal-close,
  .mi-product-placeholder, .mi-bi-bar-rank, .mi-bi-pair > span,
  .mi-fin-step i, .mi-admin-role, .mi-admin-status, .mi-admin-success,
  .mi-login-success) {
  background: var(--mi-surface-3);
  color: var(--mi-accent-text);
}
html[data-theme="dark"] :is(.mi-icon-btn:hover, .mi-edit-button:hover,
  .mi-bi-export:hover) { background: #315341; }
html[data-theme="dark"] :is(.mi-badge, .mi-category, .mi-admin-grants span,
  .mi-info, .mi-invoice-actions, .mi-bi-findings li, .mi-stock-editor .mi-check,
  .mi-product-filters button, .mi-variation-card, .mi-bi-toggle,
  .mi-progress, .mi-bi-bar-track, .mi-bi-legend i, .mi-fin-step.total) {
  background: var(--mi-surface-2);
  color: var(--mi-ink);
}
html[data-theme="dark"] :is(.mi-badge, .mi-category, .mi-info,
  .mi-fin-step.total strong) { color: var(--mi-accent-text); }
html[data-theme="dark"] :is(.mi-badge.danger, .mi-admin-status.off,
  .mi-login-error, .mi-admin-error, .mi-modal-error) {
  background: #4c2929;
  color: #ffb7b1;
}
html[data-theme="dark"] :is(.mi-badge.warn, .mi-warning, .mi-admin-self,
  .mi-fin-alert) { background: #4b3b25; color: #f2d394; }
html[data-theme="dark"] .mi-badge.muted { background: #354138; color: var(--mi-muted); }
html[data-theme="dark"] .mi-category.mi-brand { background: #3c3249; color: #d5b4f1; }
html[data-theme="dark"] :is(.mi-card th, .mi-detail-table th) {
  background: var(--mi-surface-2);
  color: var(--mi-muted);
}
html[data-theme="dark"] :is(.mi-product-filters button, .mi-stock-editor .mi-check,
  .mi-rank, .mi-mini-order, .mi-card td, .mi-detail-table td,
  .mi-edit-button, .mi-warning, .mi-invoice-actions,
  .mi-invoice-actions button, .mi-bi-export, .mi-bi-plot,
  .mi-bi-bar-row, .mi-bi-pair, .mi-bi-findings li,
  .mi-fin-step, .mi-fin-trend-chart, .mi-fin-method,
  .mi-fin-alert, .mi-admin-row details) { border-color: var(--mi-line); }
html[data-theme="dark"] .mi-rank:nth-child(1) > span { color: #17231f; }
html[data-theme="dark"] .mi-modal-card { background: var(--mi-bg); }
html[data-theme="dark"] .mi-loading { background: rgba(9,16,12,.76); }
html[data-theme="dark"] .mi-order-totals > strong { background: var(--mi-surface-3); color: var(--mi-accent-text); }
html[data-theme="dark"] .mi-detail-grid article > span,
html[data-theme="dark"] .mi-fin-guidance,
html[data-theme="dark"] .mi-fin-step span,
html[data-theme="dark"] .mi-fin-step strong,
html[data-theme="dark"] .mi-products-table .mi-view-stock,
html[data-theme="dark"] .mi-products-table .mi-view-price small { color: var(--mi-ink); }
html[data-theme="dark"] .mi-bi-plot {
  background: repeating-linear-gradient(to top, transparent 0, transparent 59px, #2d4034 60px);
}
html[data-theme="dark"] .mi-fin-trend-chart {
  background: repeating-linear-gradient(to top, transparent 0, transparent 45px, #2d4034 46px);
}
html[data-theme="dark"] .mi-bi-donut {
  background: conic-gradient(#58bf8d 0 var(--portion), #385646 var(--portion) 100%);
}
html[data-theme="dark"] .mi-bi-legend i.returning { background: #58bf8d; }
html[data-theme="dark"] :is(.mi-products-table tr.is-dirty, .mi-products-table tr.is-editing) {
  background: #383527;
}
html[data-theme="dark"] .mi-bulk-bar { background: #16452e; }
html[data-theme="dark"] .mi-toast { background: #2d4838; }
html[data-theme="dark"] .mi-toast.error { background: #713539; }
html[data-theme="dark"] .mi-header-brand {
  border-color: var(--mi-line);
  background: linear-gradient(135deg, #1c2a22 45%, #33252d);
}
html[data-theme="dark"] .mi-tabs { background: rgba(17,26,22,.96); }
html[data-theme="dark"] .mi-mobile-table tbody tr { background: var(--mi-card); }
html[data-theme="dark"] .mi-admin-danger summary { color: #ffb7b1 !important; }
html[data-theme="dark"] .mi-admin-delete { background: #a54448; }
html[data-theme="dark"] .mi-settings-preview { background: var(--mi-card); }
