/* ==========================================================================
   Система ПРО — дизайн-система портала
   Один файл, без внешних зависимостей: локальный сервер работает автономно,
   а Content-Security-Policy не пропускает сторонние CDN.
   ========================================================================== */

/* ------------------------------------------------------------------ Токены */
:root {
    /* Фирменный цвет — «пожарный» красный */
    --accent: #d92d20;
    --accent-600: #b42318;
    --accent-700: #912018;
    --accent-soft: #fef3f2;
    --accent-border: #fecdca;

    --blue: #1e5eff;
    --blue-soft: #eef3ff;
    --green: #039855;
    --green-soft: #ecfdf3;
    --amber: #dc6803;
    --amber-soft: #fffaeb;
    --violet: #7839ee;
    --violet-soft: #f4f3ff;
    --cyan: #0e7090;
    --cyan-soft: #ecfdff;
    --slate: #475467;
    --slate-soft: #f2f4f7;

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;

    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    --muted-2: #98a2b3;

    --sidebar-bg: #101623;
    --sidebar-hover: #1b2434;
    --sidebar-text: #c3cad8;
    --sidebar-active: #ffffff;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);
    --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, .08), 0 8px 8px -4px rgba(16, 24, 40, .03);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto",
        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

    --sidebar-w: 268px;
    --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1117;
        --surface: #151b24;
        --surface-2: #1a212c;
        --border: #263140;
        --border-strong: #35435a;

        --text: #e6edf3;
        --text-2: #c3cad8;
        --muted: #8b98ab;
        --muted-2: #6b7889;

        --accent-soft: #2a1614;
        --accent-border: #5c2622;
        --blue-soft: #14213f;
        --green-soft: #0d2a1e;
        --amber-soft: #2c2110;
        --violet-soft: #1e1838;
        --cyan-soft: #0e2833;
        --slate-soft: #1c232e;

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
        --shadow-md: 0 4px 10px rgba(0, 0, 0, .45);
        --shadow-lg: 0 14px 26px rgba(0, 0, 0, .5);
        --shadow-xl: 0 24px 40px rgba(0, 0, 0, .55);
    }
}

/* ------------------------------------------------------------------- Сброс */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
small { font-size: .82rem; }
code, .mono { font-family: var(--font-mono); font-size: .88em; }

