/* ==========================================================================
   SIP-панель — дизайн-система
   Токены → база → компоненты → экраны. Тёмная и светлая тема, адаптив, доступность.
   ========================================================================== */

/* ---------- шрифт: Inter (OFL), локально — без внешних запросов и без ослабления CSP ---------- */
@font-face {
    font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
    src: url("/assets/fonts/inter-cyrillic-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
    src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- токены ----------
   Нейтральная палитра (zinc), один акцент для фокуса и выбора, графитовая основная кнопка.
   Цвет — только для смысла (статусы), всё остальное — оттенки серого. */
:root {
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

    --r-sm: 6px;
    --r: 8px;
    --r-lg: 10px;
    --r-pill: 999px;

    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;

    --t-fast: 120ms cubic-bezier(.2, .7, .3, 1);
    --t: 200ms cubic-bezier(.2, .7, .3, 1);

    --topbar-h: 56px;
    --sidebar-w: 236px;
    --z-sticky: 20; --z-pop: 60; --z-drawer: 70; --z-toast: 90;

    /* тёмная тема по умолчанию */
    color-scheme: dark;
    --bg: #09090b;
    --bg-elev: #0f0f12;
    --sidebar: #0c0c0e;
    --surface: #111113;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --border: #232327;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --muted: #71717a;
    --primary: #fafafa;
    --primary-hover: #e4e4e7;
    --on-primary: #09090b;
    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-soft: rgba(59, 130, 246, .14);
    --on-accent: #fff;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(59, 130, 246, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
    --overlay: rgba(0, 0, 0, .6);

    --ok: #22c55e;      --ok-soft: rgba(34, 197, 94, .12);     --ok-text: #4ade80;
    --work: #f59e0b;    --work-soft: rgba(245, 158, 11, .12);  --work-text: #fbbf24;
    --load: #38bdf8;    --load-soft: rgba(56, 189, 248, .12);  --load-text: #7dd3fc;
    --bad: #ef4444;     --bad-soft: rgba(239, 68, 68, .12);    --bad-text: #f87171;
}

/* Светлая: явно выбранная или «как в системе» (медиазапрос ниже) */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #fafafa; --bg-elev: #ffffff; --sidebar: #f4f4f5; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #e4e4e7;
    --border: #e4e4e7; --border-strong: #d4d4d8; --text: #09090b; --text-2: #3f3f46; --muted: #71717a;
    --primary: #18181b; --primary-hover: #27272a; --on-primary: #fafafa;
    --accent: #2563eb; --accent-strong: #1d4ed8; --accent-soft: rgba(37, 99, 235, .08);
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(37, 99, 235, .45);
    --shadow: 0 1px 2px rgba(9, 9, 11, .05);
    --shadow-lg: 0 16px 40px rgba(9, 9, 11, .14), 0 0 0 1px rgba(9, 9, 11, .06);
    --overlay: rgba(9, 9, 11, .32);
    --ok: #16a34a; --ok-text: #15803d; --ok-soft: rgba(22, 163, 74, .09);
    --work: #d97706; --work-text: #b45309; --work-soft: rgba(217, 119, 6, .1);
    --load: #0284c7; --load-text: #0369a1; --load-soft: rgba(2, 132, 199, .09);
    --bad: #dc2626; --bad-text: #dc2626; --bad-soft: rgba(220, 38, 38, .08);
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
        --bg: #fafafa; --bg-elev: #ffffff; --sidebar: #f4f4f5; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #e4e4e7;
        --border: #e4e4e7; --border-strong: #d4d4d8; --text: #09090b; --text-2: #3f3f46; --muted: #71717a;
        --primary: #18181b; --primary-hover: #27272a; --on-primary: #fafafa;
        --accent: #2563eb; --accent-strong: #1d4ed8; --accent-soft: rgba(37, 99, 235, .08);
        --focus: 0 0 0 2px var(--bg), 0 0 0 4px rgba(37, 99, 235, .45);
        --shadow: 0 1px 2px rgba(9, 9, 11, .05);
        --shadow-lg: 0 16px 40px rgba(9, 9, 11, .14), 0 0 0 1px rgba(9, 9, 11, .06);
        --overlay: rgba(9, 9, 11, .32);
        --ok: #16a34a; --ok-text: #15803d; --ok-soft: rgba(22, 163, 74, .09);
        --work: #d97706; --work-text: #b45309; --work-soft: rgba(217, 119, 6, .1);
        --load: #0284c7; --load-text: #0369a1; --load-soft: rgba(2, 132, 199, .09);
        --bad: #dc2626; --bad-text: #dc2626; --bad-soft: rgba(220, 38, 38, .08);
    }
}

