:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e8e9ed;
  --line-soft: #f0f1f4;
  --text: #15161a;
  --muted: #7b7f8a;
  --side: #17181c;
  --side-active: #2a2c33;
  --side-text: #c9cbd2;
  --pos: #1f8a4c;
  --pos-bg: #e6f4ec;
  --neg: #c8372d;
  --bar: #c9d7f5;
  --bar-hot: #1f6feb;
  --warn-bg: #fff3dc;
  --warn: #9a5b00;
  --info-bg: #e6eefc;
  --info: #1f4fae;
  --err-bg: #fde8e6;
  --tile: #f4f5f7;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: #fff; color: var(--side); font-weight: 800; font-size: 17px;
}

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: var(--radius);
  padding: 28px; display: grid; gap: 14px;
}
.login-card .brand-mark { background: var(--side); color: #fff; }

/* shell */
.shell { display: grid; grid-template-columns: 206px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 9px; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--side-text); text-decoration: none; font-weight: 500; cursor: pointer;
}
.nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: #22242a; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav a.disabled { opacity: .45; cursor: default; }
.nav a.disabled:hover { background: none; color: var(--side-text); }
.nav a em { margin-left: auto; font-style: normal; font-size: 11px; color: #8a8d96; }
.sidebar-foot { margin-top: auto; padding: 0 9px; color: #8a8d96; font-size: 12px; display: grid; gap: 8px; }
.link-btn { background: none; border: 0; padding: 0; color: #8a8d96; text-align: left; cursor: pointer; text-decoration: underline; }

.main { padding: 26px 28px 40px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 21px; margin: 0; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 14px; font-weight: 600; }
h3.mt { margin-top: 24px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.seg { display: inline-flex; background: #e9eaee; border-radius: 11px; padding: 4px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 7px 16px; border-radius: 8px; cursor: pointer; color: #4a4d56; font-weight: 500;
}
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

.btn { border: 0; border-radius: 11px; padding: 11px 18px; font-weight: 600; cursor: pointer; }
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover { background: #2b2d33; }
.btn-light { background: #eceef1; }
.btn-light:hover { background: #e2e4e8; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 338px; gap: 20px; align-items: start; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.col { display: grid; gap: 20px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }

.label { color: #4a4d56; font-size: 13px; margin-bottom: 4px; }
.profit-row { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.profit { padding-right: 28px; border-right: 1px solid var(--line); }
.big { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 8px; }
.pill { display: inline-block; font-size: 12px; border-radius: 6px; padding: 3px 8px; background: var(--tile); color: var(--muted); }
.pill b { font-weight: 700; }
.pill.up { background: var(--pos-bg); color: #3d6b50; }
.pill.up b { color: var(--pos); }
.pill.down { background: var(--err-bg); color: #8b3a33; }
.pill.down b { color: var(--neg); }
.breakdown { display: flex; gap: 26px; flex-wrap: wrap; }
.num { font-size: 18px; font-weight: 700; white-space: nowrap; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.divider { height: 1px; background: var(--line); margin: 20px 0; }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 0 4px; position: relative; }
.chart .bar-wrap { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; position: relative; }
.chart .bar { width: 100%; max-width: 40px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.hot { background: var(--bar-hot); }
.chart .bar.negative { background: #f3c7c3; border-radius: 0 0 4px 4px; }
.chart .bar-label { font-size: 11px; font-weight: 700; margin-bottom: 4px; white-space: nowrap; }
.chart .tick { font-size: 11px; color: var(--muted); margin-top: 8px; height: 14px; white-space: nowrap; }
.chart .bars-area { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid var(--line); }
.chart-empty { color: var(--muted); font-size: 13px; align-self: center; margin: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .r { text-align: right; }
.table td.b { font-weight: 700; }
.table td.muted, .muted { color: var(--muted); }
.table.ops td.details { white-space: normal; max-width: 280px; color: var(--muted); font-size: 13px; }
.row-actions button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; text-decoration: underline; }
.card:has(.table) { overflow-x: auto; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--tile); border-radius: 10px; padding: 12px 10px; min-width: 0; }
.tile .label { font-size: 12px; }
.tile .num { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }

.alerts { display: grid; gap: 10px; }
.alert { border-radius: 10px; padding: 11px 12px; font-size: 13px; }
.alert b { display: block; font-weight: 600; }
.alert.warn { background: var(--warn-bg); color: #6b4a12; }
.alert.warn b { color: var(--warn); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.error { background: var(--err-bg); color: #7a2b24; }
.alert.error b { color: var(--neg); }
.alert.ok { background: var(--tile); color: var(--muted); }

.feed { display: grid; }
.feed-item > div { min-width: 0; }
.feed-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .time { color: var(--muted); font-size: 13px; }
.feed-item .title { font-weight: 600; }
.feed-item .meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .amount { font-weight: 700; white-space: nowrap; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
select, input {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; min-width: 0;
}
input:focus, select:focus { outline: 2px solid #bcd0fb; border-color: var(--bar-hot); }
label { display: grid; gap: 6px; font-size: 13px; color: #4a4d56; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.more { margin-top: 14px; width: 100%; }
.form-error { color: var(--neg); margin: 0; min-height: 1em; font-size: 13px; }
.form-ok { color: var(--pos); margin: 0 0 10px; min-height: 1em; font-size: 13px; }

/* bots / ads pages */
.metrics { display: grid; }
.metric { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.metric:last-child { border-bottom: 0; }
.metric .name { font-weight: 500; }
.metric .value { font-weight: 700; text-align: right; white-space: nowrap; }
.metric .why { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 2px 7px; font-weight: 600; }
.tag.yes { background: var(--pos-bg); color: var(--pos); }
.tag.no { background: var(--err-bg); color: var(--neg); }
.tag.wait { background: var(--tile); color: var(--muted); }
.head-actions select { min-width: 170px; }

/* server page */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat .num { font-size: 22px; margin-top: 2px; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.meter { height: 6px; background: var(--line-soft); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--bar-hot); border-radius: 3px; }
.meter i.warn { background: #e0a100; }
.meter i.crit { background: var(--neg); }
.mt-card { margin-top: 20px; }
.table th.check, .table td.check { width: 28px; }
.state { display: inline-flex; align-items: center; gap: 6px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.online::before { background: var(--pos); }
.state.down::before { background: var(--neg); }
.state.down { color: var(--neg); font-weight: 600; }
.btn-sm { padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.restart-msg { font-size: 12px; color: var(--muted); }
@media (max-width: 1000px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 16, 20, .45); }
.dialog { padding: 22px; display: grid; gap: 14px; }
.dialog h3 { margin: 0; font-size: 16px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (max-width: 1180px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .nav a em, .nav a.disabled { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .main { padding: 18px 16px 32px; }
  .grid.two { grid-template-columns: 1fr; }
  .profit { border-right: 0; padding-right: 0; }
  .big { font-size: 32px; }
  .seg button { padding: 7px 10px; }
}