::selection { background: var(--accent); color: #fff; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------- Утилиты */
.container { width: min(1280px, 100% - 48px); margin-inline: auto; }
.container-narrow { width: min(880px, 100% - 48px); margin-inline: auto; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.end { justify-content: flex-end; }
.items-start { align-items: flex-start; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--accent-600); }
.text-success { color: var(--green); }
.text-warning { color: var(--amber); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.uppercase { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 650; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .container, .container-narrow { width: calc(100% - 32px); }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ Иконки */
.icon { width: 20px; height: 20px; flex: none; stroke-width: 1.7; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }
.icon-xl { width: 34px; height: 34px; }

/* ------------------------------------------------------------------ Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-600); }

.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover { background: #000; }

.btn-outline {
    background: var(--surface);
    color: var(--text-2);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--muted-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--slate-soft); }

.btn-danger { background: var(--accent-600); color: #fff; }
.btn-danger:hover { background: var(--accent-700); }

.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* ------------------------------------------------------------------ Бейджи */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.badge-neutral { background: var(--slate-soft); color: var(--slate); border-color: var(--border); }
.badge-info    { background: var(--blue-soft);  color: var(--blue); }
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-warning { background: var(--amber-soft); color: var(--amber); }
.badge-danger  { background: var(--accent-soft); color: var(--accent-600); border-color: var(--accent-border); }
.badge-plain::before { display: none; }

/* Пометка стадии готовности: «beta» рядом с названием портала, в настройках
   и на кнопке возврата внутри программ. Цвет — предупреждающий, но негромкий:
   это уведомление, а не ошибка. */
.badge-stage {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber);
    border: 1px solid var(--amber);
    font-size: .66rem;
    font-weight: 700;
    line-height: 1.6;
    letter-spacing: .05em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* ------------------------------------------------------------------ Карточки */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-pad { padding: 22px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}
.card-header h3, .card-header h2 { margin: 0; }
.card-body { padding: 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* --------------------------------------------------------- Каркас портала */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    color: #fff;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo-mark { width: 38px; height: 38px; }
.sidebar-brand b { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
.sidebar-brand span { display: block; font-size: .72rem; color: var(--muted-2); letter-spacing: .04em; text-transform: uppercase; }
/* Значок стадии внутри названия: правило выше делает блочными все вложенные
   span, поэтому пометка растягивалась во всю ширину меню. Цвета — под тёмный
   фон бокового меню, где светлая заливка бейджа была бы слишком громкой. */
.sidebar-brand .badge-stage {
    display: inline-block;
    background: rgba(220, 104, 3, .18);
    color: #fdb022;
    border-color: rgba(253, 176, 34, .45);
}

.sidebar-nav { padding: 14px 12px; flex: 1; }
.sidebar-label {
    padding: 14px 12px 6px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #5f6b7f;
    font-weight: 700;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .92rem;
    font-weight: 500;
    transition: background .14s, color .14s;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(217, 45, 32, .35); }
.sidebar-link .icon { opacity: .85; }
.sidebar-link.active .icon { opacity: 1; }
.sidebar-link .count {
    margin-left: auto;
    background: rgba(255, 255, 255, .12);
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.sidebar-user {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    gap: 11px;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user b { display: block; color: #fff; font-size: .88rem; }
.sidebar-user small { display: block; color: var(--muted-2); font-size: .74rem; }

.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #f97066);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .84rem;
    flex: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: .72rem; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.breadcrumbs { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { color: var(--muted-2); }

/* Поиск в шапке. На узком экране прячется: там шапку занимают хлебные
   крошки, а поиск остаётся доступен со страницы /search. */
.topsearch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 260px;
    padding: 0 12px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--muted);
    transition: border-color .14s, background .14s;
}
.topsearch:focus-within { border-color: var(--accent); background: var(--surface); }
.topsearch input {
    flex: 1;
    border: 0;
    background: none;
    outline: none;
    font: inherit;
    font-size: .88rem;
    color: var(--text);
    min-width: 0;
}
.topsearch input::placeholder { color: var(--muted-2); }
@media (max-width: 900px) { .topsearch { display: none; } }

/* Находки сквозного поиска. */
.hit {
    display: flex;
    gap: 14px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
}
.hit:last-child { border-bottom: 0; }
.hit .hit-icon { flex: 0 0 22px; color: var(--muted); padding-top: 2px; }
.hit .hit-body { flex: 1; min-width: 0; }
.hit .hit-body > a { font-weight: 600; }
.hit .hit-sub { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.hit .hit-blocks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.hit .hit-block {
    font-size: .76rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--surface);
}
a.hit-block:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Колокольчик уведомлений в шапке.
   Счётчик — не украшение: пока он не ноль, у сотрудника есть непрочитанное,
   и цвет здесь тот же тревожный, что у просроченного срока. */
.bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    transition: background .14s, color .14s;
}
.bell:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.bell.has-new { color: var(--text); }
.bell-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}
.sidebar-count {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    text-align: center;
}

/* Лента уведомлений. Непрочитанное отмечено полосой слева и фоном —
   в списке из тридцати строк глазом ищут именно новое. */
.notice-list { display: flex; flex-direction: column; }
.notice {
    display: flex;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
}
.notice:last-child { border-bottom: 0; }
.notice.unread { background: var(--bg); border-left-color: var(--accent); }
.notice .notice-icon {
    flex: 0 0 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
}
.notice .notice-body { flex: 1; min-width: 0; }
.notice .notice-body a { color: inherit; font-weight: 600; }
.notice .notice-meta { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.notice .notice-text { font-size: .88rem; color: var(--muted); margin-top: 4px; }

.content { padding: 28px; flex: 1; }
@media (max-width: 900px) { .content { padding: 18px 16px; } .topbar { padding: 0 16px; } }

/* Мобильное меню */
.menu-toggle { display: none; }
@media (max-width: 1000px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.open { transform: none; box-shadow: var(--shadow-xl); }
    .menu-toggle { display: inline-flex; }
    .scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 55; }
}

/* ------------------------------------------------------------- Заголовок */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head h1 { margin: 0 0 4px; }
.page-head .sub { color: var(--muted); font-size: .92rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------- Плитки показателей */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--border-strong);
}
.stat.is-danger::after { background: var(--accent); }
.stat.is-warning::after { background: var(--amber); }
.stat.is-success::after { background: var(--green); }
.stat.is-info::after { background: var(--blue); }
.stat .label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .hint { font-size: .8rem; color: var(--muted); }

/* --------------------------------------------------- Карточки модулей */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

.module-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.module-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--card-accent, var(--accent));
}
.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
    text-decoration: none;
}
.module-card .m-top { display: flex; align-items: center; gap: 14px; }
.module-card .m-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--card-soft, var(--accent-soft));
    color: var(--card-accent, var(--accent));
    flex: none;
}
.module-card h3 { margin: 0; font-size: 1.08rem; }
.module-card .m-short { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.module-card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.module-card .m-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.module-card .m-tag {
    font-size: .74rem;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
}
.module-card .m-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .85rem;
    font-weight: 600;
    color: var(--card-accent, var(--accent));
}
.module-card .m-metrics { display: flex; gap: 16px; flex-wrap: wrap; }
.module-card .m-metric { font-size: .82rem; color: var(--muted); }
.module-card .m-metric b { display: block; font-size: 1.15rem; color: var(--text); font-weight: 700; }