/* ---------- база ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 14px/1.5 var(--font);
    letter-spacing: -.006em;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11" 1, "ss01" 1, "calt" 1;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: var(--accent-soft); }
h1, h2, h3, p { margin: 0; }
code, kbd { font-family: var(--mono); font-size: .92em; }
kbd {
    display: inline-block; min-width: 1.6em; padding: 0 .4em; text-align: center;
    border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px;
    background: var(--surface-2); color: var(--text-2); font-size: 11px; line-height: 1.6;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
/* Lucide — контурные иконки: обводка наследует цвет текста, толщина чуть тоньше стандартной — аккуратнее на 14 px. */
.ico { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px;
    fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 14px; height: 14px; vertical-align: -2px; stroke-width: 2; }
.ico--fill { fill: currentColor; stroke: none; }
.num, .kpi__value, .status-btn__time { font-feature-settings: "tnum" 1, "cv11" 1; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 12px; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 500; font-size: 13.5px; white-space: nowrap; user-select: none;
    box-shadow: var(--shadow);
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); border-color: transparent; color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: transparent; }
.btn--primary.is-busy::after { border-color: color-mix(in srgb, var(--on-primary) 35%, transparent); border-top-color: var(--on-primary); }
.btn--danger { background: var(--bad); border-color: transparent; color: #fff; }
.btn--danger:hover { background: #dc2626; border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn--sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: var(--r-sm); gap: 6px; }
.btn--lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--icon { width: 34px; padding: 0; }
.btn--sm.btn--icon { width: 28px; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
    content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn--ghost.is-busy::after, .btn:not(.btn--primary):not(.btn--danger).is-busy::after { border-color: var(--border-strong); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- поля ---------- */
.input, .select, .textarea {
    width: 100%; height: 34px; padding: 0 11px; border-radius: var(--r);
    border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-size: 13.5px;
    box-shadow: var(--shadow);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.select {
    appearance: none; padding-right: 32px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237c8599'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 18px;
}
.select--sm { height: 30px; font-size: 13px; padding-left: 10px; border-radius: 8px; }
.field { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.field__error { font-size: 12.5px; color: var(--bad-text); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.input-group > .ico ~ .input { padding-left: 36px; }
.input-group > .input:has(~ .input-group__end) { padding-right: 44px; }
.input-group > .input-group__end { position: absolute; right: 6px; display: flex; gap: 4px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }

/* ---------- бейджи, пилюли ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px;
    border-radius: var(--r-sm); font-size: 12px; font-weight: 500; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge--ok { background: var(--ok-soft); color: var(--ok-text); border-color: transparent; }
.badge--work { background: var(--work-soft); color: var(--work-text); border-color: transparent; }
.badge--load { background: var(--load-soft); color: var(--load-text); border-color: transparent; }
.badge--bad { background: var(--bad-soft); color: var(--bad-text); border-color: transparent; }
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- оболочка: боковая навигация + рабочая область ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
    padding: 12px 10px; background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto;
}
.main { min-width: 0; display: flex; flex-direction: column; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__logo {
    width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none;
    background: var(--primary); color: var(--on-primary);
}
.brand__logo .ico { width: 15px; height: 15px; }
.brand__text { display: grid; min-width: 0; line-height: 1.2; }
.brand__name { font-weight: 650; font-size: 14px; letter-spacing: -.015em; white-space: nowrap; }
.brand__panel { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: grid; gap: 1px; }
.nav__label { padding: 14px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.nav__item {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border-radius: var(--r-sm);
    border: 0; background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 500; text-align: left;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav__item[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.nav__item .ico { color: var(--muted); }
.nav__item[aria-current="page"] .ico, .nav__item:hover .ico { color: var(--text); }
.nav__item kbd { margin-left: auto; opacity: 0; transition: opacity var(--t-fast); }
.nav__item:hover kbd { opacity: 1; }
.nav__count { margin-left: auto; font-size: 12px; color: var(--muted); font-feature-settings: "tnum" 1; }
.nav__count--bad { color: var(--bad-text); font-weight: 600; }

.sidebar__foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); display: grid; gap: 2px; }
.sidebar__foot .avatar-btn { width: 100%; height: 44px; padding: 0 8px; border-radius: var(--r-sm); justify-content: flex-start; }
.sidebar__foot .avatar-btn__text { flex: 1; min-width: 0; }
.sidebar__foot .avatar-btn__name, .sidebar__foot .avatar-btn__role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar {
    position: sticky; top: 0; z-index: var(--z-sticky);
    height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-3);
    padding: 0 var(--s-6);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 14px; font-weight: 600; white-space: nowrap; }
.topbar__search { flex: 1; max-width: 420px; }
.topbar__search .input { background: var(--surface); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 6px; }
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1000px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: var(--z-drawer); width: min(280px, 86vw);
        transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--shadow-lg);
    }
    .nav-open .sidebar { transform: none; }
    .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--overlay); }
    .nav-toggle { display: inline-flex; }
}
.conn {
    display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px;
    border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; color: var(--text-2);
    background: var(--surface); border: 1px solid var(--border); white-space: nowrap;
}
.conn .dot { background: var(--muted); }
.conn[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.conn[data-state="poll"] .dot { background: var(--work); }
.conn[data-state="off"] { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.conn[data-state="off"] .dot { background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.avatar-btn { display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 6px 0 4px; border-radius: var(--r-pill); border: 1px solid transparent; background: transparent; color: var(--text); }
.avatar-btn:hover { background: var(--surface-2); }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 11px; text-transform: uppercase;
}
.avatar-btn__text { display: grid; text-align: left; line-height: 1.15; }
.avatar-btn__name { font-weight: 600; font-size: 13px; }
.avatar-btn__role { font-size: 11.5px; color: var(--muted); }

/* ---------- баннер связи ---------- */
.banner {
    display: flex; align-items: center; gap: 10px; padding: 10px var(--s-6);
    background: var(--bad-soft); color: var(--bad-text); font-weight: 550; border-bottom: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}
.banner .btn { margin-left: auto; }

/* ---------- основная область ---------- */
.page { width: 100%; max-width: 1560px; margin: 0 auto; padding: var(--s-6) var(--s-6) var(--s-8); }
@media (min-width: 1400px) { .page { padding-inline: var(--s-8); } }
@media (max-width: 860px) { .page { padding: var(--s-4) var(--s-3) var(--s-8); } }
.overview { display: flex; align-items: stretch; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.kpi {
    flex: 1 1 150px; min-width: 140px; display: grid; gap: 4px; text-align: left;
    padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
    position: relative; transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.kpi__label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.kpi__label .dot { width: 7px; height: 7px; }
.kpi__value { font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.kpi__sub { font-size: 12px; color: var(--muted); }
.kpi--bad .dot { color: var(--bad); } .kpi--bad .kpi__value { color: var(--bad-text); }
.kpi--work .dot { color: var(--work); }
.kpi--ok .dot { color: var(--ok); }
.kpi--all .dot { color: var(--accent); }

.filters { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); flex-wrap: wrap; }
.filters__group { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.filters__spacer { flex: 1; }
.filters .select { width: auto; min-width: 170px; }
.filters__search { width: min(320px, 100%); }
.result-count { font-size: 13px; color: var(--muted); margin-right: 4px; }
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); }
.segmented button {
    flex: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 7px;
    border: 0; background: transparent; color: var(--text-2); font-weight: 550; font-size: 13px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.selection-bar {
    position: sticky; top: calc(var(--topbar-h) + 8px); z-index: calc(var(--z-sticky) - 1);
    display: flex; align-items: center; gap: var(--s-3); padding: 8px 8px 8px 14px; margin-bottom: var(--s-3);
    border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--shadow);
}
.selection-bar__count { font-weight: 650; }
.selection-bar__spacer { flex: 1; }

/* ---------- карточки ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: var(--s-3); }
.sip-card {
    --tone: var(--muted); --tone-soft: var(--surface-3); --tone-text: var(--text-2);
    position: relative; display: grid; align-content: start; gap: 10px; padding: 14px 14px 12px;
    border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
    min-width: 0;
}
.sip-card > * { min-width: 0; }
/* Без цветной полосы: статус уже говорит плашка; карточка — спокойная поверхность. */
.sip-card:hover { border-color: var(--border-strong); }
.sip-card.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sip-card.is-flash { animation: flash 900ms ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
[data-tone="ok"]      { --tone: var(--ok);   --tone-soft: var(--ok-soft);   --tone-text: var(--ok-text); }
[data-tone="working"] { --tone: var(--work); --tone-soft: var(--work-soft); --tone-text: var(--work-text); }
[data-tone="loading"] { --tone: var(--load); --tone-soft: var(--load-soft); --tone-text: var(--load-text); }
[data-tone="broken"]  { --tone: var(--bad);  --tone-soft: var(--bad-soft);  --tone-text: var(--bad-text); }

.sip-card__head { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.sip-card__select { margin-top: 3px; }
.sip-card__title { min-width: 0; flex: 1; display: grid; gap: 1px; }
.sip-card__name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sip-card__owner { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sip-card__menu { margin: -4px -6px 0 0; }

.status-btn {
    display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 36px; padding: 7px 10px; overflow: hidden;
    border-radius: var(--r); border: 1px solid transparent; background: var(--tone-soft); color: var(--tone-text);
    font-weight: 650; text-align: left; line-height: 1.25; transition: filter var(--t-fast), border-color var(--t-fast);
}
.status-btn:hover { border-color: color-mix(in srgb, var(--tone) 45%, transparent); }
.status-btn:disabled { cursor: default; }
.status-btn:disabled:hover { border-color: transparent; }
/* Статус читается целиком: «Вызов не может быть установлен» не обрезается многоточием. */
.status-btn__label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sip-card__other { color: var(--text); font-style: italic; }
.sip-card__meta:empty { display: none; }

/* ---------- следующий шаг: одна кнопка, которая нужна в этом статусе ---------- */
.next { display: flex; gap: 6px; flex-wrap: wrap; }
/* Кнопки не сжимаются с многоточием: не помещаются — переносятся целиком. */
.next .btn { flex: 1 0 auto; }
/* Цвет кнопки = цвет статуса, в который она переведёт: результат виден до нажатия. */
.btn--next { --next: var(--work); --next-text: var(--work-text); background: transparent; color: var(--next-text); font-weight: 650;
    border-color: color-mix(in srgb, var(--next) 45%, var(--border)); }
.btn--next:hover { background: var(--next); border-color: transparent; color: #1c1300; }
.btn--next-ok { --next: var(--ok); --next-text: var(--ok-text); }
.btn--next-ok:hover { color: #03230f; }
.btn--report { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn--report:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.next--wait { align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

/* ---------- экран менеджера «Мой SIP» ---------- */
.mode-mine .overview, .mode-mine .filters, .mode-mine .topbar__search, .mode-mine .mobile-search { display: none !important; }
.cards--mine { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 460px)); justify-content: center; gap: var(--s-4); padding-top: var(--s-3); }
.mine {
    --tone: var(--muted); --tone-soft: var(--surface-3); --tone-text: var(--text-2);
    display: grid; align-content: start; gap: 14px; padding: 20px 20px 18px; min-width: 0;
    border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.mine.is-flash { animation: flash 900ms ease-out; }
.mine__head { display: flex; align-items: flex-start; gap: 8px; }
.mine__title { flex: 1; min-width: 0; }
.mine__eyebrow, .mine__label { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.mine__name { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.mine .status-btn { min-height: 48px; padding: 10px 14px; font-size: 16px; border-radius: 12px; }
.mine .status-btn__time { font-size: 13.5px; }
.mine .next .btn { height: 42px; font-size: 14px; border-radius: var(--r); }
.mine__section { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }

.steps__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step__mark {
    width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
    font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted);
}
.step[data-state="done"] .step__mark { background: var(--ok); color: #fff; }
.step[data-state="todo-now"] .step__mark { background: var(--bad); color: #fff; }
.step[data-state="pending"] .step__mark { background: var(--work-soft); }
.step__spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--work); border-top-color: transparent; animation: spin .8s linear infinite; }
.step__body { display: grid; gap: 2px; padding-top: 1px; min-width: 0; }
.step__title { font-weight: 600; }
.step[data-state="done"] .step__title { color: var(--text-2); }
.step[data-state="todo"] .step__title { color: var(--muted); }
.step__hint { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.steps__ready { margin-top: 12px; display: flex; gap: 6px; align-items: center; font-weight: 650; color: var(--ok-text); }

/* ---------- выбор по смыслу (диалог «Что случилось?») ---------- */
.dialog__lead { margin: 0; line-height: 1.5; }
.field__error--box:empty { display: none; }
.field__error--box { padding: 8px 12px; border-radius: var(--r); background: var(--bad-soft); font-weight: 600; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.choice {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
    transition: border-color var(--t-fast), background var(--t-fast);
}
.choice:hover { border-color: var(--border-strong); }
.choice input { margin: 3px 0 0; accent-color: var(--bad); flex: none; }
.choice:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.choice__text { display: grid; gap: 2px; min-width: 0; }
.choice__title { font-weight: 600; }
.choice__hint { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.textarea--plain { font-family: var(--font); font-size: 14px; min-height: 64px; }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix .input { width: 120px; font-size: 16px; }

/* ---------- мягкая подсказка (nudge) ---------- */
.nudge {
    display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; margin-bottom: var(--s-4);
    border-radius: var(--r-lg); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.nudge__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent); color: #fff; }
.nudge__text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; color: var(--text-2); }
.nudge__text strong { color: var(--text); font-size: 14px; }
.status-btn__time { font-size: 12.5px; font-weight: 600; opacity: .9; white-space: nowrap; }
.status-btn__chev { opacity: .7; }
.status-btn:disabled .status-btn__chev { display: none; }

.sip-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12.5px; color: var(--text-2); min-height: 18px; }
.meta { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.meta--warn { color: var(--bad-text); }
.meta--ok { color: var(--ok-text); }
.meta--pending { color: var(--work-text); }
.meta select.meta-select {
    width: auto; max-width: 160px;
    height: 24px; padding: 0 22px 0 6px; border-radius: 6px; border: 1px solid var(--border); background-color: var(--surface);
    background-position: right 2px center; background-size: 16px; font-size: 12.5px; color: var(--text);
}

.note {
    display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: var(--r);
    background: var(--surface-2); color: var(--text); font-size: 13px; line-height: 1.4; cursor: text;
    border: 1px solid transparent; text-align: left; width: 100%;
}
.note:hover { border-color: var(--border-strong); }
.note__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.note--empty { background: transparent; color: var(--muted); border: 1px dashed var(--border); padding: 6px 10px; }
.note--empty:hover { color: var(--text-2); }
.note-edit { display: flex; gap: 6px; }
.note-edit .input { height: 34px; }
.note-edit .btn { height: 34px; }

.skeleton { border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); height: 168px; position: relative; overflow: hidden; }
.skeleton::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface-3) 70%, transparent), transparent);
    animation: shimmer 1.3s infinite; transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }

.empty {
    display: grid; justify-items: center; gap: 10px; text-align: center; padding: 64px 16px;
    border: 1px dashed var(--border); border-radius: var(--r-lg); color: var(--text-2);
}
.empty__icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.empty__title { font-size: 16px; font-weight: 650; color: var(--text); }

/* ---------- таблица (вид «Список» и админка) ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
/* Заголовки — обычным регистром и приглушённо: таблица читается по данным, а не по шапке. */
.table th {
    position: sticky; top: 0; z-index: 1; text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted);
    padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr.is-selected td { background: var(--accent-soft); }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 48px; text-align: right; }
.table .col-sip { font-weight: 700; white-space: nowrap; }
.table .status-btn { height: 30px; min-width: 190px; }
.table .cell-note { max-width: 320px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Тонкая метка слева — только у строк, где что-то не так; исправные строки без цвета. */
.table tr[data-tone]:not([data-tone="ok"]) td:first-child { box-shadow: inset 2px 0 0 var(--tone); }
.table tr.is-disabled td { color: var(--muted); }

/* ---------- всплывающие меню (статусы, «⋯», профиль) ---------- */
.popover {
    position: fixed; z-index: var(--z-pop); min-width: 220px; max-width: min(340px, calc(100vw - 16px));
    max-height: min(420px, calc(100vh - 16px)); overflow: auto; padding: 6px;
    border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    animation: pop 120ms ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-label { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px;
    border-radius: 8px; border: 0; background: transparent; color: var(--text); text-align: left; font-size: 13.5px;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); box-shadow: none; }
.menu-item[aria-checked="true"]::after, .menu-item.is-current::after {
    content: ""; margin-left: auto; width: 16px; height: 16px; flex: none;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center/contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center/contain no-repeat;
    color: var(--accent);
}
.menu-item--danger { color: var(--bad-text); }
.menu-item--danger:hover { background: var(--bad-soft); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; }
.menu-item .ico { color: var(--muted); }
.menu-item--danger .ico { color: inherit; }
.menu-item__hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.menu-item .dot { margin: 0 4px; }
.menu-item[data-tone] .dot { color: var(--tone); }
.menu-group + .menu-group { margin-top: 2px; }

.toast__count { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 8px; background: var(--surface-3); font-size: 11px; font-weight: 700; color: var(--text-2); }

/* ---------- колокольчик ---------- */
.bell { position: relative; }
.bell__badge {
    position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg);
}
.notif-pop { width: min(400px, calc(100vw - 16px)); max-height: min(520px, calc(100vh - 80px)); padding: 0; display: flex; flex-direction: column; }
.notif-pop__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--border); }
.notif-list { overflow: auto; padding: 6px; }
.notif-offer { display: flex; align-items: center; gap: 10px; margin: 8px 8px 0; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.notif-offer__text { flex: 1; line-height: 1.4; }
.notif {
    display: flex; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: transparent;
    text-align: left; color: var(--text);
}
.notif:hover { background: var(--surface-2); }
.notif__icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.notif__icon .ico { width: 15px; height: 15px; }
.notif.is-unread .notif__icon { background: var(--accent-soft); color: var(--accent); }
.notif__main { display: grid; gap: 2px; min-width: 0; }
.notif__title { font-weight: 600; font-size: 13.5px; }
.notif.is-unread .notif__title::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: 2px; }
.notif__body { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.notif__time { font-size: 11.5px; color: var(--muted); }
.notif-empty { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--text-2); }
.preview-list { margin: 6px 0 0; padding: 0 0 0 18px; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); display: grid; gap: 2px; }
.preview-list:empty, .preview-warn:empty { display: none; }
.preview-warn { margin-top: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--work-soft); color: var(--work-text); font-size: 12.5px; display: grid; gap: 2px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 12px; color: var(--text-2); line-height: 1.5; }

/* ---------- вкладки админки ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs .ico { width: 16px; height: 16px; }
details.panel-card > summary { cursor: pointer; margin: 0; }
.tabs a {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; color: var(--text-2); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.panel-card { padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); margin-bottom: var(--s-4); }
.panel-card__title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.panel-card__sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.settings-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 10px; background: var(--surface-3); position: relative; cursor: pointer; transition: background var(--t-fast); margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-fast); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.score { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.score__num { font-weight: 700; width: 30px; text-align: right; }
.hard { font-weight: 700; }
.hard--high { color: var(--bad-text); }
.hard--low { color: var(--ok-text); }
.reason { font-size: 12.5px; color: var(--muted); max-width: 360px; }
.formula { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.toolbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- диалоги ---------- */
dialog.dialog {
    width: min(520px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--border-strong);
    border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.dialog--wide { width: min(640px, calc(100vw - 24px)); }
/* Длинный диалог прокручивает только содержимое: заголовок и кнопки всегда на экране. */
dialog.dialog { max-height: calc(100dvh - 24px); overflow: hidden; }
dialog.dialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
dialog.dialog .dialog__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
dialog.dialog .dialog__foot { flex: none; }
/* На телефоне диалог — лист снизу, кнопки на всю ширину под большим пальцем. */
@media (max-width: 600px) {
    dialog.dialog, dialog.dialog--wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
    dialog.dialog[open] { animation: sheetIn 200ms cubic-bezier(.2, .7, .3, 1); }
    dialog.dialog .dialog__foot { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
    dialog.dialog .dialog__foot .btn { flex: 1; height: 42px; }
    .choices { grid-template-columns: 1fr; gap: 6px; }
    .choice { padding: 9px 12px; }
    .nudge { flex-wrap: wrap; }
    .nudge__text { flex-basis: calc(100% - 100px); }
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } }
body:has(dialog[open]) { overflow: hidden; }
dialog.dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: dialogIn 160ms ease-out; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog__head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 4px; }
.dialog__title { font-size: 17px; font-weight: 700; flex: 1; }
.dialog__body { padding: 10px 20px 4px; display: grid; gap: 14px; color: var(--text-2); }
.dialog__body > p { line-height: 1.55; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 18px; }
.dialog__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.dialog__icon--danger { background: var(--bad-soft); color: var(--bad-text); }
.preview-line { font-size: 13px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); color: var(--text-2); }
.preview-line--error { background: var(--bad-soft); color: var(--bad-text); }

/* ---------- боковая панель (журнал, статистика, устройства) ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay); animation: fade 160ms ease-out; }
@keyframes fade { from { opacity: 0; } }
.drawer {
    position: fixed; z-index: calc(var(--z-drawer) + 1); top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
    display: flex; flex-direction: column; background: var(--bg-elev); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    animation: slideIn 200ms cubic-bezier(.2, .7, .3, 1);
}
.drawer--wide { width: min(980px, 100vw); }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
.drawer__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer__title { font-size: 17px; font-weight: 700; }
.drawer__sub { font-size: 12.5px; color: var(--muted); }
.drawer__close { margin-left: auto; }
.drawer__tools { display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.drawer__body { flex: 1; overflow: auto; padding: 16px 20px 24px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__day { position: sticky; top: -16px; padding: 10px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--bg-elev); z-index: 1; }
.timeline__item { display: grid; grid-template-columns: 52px 22px 1fr; gap: 8px; padding: 8px 0; align-items: start; }
.timeline__time { font-size: 12.5px; color: var(--muted); padding-top: 2px; }
.timeline__mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-text); }
.timeline__mark .ico { width: 13px; height: 13px; }
.timeline__text { display: grid; gap: 2px; }
.timeline__title { font-weight: 600; }
.timeline__sub { font-size: 12.5px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat-box { padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.stat-box__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-box__value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.uptime { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.uptime__bar { display: block; flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.uptime__fill { display: block; height: 100%; width: var(--p, 0%); background: var(--ok); border-radius: 3px; }
.uptime__fill[data-level="mid"] { background: var(--work); }
.uptime__fill[data-level="low"] { background: var(--bad); }
.uptime__val { font-size: 12.5px; font-weight: 650; width: 38px; text-align: right; }

/* ---------- уведомления ---------- */
.toasts { position: fixed; z-index: var(--z-toast); right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    animation: toastIn 200ms cubic-bezier(.2, .7, .3, 1);
}
.toast.is-leaving { animation: toastOut 160ms ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
.toast__icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.toast__icon .ico { width: 14px; height: 14px; }
.toast--success .toast__icon { background: var(--ok-soft); color: var(--ok-text); }
.toast--error .toast__icon { background: var(--bad-soft); color: var(--bad-text); }
.toast--warn .toast__icon { background: var(--work-soft); color: var(--work-text); }
.toast__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.toast__title { font-weight: 650; }
.toast__body { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.toast__actions { display: flex; gap: 4px; align-items: center; }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(380px, 100%); display: grid; gap: 22px; padding: 32px 28px 26px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.auth-card .brand { padding: 0; }
.auth-card__head { display: grid; gap: 6px; }
.auth-card__title { font-size: 20px; font-weight: 650; letter-spacing: -.025em; }
.auth-card__sub { color: var(--muted); }
.auth-form { display: grid; gap: 14px; }
.auth-alert { display: flex; gap: 8px; padding: 10px 12px; border-radius: var(--r); background: var(--bad-soft); color: var(--bad-text); font-size: 13.5px; font-weight: 550; }
.auth-foot { font-size: 12.5px; color: var(--muted); text-align: center; }
.otp { letter-spacing: .5em; text-align: center; font-family: var(--mono); font-size: 20px; height: 48px; }

/* ---------- админка ---------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: var(--s-4); flex-wrap: wrap; }
.page-head__title { font-size: 22px; font-weight: 650; letter-spacing: -.025em; }
.page-head__sub { color: var(--muted); margin-top: 2px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; }
/* ---------- таблица SIP (вид по умолчанию у админа и клиента) ---------- */
/* overflow: clip — углы скруглены, но контейнер не прокручивается сам, поэтому шапка липнет к странице. */
.table-wrap--cards { overflow: clip; }
/* Не помещается (узкий экран, длинные значения) — таблица прокручивается вбок; тени у краёв подсказывают,
   что колонки есть дальше. Шапка в этом режиме прилипает к таблице, а не к странице. */
.table-wrap:not(.table-wrap--cards), .table-wrap.is-scroll { overflow-x: auto; overscroll-behavior-x: contain;
    background:
        linear-gradient(to right, var(--surface) 30%, transparent) left / 24px 100% no-repeat local,
        linear-gradient(to left, var(--surface) 30%, transparent) right / 24px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .18), transparent) left / 10px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .18), transparent) right / 10px 100% no-repeat scroll,
        var(--surface); }
.table-wrap.is-scroll .table--sip td.cell-note { width: auto; max-width: 260px; }
.table-wrap.is-scroll .table td { background-color: transparent; }
.table--sip th { top: var(--topbar-h); }
.table--sip td { padding: 8px 12px; }
.table--sip tbody tr { transition: background var(--t-fast); }
.table--sip .col-sip { white-space: nowrap; }
.cell-sip__name { font-weight: 600; font-feature-settings: "tnum" 1; }
.cell-sub { font-size: 12px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.table--sip .col-status { min-width: 200px; }
.table--sip .status-btn { width: auto; max-width: 300px; min-height: 28px; padding: 3px 9px; gap: 6px; font-size: 13px; border-radius: var(--r-sm); }
.table--sip .status-btn__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table--sip .status-btn__time { font-size: 12px; }
.table--sip .dot { width: 7px; height: 7px; }
.table--sip .meta select.meta-select { max-width: 150px; }
.table--sip .col-owner { white-space: nowrap; color: var(--text-2); }
.table--sip .col-down, .table--sip .col-breaks { white-space: nowrap; text-align: right; }
.table--sip th.num { text-align: right; }
.table--sip th.num .th-sort { flex-direction: row-reverse; }

.th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.th-sort:hover, .th-sort.is-active { color: var(--text); }
.th-sort__arrow { font-size: 11px; opacity: 0; transition: opacity var(--t-fast); }
.th-sort:hover .th-sort__arrow, .th-sort.is-active .th-sort__arrow { opacity: 1; }

.agent-chip { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--muted); white-space: nowrap; }
/* Комментарий забирает только оставшееся место (width 100% + max-width 0) и режется многоточием —
   таблица помещается в любую ширину от 760 px без горизонтальной прокрутки. */
.table--sip td.cell-note { width: 100%; max-width: 0; }
.table--sip .note-cell { max-width: 100%; }
.table--sip .note-cell__text { max-width: 100%; }
.table--sip .status-btn { max-width: 240px; }
/* «Работает» — фон не нужен: цветом в таблице выделяется только то, что требует внимания. */
.table--sip [data-tone="ok"] .status-btn { background: transparent; color: var(--text); }
.table--sip [data-tone="ok"] .status-btn .dot { color: var(--ok); }
.table--sip [data-tone="ok"] .status-btn:hover { background: var(--surface-2); border-color: transparent; }
@media (max-width: 1240px) { .table--sip .col-breaks { display: none; } }
.agent-chip .dot { width: 6px; height: 6px; }
.agent-chip--ok .dot { color: var(--ok); }
.agent-chip--pending .dot { color: var(--work); }
.agent-chip--warn { color: var(--bad-text); }
.agent-chip--warn .dot { color: var(--bad); }

.note-cell {
    display: block; max-width: 280px; margin: -4px -6px; padding: 4px 6px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left;
}
.note-cell:hover { background: var(--surface-2); }
.note-cell__text { display: block; max-width: 268px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-cell--empty { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.note-cell--empty > span { display: inline-flex; align-items: center; gap: 5px; }
@media (max-width: 759px) { .filters .segmented { display: none; } }

/* ---------- аналитика: сначала вывод ---------- */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.insight__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.insight[data-tone="bad"] .insight__icon { background: var(--bad-soft); color: var(--bad-text); }
.insight[data-tone="work"] .insight__icon { background: var(--work-soft); color: var(--work-text); }
.insight[data-tone="ok"] .insight__icon { background: var(--ok-soft); color: var(--ok-text); }
.insight__label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.insight__value { font-size: 18px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.insight__sub { font-size: 12.5px; color: var(--text-2); }

/* ---------- админка: задачи, а не только списки ---------- */
.settings-more { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.settings-more > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 650; list-style: none; }
.settings-more > summary::-webkit-details-marker { display: none; }
.settings-more > summary::before { content: "›"; display: inline-block; width: 12px; color: var(--muted); transition: transform var(--t-fast); }
.settings-more[open] > summary::before { transform: rotate(90deg); }
.settings-more > summary + * { margin-top: 10px; }
dialog .settings-more { margin-top: 0; }

.issue {
    display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; padding: 0; border: 0; background: none;
    font-size: 12.5px; font-weight: 500; color: var(--work-text); text-align: left; white-space: nowrap;
}
td.cell-main { min-width: 240px; }
.issue:not(:disabled):hover .issue__fix { text-decoration: underline; }
.issue:disabled { cursor: default; }
.issue__fix { color: var(--accent); font-weight: 600; }
.seg-count { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; font-weight: 700; }
.seg-count:empty { display: none; }
.segmented button.has-issues .seg-count { background: var(--work-soft); color: var(--work-text); }

.cred-card { margin: 0; padding: 14px 16px; border-radius: var(--r); background: var(--bg-elev); border: 1px solid var(--border); font: 14px/1.7 var(--mono); color: var(--text); white-space: pre-wrap; user-select: all; }
.cred-card__actions { display: flex; justify-content: flex-end; margin-top: -6px; }
.dialog__icon--ok { background: var(--ok-soft); color: var(--ok-text); }
.field__hint--warn { color: var(--work-text); cursor: pointer; }
.role-pick { display: grid; gap: 6px; }
.role-pick .choice input { accent-color: var(--accent); }
.role-pick .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.shift-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.shift-head .panel-card__sub { margin-bottom: 0; max-width: 640px; }
.reset-list { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--border); }
.reset-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.reset-item:last-child { border-bottom: 0; padding-bottom: 0; }
.reset-item__title { font-weight: 500; }
.plan-summary { margin: 12px 0 10px; font-size: 13px; }
.waiting-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.howto { margin: 6px 0 14px; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); line-height: 1.5; }

/* Таблица-стопка: на телефоне строка становится карточкой «подпись — значение» (без горизонтальной прокрутки). */
@media (max-width: 700px) {
    .table--stack thead { display: none; }
    .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
    .table--stack tr { position: relative; padding: 12px 44px 10px 12px; border-bottom: 1px solid var(--border); }
    .table--stack td { padding: 2px 0; border: 0; }
    .table--stack td[data-label] { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
    .table--stack td[data-label]::before { content: attr(data-label); color: var(--muted); }
    .table--stack td.cell-main { margin-bottom: 6px; }
    .table--stack td.cell-empty { display: none; }
    .table--stack td.col-actions { position: absolute; top: 10px; right: 6px; width: auto; }
    .table-wrap:has(.table--stack) { overflow: visible; }
}

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell__name { font-weight: 650; }
.user-cell .muted { font-size: 12px; white-space: nowrap; }
.table td.num { white-space: nowrap; }
.secret-box { display: flex; gap: 8px; align-items: center; }
.secret-box .input { font-family: var(--mono); }
.callout { padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); color: var(--text-2); font-size: 13px; line-height: 1.5; }
.callout--warn { background: var(--work-soft); color: var(--work-text); }
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.device__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.device__name { font-weight: 650; }
.device__sub { font-size: 12.5px; color: var(--muted); }

/* ---------- загрузка ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* ---------- адаптив ---------- */
/* Подписи у кнопок шапки держим как можно дольше: значок без подписи приходится угадывать. */
@media (max-width: 1000px) {
    .topbar__btn-label { display: none; }
}
@media (max-width: 1000px) {
    .topbar__search { display: none; }
    .mobile-search { display: flex !important; margin-bottom: var(--s-3); }
}
@media (max-width: 860px) {
    .topbar { padding: 0 var(--s-3); gap: var(--s-2); }
    .brand__panel { display: none; }
    .avatar-btn__text { display: none; }
    .page { padding: var(--s-3) var(--s-3) var(--s-8); }
    .overview { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .kpi { min-width: 0; padding: 10px 12px; }
    .kpi__value { font-size: 22px; }
    .filters .select { min-width: 0; flex: 1 1 140px; }
    .filters__spacer { display: none; }
    .cards { grid-template-columns: 1fr; }
    .drawer, .drawer--wide { width: 100vw; }
    .toasts { left: 12px; right: 12px; bottom: 12px; width: auto; }
    .hide-sm { display: none !important; }
}
@media (max-width: 600px) {
    .brand > span:last-child { display: none; }
    .conn { padding: 0 9px; }
    .conn #connText { display: none; }
    .topbar__actions { gap: 2px; }
    .topbar__actions .btn { padding: 0 9px; }
    .avatar-btn { padding: 0 2px; }
    .page-head__actions { margin-left: 0; width: 100%; }
    .page-head__actions .btn { flex: 1; }
    .filters__search { width: 100%; }
    dialog.dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
    .dialog__foot { flex-wrap: wrap; }
    .dialog__foot .btn { flex: 1; }
}
@media (min-width: 1001px) {
    .mobile-search { display: none; }
}
