/* PMS v10 · Unified appearance layer. Loaded after module styles so that all
   screens inherit one palette without changing business logic or print/PDF. */
:root {
  --theme-card: #fff;
  --theme-panel: #f8fbff;
  --theme-panel-hover: #f4f7ff;
  --theme-input: #fff;
  --theme-field-text: #344057;
  --theme-scrollbar: #b8c7df;
  --theme-overlay: rgba(241,246,253,.72);
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1222;
  --surface: #172338;
  --surface-2: #1c2a42;
  --ink: #eef3ff;
  --muted: #b0bfd6;
  --muted-2: #90a3c1;
  --line: #33435e;
  --line-2: #405472;
  --primary: #8196ff;
  --primary-dark: #6981f9;
  --primary-soft: #27365c;
  --cyan: #49bedd;
  --success: #4bd190;
  --danger: #ff737d;
  --warning: #f2b75e;
  --purple: #b99cff;
  --orange: #ffae7b;
  --theme-card: #172338;
  --theme-panel: #1c2a42;
  --theme-panel-hover: #263650;
  --theme-input: #111c30;
  --theme-field-text: #d8e3f6;
  --theme-scrollbar: #61789a;
  --theme-overlay: rgba(5,12,25,.77);
  --shadow: 0 18px 48px rgba(0,0,0,.3);
  --shadow-soft: 0 10px 24px rgba(0,0,0,.22);
}
/* A single compact, keyboard-accessible header control. */
.theme-switch {
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:9px 12px;min-height:40px;border-radius:13px;
  background:var(--theme-card);color:var(--ink);border:1px solid var(--line);
  white-space:nowrap;font:700 .79rem Inter,system-ui,sans-serif;
  transition:background .15s ease,border-color .15s ease,color .15s ease;
}
.theme-switch:hover{background:var(--primary-soft);border-color:var(--primary)}
.theme-switch i{font-size:1.05rem;color:var(--primary)}
.theme-switch:focus-visible{outline:3px solid var(--primary);outline-offset:3px}
.theme-switch-auth{position:fixed;right:22px;top:20px;z-index:50;box-shadow:var(--shadow-soft)}
.scriptcraft-frame{
  display:block;width:100%;height:calc(100vh - 260px);min-height:640px;
  border:1px solid var(--line);border-radius:20px;background:var(--theme-panel);
}
@media(max-width:1100px){.theme-switch{padding:9px 11px}.topbar-actions .theme-switch span{display:none}}
@media(max-width:520px){.theme-switch-auth{top:12px;right:12px}.topbar-actions .theme-switch{width:40px;padding:8px}.scriptcraft-frame{min-height:520px}}
/* Document, scrollbars and native selection. */
:root[data-theme="dark"] body,
:root[data-theme="dark"] body.auth-body,
:root[data-theme="dark"] body.password-gate-body{
  background:radial-gradient(circle at 8% 2%,rgba(62,90,190,.18),transparent 30%),
             radial-gradient(circle at 92% 0%,rgba(39,111,152,.15),transparent 27%),
             linear-gradient(180deg,#0b1222,#101a2d);
  color:var(--ink);
}
:root[data-theme="dark"] ::selection{background:#4c63a5;color:#fff}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb{background:var(--theme-scrollbar)}
:root[data-theme="dark"] :where(input,textarea,select){color-scheme:dark}
:root[data-theme="dark"] :where(input,textarea)::placeholder{color:#9aabc7;opacity:1}
:root[data-theme="dark"] :where(input,select,textarea,button):disabled{opacity:.65}
/* Shell, common cards, KPI tiles, tables, projects, working-area cards. */
:root[data-theme="dark"] .sidebar{background:linear-gradient(180deg,#0d1425,#121e32 57%,#0b1425);border-color:#263752}
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .modern-head,
:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .project-card,
:root[data-theme="dark"] .module-card,
:root[data-theme="dark"] .empty-card,
:root[data-theme="dark"] .form-card,
:root[data-theme="dark"] .onboarding-upload-card,
:root[data-theme="dark"] .audit-stat,
:root[data-theme="dark"] .audit-card,
:root[data-theme="dark"] .audit-panel{
  background:var(--surface);border-color:var(--line);color:var(--ink);
}
:root[data-theme="dark"] .topbar{background:rgba(22,34,54,.95)}
:root[data-theme="dark"] .onboarding-upload-card{box-shadow:var(--shadow)}
:root[data-theme="dark"] :where(.user-pill,.icon-btn,.btn,.btn-ghost,.theme-switch,.sidebar-toggle){color:var(--ink)}
:root[data-theme="dark"] :where(.user-pill,.icon-btn,.btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.btn-outline-light):not(.btn-light),.btn-ghost){background:var(--theme-panel);border-color:var(--line)}
:root[data-theme="dark"] .btn-primary{background:linear-gradient(135deg,#4e65ea,#657eff);color:#fff;border:0}
:root[data-theme="dark"] .btn-secondary{background:#293a67;color:#cfdaff;border-color:#42578d}
:root[data-theme="dark"] .btn-light{background:#e7edff;color:#15223b}
:root[data-theme="dark"] .btn-danger{background:#512536;border-color:#8d4151;color:#ffc1c7}
:root[data-theme="dark"] .btn-ghost:hover{background:#2c3e5c}
:root[data-theme="dark"] .eyebrow{color:#91a6ff}
:root[data-theme="dark"] .badge{background:#2a3a66;color:#ced9ff}
:root[data-theme="dark"] .progress,
:root[data-theme="dark"] .mini-progress,
:root[data-theme="dark"] .audit-progress,
:root[data-theme="dark"] .audit-mini-progress{background:#30425d}
:root[data-theme="dark"] :where(th,td){border-color:var(--line);background:var(--surface);color:var(--ink)}
:root[data-theme="dark"] th{background:#24334b;color:#b3c5df}
:root[data-theme="dark"] tbody tr:hover td{background:#23334e}
:root[data-theme="dark"] :where(.delta-row,.summary-tile,.permission-panel,.permission-card,.pretty-check,.project-check-card,.empty-inline,.soft-delete-note){background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .project-check-card:hover{background:var(--theme-panel-hover);border-color:var(--primary)}
:root[data-theme="dark"] .project-check-card strong{color:var(--ink)}
:root[data-theme="dark"] .project-check-card small{color:var(--muted)}
:root[data-theme="dark"] :where(.field,.grid-form p,.stack-form p){color:var(--theme-field-text)}
:root[data-theme="dark"] :where(.field input,.field select,.field textarea,.grid-form input,.grid-form select,.grid-form textarea,.stack-form input,.stack-form select,.stack-form textarea,.inline-form select,.inline-form,.field.compact input){background:var(--theme-input);color:var(--ink);border-color:var(--line-2)}
:root[data-theme="dark"] :where(.field input,.field select,.field textarea,.grid-form input,.grid-form select,.grid-form textarea):focus{border-color:var(--primary)}
:root[data-theme="dark"] :where(.delta-toolbar,.onboarding-note){background:var(--theme-panel)!important;border-color:var(--line)}
:root[data-theme="dark"] :where(.error-card,.loading-card,.auth-card,.pms-modal-dialog){background:var(--surface);color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .auth-stats span{background:var(--surface);border-color:var(--line)}
:root[data-theme="dark"] .auth-note{background:#233b58;color:#d6e7fa;border-color:#456084}
:root[data-theme="dark"] .auth-note i{color:#adc2ff}
:root[data-theme="dark"] .password-gate-copy h1{color:var(--ink)}
:root[data-theme="dark"] .password-gate-copy p{color:var(--muted)}
:root[data-theme="dark"] .muted-note{background:var(--theme-panel)}
:root[data-theme="dark"] .muted-note a{color:var(--primary)}
:root[data-theme="dark"] .global-loading-overlay{background:var(--theme-overlay)}
:root[data-theme="dark"] .excel-dropzone{background:linear-gradient(180deg,#192740,#142138);border-color:#627ba5}
:root[data-theme="dark"] .excel-dropzone:hover,
:root[data-theme="dark"] .excel-dropzone.is-dragging{background:var(--theme-panel-hover)}
:root[data-theme="dark"] .dropzone-icon{background:var(--surface);border-color:var(--line);color:var(--primary)}
:root[data-theme="dark"] .excel-dropzone strong{color:var(--ink)}
:root[data-theme="dark"] .excel-dropzone em{background:#2a3a66;color:#d1dcff}
:root[data-theme="dark"] .pms-modal-close{background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .import-error-list{background:#351d30;border-color:#7e3648}
:root[data-theme="dark"] .import-error-row{color:#ffd1d8}
:root[data-theme="dark"] .import-error-row strong{color:#ffb9c9}
:root[data-theme="dark"] .import-error-more{color:#ffadbc}
:root[data-theme="dark"] :where(.alert,.errorlist){background:#263662;color:#cfdbff;border-color:#4b609a}
:root[data-theme="dark"] :where(.alert-danger,.alert-error,.errorlist){background:#472333;color:#ffcad0;border-color:#864457}
:root[data-theme="dark"] .alert-success{background:#143e34;color:#b6ffdb;border-color:#38775f}
:root[data-theme="dark"] :where(.status.good,.status-dot,.delta-up){background:#123f35;color:#a5f2c7;border-color:#306d58}
:root[data-theme="dark"] :where(.status.warn,.delta-flat){background:#3c3429;color:#ffe1a5}
:root[data-theme="dark"] :where(.status.bad,.delta-down){background:#4a2534;color:#ffb9c3}
/* Sales Audit — all assessment, results, filters and actions. */
:root[data-theme="dark"] :where(.audit-filter input,.audit-filter select,.audit-form-grid input,.audit-form-grid select,.audit-form-grid textarea,.audit-sign-grid input,.audit-score-form textarea,.audit-rec-table input,.audit-rec-table select){background:var(--theme-input);color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .audit-tab{background:var(--theme-panel);border-color:var(--line);color:var(--muted)}
:root[data-theme="dark"] .audit-tab:hover{background:var(--theme-panel-hover);color:var(--ink)}
:root[data-theme="dark"] .audit-tab.active{background:#4d64e2;border-color:#6076ff;color:#fff}
:root[data-theme="dark"] .audit-workspace-head{background:linear-gradient(135deg,#111b32,#263e9b 72%,#1d7090)}
:root[data-theme="dark"] .audit-section-score{background:#26365a;border-color:#455783}
:root[data-theme="dark"] .audit-section-score strong{color:#bacbff}
:root[data-theme="dark"] :where(.audit-scale-legend,.audit-score-head,.audit-derived-grid>div,.audit-summary-kpis>div,.audit-finalise-card,.objection-card,.audit-choice-section>div,.audit-gap-card){background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .audit-score-row{border-color:var(--line)}
:root[data-theme="dark"] .score-choice span{background:var(--theme-input);border-color:var(--line-2);color:var(--ink)}
:root[data-theme="dark"] .score-choice.score-clear input:checked+span{background:#33445d;border-color:#61708d;color:#fff}
:root[data-theme="dark"] .audit-question b{color:var(--muted)}
:root[data-theme="dark"] .audit-note{background:transparent;color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .objection-card blockquote{color:#e6edff}
:root[data-theme="dark"] .audit-check-row label{background:var(--theme-input);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .audit-ring{background:conic-gradient(var(--ring-color) var(--pct),#2c3c56 0)}
:root[data-theme="dark"] .audit-ring::before{background:var(--surface)}
:root[data-theme="dark"] .audit-combobox-control{background:var(--theme-input);border-color:var(--line)}
:root[data-theme="dark"] .audit-combobox-control:focus-within{border-color:var(--primary)}
:root[data-theme="dark"] .audit-combobox-toggle{color:var(--muted)}
:root[data-theme="dark"] .audit-combobox-toggle:hover:not(:disabled){background:#23385b;color:#d6e2ff}
:root[data-theme="dark"] .audit-combobox-menu{background:#1d2b44;border-color:var(--line);scrollbar-color:var(--theme-scrollbar) var(--theme-panel)}
:root[data-theme="dark"] .audit-combobox-menu::-webkit-scrollbar-track{background:var(--theme-panel)}
:root[data-theme="dark"] .audit-combobox-option{background:transparent;color:var(--ink)}
:root[data-theme="dark"] .audit-combobox-option:hover,
:root[data-theme="dark"] .audit-combobox-option.active{background:#2c3e6b;color:#d4e2ff}
:root[data-theme="dark"] .audit-area-select{background:var(--theme-input);color:var(--ink)}
:root[data-theme="dark"] .audit-area-select:focus{background:var(--theme-panel);color:var(--ink)}
:root[data-theme="dark"] .audit-status.draft{background:#473722;color:#ffd9a5;border-color:#916435}
:root[data-theme="dark"] .audit-status.completed{background:#173f34;color:#b4f6d2;border-color:#44775e}
:root[data-theme="dark"] .audit-tabs{scrollbar-color:var(--primary) var(--theme-panel)}
:root[data-theme="dark"] .audit-tabs::-webkit-scrollbar-track{background:var(--theme-panel)}
:root[data-theme="dark"] .audit-summary-table th{background:var(--theme-panel)}
:root[data-theme="dark"] .audit-summary-table td{background:var(--surface)}
:root[data-theme="dark"] .audit-summary-table tbody tr:hover td{background:var(--theme-panel-hover)}
:root[data-theme="dark"] .audit-company{color:#a2b6ff}
:root[data-theme="dark"] .audit-card:hover{border-color:#667bbc}
:root[data-theme="dark"] .audit-summary-hero{background:linear-gradient(135deg,#0b1428,#182b4a);color:#fff}
:root[data-theme="dark"] .audit-summary-hero *{color:inherit}
/* Keep dark mode readable when default HTML contains an inline white surface. */
:root[data-theme="dark"] :where(.audit-section-score,.audit-form-icon){color:var(--ink)}
@media print {
  .theme-switch{display:none!important}
  :root[data-theme="dark"]{color-scheme:light}
  :root[data-theme="dark"] body{background:white!important;color:black!important}
}
/* Less frequently used project and onboarding components */
:root[data-theme="dark"] .project-more-btn{background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .project-more-btn:hover{background:#512637;border-color:#945264;color:#ffb8c1}
:root[data-theme="dark"] .badge-new{background:#184236;color:#b9f4d0;border-color:#34765a}
:root[data-theme="dark"] .onboarding-report-summary>div{background:var(--theme-panel);border-color:var(--line)}
:root[data-theme="dark"] .skipped-project-list{background:#392d2a;border-color:#7b5a39}
:root[data-theme="dark"] .skipped-project-list-head{background:#47352a;border-color:#7b5a39;color:#ffdda9}
:root[data-theme="dark"] .modal-status-icon.warning{background:#523a26;color:#ffdaaa;border-color:#835d3d}
:root[data-theme="dark"] .modal-status-icon.error{background:#4b2636;color:#ffbdc5;border-color:#824355}
:root[data-theme="dark"] .modal-status-icon.success{background:#194436;color:#abf1cd;border-color:#39775e}
:root[data-theme="dark"] .audit-gap-card input,
:root[data-theme="dark"] .audit-gap-card textarea{background:var(--theme-input);color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .audit-combobox-input:disabled{color:var(--muted)}
:root[data-theme="dark"] .audit-combobox-toggle:disabled{color:var(--muted)}
:root[data-theme="dark"] .audit-score-percent-cell strong{color:var(--ink)}
:root[data-theme="dark"] :where(.audit-gap-card,.audit-summary-table-wrap,.audit-rec-wrap,.audit-score-table){border-color:var(--line)}
