/* Меридиан CRM shared foundations. Product-specific layouts live in *-brand.css. */
:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #eef2f7;
  --text: #192332;
  --text-secondary: #526278;
  --text-muted: #5d6e85;
  --line: #dde5ef;
  --accent: #246beb;
  --accent-hover: #1857cb;
  --accent-soft: #eaf1ff;
  --accent-text: #225fbd;
  --success: #207351;
  --success-soft: #e8f5ee;
  --warning: #94601c;
  --warning-soft: #fff3dd;
  --danger: #b84444;
  --danger-solid: #b84444;
  --danger-soft: #fff0ef;
  --shadow-sm: 0 2px 6px #182b4704, 0 5px 18px #182b4704;
  --shadow-md: 0 16px 48px #172c4810, 0 3px 12px #172c4806;
  --radius: 18px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1017;
  --surface: #141b26;
  --surface-raised: #1a2432;
  --surface-muted: #101722;
  --text: #eef3fc;
  --text-secondary: #bac7d9;
  --text-muted: #91a2b9;
  --line: #293547;
  --accent: #2f72dd;
  --accent-hover: #236be0;
  --accent-soft: #1a2d4c;
  --accent-text: #8db9ff;
  --success: #83d9b1;
  --success-soft: #15342b;
  --warning: #edc27b;
  --warning-soft: #382c1b;
  --danger: #ffaaa4;
  --danger-soft: #3b2329;
  --shadow-sm: 0 3px 16px #00000010;
  --shadow-md: 0 20px 60px #00000030;
}
html {background:var(--bg);scroll-padding-top:90px;scrollbar-color:var(--line) var(--bg)}
body {background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
::selection {background:var(--accent);color:#fff}
button,input,select,textarea {accent-color:var(--accent)}
input,select,textarea {color-scheme:inherit}
button,a {touch-action:manipulation}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {outline:3px solid var(--accent-text);outline-offset:3px}
input::placeholder,textarea::placeholder {color:var(--text-muted);opacity:1}
input[type=search]::-webkit-search-cancel-button {cursor:pointer}
.masthead {background:#101318;color:#fff;border-bottom:1px solid #ffffff0c}
:root[data-theme=dark] .masthead {background:#0c1017;border-bottom-color:var(--line)}
.brand>span {border-color:#ffffff25;color:#a7b4c6}
.brand b {color:#f6f8fd}
.brand img {object-fit:contain}
.btn {border-color:var(--line);background:var(--surface);color:var(--text-secondary);box-shadow:var(--shadow-sm);transition:background .16s,border-color .16s,box-shadow .16s,transform .16s}
.btn:hover {background:var(--surface-muted);border-color:var(--accent-text);filter:none}
.btn:active {transform:translateY(1px)}
.btn.primary {background:var(--accent);border-color:var(--accent);color:#fff;box-shadow:0 4px 12px #246beb25}
.btn.primary:hover {background:var(--accent-hover);border-color:var(--accent-hover)}
.btn.soft {background:var(--accent-soft);border-color:transparent;color:var(--accent-text);box-shadow:none}
.btn.ghost {background:transparent;border-color:transparent;box-shadow:none;color:var(--text-secondary)}
.btn.ghost:hover {background:var(--surface-muted)}
.text-btn {color:var(--accent-text)}
.panel {background:var(--surface);border-color:var(--line);box-shadow:var(--shadow-sm)}
.input,.select {background:var(--surface);border-color:var(--line);color:var(--text)}
.field>span {color:var(--text-secondary)}
.field small,.muted,.note {color:var(--text-muted)}
.eyebrow {color:var(--text-muted)}
.icon-btn {background:var(--surface);border-color:var(--line);color:var(--text-secondary)}
.avatar {background:var(--accent-soft);color:var(--accent-text)}
.boot-status {background:var(--bg);color:var(--text-secondary)}
.app-footer {color:var(--text-muted)}
.theme-toggle {
  flex:0 0 42px;display:inline-flex;align-items:center;justify-content:center;
  width:42px;height:42px;min-width:42px;padding:0;border:1px solid #ffffff28;
  border-radius:50%;background:#ffffff08;color:#d3dceb;cursor:pointer;
  transition:background .18s,color .18s,border-color .18s,transform .18s;
}
.theme-toggle svg {width:20px;height:20px;pointer-events:none}
.theme-toggle:hover {background:#ffffff14;border-color:#8db9ff;color:#fff}
.theme-toggle:active {transform:scale(.95)}
.theme-toggle:focus-visible {outline-color:#8db9ff;outline-offset:4px}
.theme-toggle[aria-pressed=true] {color:#a8caff;border-color:#4271aa;background:#152943}
.auth-theme-switch {position:fixed;right:max(25px,env(safe-area-inset-right));top:24px;z-index:95;background:var(--surface-raised);color:var(--text);border-color:var(--line);box-shadow:var(--shadow-sm)}
body:has(#workspace:not([hidden]))>.auth-theme-switch {display:none}
.auth-theme-switch:hover {background:var(--accent-soft);color:var(--accent-text)}
.portal-top-actions {display:flex;align-items:center;gap:16px;margin-left:auto;flex:none}
.portal-top-actions #portal-account {margin-left:0}
@media(max-width:800px) {
  .theme-toggle {width:44px;height:44px;min-width:44px;flex-basis:44px}
  .portal-top-actions {gap:10px}
}
@media(max-width:600px) {
  .auth-theme-switch {top:18px;right:16px}
}
@media(prefers-reduced-motion:reduce) {
  .btn,.theme-toggle {transition:none}
}