.accent-red    { --card-accent: var(--accent); --card-soft: var(--accent-soft); }
.accent-blue   { --card-accent: var(--blue);   --card-soft: var(--blue-soft); }
.accent-green  { --card-accent: var(--green);  --card-soft: var(--green-soft); }
.accent-amber  { --card-accent: var(--amber);  --card-soft: var(--amber-soft); }
.accent-violet { --card-accent: var(--violet); --card-soft: var(--violet-soft); }
.accent-cyan   { --card-accent: var(--cyan);   --card-soft: var(--cyan-soft); }
.accent-slate  { --card-accent: var(--slate);  --card-soft: var(--slate-soft); }

/* ------------------------------------------------------------- Таблицы */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
table.data th {
    text-align: left;
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}
table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .row-title { font-weight: 600; color: var(--text); }
table.data .row-sub { font-size: .8rem; color: var(--muted); }
tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.is-warning td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

/* --------------------------------------------------------------- Формы */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .84rem; font-weight: 600; color: var(--text-2); }
.field .help { font-size: .78rem; color: var(--muted); }
.req::after { content: " *"; color: var(--accent); }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="search"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    font-size: .92rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: .9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    margin-top: 22px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.filters .field { min-width: 170px; }
.filters .field > label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ------------------------------------------------------- Уведомления */
.alerts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.alert {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 16px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .91rem;
}
.alert-info    { background: var(--blue-soft);   border-color: #b2ccff; color: #0b3fa8; }
.alert-success { background: var(--green-soft);  border-color: #a6f4c5; color: #05603a; }
.alert-warning { background: var(--amber-soft);  border-color: #fedf89; color: #b54708; }
.alert-danger  { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-700); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .alert-info { color: #93b8ff; border-color: #1d3a72; }
    :root:not([data-theme="light"]) .alert-success { color: #6ce9a6; border-color: #12603d; }
    :root:not([data-theme="light"]) .alert-warning { color: #fdb022; border-color: #7a4b0d; }
    :root:not([data-theme="light"]) .alert-danger { color: #fda29b; border-color: #7a2a24; }
}

/* --------------------------------------------------------- Пустой список */
.empty {
    padding: 56px 24px;
    text-align: center;
    color: var(--muted);
}
.empty .icon-xl { color: var(--muted-2); margin-bottom: 12px; }
.empty h3 { color: var(--text-2); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 18px; font-size: .9rem; }

/* --------------------------------------------------------------- Прочее */
.progress { height: 7px; background: var(--slate-soft); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.progress.low > span { background: var(--amber); }
.progress.late > span { background: var(--accent); }

.attention-list { display: flex; flex-direction: column; }
.attention-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 22px;
    border-bottom: 1px solid var(--border);
    color: inherit;
}
.attention-item:last-child { border-bottom: 0; }
.attention-item:hover { background: var(--surface-2); text-decoration: none; }
.attention-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.attention-item .dot.danger { background: var(--accent); }
.attention-item .dot.warning { background: var(--amber); }
.attention-item .dot.info { background: var(--blue); }
.attention-item .body { min-width: 0; flex: 1; }
.attention-item b { display: block; font-size: .92rem; font-weight: 600; }
.attention-item small { color: var(--muted); }
.attention-item .meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
    padding: 10px 15px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: .92rem;
    white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent-600); border-bottom-color: var(--accent); }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.board-col h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; }
.board-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 9px;
    box-shadow: var(--shadow-xs);
    font-size: .88rem;
}
.board-card b { display: block; margin-bottom: 4px; }
.board-card .m { color: var(--muted); font-size: .8rem; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

/* =========================================================================
   Публичный (титульный) сайт
   ========================================================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .site-header { background: rgba(21, 27, 36, .9); }
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { font-size: 1.12rem; letter-spacing: -.02em; display: block; line-height: 1.15; }
.brand span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav a { color: var(--text-2); font-size: .92rem; font-weight: 500; }
.site-nav a:hover { color: var(--accent-600); text-decoration: none; }
@media (max-width: 860px) { .site-nav .nav-link { display: none; } }

.logo-mark {
    width: 42px; height: 42px;
    border-radius: 11px;
    background: linear-gradient(140deg, var(--accent) 0%, #f97066 100%);
    display: grid;
    place-items: center;
    color: #fff;
    flex: none;
    box-shadow: 0 4px 12px rgba(217, 45, 32, .3);
}

.hero {
    position: relative;
    overflow: hidden;
    padding: 88px 0 76px;
    background:
        radial-gradient(1000px 460px at 78% -8%, rgba(217, 45, 32, .16), transparent 62%),
        radial-gradient(760px 380px at 8% 105%, rgba(30, 94, 255, .1), transparent 60%),
        linear-gradient(180deg, #0d1220 0%, #131a2b 100%);
    color: #fff;
}
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(900px 460px at 50% 20%, #000, transparent 78%);
    pointer-events: none;
}
.hero .inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
@media (max-width: 980px) { .hero .inner { grid-template-columns: 1fr; } .hero { padding: 58px 0 52px; } }

.hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .14);
    font-size: .8rem;
    font-weight: 600;
    color: #fecdca;
    margin-bottom: 22px;
}
.hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.35rem); line-height: 1.1; letter-spacing: -.03em; color: #fff; margin-bottom: 18px; }
.hero h1 em { font-style: normal; color: #fda29b; }
.hero .lead { font-size: 1.09rem; color: #b8c1d1; max-width: 620px; margin-bottom: 30px; }
.hero-actions { display: flex; gap: 13px; flex-wrap: wrap; }
.hero .btn-outline { background: rgba(255, 255, 255, .06); color: #fff; border-color: rgba(255, 255, 255, .22); }
.hero .btn-outline:hover { background: rgba(255, 255, 255, .12); }

.hero-panel {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-xl);
    padding: 26px;
    backdrop-filter: blur(8px);
}
.hero-panel h4 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: #93a0b8; margin-bottom: 16px; }
.hero-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 16px; }
.hero-stat .v { font-size: 1.9rem; font-weight: 700; color: #fff; letter-spacing: -.02em; line-height: 1.1; }
.hero-stat .l { font-size: .8rem; color: #93a0b8; line-height: 1.35; }

.section { padding: 76px 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }
.section-head { max-width: 660px; margin: 0 auto 46px; text-align: center; }
.section-head .eyebrow {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--accent-600);
    font-weight: 700;
    margin-bottom: 10px;
    display: block;
}
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.15rem); letter-spacing: -.025em; }
.section-head p { color: var(--muted); font-size: 1.02rem; margin: 0; }

.service-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.section-alt .service-card { background: var(--surface-2); }
.service-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--border-strong); }
.service-card .s-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    margin-bottom: 18px;
}
.service-card h3 { font-size: 1.13rem; }
.service-card p { color: var(--muted); font-size: .93rem; }
.service-card ul { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 8px; }
.service-card li { display: flex; align-items: center; gap: 9px; font-size: .88rem; color: var(--text-2); }
.service-card li .icon-sm { color: var(--green); flex: none; }

.stat-band { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
@media (max-width: 860px) { .stat-band { grid-template-columns: repeat(2, 1fr); } }
.stat-band .b-item { text-align: center; padding: 20px; }
.stat-band .b-value { font-size: 2.5rem; font-weight: 700; color: var(--accent); letter-spacing: -.03em; line-height: 1; }
.stat-band .b-label { color: var(--muted); font-size: .9rem; margin-top: 8px; }

.steps { counter-reset: step; display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
@media (max-width: 980px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }
.step { position: relative; padding-top: 22px; border-top: 3px solid var(--border); }
.step .n { font-size: .82rem; font-weight: 800; color: var(--accent); letter-spacing: .08em; }
.step h4 { margin: 6px 0 8px; font-size: 1.02rem; }
.step p { color: var(--muted); font-size: .9rem; margin: 0; }

.cta {
    background: linear-gradient(135deg, #131a2b 0%, #1f2940 100%);
    border-radius: var(--radius-xl);
    padding: 52px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    flex-wrap: wrap;
}
.cta h2 { color: #fff; margin-bottom: 8px; }
.cta p { color: #a9b4c8; margin: 0; max-width: 560px; }

.site-footer {
    background: #0d1220;
    color: #8f9bb0;
    padding: 54px 0 28px;
    font-size: .9rem;
}
/* Колонок четыре: к контактам и разделу для сотрудников добавился раздел
   для заказчиков — у них теперь свой вход в систему. */
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 34px; }
@media (max-width: 1080px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 30px; } }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr; gap: 26px; } }
.site-footer h5 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
.site-footer a { color: #8f9bb0; }
.site-footer a:hover { color: #fff; }
.site-footer .brand b, .site-footer .brand { color: #fff; }
.footer-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, .09);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    font-size: .82rem;
    color: #6b7789;
}

/* --------------------------------------------------------- Страница входа */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}
@media (max-width: 940px) { .auth-page { grid-template-columns: 1fr; } .auth-aside { display: none; } }

