/* CRM Надежда — дизайн-токены (переменные) и стили вне Tailwind-билда.
   Значения — из redesign_plan/README.md «Дизайн-токены».
   Этот файл подключается в <head> рядом со static/tw.css. tw.css резолвит
   имена классов через Tailwind @apply, app.css задаёт переменные для них. */

:root {
    /* поверхности и текст (светлая тема) */
    --bg:        #eef1f6;
    --surface:   #ffffff;
    --surface-2: #f7f9fc;
    --ink:       #1a2233;
    --ink-2:     #55617a;
    --ink-3:     #8b96ad;
    --border:    #e2e7f0;
    --border-2:  #d3dae6;
    --accent:    #2563eb;   /* синий Надежды (НЕ кобальт источника) */
    --accent-ink:#1e40af;
    --accent-sf: #eff6ff;   /* мягкий фон акцента */
    /* сигнальные */
    --good: #12916a;
    --warn: #c9820f;
    --bad:  #d1495b;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg:        #0e131f;
    --surface:   #161d2c;
    --surface-2: #1b2233;
    --ink:       #e7ecf5;
    --ink-2:     #9aa6bd;
    --ink-3:     #6b7689;
    --border:    #232b3d;
    --border-2:  #2d3650;
    --accent:    #3b82f6;   /* светлее для контраста на тёмном */
    --accent-ink:#93c5fd;
    --accent-sf: #1e293b;
    --good: #3fbe93;
    --warn: #e0a53f;
    --bad:  #ec6c7d;
    color-scheme: dark;
}

/* ── Пилюли в тёмной теме: приглушённые фоны, чтобы не «горели» ── */
[data-theme="dark"] .pill-new        { background: #222b3c; }
[data-theme="dark"] .pill-in_progress{ background: #1a2947; }
[data-theme="dark"] .pill-done       { background: #0f3025; }
[data-theme="dark"] .pill-issued     { background: #241d3d; }
[data-theme="dark"] .pill-scheduled  { background: #1a2947; }
[data-theme="dark"] .pill-cancelled  { background: #361a20; }

/* ── Системные форм-контролы в тёмной теме: нативный appearance мешает ── */
[data-theme="dark"] input:not([type=submit]):not([type=button]):not([type=checkbox]):not([type=radio]):not([type=date]),
[data-theme="dark"] select, [data-theme="dark"] textarea {
    -webkit-appearance: none; appearance: none;
    background-color: #1b2233; color: #e7ecf5; border-color: #2d3650;
}
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7689' d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center; padding-right: 1.8rem;
}
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: #6b7689; opacity: 1; }

/* ── Скроллбары под тему ── */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ── Печать: скрываем sidebar/topbar, контент на всю ширину ── */
@media print {
    .app-side, .app-top, #toasts, #app-modal { display: none !important; }
    .app-grid { grid-template-columns: 1fr !important; }
    .app-main { max-width: 100% !important; padding: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* ── Адаптив контентных сеток (без пересборки Tailwind) ──
   Шаблоны помечают гриды data-cols="…". Без брейкпоинтов
   KPI 4×1fr и колонки 1fr+340px дают горизонтальный overflow
   и визуально «наезжают» друг на друга на узких окнах. */
[data-cols] > * { min-width: 0; }

@media (max-width: 1100px) {
    [data-cols="kpi-4"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 980px) {
    [data-cols="2-340"],
    [data-cols="2-1"],
    [data-cols="1.6-1"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

@media (max-width: 640px) {
    [data-cols="kpi-4"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    [data-cols="form-3"],
    [data-cols="form-4"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* ── Stepper статусов наряда (#status-bar) ── */
.order-status-bar { display: flex; flex-direction: column; gap: 12px; }
.status-stepper {
    display: flex; flex-wrap: wrap; align-items: center;
    list-style: none; margin: 0; padding: 0; gap: 0;
}
.status-step {
    display: inline-flex; align-items: center; gap: 8px;
}
.status-step-node {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 999px;
    font-size: 11px; font-weight: 700; line-height: 1;
    border: 1.5px solid var(--border-2);
    color: var(--ink-3); background: var(--surface-2);
    flex-shrink: 0;
}
.status-step.is-current .status-step-node {
    border-color: var(--accent); background: var(--accent); color: #fff;
}
.status-step.is-done .status-step-node {
    border-color: var(--good); background: var(--good); color: #fff;
}
.status-step-label {
    font-size: 13px; font-weight: 600; color: var(--ink);
    display: inline-flex; flex-direction: column; gap: 1px; line-height: 1.2;
}
.status-step.is-current .status-step-label { color: var(--accent-ink); }
.status-step-label.is-muted { color: var(--ink-3); font-weight: 500; }
.status-step-hint {
    font-size: 11px; font-weight: 500; color: var(--ink-3);
}
.status-step-sep {
    width: 20px; height: 2px; margin: 0 6px;
    background: var(--border-2); border-radius: 1px; flex-shrink: 0;
}
.status-step.is-done + .status-step .status-step-sep,
.status-step.is-done .status-step-sep { background: var(--good); opacity: .45; }
.status-step-btn { white-space: nowrap; }
.status-rollback {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding-top: 10px; border-top: 1px solid var(--border);
}
.status-rollback-label {
    font-size: 12px; font-weight: 600; color: var(--ink-3); margin-right: 2px;
}
