.theme-control { position: relative; }
.theme-toggle { display:flex; min-width:42px; height:42px; align-items:center; justify-content:center; gap:7px; padding:0 10px; border:1px solid var(--line); border-radius:12px; color:var(--text); background:var(--surface); }
.theme-toggle:hover { color:var(--blue-600); background:var(--blue-50); }
.theme-toggle .icon { width:17px; height:17px; }
.theme-toggle span { font-size:10px; font-weight:750; }
.theme-menu { position:absolute; z-index:330; right:0; top:calc(100% + 8px); width:185px; padding:6px; border:1px solid var(--line); border-radius:13px; background:var(--surface); box-shadow:0 18px 45px rgba(15,23,42,.16); animation:themeMenuIn 220ms var(--spring) both; }
.theme-menu button { display:grid; width:100%; min-height:39px; grid-template-columns:18px 1fr 14px; align-items:center; gap:8px; padding:7px 9px; border-radius:9px; color:var(--text); background:transparent; text-align:left; }
.theme-menu button:hover { color:var(--blue-700); background:var(--blue-50); }
.theme-menu button > .icon { width:15px; height:15px; }
.theme-menu button span { font-size:10px; font-weight:650; }
.theme-menu button .theme-check { color:transparent; }
.theme-menu button.is-active { color:var(--blue-700); background:var(--blue-50); }
.theme-menu button.is-active .theme-check { color:var(--blue-600); }
.access-theme { position:fixed; z-index:20; right:max(18px,env(safe-area-inset-right)); top:max(18px,env(safe-area-inset-top)); }
@keyframes themeMenuIn { from { opacity:0; transform:translateY(-6px) scale(.98); } to { opacity:1; transform:none; } }

