/* Classic keeps the existing palette. Non-default themes only affect the screen. */
:root{--theme-surface:#fff;--theme-raised:#f7f8fb;--theme-hover:#edf2ff;--theme-accent:#315bcc;--theme-accent-fill:#416bdd;--theme-accent-hover:#315acb;--theme-on-accent:#fff;--theme-input:#fff;--theme-border:#d7dee8}
.theme-settings>p{margin-bottom:12px}.theme-settings .panelhead{flex-wrap:wrap}.theme-settings .panelhead>span{font-size:12px}
.theme-options{margin:0;padding:0;border:0;min-width:0;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.theme-options-legend{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.theme-choice{display:grid;grid-template-columns:18px minmax(0,1fr);gap:9px;align-items:start;margin:0;padding:12px;border:1px solid var(--line);border-radius:7px;background:var(--theme-surface);cursor:pointer;min-width:0}
.theme-choice:has(input:checked){border-color:var(--blue);box-shadow:inset 0 0 0 1px var(--blue)}
.theme-choice:focus-within{outline:2px solid var(--theme-accent);outline-offset:3px}
.theme-choice input[type=radio]{display:block;appearance:auto;width:16px;height:16px;min-height:0;margin:3px 0 0;padding:0;accent-color:var(--blue)}
.theme-choice-text{min-width:0}.theme-choice-text strong{display:block;font-size:13px}.theme-choice-text small{display:block;margin-top:2px;font-size:12px;font-weight:400;white-space:normal}
.theme-preview{grid-column:1/-1;display:grid;grid-template-columns:22% minmax(0,1fr);height:72px;border:1px solid #d8e0eb;border-radius:4px;overflow:hidden;background:#f1f3f6}
.theme-preview-nav{display:block;background:#456ddd}.theme-preview-main{display:grid;gap:5px;padding:10px}.theme-preview-main b{display:block;background:#fff;border-radius:2px}.theme-preview-main b:first-child{width:45%;height:7px;background:#416bdd}
.theme-preview--navy{background:#0f172a;border-color:#3a4961}.theme-preview--navy .theme-preview-nav{background:#14243e}.theme-preview--navy .theme-preview-main b{background:#26354c}.theme-preview--navy .theme-preview-main b:first-child{background:#91b5ff}
.theme-preview--teal{background:#edf5f3;border-color:#cbded9}.theme-preview--teal .theme-preview-nav{background:#1c645d}.theme-preview--teal .theme-preview-main b{background:#fff}.theme-preview--teal .theme-preview-main b:first-child{background:#19786e}
.theme-save-status{min-height:0;font-size:12px}.theme-save-status:empty{display:none}.theme-settings .theme-save-status{margin:10px 0 0}
@media(max-width:650px){.theme-options{grid-template-columns:1fr;gap:10px}.theme-choice{grid-template-columns:18px minmax(0,1fr) 96px;align-items:center;min-height:76px;padding:12px;gap:10px}.theme-preview{grid-column:3;grid-row:1;height:50px}.theme-preview-main{padding:7px;gap:3px}.theme-choice input[type=radio]{margin-top:0}.theme-settings .panelhead>span{width:100%}}
@media screen{
  :root[data-theme=navy]{color-scheme:dark;--blue:#91b5ff;--nav:#14243e;--bg:#0f172a;--line:#34445e;--muted:#b4c1d5;--text:#e6edf8;--theme-surface:#19253b;--theme-raised:#22314a;--theme-hover:#2a3e5e;--theme-accent:#a6c4ff;--theme-accent-fill:#315eae;--theme-accent-hover:#3b6bc1;--theme-on-accent:#fff;--theme-input:#122039;--theme-border:#566983}
  :root[data-theme=teal]{color-scheme:light;--blue:#19786e;--nav:#1c645d;--bg:#edf5f3;--line:#d5e3df;--muted:#5c726d;--text:#263f3b;--theme-surface:#fff;--theme-raised:#f3f8f6;--theme-hover:#e5f1ed;--theme-accent:#17695f;--theme-accent-fill:#19786e;--theme-accent-hover:#135e56;--theme-on-accent:#fff;--theme-input:#fff;--theme-border:#bed3cc;--theme-stock-accent:#14574f}
  :root:is([data-theme=navy],[data-theme=teal]),:root:is([data-theme=navy],[data-theme=teal]) body{background:var(--bg);color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.top,.panel,.stat,.login,dialog,.dialoghead,.history-summary,.ledger-panel .tools,.ledger-heading .stock-reconciliation,.column-menu-panel,.column-menu summary,.mobile-more-panel,.inquiry-section,.inquiry-entry-dialog #form>.actions,.collection-ring>div){background:var(--theme-surface);color:var(--text);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(button,input,select,textarea){background:var(--theme-input);color:var(--text);border-color:var(--theme-border)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
  :root:is([data-theme=navy],[data-theme=teal]) :is(button:hover,button:active){background:var(--theme-hover);border-color:var(--theme-border)}
  :root:is([data-theme=navy],[data-theme=teal]) :focus-visible{outline-color:var(--blue)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(button.primary,button.primary:hover,.auth-panel .auth-submit,.auth-panel .auth-submit:hover,.history-pager .page-number[aria-current=page],.icpi-tabs .active){background:var(--theme-accent-fill);border-color:var(--theme-accent-fill);color:var(--theme-on-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) button.primary:hover{background:var(--theme-accent-hover)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.link,.quote-price,.inquiry-entry-dialog input[name=price],.icpi-price-track strong,.amount-strip strong){color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.link,.editable,.icon-button,.account-button,.slip-field){background:transparent}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.editable:hover,.icon-button.selected,.sheet-tabs button.active,.column-menu summary:hover,.column-menu[open] summary){background:var(--theme-hover);color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(th,.stock-detail-dialog th,.entry-grid th,.single-line-grid th,#stock-table th[data-column-id="1"],.stock-detail-fields,.hint,.slip-field-editor,.eagle-detail-metrics,.ledger-panel .sheet-tabs,.ledger-panel .history-pager,.purchase-grid-head){background:var(--theme-raised);color:var(--muted);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) th+th{border-left-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(tbody tr:hover,.single-line-grid tbody tr:hover){background:var(--theme-hover)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.stock-view-tabs,.sales-view-tabs,.chart-track,.ledger-panel .sheet-tabs small,.badge.gray){background:var(--theme-raised);color:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.stock-view-tabs button,.sales-view-tabs button,.ledger-panel .sheet-tabs button){background:transparent;color:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.stock-view-tabs button[aria-selected=true],.sales-view-tabs button[aria-selected=true]){background:var(--theme-surface);color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) .ledger-panel .sheet-tabs button.active{color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) .ledger-panel .sheet-tabs button.active:after{background:var(--blue)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(dialog h3,.dialoghead h2,dialog label,.ledger-content .history-summary b,.collection-ring strong,.icpi-price-track a,.icpi-ranking li a,.inquiry-extra summary){color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.inquiry-intro,.chart-row-label small,.collection-ring span,.inquiry-extra summary span){color:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.dialoghead button,.inquiry-section h3 span){background:var(--theme-raised);color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) .purchase-detail>td{background:var(--theme-raised)!important}
  :root:is([data-theme=navy],[data-theme=teal]) .icpi-chart svg text{fill:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) .column-resizer:after{background:var(--theme-border)}
  :root:is([data-theme=navy],[data-theme=teal]) .sidebar{background:var(--nav)}
  :root:is([data-theme=navy],[data-theme=teal]) .nav :is(button,.eagle-nav summary,.ledger-nav summary){background:transparent;color:#eff7ff}
  :root:is([data-theme=navy],[data-theme=teal]) .nav :is(button:hover,.eagle-nav summary:hover,.ledger-nav summary:hover){background:#ffffff15}
  :root:is([data-theme=navy],[data-theme=teal]) .nav button.active{background:#ffffff1c;color:#fff}
  :root:is([data-theme=navy],[data-theme=teal]) ::selection{background:var(--theme-accent-fill);color:#fff}
  /* Business status colors stay exactly as configured, with dark ink for legibility. */
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold){color:#303b4b;color-scheme:light}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr.stock-unsold{background:var(--stock-unsold)}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-reduced,.stock-partial){background:var(--stock-partial)}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-sold-out,.stock-sold){background:var(--stock-sold)}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr.stock-pending{background:var(--stock-pending)}
  :root:is([data-theme=navy],[data-theme=teal]) #stock-table tbody td[data-column-id="1"]{background:inherit}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold) :is(.muted,small,.sale-save-status){color:#526075}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold) .editable{color:inherit}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold) .editable:hover{background:#e8eef9}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold) :is(.link,.note-more,.editable .icon,.mobile-sale-toggle){color:var(--theme-stock-accent,#244dc4)}
  :root:is([data-theme=navy],[data-theme=teal]) tbody tr:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold) :focus-visible{outline-color:#244dc4}
  /* The embedded editor shares the theme; canvas paper and export colors are untouched. */
  :root:is([data-theme=navy],[data-theme=teal]) :is(.form-section,.save-area,.preview-panel,.download-bar,.logo-setting__preview,.large-preview-dialog,.large-preview-heading){background:var(--theme-surface);border-color:var(--line);color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.item-row,.logo-setting,.paper-scroller,.saved-paper,.large-preview-stage){background:var(--theme-raised);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.field,.item-grid .field,.item-row__head strong,.logo-setting__controls label,.paper-choice legend,.saved-top h2){color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.intro>p,.preview-caption,.save-area p,.saved-top p:last-child,.logo-setting__controls p,.items-footer p,.line-amount small,.saved-view #savedStatus){color:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.quiet-button,.text-button,.download-actions button,.editor-tabs button,.paper-choice__options label,.preview-heading span){background:var(--theme-raised);border-color:var(--theme-border);color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.primary-button,.editor-tabs button[aria-selected=true]){background:var(--theme-accent-fill);border-color:var(--theme-accent-fill);color:#fff}
  :root:is([data-theme=navy],[data-theme=teal]) .primary-button:hover{background:var(--theme-accent-hover)}
  :root:is([data-theme=navy],[data-theme=teal]) .paper-choice__options label:has(input:checked){background:var(--theme-hover);border-color:var(--blue);color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) .field :is(input,textarea):focus{border-color:var(--blue);box-shadow:0 0 0 2px var(--theme-hover)}
  :root:is([data-theme=navy],[data-theme=teal]) .auth-scene{--auth-ink:var(--text);--auth-muted:var(--muted);--auth-line:var(--line);background:var(--bg);color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) .auth-panel{background:var(--theme-surface);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.auth-panel .auth-field,.auth-intro>p,.auth-modules,.auth-product){color:var(--text)}
  :root:is([data-theme=navy],[data-theme=teal]) .auth-panel input{background:var(--theme-input);color:var(--text);border-color:var(--theme-border)}
  :root:is([data-theme=navy],[data-theme=teal]) .auth-panel input:-webkit-autofill{-webkit-text-fill-color:var(--text);box-shadow:0 0 0 1000px var(--theme-input) inset}
  :root:is([data-theme=navy],[data-theme=teal]) .slip-field:hover{background:#4274e620}
  :root[data-theme=navy] :is(.negative,.error,.inline-error,.auth-panel .auth-error){color:#ffaaa3}
  :root[data-theme=navy] :is(.inquiry-entry-dialog #form>.error,#stock-table .inline-editor .inline-error){background:#432a36;border-color:#7a454a}
}
@media screen and (max-width:650px){
  :root:is([data-theme=navy],[data-theme=teal]) .mobile-records tbody tr:not(:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold)){background:var(--theme-surface);color:var(--text);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) .mobile-records tbody tr:not(:is(.stock-unsold,.stock-reduced,.stock-sold-out,.stock-pending,.stock-partial,.stock-sold)) td:before{color:var(--muted)}
  :root:is([data-theme=navy],[data-theme=teal]) .sidebar{background:var(--theme-surface);border-color:var(--line)}
  :root:is([data-theme=navy],[data-theme=teal]) .sidebar .nav :is(button,.mobile-more summary){color:var(--muted);background:transparent}
  :root:is([data-theme=navy],[data-theme=teal]) .sidebar .nav :is(button.active,.mobile-more summary.active,.mobile-more[open] summary,.mobile-more-panel button[aria-current]){background:var(--theme-hover);color:var(--theme-accent)}
  :root:is([data-theme=navy],[data-theme=teal]) .mobile-more-panel{background:var(--theme-surface)}
  :root:is([data-theme=navy],[data-theme=teal]) :is(.mobile-sale-toggle,.mobile-records .inline-sale [data-save-order]){color:var(--theme-accent);background:var(--theme-hover);border-color:var(--theme-border)}
  :root:is([data-theme=navy],[data-theme=teal]) .mobile-record-actions button{background:var(--theme-surface);color:var(--theme-accent)}
}

/* The optional glass preset has its own screen-only stylesheets. */
.theme-preview--glass{background:linear-gradient(135deg,#dae8f8,#f5f9ff);border-color:#d0ddec}
.theme-preview--glass .theme-preview-nav{background:#ffffffae;border-right:1px solid #cad7e8}
.theme-preview--glass .theme-preview-main b{background:#ffffffdf}
.theme-preview--glass .theme-preview-main b:first-child{background:#2864d8}
@media(min-width:651px) and (max-width:1000px){.theme-options{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Shared modal chrome: opaque surfaces, a clear header and an explicit close control. */
@media screen{
  :root[data-theme] body #dialog.app-dialog{
    --dialog-surface:#fff;--dialog-footer:#f8f9fb;--dialog-edge:#e4e8ee;
    color:var(--text);background:var(--dialog-surface);backdrop-filter:none;-webkit-backdrop-filter:none;
  }
  :root[data-theme=navy] body #dialog.app-dialog{--dialog-surface:var(--theme-surface);--dialog-footer:var(--theme-raised);--dialog-edge:var(--line)}
  :root[data-theme] body #dialog.app-dialog::backdrop{background:rgba(18,27,40,.4);backdrop-filter:none;-webkit-backdrop-filter:none}
  :root[data-theme] body #dialog.app-dialog .dialoghead .dialog-close{
    display:inline-flex;align-items:center;justify-content:center;flex:none;width:32px;min-width:32px;height:32px;min-height:32px;
    padding:0;border:0;border-radius:4px;background:transparent;color:var(--muted);box-shadow:none;
  }
  :root[data-theme] body #dialog.app-dialog .dialog-close svg{width:18px;height:18px}
  :root[data-theme] body #dialog.app-dialog .dialoghead .dialog-close:hover{background:var(--theme-hover);color:var(--text)}
  :root[data-theme] body #dialog.app-dialog .dialoghead .dialog-close:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
}
@media screen and (min-width:651px){
  :root[data-theme] body #dialog.app-dialog{padding:0;border:1px solid var(--dialog-edge);border-radius:8px;box-shadow:0 20px 64px rgba(17,29,48,.22);max-height:calc(100dvh - 48px)}
  :root[data-theme] body #dialog.app-dialog.sale-entry-dialog{width:min(680px,calc(100vw - 48px))}
  :root[data-theme] body #dialog.app-dialog #dialog-body{padding:0;border-radius:inherit;max-height:calc(100dvh - 50px);background:var(--dialog-surface)}
  :root[data-theme] body #dialog.app-dialog .dialoghead{
    position:sticky;top:0;z-index:4;display:flex;align-items:center;justify-content:space-between;gap:16px;
    min-height:60px;margin:0;padding:12px 20px;border:0;border-bottom:1px solid var(--dialog-edge);background:var(--dialog-surface);
  }
  :root[data-theme] body #dialog.app-dialog .dialoghead h2{margin:0;font-size:16px;line-height:1.5;font-weight:600;color:var(--text)}
  :root[data-theme] body #dialog.app-dialog #form{padding:20px;margin:0}
  :root[data-theme] body #dialog.app-dialog:not(.receipt-slip-dialog) #form :is(input,select,textarea):not([type=checkbox],[type=radio],[type=color]){min-height:36px;border-radius:6px;font-size:13px}
  :root[data-theme] body #dialog.app-dialog #form>.dialog-actions{
    position:sticky;bottom:0;z-index:3;grid-column:1/-1;display:flex;align-items:center;justify-content:flex-end;gap:10px;
    width:calc(100% + 40px);max-width:none;margin:20px -20px -20px;padding:12px 20px;border-top:1px solid var(--dialog-edge);background:var(--dialog-footer);
  }
  :root[data-theme] body #dialog.app-dialog #form>.dialog-actions>button{min-width:80px;min-height:36px;padding:7px 18px;border-radius:5px;box-shadow:none;font-size:13px}
  :root[data-theme] body #dialog.app-dialog #form>.dialog-actions>.dialog-cancel{background:var(--theme-surface);color:var(--text);border-color:var(--dialog-edge)}
  :root[data-theme] body #dialog.app-dialog.inquiry-entry-dialog #form{padding:0}
  :root[data-theme] body #dialog.app-dialog.inquiry-entry-dialog #form>.dialog-actions{position:static;flex:none;width:100%;margin:0;padding:12px 20px}
}
@media screen and (max-width:650px){
  :root[data-theme] body #dialog.app-dialog .dialoghead .dialog-close{width:44px;min-width:44px;height:44px;min-height:44px}
}
