/* ========================================================================
   ДИЗАЙН-ТОКЕНЫ «Тёплый янтарь»
   Перенесены из Документация-Сайт/src/styles/global.css (палитра бренда
   «СоваДоки»). Меняем только здесь → обновляется везде. Имена семантических
   классов (.btn, .card, .badge) совпадают со старой версией, чтобы шаблоны
   Jinja2 править минимально.
   ======================================================================== */
:root {
    /* Бренд (primary) — янтарь */
    --primary: #d97706;            /* amber-600 — акцент */
    --primary-hover: #b45309;      /* amber-700 — hover акцента */
    --brand-light: #fef3e2;        /* персик-крем — подложки */

    /* Нейтральные (поверхности) — тёплые */
    --bg: #fffdf5;                 /* фон страницы — тёплый крем */
    --card: #ffffff;               /* карточки */
    --border: #f0e6d6;             /* границы — тёплый беж */
    --text: #451a03;               /* основной текст — коричневый */
    --muted: #78716c;              /* приглушённый текст — тёплый серый */

    /* Статусные (для бейджей) */
    --green: #15803d;              /* изумруд — оплачено/подписан/активен */
    --green-bg: #dcfce7;
    --amber: #b45309;              /* насыщенный янтарь для текста бейджа */
    --amber-bg: #fef3c7;
    --red: #dc2626;                /* отмена */
    --red-bg: #fee2e2;

    /* Радиусы */
    --radius: 8px;
}

/* ========================================================================
   ШРИфт Inter — самохостинг (.woff2 в /static/fonts/)
   Без внешних запросов к Google Fonts (важно для VPS IPv4-only + российского
   хостинга). Variable font: один файл покрывает все веса 400/500/600/700,
   браузер сам берёт нужную ось по font-weight. 4 подсистемы юникода
   (cyrillic-ext / cyrillic / latin-ext / latin) — грузится только нужная.
   ======================================================================== */

