:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --ink: #17202e;
    --muted: #667085;
    --line: #e3e7ee;
    --brand: #1f6feb;
    --brand-dark: #1557c0;
    --side: #101a2b;
    --side-ink: #c9d3e3;
    --good: #12824c;
    --bad: #c4321f;
    --warn: #9a6400;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }

.shell { display: flex; min-height: 100vh; }
.side {
    width: 232px; flex: 0 0 232px; background: var(--side); color: var(--side-ink);
    display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; font-size: 18px; font-weight: 700; color: #fff; padding: 2px 10px 16px; }
.brand span { color: #6ea8ff; font-weight: 600; }
.brand:hover { text-decoration: none; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7385a3; padding: 16px 10px 6px; }
.nav-empty { padding: 4px 10px; color: #7385a3; font-size: 13px; }
.nav-link { display: block; padding: 7px 10px; border-radius: 6px; color: var(--side-ink); }
.nav-link small { display: block; color: #7385a3; }
.nav-link:hover { background: #1a2740; text-decoration: none; color: #fff; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.nav-link.is-active small { color: #d6e4ff; }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid #22314d; }
.link-btn { background: none; border: 0; color: #9fb0cc; cursor: pointer; padding: 7px 10px; font: inherit; }
.link-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; max-width: 1440px; padding: 26px 30px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi-sub { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f6; color: #44536b; }
.badge.good { background: #e3f5ea; color: var(--good); }
.badge.bad { background: #fde8e4; color: var(--bad); }
.badge.warn { background: #fff3d6; color: var(--warn); }
.badge.info { background: #e4eeff; color: var(--brand-dark); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pills { display: flex; gap: 4px; }
.pills a { padding: 4px 10px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); background: #fff; font-size: 13px; }
.pills a.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pills a:hover { text-decoration: none; }

input[type=text], input[type=password], input[type=email], input[type=search], input[type=url], select {
    font: inherit; padding: 7px 10px; border: 1px solid #cfd6e1; border-radius: 6px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus { outline: 2px solid #b9d2ff; border-color: var(--brand); }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=url], .field select { width: 100%; max-width: 420px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 6px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #cfd6e1; }
.btn.ghost:hover { background: #f3f5f9; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e7b6ae; }
.btn.danger:hover { background: #fde8e4; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.inline-form { display: inline; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-ok { background: #e3f5ea; border-color: #b5e0c5; color: #0d5c36; }
.alert-err { background: #fde8e4; border-color: #f2c1b9; color: #8f2314; }
.alert-info { background: #e4eeff; border-color: #bcd3ff; color: #123f8f; }

.pager { display: flex; gap: 14px; align-items: center; justify-content: center; padding: 12px; border-top: 1px solid var(--line); color: var(--muted); }

.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar-in { fill: var(--brand); }
.chart .bar-out { fill: #f0a595; }
.legend { display: flex; gap: 16px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.lg-in::before { background: var(--brand); }
.lg-out::before { background: #f0a595; }

.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: .08em; background: #f3f5f9; padding: 8px 12px; border-radius: 6px; display: inline-block; word-break: break-all; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #f3f5f9; padding: 1px 5px; border-radius: 4px; }

body.bare { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: var(--side); }
.bare-box { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; }
.bare-box .brand { color: var(--ink); padding: 0 0 18px; }
.bare-box .brand span { color: var(--brand); }
.bare-box .field input { max-width: none; }
.bare-box .btn { width: 100%; }

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .side { width: 100%; flex: none; height: auto; position: static; }
    .side-foot { margin-top: 12px; }
    .main { padding: 18px 16px 40px; }
}
