/* CRM-only automatic night palette. Activated 22:00–08:00 Europe/Berlin. */
html[data-crm-theme="dark"]{
  color-scheme:dark;
  --navy:#111d35;
  --ink:#edf3ff;
  --muted:#b1c0d8;
  --blue:#9ec6ff;
  --ice:#142238;
  --line:#344660;
  --ok:#78dbb2;
  --danger:#ff817c;
  --warn:#ffce77;
  --card:#17243a;
  --dark-bg:#0c1422;
  --dark-card:#17243a;
  --dark-raised:#1d2e48;
  --dark-soft:#263c5b;
  --dark-text:#edf3ff;
  --dark-muted:#b4c4dc;
}
html[data-crm-theme="dark"] body,
html[data-crm-theme="dark"] main{
  background:#0c1422!important;
  color:var(--dark-text);
}
html[data-crm-theme="dark"] body{
  background-image:linear-gradient(180deg,#101a2b,#0c1422)!important;
}
html[data-crm-theme="dark"] .top{
  background:#0d1b36!important;color:#f1f6ff;
  box-shadow:0 8px 24px rgba(0,0,0,.18);
}
html[data-crm-theme="dark"] .top .nav-system-menu,
html[data-crm-theme="dark"] .top .nav-system-menu a,
html[data-crm-theme="dark"] .top .nav-system-menu button{
  background:#172944!important;color:#e4efff!important;
}
html[data-crm-theme="dark"] .top .nav-system-menu a:hover,
html[data-crm-theme="dark"] .top .nav-system-menu button:hover{
  background:#294468!important;color:white!important;
}
html[data-crm-theme="dark"] .top .nav-btn.active{background:#29456d!important;color:#fff!important}
html[data-crm-theme="dark"] .top .nav-system-menu .nav-menu-label{color:#b4c4da!important}
html[data-crm-theme="dark"] :is(
  .panel,.card,.page-hero,.tablebox,.stat,.action-card,.search-panel,
  .filter-panel,.contract,.contract.contract-compact,.modalbox,.login,
  .dashboard-fold,.dashboard-focus-card,.sales-shop-card,.revenue-shop-card,
  .revenue-total-small,.revenue-admin-bonus,.search-topline,.copyitem,
  .customer-hero,.feature-panel,.customer-card,.customer-tile,
  .import-result,.document-age-archive,.scan-card,.conflict-hub-card,
  .app-install-card,.phone-shop-card
){
  background:var(--dark-card)!important;
  color:var(--dark-text)!important;
  border-color:var(--line)!important;
  box-shadow:0 5px 18px rgba(0,0,0,.12);
}
html[data-crm-theme="dark"] :is(
  .contract-grid>div,.contract-compact .contract-summary,
  .contract-compact .contract-expanded,.document-age-archive .document-row,
  .revenue-bonus-main,.revenue-metrics .revenue-goal,.revenue-projection,
  .dashboard-fold>.panel,.phone-shop-details,
  .revenue-quarter-picker .active,.copyitem,.copy-mini,
  .dashboard-jump-links a,.result-count,.count-pill,.action-icon,
  .source,.period-btn,.phone-filter-panel
){
  background:var(--dark-raised)!important;
  color:var(--dark-text)!important;
  border-color:var(--line)!important;
}
html[data-crm-theme="dark"] .dashboard-fold>summary:hover,
html[data-crm-theme="dark"] tbody tr:hover,
html[data-crm-theme="dark"] .action-card:hover{
  background:#243853!important;
}
html[data-crm-theme="dark"] :is(
  .dashboard-focus-label,.dashboard-fold-title,.dashboard-focus-card strong,
  .dashboard-focus-card small,.dashboard-fold-hint,.dashboard-jump-links a,
  .contract-compact .contract-summary,.contract-compact .contract-summary-text strong,
  .revenue-tier-small strong,.revenue-projection-grid strong,
  .revenue-period strong,.source,.text-link,.section-head h2,
  .document-age-archive>summary,.dashboard-shop-extras>summary,
  .phone-control-details>summary
){
  color:var(--dark-text)!important;
}
html[data-crm-theme="dark"] :is(
  .muted,.revenue-bonus-main span,.revenue-total-small span,
  .revenue-metrics span,.revenue-admin-bonus span,
  .revenue-admin-bonus small,.revenue-projection small,
  .revenue-projection-grid span,.contract-compact .contract-summary-text small,
  .fineprint,.stat small,.copyitem small,.contract-grid small,
  .phone-shop-live-note,.phone-shop-scope
){
  color:var(--dark-muted)!important;
}
html[data-crm-theme="dark"] :is(
  input,select,textarea,.input,[contenteditable="true"],
  .dashboard-customer-search input,.search-panel input,
  input[type="date"],input[type="search"],input[type="number"]
){
  background:#111f35!important;color:#f3f7ff!important;
  border-color:#506786!important;
  caret-color:#9ed0ff;
}
html[data-crm-theme="dark"] input::placeholder,
html[data-crm-theme="dark"] textarea::placeholder{color:#a6b7d0}
html[data-crm-theme="dark"] :is(input,textarea,select,button,a):focus-visible{
  outline:2px solid #8fc5ff;outline-offset:2px;
}
html[data-crm-theme="dark"] table{color:var(--dark-text)!important}
html[data-crm-theme="dark"] th{
  background:#223450!important;color:#c8d8ee!important;
  border-color:var(--line)!important;
}
html[data-crm-theme="dark"] td,
html[data-crm-theme="dark"] .kv,
html[data-crm-theme="dark"] .audit,
html[data-crm-theme="dark"] .contract-compact .contract-expanded{
  border-color:var(--line)!important;
}
html[data-crm-theme="dark"] :is(
  .btn-soft,.btn-outline,.btn-light,.period-btn:not(.active),
  .conflict-hub-filters a,.dashboard-jump-links a,.btn-neutral
){
  background:#263e60!important;color:#e4efff!important;
  border-color:#46658d!important;
}
html[data-crm-theme="dark"] :is(
  .btn-primary,.period-btn.active,.btn-blue
){
  background:#2855a3!important;color:white!important;border-color:#4276c1!important;
}
html[data-crm-theme="dark"] .btn-danger{
  background:#a32e36!important;color:#fff!important;
}
html[data-crm-theme="dark"] :is(.badge,.badge.neutral,.result-count,.count-pill){
  background:#234864!important;color:#c4e4ff!important;
}
html[data-crm-theme="dark"] .badge.warn{
  background:#5a4221!important;color:#ffda95!important;
}
html[data-crm-theme="dark"] .badge.danger{
  background:#622c33!important;color:#ffb7b2!important;
}
html[data-crm-theme="dark"] :is(.notice,.revenue-note){
  background:#473b22!important;color:#ffe0a3!important;border-color:#745b27!important;
}
html[data-crm-theme="dark"] :is(.dangerbox,.invoice-cancel-tag,.contract-risk-tag){
  background:#542b34!important;color:#ffbbb4!important;border-color:#824653!important;
}
html[data-crm-theme="dark"] :is(
  .dashboard-clean .dashboard-tools,.dashboard-tools>.panel,
  .dashboard-calls-fold .panel,.sales-category,.sales-metric,
  .addon-item,.feature-row,.contract-list-hint,.contract-archive-wrapper,
  .feature-row form,.dashboard-customer-search,.dashboard-shop-extras
){
  border-color:var(--line)!important;
}
html[data-crm-theme="dark"] :is(.revenue-metrics>div,.sales-category,.addon-item,.revenue-projection-grid>div){
  background:#1d2e48!important;color:var(--dark-text)!important;border-color:var(--line)!important;
}
/* Preserve the distinction between active buttons and the light inactive state. */
html[data-crm-theme="dark"] #dashboard-phone-availability .phone-mode-buttons [data-phone-mode].btn-primary{
  background:#2757a5!important;color:white!important;
}
html[data-crm-theme="dark"] #dashboard-phone-availability .phone-mode-buttons [data-phone-mode].btn-danger{
  background:#aa3a41!important;color:#fff!important;
}
html[data-crm-theme="dark"] #dashboard-phone-availability .phone-mode-buttons [data-phone-mode].btn-soft{
  background:#263e60!important;color:#e4efff!important;
}
/* Stronger overrides for card backgrounds inside inline dashboard style blocks. */
html[data-crm-theme="dark"] .dashboard-clean .dashboard-focus-card,
html[data-crm-theme="dark"] .dashboard-clean .dashboard-fold,
html[data-crm-theme="dark"] .dashboard-clean .sales-shop-card,
html[data-crm-theme="dark"] .dashboard-clean .revenue-shop-card,
html[data-crm-theme="dark"] .dashboard-clean .revenue-metrics>div,
html[data-crm-theme="dark"] #dashboard-phone-availability .phone-shop-card{
  background:#17243a!important;color:#edf3ff!important;border-color:#344660!important;
}
html[data-crm-theme="dark"] .dashboard-clean .revenue-metrics .revenue-goal,
html[data-crm-theme="dark"] .dashboard-clean .revenue-bonus-main{
  background:#20344f!important;
}
/* Specific inline white-backed field and explanatory components. */
html[data-crm-theme="dark"] :is(
  .value-card,.value-card-new,.decision-pick,.decision-new,.conflict-field-card,
  .conflict-value,.conflict-new,.fax-group-box,.inline-duplicate,
  .scan-part,.scan-summary>div,.porting-review-row,.invoice-note,
  .document-row,.cancel-batch-card,.scan-integrity-warning
){
  background:#1e304b!important;color:#edf3ff!important;border-color:#486184!important;
}
html[data-crm-theme="dark"] :is(
  .value-card-title,.contract-status-badge,.conflict-list-actions small,
  .scan-reason,.scan-card small,.scan-head .muted
){color:#b9c9e0!important}
html[data-crm-theme="dark"] .conflict-savebar,
html[data-crm-theme="dark"] .phone-shop-details-body,
html[data-crm-theme="dark"] .filter-panel,
html[data-crm-theme="dark"] .scan-document-preview{
  background:#17243a!important;color:#edf3ff!important;border-color:var(--line)!important;
}
/* Future modules may include literal light inline backgrounds; neutralize them
   without recoloring warning badges, danger buttons, or highlighted states. */
html[data-crm-theme="dark"] :is(
  .panel,.card,.contract,.stat,.action-card,.dashboard-fold,.tablebox,
  .page-hero,.customer-hero,.modalbox,.scan-card,.conflict-field-card
) [style*="background:#fff"]:not(.btn):not(.badge):not(.notice):not(.dangerbox){
  background:#1d2e48!important;color:var(--dark-text)!important;
}
html[data-crm-theme="dark"] :is(dialog,[role="dialog"],.modalbox,.scan-document-preview){
  color-scheme:dark;
}
@media print{
  html[data-crm-theme="dark"]{color-scheme:light!important}
  html[data-crm-theme="dark"] body{background:white!important;color:black!important}
}
/* Compact dashboard appearance control: Auto / Hell / Dunkel. */
.dashboard-top-actions .crm-theme-switch{
  display:inline-flex;align-items:center;gap:3px;padding:4px 5px 4px 10px;
  border:1px solid #c7d5e8;border-radius:999px;background:#f4f8ff;
  color:#23446e;white-space:nowrap;min-height:42px;
}
.dashboard-top-actions .crm-theme-switch-label{
  font-size:11px;font-weight:800;letter-spacing:.02em;margin-right:4px;
}
.dashboard-top-actions .crm-theme-option{
  border:0;border-radius:999px;padding:7px 9px;min-width:39px;min-height:32px;
  background:transparent;color:inherit;font:700 12px/1.1 Inter,system-ui,sans-serif;
  cursor:pointer;transition:background .12s ease;
}
.dashboard-top-actions .crm-theme-option:hover{background:#dfebfc}
.dashboard-top-actions .crm-theme-option.is-selected,
.dashboard-top-actions .crm-theme-option[aria-pressed="true"]{
  background:#174c98;color:#fff;box-shadow:0 1px 4px rgba(0,0,0,.12);
}
.dashboard-top-actions .crm-theme-option:focus-visible{
  outline:3px solid #65b5ff;outline-offset:2px;
}
html[data-crm-theme="dark"] .dashboard-top-actions .crm-theme-switch{
  background:#1d2e48;color:#e5efff;border-color:#46658d;
}
html[data-crm-theme="dark"] .dashboard-top-actions .crm-theme-option:hover{
  background:#314e73;
}
html[data-crm-theme="dark"] .dashboard-top-actions .crm-theme-option.is-selected,
html[data-crm-theme="dark"] .dashboard-top-actions .crm-theme-option[aria-pressed="true"]{
  background:#477dcc;color:#fff;
}
@media(max-width:560px){
  .dashboard-top-actions .crm-theme-switch{padding:4px 5px 4px 8px}
  .dashboard-top-actions .crm-theme-option{min-width:35px;padding:7px}
}
