/* Theme ownership: palettes here, shared geometry below, business layout in styles.css. */
:root, [data-theme="minimal"] {
  color-scheme: light;
  --page:#f3f5f7; --surface:#ffffff; --surface-subtle:#f8f9fb; --surface-muted:#edf0f3;
  --ink:#222a32; --muted:#626d79; --line:#dce1e6; --line-strong:#b8c1ca;
  --primary:#293b48; --primary-dark:#182b38; --primary-soft:#e8eef2; --on-primary:#ffffff;
  --sidebar:#ffffff; --nav-ink:#596572; --nav-active:#edf2f5; --nav-active-ink:#172e3e; --nav-border:#dce1e6;
  --accent:#12776d; --blue:#286caf; --amber:#916200; --red:#b52e48;
  --danger:#b52e48; --warning:#916200; --success:#16715c;
  --radius-control:6px; --radius-panel:8px;
}
[data-theme="business"] {
  color-scheme:light;
  --page:#f1f4f8; --surface:#ffffff; --surface-subtle:#f7f9fc; --surface-muted:#eaf0f7;
  --ink:#202f44; --muted:#5d6d82; --line:#d7e0eb; --line-strong:#b0bed0;
  --primary:#285cb5; --primary-dark:#1e478e; --primary-soft:#eaf1ff; --on-primary:#ffffff;
  --sidebar:#ffffff; --nav-ink:#536780; --nav-active:#eaf1ff; --nav-active-ink:#2456a7; --nav-border:#d7e0eb;
  --accent:#a25375; --blue:#285cb5; --amber:#936109; --red:#b52e48;
  --danger:#b52e48; --warning:#936109; --success:#16715c;
}
[data-theme="classic"] {
  color-scheme:light;
  --page:#f1f5f3; --surface:#ffffff; --surface-subtle:#f6f9f7; --surface-muted:#e8eeeb;
  --ink:#233c34; --muted:#5d7168; --line:#d4dfd9; --line-strong:#a7bdb1;
  --primary:#246650; --primary-dark:#174e3b; --primary-soft:#e4f0e9; --on-primary:#ffffff;
  --sidebar:#1d352e; --nav-ink:#c3d3cb; --nav-active:#34574a; --nav-active-ink:#ffffff; --nav-border:#3b5147;
  --accent:#a67126; --blue:#3868a4; --amber:#92600e; --red:#b3374e;
  --danger:#b3374e; --warning:#92600e; --success:#246650;
}
[data-theme="atelier"] {
  color-scheme:light;
  --page:#f5f3f6; --surface:#ffffff; --surface-subtle:#faf7fa; --surface-muted:#eee9ee;
  --ink:#392c38; --muted:#796576; --line:#e4dce3; --line-strong:#c3b3c0;
  --primary:#8a3f69; --primary-dark:#702f54; --primary-soft:#f4e8ef; --on-primary:#ffffff;
  --sidebar:#ffffff; --nav-ink:#756171; --nav-active:#f4e8ef; --nav-active-ink:#81375f; --nav-border:#e4dce3;
  --accent:#327d78; --blue:#3967a5; --amber:#936019; --red:#b33147;
  --danger:#b33147; --warning:#936019; --success:#267466;
}
[data-theme="airy"] {
  color-scheme:light;
  --page:#eef6f8; --surface:#ffffff; --surface-subtle:#f5fafb; --surface-muted:#e6f0f3;
  --ink:#23404b; --muted:#566f7a; --line:#d2e2e7; --line-strong:#a5c1cc;
  --primary:#146d87; --primary-dark:#10576c; --primary-soft:#e1f1f5; --on-primary:#ffffff;
  --sidebar:#f9fdfe; --nav-ink:#536f7a; --nav-active:#e1f1f5; --nav-active-ink:#145f76; --nav-border:#d2e2e7;
  --accent:#ad4c64; --blue:#286eaf; --amber:#906311; --red:#b33650;
  --danger:#b33650; --warning:#906311; --success:#1f7762;
}
[data-theme="command"] {
  color-scheme:dark;
  --page:#15191b; --surface:#202628; --surface-subtle:#262d30; --surface-muted:#2d3538;
  --ink:#edf3f2; --muted:#aab8ba; --line:#384346; --line-strong:#617174;
  --primary:#86d8c2; --primary-dark:#b0ecd9; --primary-soft:#243f39; --on-primary:#122923;
  --sidebar:#1b2022; --nav-ink:#bac8c9; --nav-active:#2c443e; --nav-active-ink:#b0ecd9; --nav-border:#384346;
  --accent:#efb77f; --blue:#91bfee; --amber:#efc17a; --red:#f59bb0;
  --danger:#f59bb0; --warning:#efc17a; --success:#86d8c2;
}
body[data-theme] {
  --bg:var(--page); --canvas:var(--page); --panel:var(--surface); --control-surface:var(--surface);
  --blue-soft:color-mix(in srgb,var(--blue) 12%,var(--surface));
  --amber-soft:color-mix(in srgb,var(--amber) 12%,var(--surface));
  --red-soft:color-mix(in srgb,var(--red) 12%,var(--surface));
  --coral:var(--red); --violet:var(--accent);
  --shadow:0 2px 8px #1018200a; --shadow-small:0 1px 3px #10182008;
  --sidebar-width:248px; --page-padding:28px; --control-height:2.85rem;
  margin:0; color:var(--ink); background:var(--page); font-size:1rem; line-height:1.55;
}
body[data-theme].high-contrast { --muted:var(--ink); --line:var(--line-strong); }
body[data-density="compact"] { --page-padding:20px; --control-height:2.5rem; }
body[data-theme][data-density="compact"] .panel:not(.table-panel) { padding-block:14px; }
*, *::before, *::after { letter-spacing:0; }
button, input, select, textarea { font:inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color:transparent; }
button { cursor:pointer; }
button:active { transform:none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline:2px solid var(--primary); outline-offset:3px;
}
.ui-icon { display:inline-block; width:20px; height:20px; flex:0 0 20px; vertical-align:middle; pointer-events:none; }
body[data-theme] :is(input,select,textarea) { color:var(--ink); background:var(--surface); border-color:var(--line-strong); accent-color:var(--primary); }
body[data-theme] :is(input,select,textarea)::placeholder { color:var(--muted); opacity:1; }
body[data-theme] :is(input,select,textarea,button):disabled {
  color:var(--muted)!important; background:var(--surface-muted)!important; opacity:.65; cursor:not-allowed!important;
}
body[data-theme] input[readonly] { color:var(--ink)!important; background:var(--surface-subtle)!important; cursor:default!important; opacity:1; }
body[data-theme] :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]) { border-radius:var(--radius-control); min-width:0; max-width:100%; }
body[data-theme] :is(input[type="checkbox"],input[type="radio"]) { width:1.15rem; height:1.15rem; flex:0 0 1.15rem; margin:0; }
body[data-theme] :is(.primary,.secondary,.danger,.danger-button,.coupon-delete) { min-height:var(--control-height); border-radius:6px; font-size:1rem; font-weight:650; padding:.55rem 1rem; line-height:1.35; box-shadow:none; }
body[data-theme] .primary { background:var(--primary); color:var(--on-primary); border:1px solid var(--primary); }
body[data-theme] .primary:hover { background:var(--primary-dark); border-color:var(--primary-dark); }
body[data-theme] .secondary { background:var(--surface); color:var(--ink); border:1px solid var(--line-strong); }
body[data-theme] .secondary:hover { background:var(--surface-muted); border-color:var(--muted); }
body[data-theme] :is(.danger,.danger-button,.coupon-delete,.table-action.danger) { color:var(--danger); border:1px solid color-mix(in srgb,var(--danger) 40%,var(--line)); background:color-mix(in srgb,var(--danger) 7%,var(--surface)); }
body[data-theme] :is(.danger,.danger-button,.coupon-delete,.table-action.danger):hover { background:color-mix(in srgb,var(--danger) 14%,var(--surface)); }
body[data-theme] .small { min-height:2.4rem; padding:.35rem .75rem; font-size:.9286rem; }
body[data-theme] .icon-button { width:2.5rem; height:2.5rem; min-width:2.5rem; padding:0; display:inline-grid; place-items:center; }

