/* Shared neutral palette: no coloured ambient gradients or bright white text. */
html[data-theme=light]{color-scheme:light;--paper:#edecea;--surface:#f8f7f5;--raised:#fdfcfb;--inset:#e7e6e3;--hover:#e4e7e7;--ink:#303334;--muted:#616768;--line:#d1d2ce;--field:#fdfcfb;--field-line:#979f9f;--blue:#365e73;--orange:#42687d;--green:#426c58;--accent:#42687d;--accent-hover:#36596c;--accent-ink:#f5f6f6;--selected:#dce6eb;--focus:#537c96;--link:#365e73;--success:#3c6650;--success-bg:#e0e9e2;--warning:#795d2d;--warning-bg:#eee5d5;--danger:#934d49;--danger-bg:#f0e1de;--rail:#272a2c;--rail-raised:#363c40;--rail-ink:#d5d7d8;--rail-muted:#acb1b4;--office-shadow:0 3px 12px #20252608}
html[data-theme=dark]{color-scheme:dark;--paper:#141516;--surface:#1d1f21;--raised:#25282a;--inset:#191b1c;--hover:#303438;--ink:#d7d9db;--muted:#a5aaae;--line:#3b4043;--field:#191b1d;--field-line:#666e74;--blue:#a7bdcc;--orange:#425f73;--green:#a8c4b1;--accent:#425f73;--accent-hover:#506f83;--accent-ink:#edf0f2;--selected:#2c3b46;--focus:#98b7cf;--link:#a7bdcc;--success:#a8c4b1;--success-bg:#28372e;--warning:#d1ba90;--warning-bg:#3c3428;--danger:#dca9a4;--danger-bg:#402e2e;--rail:#181a1b;--rail-raised:#303538;--rail-ink:#d0d4d6;--rail-muted:#a0a7ac;--office-shadow:0 3px 12px #0000001c}
html[data-theme]{--bg:var(--paper);--panel:var(--surface);--mint:var(--link);--gold:var(--warning);--office-focus:var(--focus)}
html[data-theme]{--rc-bg:var(--paper);--rc-surface:var(--surface);--rc-raised:var(--raised);--rc-field:var(--field);--rc-line:var(--line);--rc-text:var(--ink);--rc-muted:var(--muted);--rc-accent:var(--link);--rc-button:var(--accent);--rc-button-ink:var(--accent-ink)}
html[data-theme=light]{--field-line:#899293}
html[data-theme=dark]{--field-line:#6e777e}
html[data-theme] body,html[data-theme] .app{background:var(--paper);color:var(--ink)}
html[data-theme] .app .shell{--bg:var(--paper);--panel:var(--surface)}
html[data-theme] .workspace:before{display:none}
html[data-theme] body .page-head{background:var(--surface)}
html[data-theme] body .page-head:after{display:none}
html[data-theme] body button:hover:not(:disabled){filter:none}
html[data-theme] :is(.office-tab-frame,.office-drawer iframe){background:var(--paper)}
html[data-theme] :is(h1,h2,h3,h4,strong,.metric):not(:where(#docx-pages *,.docx-wrapper *)){color:var(--ink)}
html[data-theme] :is(.eyebrow,.source-label,.muted,.dim,.page-head p,.page-heading p,.dashboard-intro p,.dashboard-tile p,.dashboard-primary .dashboard-tile:first-child p,.card p,.stock-comment,.crumb,footer,.dashboard-sync,.dashboard-empty,.dashboard-reference a){color:var(--muted)}
html[data-theme] :is(.workspace>header,.topbar){background:var(--surface);border-color:var(--line);box-shadow:none;backdrop-filter:none}
/* Depth comes from small surface differences, not multicoloured cards. */
html[data-theme] :is(.panel,.card,.dashboard-tile,.dashboard-primary .dashboard-tile,.task-dashboard,.stock-stat,.practice-accordion,.full-template-tile,.dashboard-stats>a,.cluster,.metrics button,.pipeline>section,.stock-card,.deal,.hero){background:var(--surface);border-color:var(--line);color:var(--ink);box-shadow:inset 0 1px 0 #ffffff03,var(--office-shadow);backdrop-filter:none}
html[data-theme] .panel .panel{background:var(--inset);border-color:var(--line);box-shadow:none}
html[data-theme] .dashboard-primary .dashboard-tile:after,html[data-theme] .hero:after{display:none}
html[data-theme] :is(.dashboard-icon,.card-icon,.dashboard-primary .dashboard-icon,.dashboard-tile:first-child .dashboard-icon,.cluster-icon,.branch-icon){background:var(--raised);border:1px solid var(--line);color:var(--link);box-shadow:inset 0 1px 0 #ffffff06,0 2px 3px #00000012}
html[data-theme] :is(.dashboard-link,.dashboard-primary .dashboard-link,.dashboard-tile:first-child .dashboard-link,.text-link,.text-button,.back,.author,.dashboard-row,.kb-list-table td a){color:var(--link)}
html[data-theme] :is(.dashboard-row,.dashboard-reference,.resource,.check-row,.lesson-list a,.proof,.entry,.task-row){border-color:var(--line)}
html[data-theme] :is(label,.option,.reading,.task-text,.mail-body,.practice-original-text):not(:where(#docx-pages *,.docx-wrapper *)){color:var(--ink)}
html[data-theme] :is(.reading,.task-text,.mail-body,.practice-original-text){line-height:1.75}
/* Inset fields, readable placeholders and an explicit keyboard focus ring. */
html[data-theme] :is(input,textarea,select){color:var(--ink)!important;background:var(--field)!important;border-color:var(--field-line)!important;box-shadow:inset 0 1px 2px #00000010;caret-color:var(--ink)}
html[data-theme] :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
html[data-theme] :is(input,textarea,select):focus{border-color:var(--focus)!important;box-shadow:none;outline:2px solid var(--focus);outline-offset:2px}
html[data-theme] :is(button,a,summary,[tabindex]):focus-visible{outline:2px solid var(--focus);outline-offset:3px;box-shadow:none}
html[data-theme] :is(input[type=checkbox],input[type=radio]){accent-color:var(--accent);box-shadow:none}
html[data-theme] input:read-only:not([type=checkbox]):not([type=radio]){background:var(--inset)!important}
html[data-theme] :is(.primary,.kb-create,.doc-source button.active){background:linear-gradient(#ffffff06,#00000012),var(--accent);color:var(--accent-ink)!important;border:1px solid var(--accent-hover);text-shadow:none;box-shadow:inset 0 1px 0 #ffffff12,0 2px 0 #00000026,0 3px 7px #00000012}
html[data-theme] :is(.secondary,.quiet,.office-navigation-button,.doc-folders button,.doc-path button,.kb-board-nav button,.kb-mobile-stages button,.icon-button){background:linear-gradient(#ffffff04,#00000006),var(--raised);color:var(--ink);border:1px solid var(--field-line);box-shadow:inset 0 1px 0 #ffffff08,0 1px 2px #00000010}
html[data-theme] :is(button,.primary,.secondary,.quiet):disabled{opacity:.55;box-shadow:none;transform:none}
html[data-theme] :is(.pill,.badge-outline,.badge,.status-pill,.crm-card-tags span,.sipuni-status,.tag){background:var(--raised);border-color:var(--line);color:var(--muted)}
html[data-theme] :is(#network,.status-pill.ok,.feedback,.kb-card-done){background:var(--success-bg);color:var(--success);border-color:var(--success)}
html[data-theme] :is(.warning,.late,.crm-no-next,.kb-date-today){color:var(--warning)}
html[data-theme] :is(.kb-substatus,.feedback.bad){background:var(--warning-bg);color:var(--warning)}
html[data-theme] :is(.kb-date-late,.kb-urgent,.crm-next-item.late small,.kb-overdue-stat){color:var(--danger)}
html[data-theme] :is(.kb-date-late,.kb-urgent){background:var(--danger-bg)}
html[data-theme] :is(.brief,.note,.course-strip,.integration-note,.ray-start){background:var(--inset);color:var(--ink);border-color:var(--line)}
html[data-theme] :is(.quote-summary,.match-row,.work-feature,.work-results,.work-tabs button){background:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme] .work-tabs button.active{background:var(--selected);color:var(--ink);border-color:var(--focus)}
html[data-theme] :is(.note,.crm-next-task){border-left-color:var(--focus)}
/* Tables and task boards. */
html[data-theme] :is(.table-scroll,.work-table td,.check-row,.crm-audit-table td,.kb-list-table td,.practice-table td){border-color:var(--line)}
html[data-theme] :is(.work-table th,.crm-audit-table th,.kb-list-table th){background:var(--raised)!important;color:var(--muted)!important;border-color:var(--line)}
html[data-theme] .work-table tbody tr:nth-child(even){background:var(--inset)}
html[data-theme] :is(.crm-column,.kb-column,.kb-workspace,.kb-command,.kb-view-switch,.mind-branch,.kb-day,.kb-backlog){background:var(--inset);border-color:var(--line);color:var(--ink)}
html[data-theme] :is(.crm-deal,.crm-pick,.kb-card,.kb-overview button,.map-leaf,.rc-notice,.chat-department,.chat-map-card,.chat-map-tools,.chat-branch){background:var(--surface);border-color:var(--line);color:var(--ink);box-shadow:var(--office-shadow)}
html[data-theme] :is(.crm-deal a,.crm-amount,.crm-pick,.kb-card-title,.branch-head,.map-chat,.rc-notice>button:first-child,.rc-history-item,.kb-col-head,.kb-day>header,.kb-menu,.kb-grip,.kb-topline h1,.kb-overview button strong){color:var(--ink)}
html[data-theme] :is(.crm-deal small,.crm-deal label,.crm-pick small,.kb-overview button>span,.kb-overview button small,.kb-excerpt,.branch-head small,.map-chat small,.kb-topline p,.kb-col-hint,.kb-meta,.kb-instruction,.kb-project,.kb-no-project,.kb-card-foot,.kb-date,.kb-list-table td small,.dashboard-row small,.dashboard-stats small,.mail-row span,.mail-row small){color:var(--muted)}
html[data-theme] :is(.kb-filterbar,.kb-week-toolbar,.kb-card-foot,.kb-command,.kb-backlog){border-color:var(--line)}
html[data-theme] .kb-day>header{background:var(--inset)!important}
html[data-theme] .kb-today>header{background:var(--selected)!important}
html[data-theme] :is(.kb-view-switch button,.kb-scope button,.kb-add-card,.kb-mobile-stages button){color:var(--muted)}
html[data-theme] :is(.kb-view-switch button.selected,.kb-scope button.selected,.kb-mobile-stages button.selected,.stock-stat.active){background:var(--selected);color:var(--ink);border-color:var(--focus)}
html[data-theme] :is(.kb-tags span,.kb-avatar,.kb-reference,.kb-check-progress){background:var(--raised);color:var(--muted);border-color:var(--line)}
html[data-theme] :is(.kb-project,.kb-col-head span,.kb-day>header span){background:var(--raised);color:var(--muted);border-color:var(--line)}
html[data-theme] .kb-overview .kb-overdue-stat strong{color:var(--danger)}
/* CRM, messages, documents, account and application menus. */
html[data-theme] :is(.task-card,.task-summary button,.quote-methods button,.quote-signature-box,.quote-order-line,.full-template-select,.map-center){background:var(--surface);border-color:var(--line);color:var(--ink);box-shadow:var(--office-shadow)}
html[data-theme] :is(.compose-bubble,.quote-price-source,.task-badge){background:var(--inset);color:var(--ink)}
html[data-theme] .quote-methods button[aria-selected=true]{background:var(--selected);border-color:var(--focus)}
html[data-theme] :is(.task-facts small,.task-card small,.task-comment time,.task-event,.quote-compose small,.quote-signer-preview,.map-center small,.map-center>span,.kb-empty-drop,.kb-empty-results,.map-empty,.crm-timeline small){color:var(--muted)}
html[data-theme] :is(.task-late-text,.task-overdue .task-due strong){color:var(--danger)}
html[data-theme] .task-priority{background:var(--warning-bg);color:var(--warning)}
html[data-theme] .task-dashboard a{color:var(--link)}
html[data-theme] :is(.task-comment,.quote-terms,.crm-timeline article){border-color:var(--line)}
html[data-theme] .map-chat:hover{background:var(--hover)}
html[data-theme] :is(.hero p,.metrics span,.metrics em,.cluster p,.branches span,.cluster-top>span:nth-child(2),.course-strip>span:last-child,.pipeline-title,.deal p,.lane-empty,.stock-card>small,.movement-list small,.integration-note,.method-note small,.rail-bottom p){color:var(--muted)}
html[data-theme] .orbit-scene{filter:grayscale(.85)}
html[data-theme] :is(.crm-card-statusbar,.crm-card-client,.crm-next-task,.crm-card-history,.crm-feed-item>div,.account-options,.compact-tools>div,.mail-message,.chat-shell,.chat-rooms,.rooms-top,.chat-top,.composer,.chat-sync,.chat){background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme] :is(.crm-card-feed,.messages){background:var(--inset)}
html[data-theme] :is(.crm-card-client section,.crm-history-toolbar,.crm-next-item,.crm-task-result,.sipuni-call-list article,.mail-row,.mail-body){border-color:var(--line)}
html[data-theme] :is(.crm-card-heading small,.crm-card-statusbar label,.crm-card-budget small,.crm-person-block>small,.crm-next-item small,.crm-feed-item small,.crm-feed-day,.crm-task-result small,.sipuni-call-list small,.crm-empty-history,.crm-composer-top span,.chat-note,.room-item small){color:var(--muted)}
html[data-theme] :is(.account-options a,.room-item strong){color:var(--ink)}
html[data-theme] :is(.bubble,.crm-feed-icon){background:var(--raised);border-color:var(--line);color:var(--ink);box-shadow:none}
html[data-theme] :is(.bubble.mine,.room-item.active,.mail-row.selected){background:var(--selected);border-color:var(--focus);color:var(--ink);box-shadow:inset 3px 0 var(--focus)}
html[data-theme] :is(#crm-import-status pre,#emoji-picker){background:var(--inset);color:var(--ink)}
html[data-theme] #emoji-picker button{background:var(--raised)}
html[data-theme] dialog{background:var(--surface);color:var(--ink);border-color:var(--field-line)!important;box-shadow:0 15px 55px #00000055!important}
html[data-theme] dialog::backdrop{background:#10111299;backdrop-filter:none}
html[data-theme] :is(.login-page,.login-box,.login-story){background:var(--surface);border-color:var(--line);color:var(--ink);box-shadow:var(--office-shadow)}
html[data-theme=dark] .login-story img{content:url('./logo-on-dark.svg')}
html[data-theme] .equipment-photo{background:#e7e6e3}html[data-theme] .equipment-photo img{background:transparent}
/* Document paper retains its original appearance and export colours. */
html[data-theme] :is(.template-card,.template-select,.preview-toolbar,.office-drawer,.office-drawer>header,.office-drawer>section button){background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme] :is(.template-select small,.template-choice,.preview-toolbar p,.preview-page figcaption){color:var(--muted)}
html[data-theme] :is(.template-card.selected){border-color:var(--focus);box-shadow:none}
html[data-theme] :is(.quote-preview-dialog,.preview-body){background:var(--inset)}
html[data-theme] #docx-pages section.rcdocx{color:#182c3d!important;background:#fff!important}
html[data-theme] .docx-wrapper section.docx{color:#182c3d!important;background:#fff!important}
html[data-theme] #toast{background:var(--raised);border:1px solid var(--field-line);color:var(--ink)}
html[data-theme] .error-message{background:var(--danger-bg);color:var(--danger)}
/* Navigation is subdued charcoal in both themes. */
html[data-theme] :is(.sidebar,.rail,.office-tab-strip,.compact-tools,.compact-bottom),html[data-theme] body.compact-more:not(.auth-locked)>.sidebar{background:var(--rail);border-color:var(--line);box-shadow:none;color:var(--rail-ink)}
html[data-theme] :is(.sidebar,.rail) :is(.brand small,.nav-label,.nav-group,.rail-caption,small,.theme-controls-title){color:var(--rail-muted)}
html[data-theme] body .sidebar #main-nav details>summary{color:var(--rail-muted)}
html[data-theme] :is(.sidebar nav a,.rail nav button,.office-tab-strip button,.compact-bottom a,.compact-bottom button,.theme-controls [role=switch]){color:var(--rail-ink)}
html[data-theme] :is(.sidebar nav a.active,.sidebar nav a.active:hover,.rail nav button.selected,.office-tab-strip button[aria-pressed=true]){background:var(--rail-raised);border-color:#606d76;box-shadow:inset 3px 0 #a0b6c5;color:#e3e6e8}
html[data-theme] body #main-nav a.active,html[data-theme] body #main-nav a[aria-current=page]{background:var(--rail-raised);border-color:#606d76;box-shadow:inset 3px 0 #a0b6c5;color:#e3e6e8}
html[data-theme] :is(.sidebar nav a:hover,.rail nav button:hover,.office-tab-strip button:hover){background:var(--rail-raised);color:#e3e6e8;border-color:#606d76}
html[data-theme] :is(.sidebar,.rail) :is(strong,b){color:var(--rail-ink)}
html[data-theme] :is(.sidebar,.rail,.office-tab-strip,.compact-bottom) :is(button,a,summary):focus-visible{outline-color:#adc1d0}
html[data-theme] #collapse-nav{background:var(--rail-raised);color:var(--rail-ink);border-color:#606d76;box-shadow:none}
.office-tab-strip>button[aria-label="Уведомления"]{margin-left:auto}
/* The single appearance switch preserves the existing local brightness preference. */
.theme-controls{flex:none;margin:12px 5px;padding:10px 9px 7px;border:1px solid #484e52;border-radius:12px;background:#ffffff03;box-shadow:none}
.theme-controls-title{display:block;font:600 8px/1.3 'Segoe UI',sans-serif;letter-spacing:1.5px;margin:0 4px 7px;color:#acb1b4}
.theme-controls [role=switch]{display:flex;justify-content:space-between;align-items:center;width:100%;min-height:42px;gap:9px;border:0;background:transparent;box-shadow:none;padding:6px 3px;font:500 12px/1.4 'Segoe UI',sans-serif;cursor:pointer;border-radius:8px}
.theme-controls [role=switch]:hover{background:#ffffff08}
.theme-switch-name{display:flex;align-items:center;gap:9px;white-space:nowrap}.theme-switch-name>span:first-child{font-size:18px;color:#bac6ce;width:20px;text-align:center}
.theme-lever{display:block;flex:none;position:relative;width:39px;height:23px;border-radius:20px;border:1px solid #7b878f;background:#292d30;box-shadow:inset 0 1px 3px #00000030;transition:background .15s}
.theme-lever>span{position:absolute;left:3px;top:3px;width:15px;height:15px;border-radius:50%;background:#ced4d8;box-shadow:0 1px 2px #00000040;transition:transform .15s}
[role=switch][aria-checked=true] .theme-lever{background:#506b7e;border-color:#a0b8c8}[role=switch][aria-checked=true] .theme-lever>span{transform:translateX(16px)}
.nav-collapsed .theme-controls{padding:6px 2px;margin:10px 0}.nav-collapsed .theme-controls-title,.nav-collapsed .theme-switch-name{display:none}.nav-collapsed .theme-controls [role=switch]{justify-content:center}
/* Avoid ambient animation, jumping cards and large hover brightness changes. */
html[data-theme] :is(.orb,.orbit-ring){animation:none}
html[data-theme] :is(.primary,.secondary,.quiet,.card,.dashboard-tile,.cluster,.doc-folders button,.office-navigation-button){transition:background-color .15s,border-color .15s;transform:none}
@media(hover:hover){
 html[data-theme] :is(.card,.dashboard-primary .dashboard-tile,.dashboard-tile,.cluster,.doc-folders button):hover{background:var(--raised);border-color:var(--field-line);box-shadow:var(--office-shadow);transform:none}
 html[data-theme] :is(.primary,.kb-create,.doc-source button.active):hover:not(:disabled){background:var(--accent-hover);box-shadow:inset 0 1px 0 #ffffff12,0 2px 0 #00000026;transform:none}
 html[data-theme] :is(.secondary,.quiet,.office-navigation-button):hover:not(:disabled){background:var(--hover);color:var(--ink);border-color:var(--focus);box-shadow:none;transform:none}
 html[data-theme] :is(.work-table tbody tr,.kb-list-table tbody tr,.mail-row,.room-item,.metrics button):hover{background:var(--hover)}
}
html[data-theme] :is(.primary,.secondary,.office-navigation-button):active:not(:disabled){transform:translateY(1px);box-shadow:inset 0 1px 3px #00000026}
html[data-theme] ::selection{background:var(--selected);color:var(--ink)}
html[data-theme] *{scrollbar-color:var(--field-line) var(--inset)}
html[data-theme] .sidebar #main-nav{scrollbar-color:var(--field-line) var(--rail)}
@media(max-width:760px){html[data-theme] body.compact-more:not(.auth-locked)>.sidebar{top:50px!important}}
@media(max-width:760px){.theme-controls{margin:8px 0;padding:6px 9px;max-width:290px}.theme-controls-title{display:none}.theme-controls [role=switch]{min-height:44px}.nav-collapsed .theme-controls{padding:6px 9px}.nav-collapsed .theme-switch-name{display:flex}html[data-theme] :is(.primary,.secondary,.office-navigation-button){min-height:44px}}
@media(prefers-reduced-motion:reduce){.theme-lever,.theme-lever>span{transition:none}}