.auth-aside {
    background:
        radial-gradient(760px 400px at 30% 8%, rgba(217, 45, 32, .22), transparent 60%),
        linear-gradient(160deg, #0d1220 0%, #16203a 100%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-aside h2 { color: #fff; font-size: 2rem; letter-spacing: -.025em; max-width: 460px; }
.auth-aside p { color: #a9b4c8; max-width: 460px; }
.auth-aside .feature-list { list-style: none; padding: 0; margin: 30px 0 0; display: flex; flex-direction: column; gap: 15px; }
.auth-aside .feature-list li { display: flex; gap: 13px; align-items: flex-start; }
.auth-aside .feature-list .icon { color: #fda29b; margin-top: 2px; }
.auth-aside .feature-list b { display: block; color: #fff; font-size: .95rem; }
.auth-aside .feature-list small { color: #93a0b8; }

.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-box { width: min(400px, 100%); }
.auth-box .logo-mark { margin-bottom: 22px; }
.auth-box h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 28px; }
.auth-box .field + .field { margin-top: 16px; }
.auth-hint {
    margin-top: 26px;
    padding: 13px 15px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: .84rem;
    color: var(--muted);
}

/* ----------------------------------------------------------- Ошибки */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 40px 24px; text-align: center; }
.error-page .code { font-size: 5rem; font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -.04em; }
.error-page h1 { margin: 12px 0 8px; }
.error-page p { color: var(--muted); max-width: 460px; margin: 0 auto 26px; }

/* ------------------------------------------------- Переписка по заявке */
/*
   Лента сообщений заявки заказчика. Используется в двух местах — в личном
   кабинете и в разделе заявок портала, — поэтому оформление одно: сотрудник
   и заказчик обсуждают одно и то же и должны видеть одну и ту же ленту.

   Слева цветная полоса, а не разные пузыри по сторонам: сообщений в заявке
   немного, и «переписка мессенджером» здесь только съедала бы ширину,
   которая нужна тексту отчёта о работах.
*/
.thread { display: flex; flex-direction: column; gap: 14px; }
.thread-item {
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.thread-item.is-mine { border-left-color: var(--blue); }
.thread-item.is-system { border-left-color: var(--border); background: transparent; }
.thread-item.is-system .thread-text { color: var(--muted); font-size: .88rem; }
.thread-item.is-internal { border-left-color: var(--amber); background: var(--amber-soft); }
.thread-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: .86rem;
    margin-bottom: 6px;
}
.thread-text { white-space: pre-line; font-size: .94rem; }

/* --------------------------------------- Ход работ по заявке (кабинет) */
/*
   Заказчику важно не «какое сейчас состояние», а «на каком шаге дело и
   сколько осталось». Поэтому состояния показаны списком целиком, а текущее
   выделено, — а не одним бейджем, по которому непонятно, что будет дальше.
*/
.steps-vertical { display: flex; flex-direction: column; gap: 10px; }
.step-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.step-row .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--border-strong);
    flex: 0 0 9px;
}
.step-row.active { color: var(--text); font-weight: 600; }
.step-row.active .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ------------------------------------------------------------- Печать */
@media print {
    .sidebar, .topbar, .page-actions, .filters, .form-actions, .site-header, .site-footer { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .content { padding: 0; }
    .card, .table-wrap { box-shadow: none; border-color: #ccc; }
    body { background: #fff; }
}