/* Navigation remains ordered by the user's saved preference. */
body[data-theme] .sidebar { width:var(--sidebar-width); height:100dvh; inset:0 auto 0 0; padding:20px 12px 12px; background:var(--sidebar); color:var(--nav-ink); border-right:1px solid var(--nav-border); overflow-y:auto; scrollbar-width:thin; }
body[data-theme] .brand { display:grid; grid-template-columns:34px minmax(0,1fr); align-items:center; gap:10px; padding:2px 8px 18px; }
body[data-theme] .brand-mark { width:34px; height:36px; font-size:1.3rem; border-radius:6px; background:var(--primary); color:var(--on-primary); box-shadow:none; }
body[data-theme] .brand>div { min-width:0; display:block; }
body[data-theme] .brand strong { color:var(--nav-active-ink); font-size:1rem; line-height:1.45; overflow-wrap:anywhere; }
body[data-theme] .brand small { color:var(--nav-ink); font-size:.8571rem; opacity:.9; line-height:1.4; }
body[data-theme] .brand-version { color:var(--nav-ink)!important; font-size:.8571rem; font-weight:500; margin-top:3px; text-shadow:none; }
body[data-theme] .sidebar-toggle { grid-column:1/-1; justify-self:end; width:30px; height:28px; margin:0; background:transparent; color:var(--nav-ink); border:1px solid var(--nav-border); }
body[data-theme] .sidebar-toggle:hover { background:var(--nav-active); }
body[data-theme] .sidebar-toggle span { transform:none; }
body[data-theme] .sidebar nav { display:flex; flex-direction:column; gap:3px; }
body[data-theme] .sidebar .nav-item { display:flex; align-items:center; justify-content:flex-start; min-height:42px; padding:9px 12px; margin:0; gap:12px; background:transparent; color:var(--nav-ink); border:0; border-radius:6px; font-size:1rem; box-shadow:none; }
body[data-theme] .sidebar .nav-icon { width:20px; flex:0 0 20px; color:inherit; display:grid; place-items:center; }
body[data-theme] .sidebar .nav-label { font-size:1rem; font-weight:500; width:auto; white-space:normal; text-align:left; }
body[data-theme] .sidebar .nav-item:hover { background:var(--nav-active); color:var(--nav-active-ink); }
body[data-theme] .sidebar .nav-item.active { background:var(--nav-active); color:var(--nav-active-ink); box-shadow:inset 3px 0 var(--primary); }
body[data-theme] .sidebar .nav-item.active .nav-label { font-weight:700; }
body[data-theme] .sidebar .checkin-nav { background:var(--primary)!important; color:var(--on-primary)!important; margin-bottom:12px; box-shadow:none; }
body[data-theme] .sidebar .checkin-nav span { color:inherit!important; }
body[data-theme] .sidebar-bottom { margin-top:auto; padding-top:18px; }
body[data-theme] .google-link { min-height:0; border:0; border-radius:0; margin:0; padding:8px; color:var(--nav-ink); background:transparent; }
body[data-theme] .google-link:hover { background:var(--nav-active); }
body[data-theme] .google-link b { font-weight:500; font-size:.8571rem; }
body[data-theme] .google-link small { display:none; }
body[data-theme] .user { display:grid; grid-template-columns:30px 1fr 28px 28px; gap:6px; padding:14px 4px 0; margin-top:12px; border-top:1px solid var(--nav-border); }
body[data-theme] .user b { font-size:.9286rem; color:var(--nav-active-ink); overflow-wrap:anywhere; }
body[data-theme] .user small { font-size:.8571rem; color:var(--nav-ink); }
body[data-theme] .avatar { width:30px; height:30px; background:var(--nav-active); color:var(--nav-active-ink); }
body[data-theme] :is(.change-password-btn,.logout-btn) { display:grid; place-items:center; width:28px; min-width:28px; height:30px; border:0; padding:0; color:var(--nav-ink); background:transparent; border-radius:4px; }
body[data-theme] :is(.change-password-btn,.logout-btn):hover { background:var(--nav-active); color:var(--nav-active-ink); }
body[data-theme][data-sidebar="compact"] { --sidebar-width:72px; }
body[data-theme][data-sidebar="compact"] .brand { display:flex; flex-direction:column; padding:0 0 16px; }
body[data-theme][data-sidebar="compact"] .brand>div, body[data-theme][data-sidebar="compact"] .nav-label { display:none; }
body[data-theme][data-sidebar="compact"] .sidebar .nav-item { justify-content:center; padding:10px 6px; }
body[data-theme][data-sidebar="compact"] .google-link { display:none; }
body[data-theme][data-sidebar="compact"] .user { display:flex; flex-direction:column; }
body[data-theme][data-sidebar="compact"] .user>div, body[data-theme][data-sidebar="compact"] .avatar { display:none; }

