/* ==========================================================================
   PPTV Server — светлая строгая зелёная тема
   ========================================================================== */

:root {
    --bg: #f3f7f3;
    --surface: #ffffff;
    --surface-2: #f7faf7;
    --text: #17221a;
    --text-2: #4c5a50;
    --text-3: #8b988e;
    --border: #dde7dd;
    --border-strong: #c3d2c4;
    --accent: #15803d;
    --accent-hover: #166534;
    --accent-soft: #e5f2e7;
    --accent-soft-2: #d3e8d6;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --success: #15803d;
    --success-soft: #dcf3e0;
    --warning: #92400e;
    --warning-soft: #fdf0dc;
    --info: #1e5f74;
    --info-soft: #e2f0f4;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(13, 32, 18, .05);
    --shadow-md: 0 10px 30px rgba(13, 32, 18, .08);
    --focus: 0 0 0 3px rgba(21, 128, 61, .22);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #15803d, #16a34a);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.brand-title { font-size: 16px; font-weight: 650; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-2); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.who { font-size: 13px; color: var(--text-2); }
.who b { color: var(--text); font-weight: 600; }

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

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title { font-size: 16px; font-weight: 650; }
.card-hint { font-size: 12.5px; color: var(--text-2); }
.card-body { padding: 20px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 9px 16px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); color: var(--accent-hover); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: #eab8b8; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn-ghost { background: transparent; color: var(--accent); padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }

.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 550; color: var(--text-2); }

.input, .select {
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    width: 100%;
}

.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 180px; }

/* ---------- Badges / chips ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 550;
    border-radius: 999px;
    padding: 3px 10px;
    border: 1px solid transparent;
}

.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge-waiting { color: var(--info); background: var(--info-soft); border-color: #c8e2e9; }
.badge-arrived { color: var(--success); background: var(--success-soft); border-color: #b4dfba; }
.badge-absent { color: var(--danger); background: var(--danger-soft); border-color: #f0c6c6; }
.badge-muted { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    border: 1px solid var(--accent-soft-2);
    border-radius: 999px;
    padding: 5px 8px 5px 14px;
    font-size: 13.5px;
    font-weight: 550;
}

.chip button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 50%;
}
.chip button:hover { background: var(--accent-soft-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Stats ---------- */

.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    min-width: 140px;
    box-shadow: var(--shadow-sm);
}

.stat-value { font-size: 22px; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-2); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

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

table.data th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-2);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    padding: 9px 12px;
    white-space: nowrap;
}

table.data td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

.num { font-variant-numeric: tabular-nums; }

.mono {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
}

/* ---------- Date/cabinet groups ---------- */

.date-group { margin-bottom: 26px; }

.date-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    border-left: 4px solid var(--accent);
    padding: 2px 0 2px 12px;
    margin-bottom: 12px;
}

.date-head h2 { font-size: 18px; }
.date-head .count { color: var(--text-2); font-size: 13px; }

.cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
    gap: 16px;
}

.cabinet-card .card-head { padding: 12px 16px; background: var(--accent-soft); border-radius: var(--radius) var(--radius) 0 0; }
.cabinet-title { font-size: 15px; font-weight: 650; color: var(--accent-hover); }

/* ---------- Toolbar / filters ---------- */

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 18px;
}

.toolbar .field { flex: 0 1 200px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar-actions { display: flex; gap: 10px; align-items: flex-end; margin-left: auto; }

/* ---------- Auth screens ---------- */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 400px at 85% -10%, #d6ecd9 0%, transparent 60%),
        radial-gradient(700px 380px at -10% 110%, #e0efe2 0%, transparent 55%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 34px 32px 28px;
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.auth-title { font-size: 18px; font-weight: 650; }
.auth-sub { font-size: 13px; color: var(--text-2); }

.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; margin-top: 6px; }

.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 13px; }

/* ---------- Alerts / toasts ---------- */

.alert {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13.5px;
    border: 1px solid;
    margin-bottom: 14px;
    display: none;
    white-space: pre-wrap;
}

.alert.show { display: block; }
.alert-error { background: var(--danger-soft); border-color: #f0c6c6; color: var(--danger); }
.alert-ok { background: var(--success-soft); border-color: #b4dfba; color: var(--accent-hover); }
.alert-info { background: var(--info-soft); border-color: #c8e2e9; color: var(--info); }

#toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-size: 13.5px;
    box-shadow: var(--shadow-md);
    max-width: 420px;
    animation: toast-in .2s ease;
}

.toast-item.err { background: var(--danger); }

@keyframes toast-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* ---------- Modal ---------- */

.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 20, .45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 60;
}

.modal-back.show { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    overflow: auto;
}

.modal-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-head h3 { font-size: 16.5px; }
.modal-body { padding: 22px; }
.modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--text-3);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.modal-close:hover { color: var(--text); }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }

.tab {
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    color: var(--text-2);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
}

.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }

/* ---------- Misc ---------- */

.empty {
    text-align: center;
    color: var(--text-2);
    padding: 48px 20px;
}

.empty-icon { font-size: 34px; margin-bottom: 8px; color: var(--border-strong); }

.muted { color: var(--text-2); font-size: 13px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

.dropzone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 26px;
    text-align: center;
    color: var(--text-2);
    font-size: 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

.token-box {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot-ok { background: var(--success); }
.dot-err { background: var(--danger); }
.dot-warn { background: #d97706; }

@media (max-width: 640px) {
    .cabinet-grid { grid-template-columns: minmax(0, 1fr); }
    .cabinet-card { min-width: 0; }
    .topbar-inner, .container { padding-left: 14px; padding-right: 14px; }
    .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
    .topbar-actions { width: 100%; margin-left: 0; justify-content: space-between; flex-wrap: wrap; }
    .who { min-width: 0; }
    .toolbar-actions { margin-left: 0; width: 100%; }
}

/* ================= v2.0: навигация, подвал, мониторинг ================= */

.topbar-actions nav, nav.topbar-actions { display: flex; align-items: center; gap: 10px; }

.site-footer {
    margin-top: 40px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.site-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-2);
}

.stat-ok .stat-value { color: var(--success); }
.stat-warn .stat-value { color: var(--danger); }

.mon-sub {
    font-size: 14px;
    font-weight: 600;
    margin: 22px 0 10px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    cursor: pointer;
    font-size: 14px;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check:focus-within { outline: none; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.metrics-form { margin-bottom: 8px; }
.metrics-link {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.toolbar-actions-inline { display: flex; flex-wrap: wrap; gap: 10px; }


@media (max-width: 640px) {
    .site-footer-inner { padding: 14px; }
    .metrics-form .form-row { flex-direction: column; }
    .card-head { flex-wrap: wrap; }
}

/* Ячейки записей в админке: статус и кнопка скачивания в одну строку */
.rec-cell { white-space: nowrap; }
.rec-cell .btn { margin-left: 6px; }
