/* Админ-панель Dataprint. Базовые токены — в tokens.css. */

.hidden { display: none !important; }

/* ===== Вход ===== */
.login {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px;
    width: 100%; max-width: 360px; text-align: center;
    display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { font-size: 28px; }
.login-sub { color: var(--muted); margin-top: -6px; margin-bottom: 8px; }
.login-card input {
    font: inherit; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: var(--bg); color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.login-error { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ===== Дашборд ===== */
.dashboard {
    max-width: 1200px; margin: 0 auto; padding: 20px;
    display: flex; flex-direction: column; min-height: 100vh;
}
/* Виджет выпуска прижат к нижней границе экрана. */
.issue-panel { margin-top: auto; margin-bottom: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h1 { font-size: 24px; }
.topbar-tag {
    font-family: var(--font-ui); font-size: 12px; font-weight: 600;
    color: var(--brand-dark); background: #e7f3e8;
    padding: 2px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px;
}

.grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; align-items: start; }

@media (max-width: 880px) {
    /* Раскрываем grid, чтобы панели стали прямыми flex-детьми .dashboard и
       можно было задать порядок: Активность -> Выпуск -> Клиенты. */
    .grid { display: contents; }
    .chart-panel { order: 1; }
    .issue-panel { order: 2; margin-top: 0; margin-bottom: 16px; }
    .table-panel { order: 3; }

    /* В таблице оставляем только Активность, Заметку и столбец действий.
       Заметку делаем уже (≈вдвое), остаток отдаём Активности.
       `thead th` — выше специфичности базовых правил, чтобы перекрыть их
       независимо от порядка в файле. */
    table.clients th:nth-child(1), table.clients td:nth-child(1),
    table.clients th:nth-child(3), table.clients td:nth-child(3) { display: none; }
    table.clients thead th:nth-child(2) { width: auto; }
    table.clients thead th:nth-child(4) { width: 28%; }
    table.clients thead th:nth-child(5) { width: 40px; }
    /* Текст «Активности» не переносим. */
    table.clients tbody td:nth-child(2) { white-space: nowrap; }
    /* Слово «назад» на мобильной убираем. */
    .ago { display: none; }
    .mob-dot { display: inline-block; margin-right: 8px; vertical-align: middle; }

    /* Кнопки выпуска — вертикально, на всю ширину. */
    .issue-actions { flex-direction: column; align-items: stretch; }
    .issue-actions .btn, .issue-actions .btn-outline { width: 100%; }
    .issue-actions #issueFree { margin-left: 0; }

    /* Шапки панелей переносятся, чтобы переключатель/мета не вылезали на узком экране. */
    .panel-head { flex-wrap: wrap; gap: 8px; }
    .topbar { flex-wrap: wrap; gap: 8px; }
}

/* Десктоп: список клиентов не выше графика — лишнее прокручивается. */
@media (min-width: 881px) {
    .table-panel .table-scroll { max-height: 280px; overflow-y: auto; }
}

.panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; }
.meta { color: var(--muted); font-size: 13px; }

/* Сегмент-переключатель окна графика */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.seg button {
    font: inherit; font-size: 13px; border: 0; background: var(--card); color: var(--muted);
    padding: 6px 12px; cursor: pointer;
}
.seg button.active { background: var(--brand); color: #fff; }

.chart-wrap { position: relative; height: 280px; }

/* ===== Таблица ===== */
.table-scroll { overflow-x: auto; }
table.clients { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14px; }
table.clients th:nth-child(1) { width: 24%; }
table.clients th:nth-child(2) { width: 20%; }
table.clients th:nth-child(3) { width: 14%; }
table.clients th:nth-child(4) { width: auto; }
table.clients th:nth-child(5) { width: 40px; }
table.clients th {
    text-align: left; font-family: var(--font-head); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted);
    padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
    position: sticky; top: 0; background: #f7f8fa; z-index: 1;
}
table.clients td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.clients tr:last-child td { border-bottom: 0; }
table.clients tbody tr:nth-child(even) td { background: #f7f8fa; }
.col-action { width: 36px; }

.user-cell { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.dot.on { background: var(--brand); box-shadow: 0 0 0 3px rgba(67,160,71,0.18); }
/* Кружок активности в колонке «Активность» — только на мобильной (на десктопе
   он в колонке «Пользователь», которая на мобильной скрыта). */
.mob-dot { display: none; }
.mono { font-variant-numeric: tabular-nums; }
.demo { color: var(--license-demo); }
.demo i { margin-right: 4px; }
.note-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.icon-btn {
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    padding: 6px; border-radius: 8px; font-size: 14px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ===== Виджет выпуска ===== */
.issue-panel h2 { font-size: 16px; margin-bottom: 12px; }
.issue-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* Десктоп: «Свободные лицензии» прижата к правому краю. */
.issue-actions #issueFree { margin-left: auto; }

/* ===== Кнопки ===== */
.btn {
    font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
    background: var(--brand); color: #fff; border: 0;
    padding: 10px 20px; border-radius: var(--radius-md);
}
.btn:hover { background: var(--brand-dark); }
.btn-outline {
    font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
    background: var(--card); color: var(--brand-dark);
    border: 1px solid var(--border); padding: 10px 20px; border-radius: var(--radius-md);
}
.btn-outline:hover { background: var(--bg); }
.btn-outline:disabled { opacity: .5; cursor: default; }
.btn-text {
    font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
    background: transparent; color: var(--muted); border: 0; padding: 10px 16px;
}
.btn-text:hover { color: var(--text); }
.btn-danger {
    font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
    background: transparent; color: var(--danger);
    border: 1px solid var(--danger); padding: 10px 16px; border-radius: var(--radius-md);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ===== Оверлеи ===== */
.overlay {
    position: fixed; inset: 0; background: rgba(20,22,26,0.45);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
    background: var(--card); border-radius: var(--radius-lg); padding: 24px;
    width: 100%; max-width: 440px; box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.kv span { color: var(--muted); }
.field-label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.modal textarea {
    width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: var(--bg); color: var(--text); resize: vertical;
}
.modal textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.modal-foot-right { display: flex; gap: 8px; margin-left: auto; }

.gen-input { display: flex; gap: 10px; margin-bottom: 8px; }
.gen-input input {
    font: inherit; width: 100px; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: var(--bg); color: var(--text);
}
.gen-result {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 12px; margin: 4px 0; font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 15px; line-height: 1.8; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto;
}

/* ===== Список свободных лицензий ===== */
.free-list { max-height: 360px; overflow: auto; margin-top: 6px; }
.free-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
    margin-bottom: 8px; cursor: pointer;
}
.free-item:hover { background: var(--bg); }
.free-item .code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; }
.free-item.released { border-color: var(--brand); background: #f1f9f1; }
.free-item .tag {
    font-size: 12px; font-weight: 600; color: var(--brand-dark);
    background: #e1f1e2; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.free-empty { color: var(--muted); padding: 12px; text-align: center; }

/* ===== Тост ===== */
.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius-md);
    font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