/* Header and page sections are working surfaces, not floating cards. */
body[data-theme] main { margin-left:var(--sidebar-width); background:var(--page); min-width:0; }
body[data-theme] main>header { min-height:78px; padding:16px var(--page-padding); gap:16px; flex-wrap:wrap; background:var(--surface); border-color:var(--line); }
body[data-theme] main>header>div:first-child { min-width:0; }
body[data-theme] h1 { font-size:1.55rem; font-weight:700; margin:0; }
body[data-theme] .header-actions { gap:10px; flex-wrap:wrap; }
body[data-theme] .ai-search { width:auto; flex:1 1 360px; min-width:280px; max-width:650px; min-height:42px; padding:4px 6px 4px 12px; background:var(--surface-subtle); border-color:var(--line); border-radius:6px; box-shadow:none; }
body[data-theme] .header-actions .ai-search { position:static; inset:auto; }
body[data-theme] .ai-search>span { color:var(--primary); }
body[data-theme] .ai-search textarea { background:transparent; color:var(--ink); font-size:1rem; }
body[data-theme] .ai-search .ai-model-select { max-width:150px; font-size:.8571rem; background:var(--surface); color:var(--muted); }
body[data-theme] .ai-search button { background:var(--primary); color:var(--on-primary); font-size:.9286rem; padding:0 12px; }
body[data-theme] .ai-search:focus-within { border-color:var(--primary); }
body[data-theme] .store-select { min-width:174px; height:auto; min-height:42px; background:var(--surface); font-size:.8571rem; }
body[data-theme] .store-select select { font-size:.9286rem; }
body[data-theme] .page { padding:24px var(--page-padding) 40px; max-width:1800px; margin:0 auto; }
body[data-theme] :is(.period-row,.toolbar) { border:0; border-radius:0; padding:0; background:transparent; box-shadow:none; gap:12px; flex-wrap:wrap; margin-bottom:20px; }
body[data-theme] .segmented { background:var(--surface-muted); border:1px solid var(--line); padding:3px; border-radius:6px; max-width:100%; overflow-x:auto; }
body[data-theme] .segmented button { color:var(--muted); font-size:.9286rem; min-height:32px; padding:6px 13px; flex-shrink:0; }
body[data-theme] .segmented button.active { background:var(--surface); color:var(--primary); box-shadow:0 1px 3px #00000012; }
body[data-theme] :is(.records-tabs,.access-tabs,.ledger-view-tabs) { background:transparent; border:0; border-bottom:1px solid var(--line); padding:0; gap:22px; border-radius:0; }
body[data-theme] :is(.records-tabs,.access-tabs,.ledger-view-tabs) button { border:0; border-bottom:2px solid transparent; background:none; color:var(--muted); border-radius:0; padding:10px 2px; white-space:nowrap; }
body[data-theme] :is(.records-tabs,.access-tabs,.ledger-view-tabs) button.active { background:none; color:var(--primary); border-bottom-color:var(--primary); box-shadow:none; }
body[data-theme] .metric-grid { gap:14px; margin-bottom:24px; }
body[data-theme] #dashboardMetrics { grid-template-columns:repeat(5,minmax(0,1fr)); }
body[data-theme] .metric { min-height:122px; padding:18px 20px; background:var(--surface); border:1px solid var(--line); box-shadow:none; border-radius:8px; }
body[data-theme] .metric::before { display:none; }
body[data-theme] .metric-label { font-size:.9286rem; }
body[data-theme] .metric strong { font-size:2rem; margin:12px 0 0; line-height:1.2; }
body[data-theme] .clickable-metric:hover { transform:none; border-color:var(--line-strong); background:var(--surface-subtle); box-shadow:none; }
body[data-theme] .dashboard-grid { gap:26px; margin-bottom:24px; }
body[data-theme] .panel { padding:20px 0; border:0; border-top:1px solid var(--line); border-radius:0; box-shadow:none; background:transparent; }
body[data-theme] .dashboard-grid>.panel { min-height:0; }
body[data-theme] .panel-head { margin-bottom:16px; gap:12px; }
body[data-theme] :is(.panel h2,.page-context h2) { font-size:1.2rem; color:var(--ink); margin:0; }
body[data-theme] .panel h3 { font-size:1rem; }
body[data-theme] :is(.rank-row,.compact-row,.store-card) { font-size:.9286rem; min-width:0; }
body[data-theme] :is(.compact-row.head,.data-row.head) { color:var(--muted); }
body[data-theme] :is(.compact-row.drill-link,.detail-row.drill-link) { background:transparent; }
body[data-theme] :is(.compact-row.drill-link,.detail-row.drill-link):hover { background:var(--surface-subtle); }
body[data-theme] :is(.visit-cell,.member-reserve,.analysis-kpi) { background:var(--surface); border-color:var(--line); color:var(--ink); }
body[data-theme] :is(.rank-bar,.mini-bar) { background:var(--surface-muted); }
body[data-theme] .table-panel { padding:0; background:var(--surface); border:1px solid var(--line); border-radius:6px; overflow:hidden; }
body[data-theme] .table-panel .panel-head { padding:16px 18px; }
body[data-theme] .data-table { scrollbar-width:thin; }
body[data-theme] :is(.data-row,.payroll-detail-row) { color:var(--ink); background:var(--surface); border-color:var(--line); font-size:1rem; min-height:52px; }
body[data-theme] :is(.data-row.head,.payroll-detail-row.head,.coupon-detail-head,.ocr-structured-row.head) { background:var(--surface-muted); color:var(--muted); font-weight:600; font-size:.9286rem; }
body[data-theme] .data-row:not(.head):hover { background:var(--surface-subtle); }
body[data-theme] .data-row>*, body[data-theme] .panel-head>* { min-width:0; }
body[data-theme][data-table-density="dense"] .data-row { min-height:40px; }
body[data-theme][data-table-density="relaxed"] .data-row { min-height:66px; }
body[data-theme] :is(.table-action,.flag-button,.payroll-drill) { background:var(--surface); color:var(--ink); border-color:var(--line); }
body[data-theme] :is(.table-action.text-action,.record-link,.text-btn) { font-size:.9286rem; color:var(--primary); }
body[data-theme] :is(.table-action,.payroll-drill):hover { background:var(--primary-soft); }
body[data-theme] :is(.flagged-row,.flag-button.active,.flag-toggle) { background:var(--red-soft); color:var(--danger); border-color:var(--line); }
body[data-theme] :is(.status-chip,.panel-tag,.version-chip,.coupon-badge) { font-size:.8571rem; padding:3px 7px; background:var(--primary-soft); color:var(--primary); border:0; }
body[data-theme] :is(.free-badge,.coupon-free-toggle) { color:var(--success); background:color-mix(in srgb,var(--success) 12%,var(--surface)); border-color:var(--line); }
body[data-theme] .coupon-purchase-row { box-shadow:inset 3px 0 var(--warning); }
body[data-theme] :is(.warning-chip,.online-note,.favorite-action.active) { background:var(--amber-soft); color:var(--warning); }
body[data-theme] :is(.analysis-filter,.ledger-summary,.ledger-filters,.filter-panel,.detail-summary,.payroll-detail-summary) { background:var(--surface); border-color:var(--line); color:var(--ink); border-radius:6px; }
body[data-theme] :is(.ledger-filters label,.analysis-filter label,.inline-label) { font-size:.9286rem; }
body[data-theme] .ledger-filters { grid-template-columns:repeat(7,minmax(0,1fr)) auto; }
body[data-theme] .ledger-filters label { min-width:0; }
body[data-theme] .ledger-summary { grid-template-columns:repeat(3,minmax(0,1fr)); }
body[data-theme] .ledger-summary>div { min-width:0; padding:16px 12px; }
body[data-theme] .summary-split-item { min-width:0; padding:12px 4px; }
body[data-theme] .summary-split-item em { overflow-wrap:anywhere; }
body[data-theme] .analysis-filter { flex-wrap:wrap; }
body[data-theme] .analysis-filter label { flex:1 1 150px; min-width:0; }
body[data-theme] .analysis-filter :is(input,select) { width:100%; min-width:0; }
body[data-theme] :is(.rank-bar,.mini-bar,.profit-row i,.dimension-row i) { background:var(--surface-muted); }
body[data-theme] .ledger-filter-search { background:var(--primary); color:var(--on-primary); }
body[data-theme] :is(.analysis-banner,.access-hero) { background:var(--primary-soft); color:var(--ink); border:1px solid var(--line); border-radius:6px; padding:18px 22px; }
body[data-theme] :is(.analysis-banner,.access-hero) :is(.eyebrow,span,p) { color:var(--muted); }
body[data-theme] :is(.analysis-score,.store-stat) { border-color:var(--line); }
body[data-theme] :is(.analysis-kpi strong,.payroll-row strong,.entry-total-row strong) { color:var(--primary); }
body[data-theme] :is(.operation-log-list,.operation-log-row,.permission-check,.permission-override,.permission-group-card,.message-item,.release-card,.idea-item) { background:var(--surface); border-color:var(--line); color:var(--ink); }
body[data-theme] .operation-log-row { grid-template-columns:150px 110px 130px minmax(0,1fr); font-size:.9286rem; }
body[data-theme] .operation-log-row>* { min-width:0; overflow-wrap:anywhere; }
body[data-theme] :is(.operation-log-row .log-details,.privacy-copy,.release-list,.message-item small) { color:var(--muted); }
body[data-theme] :is(.cash-settled-row,.appointment-day-head,.attendance-strip,.zoom-control) { background:var(--surface-subtle); color:var(--ink); border-color:var(--line); }
body[data-theme] .appointment-scroll { scrollbar-color:var(--line-strong) var(--surface); }

/* One complete miniature per palette, using the same tokens as the real workbench. */
body[data-theme] .settings-layout { gap:8px; }
body[data-theme] .settings-panel { padding:24px 0; }
body[data-theme] .settings-panel:first-child { padding-top:0; border-top:0; }
body[data-theme] .theme-options { grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
body[data-theme] .theme-option { display:flex; flex-direction:column; gap:12px; padding:12px; position:relative; border:2px solid transparent; border-radius:8px; background:var(--surface); box-shadow:0 0 0 1px var(--line); color:var(--ink); text-align:left; min-width:0; }
body[data-theme] .theme-option:hover { border-color:var(--line-strong); box-shadow:none; }
body[data-theme] .theme-option.active { border-color:var(--primary); box-shadow:none; }
body[data-theme] .theme-option b { font-size:1rem; font-weight:650; align-self:auto; }
.theme-label { display:flex; justify-content:space-between; align-items:center; width:100%; gap:8px; }
.theme-check { display:grid; place-items:center; width:22px; height:22px; border-radius:50%; background:var(--primary); color:var(--on-primary); visibility:hidden; }
.theme-option.active .theme-check { visibility:visible; }
body[data-theme] .theme-preview { display:grid; width:100%; height:130px; grid-template-columns:23% minmax(0,1fr); grid-template-rows:24px 1fr; gap:0; border:1px solid var(--line); border-radius:5px; background:var(--page); overflow:hidden; }
.theme-preview i:nth-child(n) { grid-column:auto; grid-row:auto; }
.theme-preview .preview-nav { grid-row:1/-1; padding:12px 8px; background:var(--sidebar); border-right:1px solid var(--nav-border); display:grid; align-content:start; gap:8px; }
.theme-preview .preview-nav i { height:4px; width:75%; border-radius:2px; background:var(--nav-ink); opacity:.45; }
.theme-preview .preview-nav i:first-child { height:9px; width:100%; background:var(--primary); opacity:1; margin-bottom:4px; }
.theme-preview .preview-header { background:var(--surface); border-bottom:1px solid var(--line); }
.theme-preview .preview-body { padding:10px; display:grid; gap:8px; align-content:start; }
.theme-preview .preview-metrics { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; }
.theme-preview .preview-metrics i { height:25px; background:var(--surface); border:1px solid var(--line); border-top:3px solid var(--primary); border-radius:3px; }
.theme-preview .preview-metrics i:nth-child(2) { border-top-color:var(--blue); }
.theme-preview .preview-metrics i:nth-child(3) { border-top-color:var(--accent); }
.theme-preview .preview-rows { display:grid; gap:5px; }
.theme-preview .preview-rows i { height:7px; background:var(--surface-muted); border-radius:2px; }
body[data-theme] .settings-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:22px; }
body[data-theme] .settings-grid label { font-size:.9286rem; font-weight:500; }
body[data-theme] .settings-grid select { height:var(--control-height); margin-top:8px; font-size:1rem; }
body[data-theme] .switch-setting { align-self:end; min-height:44px; padding:8px 0; border-bottom:1px solid var(--line); }
body[data-theme] .switch-setting input { appearance:none; width:38px; flex:0 0 38px; height:22px; border:1px solid var(--line-strong); border-radius:12px; background:var(--surface-muted); position:relative; cursor:pointer; }
.switch-setting input::before { content:""; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:var(--muted); transition:transform .15s; }
body[data-theme] .switch-setting input:checked { background:var(--primary); border-color:var(--primary); }
.switch-setting input:checked::before { background:var(--on-primary); transform:translateX(16px); }
body[data-theme] .nav-order-list { grid-template-columns:repeat(3,minmax(0,1fr)); gap:0 22px; }
body[data-theme] .nav-order-item { padding:10px 0; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; grid-template-columns:22px minmax(0,1fr) auto; }
.nav-order-item>div { display:flex; gap:4px; }
body[data-theme] .nav-order-item b { font-size:.9286rem; font-weight:500; }

/* Dialogs and auth share the exact same surfaces and typography. */
body[data-theme]:has(.modal-backdrop.open) { overflow:hidden; }
body[data-theme] .modal-backdrop { padding:24px; background:#10191f80; backdrop-filter:blur(3px); align-items:center; }
body[data-theme] .modal { width:min(720px,100%); padding:24px; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:8px; box-shadow:0 24px 80px #00000038; max-height:calc(100dvh - 48px); overflow:auto; overscroll-behavior:contain; }
body[data-theme] :is(.wide-modal,#recordModal .modal) { width:min(1120px,100%); }
body[data-theme] .compact-detail-modal { width:min(980px,100%); }
body[data-theme] .modal-head { align-items:flex-start; gap:16px; margin-bottom:22px; padding-bottom:18px; border-bottom:1px solid var(--line); }
body[data-theme] .modal-head h2 { font-size:1.4rem; line-height:1.4; margin:0; }
body[data-theme] .modal-head p:not(:empty) { display:block; font-size:.9286rem; color:var(--muted); line-height:1.5; margin:6px 0 0; }
body[data-theme] .close { width:32px; height:32px; min-width:32px; display:grid; place-items:center; color:var(--muted); background:var(--surface-subtle); border:1px solid var(--line); border-radius:6px; }
body[data-theme] .close:hover { color:var(--ink); background:var(--surface-muted); }
body[data-theme] :is(.form-grid,.form-grid.three) { gap:18px 20px; }
body[data-theme] :is(.form-grid label,.wide-label,.message-form label,.assignment-form label) { color:var(--muted); font-size:.9286rem; font-weight:550; min-width:0; }
body[data-theme] :is(.form-grid input,.form-grid select,.message-form input,.message-form select) { width:100%; height:var(--control-height); font-size:1rem; margin-top:6px; padding:0 10px; }
body[data-theme] :is(.wide-label textarea,.message-form textarea) { font-size:1rem; padding:10px; }
body[data-theme] .form-grid small { color:var(--muted); font-size:.8571rem; font-weight:400; }
body[data-theme] .modal-actions { position:sticky; bottom:-24px; z-index:4; padding:16px 0; margin-top:24px; background:var(--surface); border-top:1px solid var(--line); gap:10px; }
body[data-theme] :is(.entry-item-row,.entry-defaults,.entry-payment-details,.ocr-structure,.coupon-context,.entry-total-row) { background:var(--surface-subtle); border-color:var(--line); color:var(--ink); }
body[data-theme] .entry-item-row input, body[data-theme] .entry-item-row select { font-size:.9286rem; }
body[data-theme] .calculation { border-color:var(--line); background:var(--primary-soft); color:var(--ink); }
body[data-theme] .calculation strong { color:var(--primary); font-size:1.8rem; }
body[data-theme] :is(.detail-row,.coupon-detail-row,.payroll-detail-summary) { border-color:var(--line); }
body[data-theme] .detail-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:16px; padding:0 0 20px; margin-bottom:22px; border-bottom:1px solid var(--line); border-radius:0; }
body[data-theme] .detail-summary span { display:block; color:var(--muted); font-size:.9286rem; }
body[data-theme] .detail-summary strong { display:block; margin-top:4px; font-size:1.4rem; overflow-wrap:anywhere; }
body[data-theme] :is(.detail-table,.payroll-detail-table) { min-width:0; max-width:100%; overflow-x:auto; scrollbar-width:thin; }
body[data-theme] .payroll-detail-table .payroll-detail-row { min-width:1280px; }
body[data-theme] .coupon-detail-table .coupon-detail-head { background:var(--surface-muted); }
body[data-theme] .coupon-detail-table :is(.coupon-meta,.coupon-usage) { font-size:.9286rem; }
body[data-theme] :is(.ocr-preview,.upload-zone) { background:var(--surface-subtle); border-color:var(--line-strong); color:var(--muted); }
body[data-theme] #cloudLoginOverlay { background:var(--page); color:var(--ink); font-family:var(--font-family); padding:20px; overflow:auto; }
body[data-theme] .cloud-login-card { background:var(--surface); border:1px solid var(--line); box-shadow:0 16px 60px #15202b10; padding:32px; border-radius:8px; }
body[data-theme] .cloud-login-header h2 { color:var(--ink); font-size:1.55rem; }
body[data-theme] :is(.cloud-login-header p,.cloud-login-card label span,.cloud-login-footer,.cloud-login-register) { color:var(--muted); font-size:.9286rem; }
body[data-theme] .cloud-login-card input { background:var(--surface); color:var(--ink); border-color:var(--line-strong); font-size:1rem; }
body[data-theme] .cloud-login-btn { background:var(--primary); color:var(--on-primary); font-size:1rem; border-radius:6px; }
body[data-theme] .cloud-login-btn:hover { background:var(--primary-dark); }
body[data-theme] .toggle-btn { background:transparent; color:var(--primary); font-size:.9286rem; }
body[data-theme] :is(.cloud-login-error,.form-error,.required-mark) { color:var(--danger); }
body[data-theme] .cloud-login-error { font-size:.9286rem; }
body[data-theme] .cloud-login-card input:focus { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }
body[data-theme] .cloud-recovery-panel { border-color:var(--line); }
body[data-theme] #quickEntry { display:inline-flex; align-items:center; gap:6px; }
body[data-theme] .toast { font-size:1rem; background:var(--ink); color:var(--surface); border-radius:6px; }
body[data-theme] .error-toast { background:var(--surface); color:var(--danger); border:1px solid var(--danger); box-shadow:0 8px 30px #00000026; }

/* Schedule colors remain semantic, independent of the selected palette. */
body[data-theme] :is(.appointment-calendar,.appointment-time-header,.appointment-time-axis,.appointment-resource-label,.appointment-row-track) { background-color:var(--surface); border-color:var(--line); color:var(--ink); }
body[data-theme] :is(.appointment-date-divider,.appointment-date-heading,.appointment-staff-heading) { background:var(--surface-muted); border-color:var(--line); color:var(--ink); }
body[data-theme] .appointment-row-track { background-image:repeating-linear-gradient(to right,transparent 0,transparent calc(var(--hour-width)/2 - 1px),var(--line) calc(var(--hour-width)/2 - 1px),var(--line) calc(var(--hour-width)/2)); }
body[data-theme] .appointment-block.male { background:var(--blue-soft); color:var(--blue); border-color:color-mix(in srgb,var(--blue) 50%,var(--line)); }
body[data-theme] .appointment-block.female { background:var(--red-soft); color:var(--red); border-color:color-mix(in srgb,var(--red) 50%,var(--line)); }
body[data-theme] .appointment-block.unspecified { background:var(--primary-soft); color:var(--primary); border-color:var(--line-strong); }
body[data-theme] .appointment-block button { background:var(--surface); color:inherit; }
body[data-theme] .appointment-view-controls { background:var(--surface-subtle); border-color:var(--line); }

@media(max-width:1250px) {
  body[data-theme] #dashboardMetrics { grid-template-columns:repeat(3,minmax(0,1fr)); }
  body[data-theme] main>header { align-items:flex-start; }
  body[data-theme] main>header>div:first-child { flex-basis:100%; }
  body[data-theme] .header-actions { justify-content:flex-start; flex-basis:100%; min-width:0; max-width:100%; }
  body[data-theme] .ledger-filters { grid-template-columns:repeat(4,minmax(0,1fr)); }
  body[data-theme] .ledger-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-theme] .ledger-summary>div:last-child { grid-column:auto; }
  body[data-theme] .ai-search { max-width:none; }
  body[data-theme] .settings-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-theme] .nav-order-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:960px) {
  body[data-theme] { --sidebar-width:216px; --page-padding:20px; }
  body[data-theme] .theme-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-theme] .dashboard-grid, body[data-theme] .dashboard-grid.lower { grid-template-columns:1fr; }
  body[data-theme] .store-select { min-width:155px; }
  body[data-theme] .ledger-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media(max-width:760px) {
  body[data-theme],body[data-theme][data-sidebar="compact"] { --sidebar-width:0px; --page-padding:16px; }
  body[data-theme] .sidebar { position:sticky; inset:auto; top:0; width:100%; height:auto; z-index:15; padding:12px 16px 0; overflow:visible; border-right:0; border-bottom:1px solid var(--nav-border); }
  body[data-theme] .brand,body[data-theme][data-sidebar="compact"] .brand { display:grid; grid-template-columns:32px minmax(0,1fr) 32px; gap:10px; padding:0 0 12px; }
  body[data-theme] .brand>div,body[data-theme][data-sidebar="compact"] .brand>div { display:block; }
  body[data-theme] .brand strong { font-size:1rem; }
  body[data-theme] .brand small { display:none; }
  body[data-theme] .brand-version { font-size:.8571rem; margin:0; }
  body[data-theme] .sidebar-toggle { grid-column:3; width:32px; height:32px; align-self:center; }
  body[data-theme] .sidebar nav { display:flex; flex-direction:row; overflow-x:auto; max-height:65vh; gap:5px; padding:0 0 10px; scrollbar-width:thin; }
  body[data-theme] .sidebar .nav-item,body[data-theme][data-sidebar="compact"] .sidebar .nav-item { flex:0 0 auto; min-height:36px; padding:7px 10px; gap:8px; }
  body[data-theme] .sidebar .nav-label,body[data-theme][data-sidebar="compact"] .sidebar .nav-label { display:block; font-size:.9286rem; white-space:nowrap; }
  body[data-theme] .sidebar .checkin-nav { margin-bottom:0; }
  body[data-theme] .sidebar-bottom { display:none!important; }
  body[data-theme].mobile-menu-open .sidebar nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); overflow-y:auto; }
  body[data-theme].mobile-menu-open .sidebar .nav-item { justify-content:flex-start; }
  body[data-theme].mobile-menu-open .sidebar-bottom { display:block!important; padding:0 0 10px; }
  body[data-theme].mobile-menu-open .google-link { display:none; }
  body[data-theme].mobile-menu-open .user { display:flex; flex-direction:row; justify-content:flex-end; min-height:40px; padding:5px 0 0; margin:0; }
  body[data-theme].mobile-menu-open .user>div { display:block; margin-right:auto; }
  body[data-theme] main,body[data-theme][data-sidebar="compact"] main { margin-left:0; }
  body[data-theme] main>header { position:static; min-height:0; padding:18px 16px; gap:14px; }
  body[data-theme] .header-actions { width:100%; gap:8px; }
  body[data-theme] .ai-search { order:3; flex-basis:100%; min-width:0; display:grid; grid-template-columns:20px minmax(0,1fr) auto; gap:8px; padding:8px; }
  body[data-theme] .ai-search textarea { grid-column:2/-1; width:100%; min-height:32px; }
  body[data-theme] .ai-search .ai-model-select { grid-column:1/3; max-width:none; width:100%; padding:0 8px; }
  body[data-theme] .ai-search button { grid-column:3; }
  body[data-theme] .store-select { display:flex; flex:1; min-width:0; }
  body[data-theme] .icon-text { display:flex; }
  body[data-theme] #ocrEntry { display:inline-flex; padding:.5rem .75rem; }
  body[data-theme] #ocrEntry span { display:none; }
  body[data-theme] .page { padding:18px 16px 32px; }
  body[data-theme] .metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  body[data-theme] #dashboardMetrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-theme] .metric { padding:14px; min-height:110px; }
  body[data-theme] .metric strong { font-size:1.65rem; }
  body[data-theme] .metric-icon { width:24px; height:24px; }
  body[data-theme] .metric-label { gap:6px; }
  body[data-theme] .theme-options { gap:10px; }
  body[data-theme] .theme-option { padding:8px; }
  body[data-theme] .theme-preview { height:104px; }
  body[data-theme] .nav-order-list { grid-template-columns:1fr; }
  body[data-theme] .settings-grid { gap:18px 12px; }
  body[data-theme] :is(.toolbar,.toolbar-actions,.record-head,.period-row,.coupon-detail-actions) { flex-wrap:wrap; }
  body[data-theme] .toolbar-actions .search { flex:1 0 100%; width:100%; }
  body[data-theme] .ledger-summary>div:nth-child(n+5) { grid-column:1/-1; }
  body[data-theme] .ledger-summary>div:nth-child(-n+4) .summary-split { flex-direction:column; }
  body[data-theme] .custom-range { flex-wrap:wrap; }
  body[data-theme] .custom-range input { width:8.8rem; max-width:100%; }
  body[data-theme] .table-pagination { flex-wrap:wrap; }
  body[data-theme] .table-pagination>div { flex-wrap:wrap; }
  body[data-theme] .modal-backdrop { padding:10px; }
  body[data-theme] .modal { max-height:calc(100dvh - 20px); padding:18px; }
  body[data-theme] :is(.form-grid,.form-grid.three) { grid-template-columns:1fr; }
  body[data-theme] .modal-actions { bottom:-18px; padding:14px 0; gap:8px; }
  body[data-theme] .modal-actions button { flex:1 1 auto; }
  body[data-theme] .entry-total-row { grid-template-columns:1fr auto; }
  body[data-theme] .entry-item-row { grid-template-columns:24px minmax(0,1fr) minmax(0,1fr); }
  body[data-theme] .entry-item-row label:first-of-type { min-width:0; }
  body[data-theme] .operation-log-row { grid-template-columns:1fr 1fr; gap:6px 12px; }
  body[data-theme] .operation-log-row>:last-child { grid-column:1/-1; }
  body[data-theme] .detail-row { grid-template-columns:1fr; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } }
