/* ===== Alavir Трекер — дизайн-система (Soft UI Evolution) ===== */
/* Стиль: soft-UI (мягкие слоистые тени, subtle depth, WCAG AA+)   */
/* Плотность: 8/10 (dashboard) · Шрифт: Fira Sans + mono для цифр   */
:root {
    /* Нейтральная палитра (slate) */
    --bg: #eef1f7;
    --surface: #ffffff;
    --surface-2: #f4f6fb;
    --surface-3: #eaeef6;
    --line: #e2e7f0;
    --line-strong: #cfd6e4;
    --ink: #0f172a;
    --ink-2: #475069;
    --muted: #8a93a8;

    /* Бренд Alavir */
    --primary: #e01b2d;
    --primary-hover: #c4162a;
    --primary-ink: #ffffff;
    --primary-soft: #fdecee;

    --accent: #2f57e6;
    --accent-soft: #e8edfd;

    /* Семантика статусов (green/amber/red — как советует ops-паттерн) */
    --ok: #12915a;        --ok-soft: #e3f5ec;
    --warn: #b9770a;      --warn-soft: #fbf0da;
    --danger: #d5324a;    --danger-soft: #fde7ea;
    --info: #2f6fe6;      --info-soft: #e6efff;
    --violet: #7a44d6;    --violet-soft: #f0e9fc;   /* карточки оценки */
    --teal: #0c8a8a;      --teal-soft: #ddf4f4;

    /* Мягкие слоистые тени (soft-UI) */
    --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.06);
    --shadow-md: 0 2px 6px rgba(15,23,42,.06), 0 10px 24px rgba(15,23,42,.08);
    --shadow-lg: 0 12px 40px rgba(15,23,42,.16);

    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --sidebar-w: 248px;

    /* Шкала отступов (плотность 8) */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

    --font: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f1a;
        --surface: #151b29;
        --surface-2: #1b2233;
        --surface-3: #212a3e;
        --line: #2a3346;
        --line-strong: #384360;
        --ink: #f1f4fb;
        --ink-2: #b4bed4;
        --muted: #7b859e;

        --primary-soft: #3a1519;
        --accent-soft: #1c2748;
        --ok-soft: #103227;
        --warn-soft: #33270f;
        --danger-soft: #37151d;
        --info-soft: #14233f;
        --violet-soft: #241a3b;
        --teal-soft: #0e2a2a;

        --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
        --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.4);
        --shadow-md: 0 2px 6px rgba(0,0,0,.4), 0 10px 24px rgba(0,0,0,.5);
        --shadow-lg: 0 14px 44px rgba(0,0,0,.6);
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.ic { width: 20px; height: 20px; flex: 0 0 auto; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }
.hidden { display: none !important; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
/* На странице канбана фиксируем высоту приложения по вьюпорту, чтобы колонки
   получили ограниченную высоту и включился вертикальный скролл внутри колонки. */
.app-board { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--primary); color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 20px;
}
.brand-mark.lg { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.1; }
.brand-text small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--ink-2); font-weight: 600; font-size: 14.5px;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .ic { opacity: .9; }
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 14px;
    padding: 12px 24px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
}
.page-title { font-size: 19px; font-weight: 750; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: 10px;
    background: transparent; border: 1px solid transparent;
    color: var(--ink-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.only-mobile { display: none; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6b8cff);
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta b { font-size: 14px; }
.user-meta small { color: var(--muted); font-size: 12px; }
.logout-form { margin: 0; }

.content { padding: 24px; max-width: 1240px; width: 100%; margin: 0 auto; }
/* Широкие страницы — во весь экран */
.content-wide { max-width: none; padding: 16px 20px; }
/* Доска (канбан) — заполняет высоту, горизонтальный скролл прижат к низу */
.content-board { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.content-board .toolbar { margin-bottom: 12px; flex: 0 0 auto; }
.content-board .flashes { flex: 0 0 auto; }

/* ===== Notifications ===== */
.notif { position: relative; }
.badge {
    position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px;
    padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff;
    font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.notif-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: 340px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40;
}
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item time { color: var(--muted); font-size: 11.5px; }
.notif-empty { padding: 22px 14px; text-align: center; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; font-weight: 600; }

/* ===== Flash ===== */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; border: 1px solid; }
.flash-success { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }
.flash-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.flash-info { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent); }

/* ===== Cards / toolbar ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; margin: 0 0 16px; }
.form-card { max-width: 720px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-info { color: var(--muted); font-size: 14px; margin-right: auto; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.btn-block { width: 100%; justify-content: center; }

/* ===== Forms ===== */
.form { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--surface-2); color: var(--ink);
    font-family: inherit; font-size: 14.5px;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent); background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field textarea { resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.field-check { justify-content: center; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { display: none; }
.switch-track { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-compact td, .table-compact th { padding: 8px 10px; }
.row-link { cursor: pointer; }
.row-link:hover { background: var(--surface-2); }
.cell-user { display: flex; align-items: center; gap: 10px; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 650; }
.tag-admin { background: var(--primary-soft); color: var(--primary); }
.tag-manager { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.tag-programmer { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot-on { background: var(--ok); }
.dot-off { background: var(--muted); }

.hours-pill { display: inline-block; padding: 3px 10px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok); font-weight: 700; }
.hours-pill.zero { background: var(--surface-2); color: var(--muted); }
.hours-pill.neg { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }

/* ===== Client view ===== */
.client-head { margin-bottom: 18px; }
.client-name { margin: 0 0 6px; font-size: 24px; }
.client-sub { display: flex; flex-wrap: wrap; gap: 16px; color: var(--ink-2); font-size: 14px; }
.client-sub span { display: inline-flex; align-items: center; gap: 6px; }
.client-sub .ic { width: 16px; height: 16px; color: var(--muted); }
.client-note { color: var(--ink-2); margin: 10px 0 0; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card.stat-neg { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 800; }

.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; margin-right: auto; }
.search .ic { color: var(--muted); width: 18px; height: 18px; }
.search input { border: none; background: none; padding: 9px 0; font-size: 14px; color: var(--ink); width: 280px; max-width: 60vw; }
.search input:focus { outline: none; }

.stat-unit { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ===== Combobox (фильтр клиента) ===== */
.combo { position: relative; }
.combo-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
    max-height: 260px; overflow-y: auto; display: none; }
.combo-list.open { display: block; }
.combo-opt { padding: 9px 12px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.combo-opt:hover { background: var(--surface-2); }
.combo-bal { color: var(--muted); font-size: 12px; white-space: nowrap; }
.combo-empty { padding: 12px; color: var(--muted); text-align: center; font-size: 13px; }
.row-actions form { margin: 0; display: inline-block; }

.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.profile-grid > div { display: flex; flex-direction: column; gap: 3px; }
.tg-ok { color: var(--ok); display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* ===== Кнопки статусов ===== */
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.94); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover { filter: brightness(.94); }

/* ===== Статус-бейджи ===== */
.st-badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.st-new         { background: var(--info-soft);   color: var(--info); }
.st-queue       { background: var(--surface-3);   color: var(--ink-2); }
.st-in_progress { background: var(--accent-soft); color: var(--accent); }
.st-review      { background: var(--warn-soft);   color: var(--warn); }
.st-rework      { background: var(--danger-soft); color: var(--danger); }
.st-waiting     { background: var(--violet-soft); color: var(--violet); }
.st-accepted    { background: var(--ok-soft);     color: var(--ok); }
.st-react { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px;
    background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.st-react .ic { width: 15px; height: 15px; }
.st-est-open  { background: var(--violet-soft); color: var(--violet); }
.st-est-ready { background: var(--ok-soft); color: var(--ok); }
.st-est-done  { background: var(--surface-3); color: var(--muted); }

/* ===== Канбан ===== */
/* Доска заполняет доступную высоту; горизонтальный скролл — внизу экрана */
.kanban { display: flex; gap: 14px; align-items: stretch;
    flex: 1 1 auto; min-height: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.kb-col { flex: 1 1 0; min-width: 262px; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius); display: flex; flex-direction: column; height: 100%; }
.kb-col-react { background: color-mix(in srgb, var(--primary) 6%, var(--surface-2)); border-color: color-mix(in srgb, var(--primary) 22%, var(--line)); }
.kb-col-done { background: color-mix(in srgb, var(--ok) 6%, var(--surface-2)); border-color: color-mix(in srgb, var(--ok) 24%, var(--line)); }
.kb-col-done .kb-col-title { color: var(--ok); }
.kb-col-done .kb-card { opacity: .82; }
.check-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); user-select: none; }
.check-toggle input { width: 17px; height: 17px; accent-color: var(--ok); cursor: pointer; }
.as-select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; font-family: inherit; }
.impersonate-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; margin-bottom: 10px; flex: 0 0 auto;
    background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 10px; font-size: 13.5px; }
.impersonate-bar .ic { width: 16px; height: 16px; vertical-align: middle; }
.kb-col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; position: sticky; top: 0; }
.kb-col-title { font-weight: 700; font-size: 13.5px; }
.kb-col-react .kb-col-title { color: var(--primary); }
.kb-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3);
    color: var(--ink-2); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.kb-col-body { padding: 0 10px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.kb-col-body.drop-hint { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 10px; }
.kb-empty { text-align: center; color: var(--muted); font-size: 12.5px; padding: 14px 0; }

.kb-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.kb-card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.kb-card.dragging { opacity: .5; }
.kb-card.kb-due { border-left: 3px solid var(--danger); }
.kb-card.kb-overdue { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.kb-dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.kb-title { font-weight: 650; font-size: 14px; line-height: 1.35; padding-right: 12px; }
.kb-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 7px;
    background: var(--surface-2); color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.kb-chip .ic { width: 13px; height: 13px; }
.kb-chip-dev { background: var(--ok-soft); color: var(--ok); }
.kb-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.kb-who { font-weight: 600; color: var(--ink-2); }
.kb-deadline { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.kb-deadline.overdue { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.kb-age { margin-left: auto; }
.kb-quick { margin: 2px 0 0; }
.kb-quick .btn { width: 100%; justify-content: center; }

.kb-virtual { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); border-style: dashed;
    border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }
.kb-estimate { background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 32%, var(--line)); }
.kb-estimate:hover { border-color: var(--violet); }
.kb-est-flag { display: inline-flex; align-items: center; gap: 5px; color: var(--violet); font-size: 11.5px; font-weight: 700; }
.kb-est-flag .ic { width: 14px; height: 14px; }
.kb-react-flag { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); font-size: 11.5px; font-weight: 700; }
.kb-react-flag .ic { width: 14px; height: 14px; }
.kb-open { font-size: 11.5px; color: var(--accent); font-weight: 600; }

/* ===== Детальные: служебные данные слева, чат справа (широкий) ===== */
.est-grid, .detail-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; align-items: start; }
.est-side, .detail-main { display: flex; flex-direction: column; gap: 20px; }
/* оценка: в DOM чат идёт первым — переставляем порядком, чтобы служебное было слева */
.est-grid > .chat-card { order: 2; }
.est-grid > .est-side { order: 1; }
.est-chat { max-height: calc(100vh - 250px); min-height: 420px; }
@media (max-width: 1000px) { .est-grid, .detail-grid { grid-template-columns: 1fr; } .est-chat { max-height: 60vh; min-height: 300px; } }

/* ===== Детальная задача ===== */
.task-head { margin-bottom: 16px; }
.task-head-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-title { width: 100%; margin: 8px 0 0; font-size: 22px; }
.task-desc { white-space: pre-wrap; line-height: 1.6; }
.task-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.task-actions form { margin: 0; }
.info-list { display: flex; flex-direction: column; gap: 10px; }
.info-list > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.info-list .muted { font-size: 13px; }
.time-track { display: flex; flex-direction: column; gap: 8px; }
.tt-row { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.tt-row.tt-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { position: relative; padding-left: 18px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 6.5px; top: 13px; bottom: -10px; width: 1px; background: var(--line-strong); }
.tl-to { font-weight: 600; font-size: 13.5px; }
.tl-meta { display: block; color: var(--muted); font-size: 12px; }

/* ===== Чат ===== */
.chat-card { display: flex; flex-direction: column; }
.chat-scroll { flex: 1; overflow-y: auto; max-height: calc(100vh - 360px); min-height: 300px; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.msg { max-width: 84%; align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; margin-bottom: 3px; }
.msg-meta b { font-size: 12.5px; }
.msg-role { color: var(--muted); }
.msg-meta time { margin-left: auto; color: var(--muted); }
.msg-text { white-space: pre-wrap; line-height: 1.45; font-size: 14px; word-break: break-word; }
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.msg-img img { max-width: 190px; max-height: 170px; border-radius: 8px; display: block; border: 1px solid var(--line); }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; max-width: 240px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .ic { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }
.file-chip small { color: var(--muted); flex: 0 0 auto; }
.chat-empty { text-align: center; color: var(--muted); padding: 24px; margin: auto; }
.chat-form { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2); resize: vertical; font-family: inherit; font-size: 14px; }
.chat-form textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.chat-controls { display: flex; align-items: center; gap: 10px; }
.chat-attach { cursor: pointer; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); color: var(--ink-2); }
.chat-attach:hover { background: var(--surface-2); color: var(--ink); }
.chat-filenames { font-size: 12.5px; color: var(--muted); margin-right: auto; }

