:root {
    --bg: #0b0f17;
    --panel: #121826;
    --panel-2: #182032;
    --line: #243049;
    --text: #e5e9f2;
    --muted: #8a96ad;
    --accent: #01c9b1;
    --good: #34d399;
    --bad: #f87171;
    --warn: #fbbf24;
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; }
.admin-box form { display: inline-flex; gap: 6px; margin-top: 6px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
h3 { font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 12px; }
.small { font-size: 11px; }

.top {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
}

.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 120px;
}
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--muted); }

main { padding: 20px 24px 40px; display: grid; gap: 18px; max-width: 1500px; margin: 0 auto; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    min-width: 0;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.panel-head.sub { margin-top: 20px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
td.num, th.num { text-align: right; }
tr.own td { background: rgba(1, 201, 177, 0.07); }
tbody tr:hover td { background: var(--panel-2); }

.srv { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: none; border: 0; color: inherit; font: inherit; padding: 0; }
.srv:hover .name { text-decoration: underline; }
.srv img, .srv .ph { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; background: var(--panel-2); flex: none; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.off { background: var(--bad); }
.tag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: rgba(1, 201, 177, 0.15); color: var(--accent); margin-left: 6px; font-weight: 700; }

.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--accent); }

.up { color: var(--good); }
.down { color: var(--bad); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #031512; font-weight: 700; }

.chart-box { position: relative; height: 380px; }
.chart-box.short { height: 280px; margin-bottom: 12px; }
.medal { display: inline-block; min-width: 22px; font-weight: 800; color: var(--warn); }

select, input {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
    background: var(--accent);
    color: #031512;
    border: 0;
    border-radius: 8px;
    padding: 7px 14px;
    font: inherit;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
.btn.ghost { background: none; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn.danger:hover { color: var(--bad); border-color: var(--bad); }

.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form input[name=code] { flex: 2 1 260px; }
.add-form input[name=label] { flex: 1 1 160px; }
.msg { min-height: 18px; font-size: 12px; margin: 6px 0; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }

.tracked { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.card.paused { opacity: 0.55; }
.card-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card-actions { display: flex; gap: 6px; align-items: center; }
.card input[type=color] { width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; }
.card .meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed { max-height: 420px; overflow-y: auto; display: grid; gap: 2px; }
.feed-item { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
.feed-item time { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-item code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.empty { color: var(--muted); font-size: 12px; padding: 10px 0; }

.heat-wrap { overflow-x: auto; }
.heatmap { display: grid; grid-template-columns: 34px repeat(24, minmax(22px, 1fr)); gap: 2px; font-size: 10px; min-width: 640px; }
.heatmap .lbl { color: var(--muted); display: flex; align-items: center; justify-content: center; }
.heatmap .cell { height: 22px; border-radius: 3px; background: var(--panel-2); }

dialog { border: 0; padding: 0; background: none; max-width: min(960px, 94vw); width: 100%; color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; max-height: 90vh; overflow-y: auto; }
.modal-banner { width: 100%; max-height: 160px; object-fit: cover; display: block; }
.modal-head { display: flex; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.modal-head img { width: 48px; height: 48px; border-radius: 10px; }
.modal-head h2 { font-size: 18px; text-transform: none; letter-spacing: 0; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 16px; display: grid; gap: 16px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.info { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.info span { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; }
.info b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; font-size: 11px; }
.list-box { max-height: 300px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; font-size: 12px; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.list-box div { padding: 1px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.chip { color: var(--accent); text-decoration: none; }
a.chip:hover { border-color: var(--accent); }
.list-box .ping { color: var(--muted); }
.modal-chart { height: 200px; position: relative; }
.foot { text-align: center; }
