/* Палитра взята с сайта ukdobrynya.ru, чтобы админка не выглядела чужой системой */
:root {
    /* Чёрный — ровно как шапка ukdobrynya.ru: background #000, граница rgba(255,255,255,.12) */
    --dark: #000000;
    --dark-2: rgba(255, 255, 255, .06);
    --dark-3: rgba(255, 255, 255, .10);
    --dark-line: rgba(255, 255, 255, .12);

    /* Текст на чёрном. Держим высокий контраст: на чистом #000 приглушённые
       уровни читаются заметно хуже, чем на тёмно-сером. */
    --on-dark: #FFFFFF;
    --on-dark-strong: #FFFFFF;
    --on-dark-muted: rgba(255, 255, 255, .72);
    --on-dark-faint: rgba(255, 255, 255, .55);

    --green: #5CB024;
    --green-bright: #93D95C;
    --green-deep: #3D7F14;
    --green-pale: #EDF6E4;

    --bg: #F1F5EC;
    --surface: #FFFFFF;
    --line: #DFE7D7;
    --text: #141711;
    --muted: #5F6858;
    --muted-2: #848D7B;
    --danger: #FF6B4A;

    /* Шрифты сайта, объявления — в fonts.css */
    --font-text: 'Golos Text', system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: 'Unbounded', 'Golos Text', system-ui, sans-serif;

    --nav-w: 288px;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 23, 17, .05), 0 8px 24px rgba(20, 23, 17, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-text);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Unbounded — акцидентный шрифт с широкими знаками: хорош в заголовках,
   но в интерфейсе его нельзя лить в мелкий текст, поэтому размеры сдержаннее,
   а межбуквенное расстояние поджато. */
h1, h2, h3 {
    font-family: var(--font-display);
    margin: 0 0 .5em;
    font-weight: 600;
    letter-spacing: -.02em;
}

h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

a { color: var(--green-deep); }

/* ---------- Каркас: меню слева, рабочее поле справа ---------- */

.layout {
    display: grid;
    grid-template-columns: var(--nav-w) 1fr;
    min-height: 100vh;
}

.content {
    padding: 32px 36px 64px;
    min-width: 0;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-head p {
    margin: 0;
    color: var(--muted);
    max-width: 68ch;
}

/* ---------- Тёмное меню слева ---------- */

.nav {
    background: var(--dark);
    color: var(--on-dark);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--dark-line);
    position: sticky;
    top: 0;
    height: 100vh;
}

/* Логотип сайта: зелёный домик и слово «Добрыня» белым.
   Он изначально сделан под тёмный фон, поэтому в меню ставится как есть. */
.nav-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--dark-line);
}

.nav-logo {
    width: 180px;
    max-width: 100%;
    height: auto;
    display: block;
}

.nav-brand-sub {
    color: var(--on-dark-muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-line) transparent;
}

.nav-loading { color: var(--on-dark-muted); font-size: 13px; padding: 8px 10px; }

.nav-group { margin-bottom: 16px; }

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px 8px;
    color: var(--on-dark-muted);
    font-size: 11.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.nav-group-title .icon { width: 15px; height: 15px; opacity: .9; }

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px 8px 34px;
    border-radius: 8px;
    color: var(--on-dark);
    text-decoration: none;
    font-size: 14px;
    transition: background .12s, color .12s;
}

.nav-link:hover { background: var(--dark-2); color: var(--on-dark-strong); }

.nav-link.active {
    background: var(--dark-3);
    color: var(--green-bright);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--green);
}

.nav-link-planned { color: var(--on-dark-faint); cursor: default; }
.nav-link-planned:hover { background: transparent; color: var(--on-dark-faint); }

.nav-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--on-dark-muted);
    border: 1px solid var(--dark-line);
    border-radius: 20px;
    padding: 1px 7px;
}