/* ===== Вложения задачи (начальные) ===== */
.task-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tg-link-box { display: flex; flex-direction: column; gap: 10px; }
.tg-code { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); word-break: break-all; }

/* ===== Дашборд ===== */
.dash-filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; width: 100%; }
.dash-filter .field { gap: 4px; }
.dash-filter .field label { font-size: 12px; }
.dash-filter input, .dash-filter select { padding: 8px 10px; }
.dash-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 200px; padding-top: 10px; overflow-x: auto; }
.chart-col { flex: 1 1 0; min-width: 14px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.chart-bar { width: 70%; max-width: 34px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--surface))); border-radius: 4px 4px 0 0; transition: height .2s; }
.chart-col:hover .chart-bar { background: var(--primary); }
.chart-x { font-size: 10px; color: var(--muted); }
.chart-legend { font-size: 12px; margin-top: 8px; }

/* ===== Модалка ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(4,8,20,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; gap: 10px; margin-top: 16px; }

/* ===== Меню-бейдж ===== */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ===== Модерация ===== */
.mod-list { display: flex; flex-direction: column; gap: 12px; }
.mod-item { display: flex; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.mod-main { flex: 1; min-width: 240px; }
.mod-task { font-weight: 700; font-size: 15px; }
.mod-meta { font-size: 12.5px; margin: 2px 0 8px; }
.mod-change { font-size: 13.5px; }
.mod-change s { color: var(--muted); }
.mod-reason { margin-top: 6px; font-size: 13.5px; }
.mod-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.mod-actions form { margin: 0; }

/* ===== Empty / error ===== */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { color: var(--muted); max-width: 520px; margin: 0 auto; }
.error-state .error-code { font-size: 64px; font-weight: 800; color: var(--primary); line-height: 1; }
.error-state .btn { margin-top: 18px; }

/* ===== Auth ===== */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px 28px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { margin: 0 auto 14px; }
.auth-brand h1 { font-size: 20px; margin: 0 0 4px; }
.auth-brand p { color: var(--muted); margin: 0; font-size: 14px; }

.scrim { display: none; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 60;
        transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    .app.nav-open .sidebar { transform: translateX(0); }
    .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(4,8,20,.45); z-index: 50; }
    .only-mobile { display: inline-grid; }
    .content { padding: 16px; }
    .cols-2, .grid-2 { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .user-meta { display: none; }
    .topbar { padding: 10px 14px; }
    .profile-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .stat-row { grid-template-columns: 1fr; }
    .notif-panel { width: calc(100vw - 28px); position: fixed; right: 14px; }
}

/* ===== Soft-UI полировка ===== */
/* Цифры — табличными фигурами (без «прыжков» в колонках сумм/часов/времени) */
.table td.ta-right, .stat-value, .hours-pill, .error-code, code, .badge, time {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}
code { font-family: var(--font-mono); }

/* Плавность и доступный фокус */
a, .btn, .icon-btn, .nav-item, .row-link, .switch-track, .switch-track::after,
.field input, .field select, .field textarea {
    transition: background-color .16s ease, border-color .16s ease, color .16s ease,
                box-shadow .16s ease, transform .06s ease;
}
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}
.btn:focus-visible, .icon-btn:focus-visible { outline-offset: 3px; }

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

