/* =========================================================================
   BDSM Squad Analytics — графитовая тема, минимальные скругления.
   Desktop-first с адаптацией под планшет/мобайл.
   ========================================================================= */

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/Roboto-Regular-56L6iL-I.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Roboto Condensed';
    src: url('../fonts/RobotoCondensed-Regular-4sH3Sjh-.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Roboto Condensed';
    src: url('../fonts/RobotoCondensed-Bold-KZyqfZJr.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --bg:           #0c0d0e;
    --bg-2:         #141618;
    --panel:        #17191c;
    --panel-2:      #1d2024;
    --panel-3:      #23272c;
    --line:         #2a2e34;
    --line-soft:    #21252a;
    --text:         #e7e9ec;
    --text-2:       #aeb4bb;
    --muted:        #7c828b;
    --accent:       #6b7785;
    --accent-2:     #8a98a8;
    --good:         #56c98a;
    --bad:          #e06363;
    --warn:         #e0a93f;
    --global:       #7aa2c4;
    --mission:      #9d86c9;
    --radius:       6px;
    --radius-sm:    4px;
    --shadow:       0 8px 24px rgba(0,0,0,.45);
    --ff-head:      'Roboto Condensed', 'Segoe UI', Arial, sans-serif;
    --ff-body:      'Roboto', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

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

/* ---------- Skeleton (мгновенный каркас до подгрузки данных) ---------- */
@keyframes skeleton-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.skeleton-text, .skeleton-line, .skeleton-row, .skeleton-card-row, .skeleton-card {
    background: var(--panel-3);
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.skeleton-text { display: inline-block; min-width: 90px; border-radius: var(--radius-sm); color: transparent; }
.skeleton-line { display: block; height: 12px; border-radius: var(--radius-sm); margin-top: 6px; }
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-70 { width: 70%; }
.kpi.skeleton-card { justify-content: center; }
.skeleton-row { height: 38px; border-radius: var(--radius-sm); margin-top: 8px; }
.skeleton-card-row { height: 64px; border-radius: var(--radius); margin-top: 10px; }

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

.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(10,11,12,.86), rgba(255, 255, 255, 0)),
        url('../img/background.png') center top / cover no-repeat fixed;
}

a { color: inherit; text-decoration: none; }
.link { color: var(--accent-2); border-bottom: 1px solid transparent; transition: border-color .15s; }
.link:hover { border-bottom-color: var(--accent-2); }

h1, h2, h3 { font-family: var(--ff-head); font-weight: 700; margin: 0; letter-spacing: .2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.wrap { width: min(1480px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- Topbar ---------- */
.topbar {
    border-bottom: 1px solid var(--line);
    background: rgba(12,13,14,.72);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 50;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { font-family: var(--ff-head); font-weight: 700; font-size: 20px; letter-spacing: 2px; }
.brand-sub { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.topbar-meta { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--text-2); }
.badge-ro {
    font-size: 11px; letter-spacing: 1px; font-weight: 700;
    color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
    padding: 3px 8px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--good) 12%, transparent);
}

/* ---------- Hero ---------- */
.hero { padding: 32px 0 18px; }
.hero h1 { font-size: 30px; }
.hero-sub { color: var(--text-2); margin-top: 8px; max-width: 880px; }

.src-tag {
    display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .5px;
    padding: 1px 5px; border-radius: var(--radius-sm); vertical-align: middle;
}
.src-global  { color: var(--global);  background: color-mix(in srgb, var(--global) 16%, transparent); }
.src-mission { color: var(--mission); background: color-mix(in srgb, var(--mission) 16%, transparent); }

.kpi-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-top: 22px;
}
.kpi {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-family: var(--ff-head); font-size: 26px; font-weight: 700; }
.kpi-value.is-bad { color: var(--bad); }
.kpi-split { display: flex; align-items: center; gap: 8px; }
.kpi-split-value { font-family: var(--ff-head); font-size: 21px; font-weight: 700; line-height: 1.05; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin: 26px 0 16px; border-bottom: 1px solid var(--line); }
.tab {
    padding: 11px 20px; font-family: var(--ff-head); font-size: 15px; color: var(--text-2);
    border-bottom: 2px solid transparent; cursor: pointer; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-2); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Panels ---------- */
.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { font-size: 19px; }
.panel-head .muted { font-size: 13px; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-main-single { grid-template-columns: 1fr; }

/* ---------- Toolbar / inputs ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.input {
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
    padding: 9px 12px; border-radius: var(--radius-sm); font-size: 14px; min-width: 220px; font-family: var(--ff-body);
}
.input:focus { outline: none; border-color: var(--accent-2); }
.filters { display: flex; gap: 16px; }
.chk { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.count-info { margin-left: auto; font-size: 13px; }

.btn {
    background: var(--panel-3); border: 1px solid var(--line); color: var(--text);
    padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-family: var(--ff-body);
}
.btn:hover { background: var(--panel-2); }
.btn.ghost { background: transparent; }

.notice {
    border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
    background: color-mix(in srgb, var(--warn) 10%, transparent);
    color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
    text-align: right; padding: 10px 12px; font-family: var(--ff-head); font-weight: 700;
    color: var(--text-2); border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px;
}
.data-table th.th-left, .data-table td.th-left { text-align: left; }
.data-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); text-align: right; vertical-align: top; }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table td.num { font-variant-numeric: tabular-nums; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sortable.sort-asc::after { content: ' ▲'; font-size: 10px; }
.sortable.sort-desc::after { content: ' ▼'; font-size: 10px; }

.player-open {
    background: none; border: none; color: var(--text); font: inherit; font-weight: 600;
    cursor: pointer; padding: 0; display: block; text-align: left;
}
.player-open:hover { color: var(--accent-2); }
.th-left .muted { display: block; }
.ls-human { display: block; }
.is-warn { color: var(--warn); }
.warn-dot { color: var(--warn); font-weight: 700; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.good { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.tag.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.tag.bad  { color: var(--bad);  background: color-mix(in srgb, var(--bad) 14%, transparent); }
.tag.muted-tag { color: var(--muted); background: var(--panel-3); margin-left: 6px; }

.empty { color: var(--muted); padding: 30px; text-align: center; }
.empty.small { padding: 16px; font-size: 13px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.page-btn {
    padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    color: var(--text-2); font-size: 13px; background: var(--panel);
}
.page-btn:hover { background: var(--panel-2); color: var(--text); }
.page-btn.active { background: var(--panel-3); color: var(--text); border-color: var(--accent); }

/* ---------- Missions ---------- */
.mission-list { display: flex; flex-direction: column; gap: 10px; }
.mission-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); overflow: hidden; }
.mission-card.has-squad { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: color-mix(in srgb, var(--good) 5%, var(--panel-2)); }
.mission-summary {
    list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 18px;
    padding: 14px 18px; align-items: center;
}
.mission-summary::-webkit-details-marker { display: none; }
.mission-card[open] .mission-summary { border-bottom: 1px solid var(--line); }
.ms-date { font-size: 12px; color: var(--muted); }
.ms-title { font-family: var(--ff-head); font-size: 17px; font-weight: 700; margin-top: 2px; }
.ms-desc { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.ms-right { display: flex; align-items: center; gap: 18px; }
.ms-stat { display: flex; flex-direction: column; align-items: flex-end; }
.ms-stat-squad .ms-stat-val { color: var(--good); }
.ms-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.ms-stat-val { font-family: var(--ff-head); font-weight: 700; font-size: 16px; }
.ms-chevron { color: var(--muted); transition: transform .2s; }
.mission-card[open] .ms-chevron { transform: rotate(180deg); }

.mission-body { padding: 16px 18px; }
.mb-section { margin-bottom: 22px; }
.mb-section:last-child { margin-bottom: 0; }
.mb-section-title { font-family: var(--ff-head); font-weight: 700; font-size: 14px; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text-2); margin-bottom: 10px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }

.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.result-card { border: 1px solid var(--line); border-left: 3px solid var(--side, var(--accent)); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel); }
.result-head { font-family: var(--ff-head); font-weight: 700; margin-bottom: 6px; }
.result-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.task-state { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 11px; }
.task-state.ok { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.task-state.fail { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.task-score { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Лента событий: слева направо одним взглядом */
.event-feed { display: flex; flex-direction: column; }
.event-row {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 14px;
    border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.event-row:hover { background: var(--panel); }
.event-row-link { color: inherit; text-decoration: none; cursor: pointer; }
.event-row-link .ev-meta { margin-left: auto; white-space: nowrap; }
.ev-side { display: inline-flex; align-items: center; gap: 7px; }
.ev-name { font-weight: 600; }
.ev-name.squad { color: var(--good); }
.text-squad { color: var(--good); font-weight: 600; }
.ev-action { color: var(--muted); font-size: 13px; }
.ev-tk { color: var(--warn); font-weight: 600; }
.event-row.kind-teamkill { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.event-row.kind-suicide { background: color-mix(in srgb, var(--bad) 6%, transparent); color: var(--text-2); }
.side-chip {
    font-size: 11px; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
    color: var(--chip, var(--accent-2)); border: 1px solid color-mix(in srgb, var(--chip, var(--accent-2)) 50%, transparent);
    background: color-mix(in srgb, var(--chip, var(--accent-2)) 12%, transparent);
}

/* Силы сторон */
.forces { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.side-block { border: 1px solid var(--line); border-top: 3px solid var(--side, var(--accent)); border-radius: var(--radius-sm); padding: 12px; background: var(--panel); }
.side-block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.group-block { margin-bottom: 10px; }
.group-name { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); margin-bottom: 5px; }
.player-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.player-chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
    background: var(--panel-3); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px 8px;
}
.player-chip.dead { opacity: .6; }
.player-chip.squad { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); background: color-mix(in srgb, var(--good) 14%, var(--panel-3)); color: var(--good); }
.player-chip.squad .role { color: color-mix(in srgb, var(--good) 70%, var(--muted)); }
.player-chip .role { color: var(--muted); font-size: 11px; }
.player-chip .skull { color: var(--bad); }

/* ---------- Activity ---------- */
.squad-metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.squad-metric { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.squad-metric .l { font-size: 11px; color: var(--muted); }
.squad-metric .v { font-family: var(--ff-head); font-size: 16px; font-weight: 700; }
.chart-box { height: 280px; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chart-meta { color: var(--muted); font-size: 13px; }
.chart-ranges { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.btn-range { padding: 6px 10px; font-size: 12px; }
.btn.btn-range.is-active { background: var(--panel-3); border-color: var(--accent-2); color: var(--text); }
.chart-note { margin-top: 10px; line-height: 1.45; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-item { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); }
.rank-num { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--panel-3); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-2); }
.rank-name { flex: 1; font-weight: 600; }
.delta { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- Drawer (карточка игрока) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90; }
.drawer {
    position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); z-index: 100;
    background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
    display: flex; flex-direction: column; transform: translateX(0); animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(20px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-title { font-family: var(--ff-head); font-size: 20px; font-weight: 700; }
.drawer-close { background: none; border: none; color: var(--text-2); font-size: 20px; cursor: pointer; }
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 20px; overflow-y: auto; }

.dr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.dr-stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.dr-stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.dr-stat .v { font-family: var(--ff-head); font-size: 20px; font-weight: 700; }
.dr-section-title { font-family: var(--ff-head); font-weight: 700; font-size: 14px; text-transform: uppercase;
    color: var(--text-2); margin: 18px 0 8px; border-bottom: 1px solid var(--line-soft); padding-bottom: 5px; }
.dr-chart { height: 200px; margin-bottom: 8px; }
.dr-list { display: flex; flex-direction: column; }
.dr-li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.dr-li.dr-li-link { color: inherit; text-decoration: none; cursor: pointer; }
.dr-li.dr-li-link:hover { background: var(--panel-2); }
.dr-li .t { color: var(--text); }
.dr-li .m { color: var(--muted); font-size: 12px; }
.dr-links { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.dr-links a { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }

[hidden] { display: none !important; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: 13px; margin-top: 20px; }

/* ---------- Адаптивность ---------- */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .wrap { width: calc(100% - 24px); }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar-meta .meta-item:not(.badge-ro):not(:last-child) { display: none; }
    .mission-summary { flex-direction: column; align-items: flex-start; }
    .ms-right { width: 100%; justify-content: space-between; }
    .hero h1 { font-size: 24px; }
}