/* cyrillic-ext */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(/static/fonts/inter-cyr-ext.woff2) format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(/static/fonts/inter-cyr.woff2) format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(/static/fonts/inter-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(/static/fonts/inter-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

/* ========================================================================
   ВЕРХНЯЯ ШАПКА (повтор Документация-Сайт/src/components/Header.astro)
   sticky, увеличена под крупный бренд: сова 44×44 + «СоваДоки» 20px,
   навигация крупнее (15px), CTA/email прижаты вправо.
   ======================================================================== */
.topnav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Бренд: сова + название */
.topnav .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 20px;
    text-decoration: none;
    color: var(--text);
    line-height: 1;
}
.topnav .brand .brand-logo {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.topnav .nav-links {
    display: flex;
    gap: 1.5rem;
}
.topnav .nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.topnav .nav-links a:hover {
    color: var(--text);
}
.topnav .nav-links a.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.topnav .nav-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topnav .nav-user .user-email { color: var(--muted); font-size: 13px; }
.btn-link { background: none; border: none; color: var(--muted); padding: 4px 8px; cursor: pointer; font-size: 13px; }
.btn-link:hover { color: var(--red); }

.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ========================================================================
   ЗАГОЛОВКИ СТРАНИЦ
   ======================================================================== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: 26px; }
.page-header .actions { display: flex; gap: 10px; }

/* ========================================================================
   КНОПКИ
   ======================================================================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--card); color: var(--text); text-decoration: none;
    font-weight: 500; cursor: pointer; font-size: 14px; font-family: inherit;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: var(--border); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }

/* ========================================================================
   КАРТОЧКИ
   ======================================================================== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 16px 0; font-size: 18px; }

/* ========================================================================
   ТАБЛИЦЫ
   ======================================================================== */
table.data { width: 100%; border-collapse: collapse; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: #fefbf3; font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fffaf0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ========================================================================
   ФОРМЫ
   ======================================================================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: block; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; color: var(--text); }
input, select, textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; font-family: inherit; background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ========================================================================
   БЕЙДЖИ (статусы документов — оставлены по требованию заказчика)
   Подогнаны под тёплую палитру: draft — нейтральный беж, остальные — штатно.
   ======================================================================== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #f5efe6; color: #57534e; }        /* нейтральный тёплый (был индиго) */
.badge-issued { background: var(--amber-bg); color: var(--amber); }   /* янтарь — «выставлен» */
.badge-paid, .badge-signed, .badge-active { background: var(--green-bg); color: var(--green); }
.badge-cancelled { background: var(--red-bg); color: #991b1b; }

/* ========================================================================
   ПРОЧЕЕ
   ======================================================================== */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty a { color: var(--primary); }
.muted { color: var(--muted); }
.row { display: flex; gap: 16px; align-items: center; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.text-sm { font-size: 13px; }

/* ========================================================================
   РЕДАКТОР ПОЗИЦИЙ СЧЁТА
   ======================================================================== */
.line-items th { background: #fefbf3; }
.line-items input { padding: 6px 8px; }
/* Ширина инпутов в таблице позиций: глобальное input{width:100%} съедает узкие
   столбцы «Кол-во/Ед./Цена» (60–90px) вместе с padding. Даём полям «дышать»:
   наименование широкое, числовые — min-width чтобы помещали 4–6 цифр. */
.line-items td input { box-sizing: border-box; min-width: 0; }
.line-items .li-desc { min-width: 180px; }
.line-items .li-qty,
.line-items .li-unit { min-width: 56px; }
.line-items .li-price { min-width: 84px; }
/* Запрет переноса строки в ячейке с инпутом, чтобы ширина считалась от столбца */
.line-items td { white-space: nowrap; }
.line-items td:nth-child(2) { white-space: normal; }

/* ========================================================================
   COMBO-BOX ПОИСК (превращает <select> в поле с автодополнением)
   ======================================================================== */
.combo-wrap { display: block; }
.combo-input { width: 100%; }
.combo-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(69, 26, 3, 0.08);
}
.combo-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}
.combo-item:hover, .combo-item.active { background: var(--brand-light); }
.combo-empty { padding: 8px 12px; color: var(--muted); font-size: 14px; }
.text-sm { font-size: 12px; }

/* ========================================================================
   ДАШБОРД — 4 блока (v1.006)
   Палитра «Тёплый янтарь»: акцент — янтарь, подложки — персик-крем,
   alert — мягкий янтарь, плейсхолдер — нейтральный беж с пунктиром.
   ======================================================================== */

/* Блок 1: строка счётчиков-карточек */
.dash-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.dash-stat {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}
.dash-stat::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--primary);
}
.dash-stat:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.12);
}
.dash-stat-label {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.dash-stat-value {
    font-size: 34px;
    font-weight: 700;
    margin-top: 6px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* Блок 2: график (CSS-барчарт) */
.dash-chart-card { margin-bottom: 24px; }
.dash-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}
.dash-card-head h2 { margin: 0; }
.dash-card-sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}
.dash-chart {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 8px;
    align-items: end;
    height: 220px;
    padding-top: 8px;
}
.dash-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
}
.dash-bar-amt {
    font-size: 11px;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.dash-bar-track {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: flex-end;
    background: var(--brand-light);
    border-radius: 6px 6px 0 0;
    overflow: hidden;
}
.dash-bar {
    width: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 6px 6px 0 0;
    min-height: 0;
    transition: height 0.3s ease;
}
.dash-bar-col:hover .dash-bar {
    background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
}
.dash-bar-label {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    white-space: nowrap;
}

/* Блок 3: alert «на подписании» */
.dash-alert-card {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--amber-bg);
    border-color: #fcd34d;
}
.dash-alert-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}
.dash-alert-body { flex: 1; }
.dash-alert-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--amber);
    font-variant-numeric: tabular-nums;
}
.dash-alert-sub {
    font-size: 14px;
    color: #78350f;
    margin-top: 2px;
}
.dash-alert-sub strong { color: var(--amber); }

/* Блок 4: плейсхолдер «Добавить свою метрику» */
.dash-placeholder {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    padding: 28px 24px;
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}
.dash-placeholder:hover {
    border-color: var(--primary);
    background: var(--brand-light);
}
.dash-placeholder-icon {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.dash-placeholder-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.dash-placeholder-sub {
    font-size: 13px;
}

/* Адаптивность: на узких экранах счётчики в колонку */
@media (max-width: 700px) {
    .dash-stat-row { grid-template-columns: 1fr; }
    .dash-chart { grid-template-columns: repeat(6, 1fr); gap: 4px; height: 180px; }
    .dash-chart { grid-template-columns: repeat(6, 1fr); }
    /* На мобильном показываем только последние 6 месяцев — дальше плохо видно */
}

