:root {
  --bg: #0b0e14;
  --card: #141922;
  --card-2: #1b2130;
  --line: #262e3f;
  --text: #e6e9ef;
  --muted: #8a93a6;
  --accent: #f0b90b;
  --green: #16c784;
  --red: #ea3943;
  --blue: #3b82f6;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--red); min-height: 1em; }
.pos { color: var(--green); }
.neg { color: var(--red); }
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 16px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11, 14, 20, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--accent); }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
.view { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two { grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1000px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.pill { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card-2); }
.pill.running { background: rgba(22, 199, 132, .15); color: var(--green); }
.pill.paused, .pill.dry { background: rgba(240, 185, 11, .15); color: var(--accent); }
.pill.stopped, .pill.offline { background: rgba(234, 57, 67, .15); color: var(--red); }

.banner { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; background: rgba(240, 185, 11, .12); color: var(--accent); border: 1px solid rgba(240, 185, 11, .3); }
.banner.danger { background: rgba(234, 57, 67, .12); color: var(--red); border-color: rgba(234, 57, 67, .3); }

dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

canvas { width: 100%; display: block; }
.seg { display: flex; background: var(--card-2); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.seg button.active { background: var(--line); color: var(--text); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.tag.long { background: rgba(22, 199, 132, .15); color: var(--green); }
.tag.short { background: rgba(234, 57, 67, .15); color: var(--red); }
.tag.dry { background: rgba(240, 185, 11, .15); color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.filter { max-width: 220px; padding: 8px 10px; font-size: 14px; }

/* buttons & settings */
.btn { background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.danger { color: var(--red); border-color: rgba(234, 57, 67, .4); }
.btn.ghost { background: none; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.settings { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .settings { grid-template-columns: 1fr 1fr; } }
.settings .help { font-size: 12px; color: var(--muted); }
.settings .toggle { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.settings .toggle input { width: 22px; height: 22px; }
.settings .actions { grid-column: 1 / -1; }

/* bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20, 25, 34, .97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { background: none; border: 0; color: var(--muted); padding: 9px 2px 10px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 18px; }
.tabs button.active { color: var(--accent); }