html[data-theme="dark"] {
    --ink:#edf3fb;
    --text:#c3cfde;
    --muted:#8f9fb3;
    --muted-2:#718198;
    --line:#29384d;
    --line-soft:#202e40;
    --canvas:#08111f;
    --surface:#101b2b;
    --blue-50:#122b4f;
    --blue-100:#183b68;
    --shadow-sm:0 8px 25px rgba(0,0,0,.18);
    --shadow-md:0 19px 48px rgba(0,0,0,.28);
    color-scheme:dark;
}
html[data-theme="dark"] body { color:var(--text); background:radial-gradient(circle at 82% -10%,rgba(37,99,235,.12),transparent 28%),var(--canvas); }
html[data-theme="dark"] .app-topbar { border-color:#1e2c3e; background:rgba(9,18,32,.9); }
html[data-theme="dark"] .global-search input,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color:#2a3a4f; color:var(--ink); background:#0c1726; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#64758c; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus { border-color:#447dcf; background:#101d2d; box-shadow:0 0 0 4px rgba(47,120,255,.12); }
html[data-theme="dark"] kbd { border-color:#334258; color:#8595aa; background:#152235; }
html[data-theme="dark"] .company-selector,
html[data-theme="dark"] .button-secondary,
html[data-theme="dark"] .quick-actions,
html[data-theme="dark"] .surface,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .billing-kpi,
html[data-theme="dark"] .records-surface,
html[data-theme="dark"] .record-kpi,
html[data-theme="dark"] .form-section,
html[data-theme="dark"] .create-summary,
html[data-theme="dark"] .create-checklist,
html[data-theme="dark"] .operation-surface,
html[data-theme="dark"] .module-kpi,
html[data-theme="dark"] .module-process-card,
html[data-theme="dark"] .module-alerts,
html[data-theme="dark"] .module-activity,
html[data-theme="dark"] .recurring-calendar,
html[data-theme="dark"] .recurring-health,
html[data-theme="dark"] .recurring-card { border-color:var(--line); background:var(--surface); }
html[data-theme="dark"] .surface:hover,
html[data-theme="dark"] .metric-card:hover,
html[data-theme="dark"] .record-kpi:hover,
html[data-theme="dark"] .module-kpi:hover { border-color:#355071; }
html[data-theme="dark"] .button-secondary { color:var(--text); box-shadow:none; }
html[data-theme="dark"] .button-secondary:hover { border-color:#3e6598; color:#8ab7ff; background:#14253a; }
html[data-theme="dark"] .user-menu:hover,
html[data-theme="dark"] .company-selector:hover { background:#14253a; }
html[data-theme="dark"] .user-copy strong,
html[data-theme="dark"] .page-heading h1,
html[data-theme="dark"] .records-heading h1,
html[data-theme="dark"] .operation-heading h1,
html[data-theme="dark"] .surface-header h2,
html[data-theme="dark"] .form-section-head h2,
html[data-theme="dark"] .operation-card-head h2,
html[data-theme="dark"] .record-kpi strong,
html[data-theme="dark"] .module-page-heading h1 { color:var(--ink); }
html[data-theme="dark"] .records-toolbar,
html[data-theme="dark"] .record-filter-panel,
html[data-theme="dark"] .records-table thead,
html[data-theme="dark"] .line-table th,
html[data-theme="dark"] .operation-table thead,
html[data-theme="dark"] .entry-composer,
html[data-theme="dark"] .entry-totals,
html[data-theme="dark"] .receipt-application-total,
html[data-theme="dark"] .bank-filter-card > footer,
html[data-theme="dark"] .summary-placeholder,
html[data-theme="dark"] .recurring-cards { background:#0c1726; }
html[data-theme="dark"] .records-table td,
html[data-theme="dark"] .line-table td,
html[data-theme="dark"] .operation-table td { border-color:var(--line-soft); }
html[data-theme="dark"] .table-input,
html[data-theme="dark"] .money-input,
html[data-theme="dark"] .field-control input:not(.sr-only),
html[data-theme="dark"] .field-control textarea,
html[data-theme="dark"] .toggle-field,
html[data-theme="dark"] .file-drop { border-color:#2a3a4f; color:var(--ink); background:#0c1726; }
html[data-theme="dark"] .operation-status,
html[data-theme="dark"] .status-pill { filter:saturate(.9) brightness(.9); }
html[data-theme="dark"] .record-drawer,
html[data-theme="dark"] .invoice-drawer { border-color:var(--line); background:#0d1828; box-shadow:-22px 0 55px rgba(0,0,0,.34); }
html[data-theme="dark"] .create-actions,
html[data-theme="dark"] .operation-actions,
html[data-theme="dark"] .mobile-create-actions { border-color:#29384d; background:rgba(10,19,33,.94); }
html[data-theme="dark"] .toast-success { border-color:#23634f; color:#7bd9b9; background:#102a25; }
html[data-theme="dark"] .smart-select-trigger { border-color:#2a3a4f; color:var(--ink); background:#0c1726; }
html[data-theme="dark"] .smart-select-trigger:hover,
html[data-theme="dark"] .smart-select-trigger:focus-visible,
html[data-theme="dark"] .smart-select.is-open .smart-select-trigger { border-color:#447dcf; background:#101d2d; }
html[data-theme="dark"] .smart-select-popover { border-color:#304157; background:rgba(14,25,41,.99); box-shadow:0 24px 65px rgba(0,0,0,.46); }
html[data-theme="dark"] .smart-select-search { border-color:#233247; }
html[data-theme="dark"] .smart-select-search input { border-color:#2d3d53; background:#091423; }
html[data-theme="dark"] .smart-select-option { color:#bdc9d9; }
html[data-theme="dark"] .smart-select-option:hover,
html[data-theme="dark"] .smart-select-option.is-active { color:#9fc3ff; background:#142b4b; }
html[data-theme="dark"] .smart-select-option.is-selected { color:#b9d4ff; background:#17365e; }
html[data-theme="dark"] .smart-select-mobile-head button { color:#a8b6c8; background:#1a293c; }
html[data-theme="dark"] .access-panel { background:#0b1524; }
html[data-theme="dark"] .mobile-access-brand strong,
html[data-theme="dark"] .access-field > label,
html[data-theme="dark"] .field-label-row label { color:var(--ink); }
html[data-theme="dark"] .access-check { color:#a8b6c8; }
html[data-theme="dark"] .access-check i { border-color:#3a4b61; background:#111d2d; }
html[data-theme="dark"] .access-validation { color:#ffaaa3; background:#3b1a1b; }
html[data-theme="dark"] .access-form-wrap h2,
html[data-theme="dark"] .company-heading h1 { color:var(--ink); }
html[data-theme="dark"] .access-security { border-color:#29384d; background:#101b2b; }
html[data-theme="dark"] .access-security strong { color:var(--text); }
html[data-theme="dark"] .company-body { background:radial-gradient(circle at 50% -10%,#142d52,transparent 34%),#08111f; }
html[data-theme="dark"] .company-topbar { border-color:#223146; background:rgba(10,19,33,.9); }
html[data-theme="dark"] .company-brand strong,
html[data-theme="dark"] .company-user strong { color:var(--ink); }
html[data-theme="dark"] .company-user > span { color:#8db9ff; background:#172c49; }
html[data-theme="dark"] .company-user a { border-color:#314158; color:#9aa9bc; }
html[data-theme="dark"] .company-card > button { border-color:#29384d; background:#101b2b; box-shadow:0 8px 24px rgba(0,0,0,.16); }
html[data-theme="dark"] .company-card > button:hover { border-color:#3c6191; box-shadow:0 19px 42px rgba(0,0,0,.32); }
html[data-theme="dark"] .company-details strong { color:var(--ink); }
html[data-theme="dark"] .company-meta > span { color:#a8b6c8; background:#182538; }
html[data-theme="dark"] .company-search input { border-color:#2a3a4f; background:#0d1929; }
html[data-theme="dark"] .theme-menu { box-shadow:0 18px 48px rgba(0,0,0,.38); }

@media(max-width:820px) { .theme-toggle span { display:none; }.theme-toggle { padding:0; } }
@media(prefers-reduced-motion:reduce) { .theme-menu { animation:none; } }