/* Карточки с мягкой границей-подсветкой сверху для акцентных блоков */
.card { transition: box-shadow .18s ease; }
.stat-card { transition: box-shadow .18s ease, border-color .18s ease; }
.stat-card:hover { box-shadow: var(--shadow-md); }

/* ===== Пункты (оценка) и подзадачи (задача) ===== */
.items { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.items-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.item-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.item-row input {
    flex: 1 1 auto; min-width: 0;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit;
}
.item-row input:focus { border-color: var(--accent); outline: none; }
.item-row .icon-btn { flex: 0 0 auto; color: var(--muted); }
.item-row .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }

/* Список-превью (только чтение) */
.items-preview { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.items-preview li {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm);
}
.items-preview li span { color: var(--ink); }
.items-preview li b { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.items-block { margin-top: 12px; }
.items-block-title { font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.items-copied { margin-bottom: 10px; }

/* Ввод часов по пунктам оценки */
.est-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.est-item { display: flex; align-items: center; gap: 10px; }
.est-item-title { flex: 1 1 auto; min-width: 0; color: var(--ink); }
.est-item-hours {
    flex: 0 0 96px; width: 96px; text-align: right;
    padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit;
}
.est-item-hours:focus { border-color: var(--accent); outline: none; }

/* Чек-лист подзадач */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.check-item > label {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 8px 10px; border-radius: var(--radius-sm);
}
.check-item > label:hover { background: var(--surface-2); }
.check-item input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); cursor: pointer; }
.check-text { flex: 1 1 auto; color: var(--ink); }
.check-hours { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.check-item.done .check-text { text-decoration: line-through; color: var(--muted); }

/* ===== Защищённые доступы клиента ===== */
.access-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.access-head .card-title { margin: 0; }
.access-card .access-btn, .access-btn { margin-left: 8px; }
.access-box {
    margin: 12px 0 0; padding: 12px 14px;
    background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
    white-space: pre-wrap; word-break: break-word;
    font-family: var(--font-mono); font-size: 13px; line-height: 1.55; color: var(--ink);
    max-height: 340px; overflow: auto;
}