.nav-user {
    border-top: 1px solid var(--dark-line);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nav-user-info { display: flex; flex-direction: column; min-width: 0; }
.nav-user-name { color: var(--on-dark-strong); font-size: 13.5px; font-weight: 600; }
.nav-user-role { color: var(--on-dark-muted); font-size: 11.5px; }

.nav-user-actions { display: flex; gap: 4px; }
.nav-user-actions form { margin: 0; }

.nav-user-link {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--on-dark-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.nav-user-link:hover { background: var(--dark-2); color: var(--green-bright); }
.nav-user-link .icon { width: 17px; height: 17px; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Карточки и таблицы ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-head h2 { margin: 0; }
.card-body { padding: 20px; }
.card-body-flush { padding: 0; }

.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.grid th {
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: #FAFCF7;
}

table.grid td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.row-group td { background: var(--green-pale); font-weight: 600; }
table.grid tr.row-hidden td { opacity: .5; }

.child-title { padding-left: 26px; }

/* Поле ввода прямо в клетке таблицы — для ведомостей, где правят десятки строк подряд */
.cell-input {
    width: 100%;
    max-width: 130px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

.cell-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-pale); }

.tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: #fff;
    white-space: nowrap;
}

.tag-planned { border-color: #E3D9BF; background: #FDF8E8; color: #8A7430; }
.tag-hidden { border-color: #E0DDD8; background: #F4F3F1; color: var(--muted); }
.tag-ok { border-color: #CFE6BC; background: var(--green-pale); color: var(--green-deep); }
.tag-error { border-color: #F3CDC1; background: #FFF3EF; color: #A93A18; }

code.path {
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12.5px;
    color: var(--muted);
    background: #F6F8F3;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
}

/* ---------- Формы и кнопки ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { margin-top: 4px; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 220px; }

/* Селектор по классу, а не по [type]: Blazor InputText не выводит type="text",
   и поле логина оставалось без ширины, пока пароль её получал.
   Флажки и переключатели исключены явно — иначе они растягивались на всю строку
   и выталкивали свою подпись за пределы карточки. */
.field input:not([type=checkbox]):not([type=radio]),
.field select,
input[type=text], input[type=password], input[type=email], input[type=number], select {
    width: 100%;
    padding: 10px 13px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    transition: border-color .14s, box-shadow .14s, background .14s;
}

.field input:not([type=checkbox]):not([type=radio])::placeholder { color: #A9B2A0; }

.field input:not([type=checkbox]):not([type=radio]):hover,
.field select:hover { border-color: #C8D4BB; }

input:focus, select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3.5px rgba(92, 176, 36, .16);
}

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; }

.check input,
.check input[type=checkbox],
.check input[type=radio] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    flex: none;
    margin: 0;
    accent-color: var(--green);
    cursor: pointer;
}

.check label {
    margin: 0;
    font-weight: 400;
    font-size: 13.5px;
    color: var(--muted);
    cursor: pointer;
}

.login-remember { margin: 6px 0 2px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .14s, border-color .14s, color .14s, transform .14s, box-shadow .14s;
}

.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-deep); }

.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-secondary:hover { border-color: var(--muted-2); }

.btn-danger { background: #fff; border-color: #F0C9BE; color: #C0431F; }
.btn-danger:hover { background: #FFF3EF; }

.btn-icon {
    padding: 5px 8px;
    font-size: 13px;
    background: #fff;
    border-color: var(--line);
    color: var(--muted);
}

.btn-icon:hover { border-color: var(--green); color: var(--green-deep); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: flex; gap: 8px; align-items: center; }
.actions-end { justify-content: flex-end; }

/* ---------- Сообщения ---------- */

.alert {
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-error { background: #FFF3EF; border-color: #F3CDC1; color: #A93A18; }
.alert-ok { background: var(--green-pale); border-color: #CFE6BC; color: var(--green-deep); }
.alert-warn { background: #FDF8E8; border-color: #EADFBD; color: #8A7430; }

.validation-message { color: #A93A18; font-size: 13px; display: block; margin-top: 5px; }

.notice { padding: 24px; color: var(--muted); }

/* ---------- Страница входа ---------- */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
    background:
        radial-gradient(900px 430px at 10% -8%, rgba(147, 217, 92, .32), transparent 62%),
        radial-gradient(780px 420px at 94% 110%, rgba(92, 176, 36, .16), transparent 60%),
        var(--bg);
}

.login-shell { width: 100%; max-width: 416px; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 2px 4px rgba(20, 23, 17, .04),
        0 20px 50px -14px rgba(20, 23, 17, .22);
}

/* Логотип белый по замыслу, поэтому шапка карточки тёмная во всю ширину —
   так он смотрится частью интерфейса, а не наклейкой на белом. */
.login-header {
    position: relative;
    background: var(--dark);
    padding: 30px 28px 32px;
    display: grid;
    place-items: center;
}

.login-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--green-bright), var(--green) 55%, var(--green-deep));
}

.login-header img { width: 206px; max-width: 100%; height: auto; display: block; }

.login-body { padding: 26px 30px 30px; }

.login-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 0 0 5px;
}

.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.login-body .field { margin-bottom: 15px; }

.login-body .btn-primary {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    padding: 12px 16px;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(61, 127, 20, .22);
}

.login-body .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -6px rgba(61, 127, 20, .5);
}

.login-body .btn-primary:active { transform: none; }

.login-foot {
    text-align: center;
    color: var(--muted-2);
    font-size: 12px;
    line-height: 1.65;
    margin: 18px 0 0;
}

/* ---------- Панель ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.tile-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.tile-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.03em; }
.tile-note { color: var(--muted-2); font-size: 12px; margin-top: 4px; }

.checklist { margin: 0; padding-left: 20px; color: var(--muted); }
.checklist li { margin-bottom: 6px; }
.checklist strong { color: var(--text); }

/* ---------- Поле даты с календарём ---------- */

.datefield { position: relative; }

/* Место справа под кнопку календаря, чтобы она не наезжала на текст */
.datefield-input { padding-right: 38px !important; }

.datefield-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
}

.datefield-toggle:hover { background: var(--green-pale); color: var(--green-deep); }
.datefield-toggle .icon { width: 16px; height: 16px; }
.datefield-toggle:disabled { opacity: .4; cursor: not-allowed; }

/* Подложка ловит клик мимо календаря */
.datefield-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.datefield-popup {
    position: absolute;
    z-index: 41;
    top: calc(100% + 6px);
    left: 0;
    width: 268px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(20, 23, 17, .28);
    padding: 10px;
}

.datefield-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 8px;
}

.datefield-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.datefield-nav-btn {
    width: 26px;
    height: 26px;
    flex: none;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.datefield-nav-btn:hover { background: var(--green-pale); color: var(--green-deep); }

.datefield-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.datefield-dow {
    text-align: center;
    font-size: 10.5px;
    color: var(--muted-2);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding-bottom: 4px;
}

.datefield-day {
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.datefield-day:hover { background: var(--green-pale); }

/* Сегодняшний день обведён, выбранный — залит: их не следует путать */
.datefield-day.is-today { box-shadow: inset 0 0 0 1px var(--green); }

.datefield-day.is-selected {
    background: var(--green);
    color: #fff;
    font-weight: 600;
}

.datefield-day.is-selected:hover { background: var(--green-deep); }

.datefield-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.datefield-link {
    border: 0;
    background: transparent;
    color: var(--green-deep);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 5px;
}

.datefield-link:hover { background: var(--green-pale); }

/* ---------- Перечень работ ---------- */

.catalog .catalog-code { font-weight: 600; color: var(--muted); white-space: nowrap; }
.catalog .catalog-title { padding-left: 8px; }

/* Собственная операция внутри пункта перечня — со сдвигом и полосой слева */
.catalog .catalog-sub {
    padding-left: 30px;
    position: relative;
    color: var(--muted);
}

.catalog .catalog-sub::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 12px;
    bottom: 12px;
    width: 2px;
    background: var(--line);
}

/* ---------- Диаграмма Ганта ---------- */

.gantt { font-size: 13px; }

.gantt-head {
    display: grid;
    grid-template-columns: 280px 1fr 120px;
    border-bottom: 1px solid var(--line);
    background: #FAFCF7;
    position: sticky;
    top: 0;
    z-index: 2;
}

.gantt-head-name {
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
}

.gantt-head-scale { display: grid; grid-template-columns: repeat(12, 1fr); }

.gantt-month {
    padding: 10px 0;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    border-left: 1px solid var(--line);
}

.gantt-body { }

.gantt-row {
    display: grid;
    grid-template-columns: 280px 1fr 120px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    min-height: 46px;
}

.gantt-row:hover { background: #FBFDF9; }

.gantt-name { padding: 8px 14px; min-width: 0; }

.gantt-name-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-name-sub {
    color: var(--muted);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Дорожка времени: сетка месяцев фоном, полоса поверх — в процентах от года */
.gantt-track {
    position: relative;
    height: 46px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
}

.gantt-cell { border-left: 1px solid var(--line); }

.gantt-bar {
    position: absolute;
    top: 13px;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    min-width: 6px;
    box-shadow: 0 1px 2px rgba(20, 23, 17, .12);
}

.gantt-bar-label {
    position: relative;
    z-index: 1;
    font-size: 10px;
    color: #fff;
    padding-left: 6px;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}

/* Заливка готовности — более тёмным оттенком той же полосы */
.gantt-progress {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .22);
}

.gantt-planned { background: #9AA394; }
.gantt-progress-c { background: var(--green); }
.gantt-done { background: var(--green-deep); }
.gantt-overdue { background: var(--danger); }
.gantt-cancelled { background: #C8CEC2; }

.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #FF6B4A;
    z-index: 1;
}

.gantt-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    padding: 0 12px;
}

/* Кнопка-иконка: квадрат 30 пикселей, подпись — во всплывающей подсказке.
   Текстовые кнопки в этой колонке занимали место и наезжали на полосы. */
.icon-btn {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .12s, color .12s, background .12s;
}

.icon-btn .icon { width: 15px; height: 15px; }

.icon-btn:hover { border-color: var(--muted-2); color: var(--text); background: #FAFCF7; }

.icon-btn-ok:hover { border-color: var(--green); color: var(--green-deep); background: var(--green-pale); }

.icon-btn-danger { color: #C0431F; border-color: #F0C9BE; }
.icon-btn-danger:hover { border-color: var(--danger); color: #A93A18; background: #FFF3EF; }

/* Место выполненной работы, где кнопки «готово» нет — чтобы корзина
   не съезжала влево и колонка оставалась ровной. */
.icon-btn-spacer { display: block; width: 30px; flex: none; }

.gantt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--line);
    background: #FAFCF7;
}

.gantt-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: -1px;
}

.gantt-legend .gantt-today-c { background: #FF6B4A; width: 3px; border-radius: 2px; }

@media (max-width: 1200px) {
    .gantt-head, .gantt-row { grid-template-columns: 200px 1fr 120px; }
    .gantt-month:nth-child(even) { font-size: 0; }
}

/* ---------- Квитанция ---------- */

.invoice-page { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }

.invoice-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 16px; }

.invoice {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 28px 30px;
    box-shadow: var(--shadow);
}

.invoice-head {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 2px solid var(--dark);
}

.invoice-org { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.invoice-org-sub { color: var(--muted); font-size: 12px; line-height: 1.6; }

.invoice-title { text-align: right; white-space: nowrap; }
.invoice-title-main { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.invoice-period { font-size: 14px; margin-top: 2px; }
.invoice-number { color: var(--muted); font-size: 12px; margin-top: 4px; }

.invoice-payer { padding: 16px 0; }

.invoice-meta { width: 100%; font-size: 13px; border-collapse: collapse; }
.invoice-meta td { padding: 3px 0; vertical-align: top; }
.invoice-meta td:first-child { color: var(--muted); width: 190px; }

.invoice-lines { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }

.invoice-lines th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 1px solid var(--dark);
    padding: 8px 10px;
}

.invoice-lines td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.invoice-lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-lines .muted { color: var(--muted); font-size: 12px; }

.invoice-lines tfoot td {
    border-bottom: 0;
    border-top: 1px solid var(--line);
    padding: 8px 10px;
    text-align: right;
}

.invoice-lines tfoot td:first-child { text-align: right; color: var(--muted); }

.invoice-total td {
    border-top: 2px solid var(--dark) !important;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.invoice-foot {
    display: flex;
    gap: 28px;
    justify-content: space-between;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    line-height: 1.7;
}

.invoice-block-title { font-weight: 650; margin-bottom: 4px; }
.invoice-requisites { color: var(--muted); }
.invoice-requisites .invoice-block-title { color: var(--text); }

.invoice-qr { flex: 0 0 260px; }

.invoice-qr-box, .invoice-qr-empty {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #FAFCF7;
}

.invoice-qr-empty { text-align: center; color: var(--muted-2); padding: 34px 10px; }
.invoice-qr-note { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }

/* Код печатается на белом, а не на подложке: сканеру нужен контраст,
   и цветной фон под светлыми модулями его снижает */
.invoice-qr-image {
    background: #FFFFFF;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
}

/* 220 px, а не меньше: строка платежа по ГОСТ даёт код версии 12,
   и на модуль должно приходиться около трёх пикселей, иначе не сканируется */
.invoice-qr-image svg { width: 100%; height: auto; max-width: 220px; display: block; }

.invoice-qr-payload {
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 9px;
    line-height: 1.5;
    word-break: break-all;
    color: var(--text);
}

.invoice-qr-todo { font-size: 10px; color: var(--muted-2); margin-top: 6px; }

@media print {
    .invoice-toolbar { display: none; }
    .invoice-page { padding: 0; max-width: none; }
    .invoice { border: 0; box-shadow: none; border-radius: 0; padding: 0; }
    body { background: #fff; }
}

/* ---------- Ошибки Blazor ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #FDF8E8;
    border-top: 1px solid #EADFBD;
    color: #8A7430;
    padding: 12px 20px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}

#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ---------- Узкий экран ---------- */

.nav-mobile-bar, .nav-close, .nav-backdrop { display: none; }

@media (max-width: 900px) {
    body { overflow-x: hidden; }
    .layout { display: block; min-height: 100dvh; }

    .nav-mobile-bar {
        position: fixed;
        inset: 0 0 auto;
        z-index: 80;
        height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 14px;
        background: var(--dark);
        border-bottom: 1px solid var(--dark-line);
    }

    .nav-mobile-bar img { width: 152px; height: auto; display: block; }

    .nav-mobile-toggle, .nav-close {
        width: 44px;
        height: 44px;
        display: grid;
        place-items: center;
        padding: 0;
        border: 1px solid var(--dark-line);
        border-radius: 9px;
        background: var(--dark-2);
        color: var(--on-dark);
        cursor: pointer;
    }

    .nav-mobile-toggle svg, .nav-close svg {
        width: 23px;
        height: 23px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
    }

    .nav {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 102;
        width: min(86vw, 320px);
        height: 100dvh;
        border-right: 1px solid var(--dark-line);
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 20px 0 50px rgba(0, 0, 0, .25);
    }

    .nav.is-open { transform: translateX(0); }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 101;
        padding: 0;
        border: 0;
        background: rgba(0, 0, 0, .48);
    }

    .nav-brand {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px;
    }

    .nav-brand-text { display: flex; flex-direction: column; gap: 8px; }
    .nav-logo { width: 158px; }
    .nav-close { display: grid; flex: none; }
    .nav-scroll { max-height: none; padding-top: 10px; }
    .nav-link { min-height: 42px; }
    .nav-user-link { width: 40px; height: 40px; }

    .content { padding: 84px 14px 40px; min-width: 0; }

    .page-head { flex-direction: column; gap: 14px; margin-bottom: 18px; }
    .page-head p { font-size: 14px; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1; }

    h1 { font-size: 21px; }
    h2 { font-size: 16px; }
    .card { margin-bottom: 14px; }
    .card-head { padding: 14px 16px; flex-wrap: wrap; }
    .card-body { padding: 16px; }
    .card-body-flush, .card-body:has(> table.grid) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.grid { min-width: 640px; }
    table.grid td, table.grid th { padding: 10px 12px; }

    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
    .tile { padding: 14px; }
    .tile-value { font-size: 20px; }
    .tile-label { font-size: 12px; }
    .tile-note { font-size: 11px; }

    .form-row { gap: 0; }
    .form-row > .field { flex-basis: 100%; }
    .field input:not([type=checkbox]):not([type=radio]),
    .field select,
    input[type=text], input[type=password], input[type=email], input[type=number], select {
        min-height: 46px;
        font-size: 16px;
    }

    .check { min-height: 40px; }
    .check input, .check input[type=checkbox], .check input[type=radio] { width: 20px; height: 20px; }

    .btn { min-height: 44px; justify-content: center; }
    .btn-icon { min-height: 38px; }
    .actions { flex-wrap: wrap; }
    .actions-end { justify-content: flex-start; }
    .hint { overflow-wrap: anywhere; }
    code.path { overflow-wrap: anywhere; }

    .gantt { min-width: 720px; }
    .datefield-popup { max-width: calc(100vw - 28px); }

    .login-page { padding: 16px 14px; }
    .login-body { padding: 22px 20px 24px; }
    .login-header { padding: 24px 20px 26px; }

    .invoice-page { padding: 84px 10px 40px; }
    .invoice { padding: 18px 16px; }
    .invoice-head, .invoice-foot { flex-direction: column; gap: 16px; }
    .invoice-title { text-align: left; white-space: normal; }
    .invoice-qr { flex: auto; }
    .invoice-meta td:first-child { width: 42%; }
    .invoice-lines { min-width: 620px; }
}

@media (prefers-reduced-motion: reduce) {
    .nav { transition: none; }
}
