:root {
    color-scheme: dark;
    --bg: #071019;
    --panel: #0d1924;
    --panel-2: #111f2c;
    --line: #213344;
    --text: #f4f7fb;
    --muted: #8fa4b7;
    --blue: #4ea1ff;
    --green: #67e8a5;
    --orange: #ffb05c;
    --red: #ff7d7d;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-width: 320px;
    background:
        radial-gradient(circle at 75% -10%, rgba(34, 112, 176, .18), transparent 35rem),
        var(--bg);
    color: var(--text);
    font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }
.topbar { height: 78px; display: flex; align-items: center; gap: 34px; border-bottom: 1px solid rgba(143, 164, 183, .18); }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(145deg, #57a8ff, #735cff); font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.nav { display: flex; gap: 6px; }
.nav a, .periods a { padding: 9px 14px; color: var(--muted); border-radius: 10px; }
.nav a.active, .nav a:hover, .periods a.active { background: var(--panel-2); color: var(--text); }
main { padding: 44px 0 60px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
h1 { margin: 6px 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin: 3px 0 0; font-size: 21px; letter-spacing: -.02em; }
p { color: var(--muted); }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.periods { display: flex; padding: 4px; background: rgba(13, 25, 36, .7); border: 1px solid var(--line); border-radius: 13px; }
.notice { display: flex; gap: 8px; padding: 13px 16px; margin-bottom: 18px; border: 1px solid rgba(255,176,92,.35); border-radius: 12px; background: rgba(255,176,92,.08); color: #f6d4ae; }
.cards { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.metric-card, .panel { border: 1px solid var(--line); background: linear-gradient(155deg, rgba(17,31,44,.96), rgba(10,22,32,.96)); border-radius: 18px; box-shadow: 0 15px 45px rgba(0,0,0,.14); }
.metric-card { min-height: 150px; padding: 22px; display: flex; flex-direction: column; }
.metric-card span { color: var(--muted); }
.metric-card strong { margin: auto 0 4px; font-size: clamp(28px, 3vw, 39px); letter-spacing: -.04em; }
.metric-card small, .muted { color: var(--muted); }
.metric-card.accent { border-color: rgba(103,232,165,.38); background: linear-gradient(145deg, rgba(103,232,165,.13), var(--panel)); }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.two { grid-template-columns: 1.55fr 1fr; }
.panel { padding: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span:before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.legend .blue:before { background: var(--blue); }
.legend .green:before { background: var(--green); }
.chart { display: block; width: 100%; height: 230px; }
.axis { stroke: var(--line); stroke-width: 1; }
.line { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.line.clicks { stroke: var(--blue); }
.line.joins { stroke: var(--green); }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; overflow: hidden; }
.stat-list { margin: 0; }
.stat-list div { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.stat-list div:last-child { border-bottom: 0; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-size: 18px; font-weight: 700; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.network-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.network-grid > div { padding: 16px; background: rgba(5,14,22,.35); border-radius: 13px; }
.network-grid strong, .network-grid span, .network-grid small { display: block; }
.network-grid span { margin-top: 8px; font-size: 18px; }
.network-grid small { color: var(--muted); margin-top: 4px; }
.chip, .status { display: inline-flex; width: fit-content; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.status.ok { color: var(--green); border-color: rgba(103,232,165,.35); background: rgba(103,232,165,.08); }
.model-value { display: block; margin-top: 22px; font-size: 52px; line-height: 1; color: var(--green); }
.proximity { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 24px 0 10px; }
.proximity div { padding: 9px; text-align: center; border-radius: 10px; background: rgba(5,14,22,.4); }
.proximity dt { color: var(--muted); font-size: 11px; }
.proximity dd { margin: 2px 0 0; font-weight: 800; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--muted); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid rgba(33,51,68,.7); white-space: nowrap; }
td strong, td small { display: block; }
td small { color: var(--muted); }
code { color: #bddcff; }
.empty { padding: 42px 12px !important; color: var(--muted); text-align: center; }
.health { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.health .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.health .dot.on { background: var(--green); box-shadow: 0 0 12px var(--green); }
.health span:nth-of-type(3) { margin-left: auto; }
.button { padding: 9px 14px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.button:hover { border-color: var(--blue); }
.button.primary { border-color: transparent; background: linear-gradient(135deg, #338ee9, #6862ed); }
.button.ghost { background: transparent; }
.button.wide { width: 100%; padding: 12px; }
.login-wrap { min-height: calc(100vh - 180px); display: flex; align-items: center; justify-content: center; }
.login-card { width: min(100%, 420px); padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); }
.login-card h2 { margin-bottom: 24px; }
label { display: block; margin: 14px 0; color: var(--muted); }
label span { display: block; margin-bottom: 6px; }
input, select { width: 100%; padding: 11px 12px; color: var(--text); border: 1px solid var(--line); border-radius: 10px; background: #09141e; outline: none; }
input:focus, select:focus { border-color: var(--blue); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check span { margin: 0; }
.field-error { color: var(--red); }
.filters { display: flex; align-items: center; gap: 8px; min-width: min(100%, 520px); }
.filters select { max-width: 160px; }
.danger-link { color: var(--red); border: 0; background: none; cursor: pointer; }
.flash { padding: 12px 16px; margin-bottom: 18px; color: var(--green); border: 1px solid rgba(103,232,165,.3); border-radius: 12px; background: rgba(103,232,165,.08); }
.pagination { margin-top: 18px; }
.pagination nav > div:first-child { display: none; }
.pagination nav > div:last-child { display: flex; justify-content: space-between; align-items: center; }
.pagination svg { width: 18px; }

@media (max-width: 960px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .grid.two { grid-template-columns: 1fr; }
    .page-head { align-items: start; flex-direction: column; }
    .health .dot:nth-of-type(2) { margin-left: 0; }
}
@media (max-width: 640px) {
    .shell { width: min(100% - 24px, 1440px); }
    .topbar { gap: 10px; }
    .nav a { padding: 8px; }
    .brand small { display: none; }
    main { padding-top: 28px; }
    .metrics { grid-template-columns: 1fr; }
    .notice { flex-direction: column; }
    .periods { width: 100%; }
    .periods a { flex: 1; text-align: center; }
    .filters { width: 100%; flex-wrap: wrap; }
}
