:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --line: #262e39;
  --text: #e6edf3;
  --dim: #8b98a8;
  --accent: #3fb950;
  --accent-dim: #1f6f2c;
  --blue: #4a9eff;
  --amber: #d29922;
  --red: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- layout */
header.top {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand span { color: var(--accent); }
nav.tabs { display: flex; gap: 4px; flex: 1; }
nav.tabs a {
  padding: 7px 13px;
  border-radius: 7px;
  color: var(--dim);
  font-weight: 500;
}
nav.tabs a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
nav.tabs a.on { background: var(--panel-2); color: var(--text); }
.top .meta { color: var(--dim); font-size: 12px; text-align: right; }

main { max-width: 1240px; margin: 0 auto; padding: 22px; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.sub { color: var(--dim); font-size: 13px; margin: 0 0 18px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.row > * { min-width: 0; }
.grow { flex: 1; }

/* -------------------------------------------------------------- panels */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card.tight { padding: 0; overflow: hidden; }
.card h2 { display: flex; align-items: center; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.15; }
.stat .l { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat.good .n { color: var(--accent); }
.stat.warn .n { color: var(--amber); }

/* -------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { max-height: 460px; overflow: auto; }

code, .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* --------------------------------------------------------------- chips */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--dim);
}
.chip.on { color: var(--accent); border-color: var(--accent-dim); background: rgba(63,185,80,.08); }
.chip.off { color: var(--dim); }
.chip.err { color: var(--red); border-color: #612; background: rgba(248,81,73,.08); }
.chip.info { color: var(--blue); border-color: #1d3c5c; background: rgba(74,158,255,.08); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: #3a4553; text-decoration: none; }
.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #eafbee; }
.btn.primary:hover { background: #268036; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* --------------------------------------------------------------- forms */
label { display: block; margin-bottom: 5px; color: var(--dim); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
textarea { resize: vertical; min-height: 62px; }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.inline { display: flex; gap: 8px; align-items: center; }
.hint { color: var(--dim); font-size: 12px; margin-top: 4px; text-transform: none; letter-spacing: 0; font-weight: 400; }

.switch { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; text-transform: none; letter-spacing: 0; }
.switch input { width: auto; }

/* -------------------------------------------------------------- picker */
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .picker { grid-template-columns: 1fr; } }
.picker .box { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.picker .box header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.picker .box header b { font-size: 13px; }
.picker .list { max-height: 330px; overflow: auto; }
.opt { display: flex; align-items: center; gap: 10px; padding: 7px 13px; border-bottom: 1px solid rgba(38,46,57,.6); cursor: pointer; }
.opt:hover { background: var(--panel); }
.opt input { width: auto; }
.opt .name { flex: 1; }
.opt .meta { color: var(--dim); font-size: 12px; }
.opt.hidden { display: none; }
.picker .search { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.picker .search input { padding: 6px 10px; }

.preview {
  display: flex; gap: 18px; align-items: center;
  padding: 11px 14px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); margin-top: 14px;
}
.preview b { font-size: 18px; }

/* ------------------------------------------------------------- flashes */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--line); }
.flash.ok { border-color: var(--accent-dim); background: rgba(63,185,80,.1); }
.flash.error { border-color: #612; background: rgba(248,81,73,.1); }

/* --------------------------------------------------------------- login */
.login-wrap { max-width: 380px; margin: 90px auto; }
.login-wrap .card { padding: 26px; }

.endpoint {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px;
}
.endpoint .l { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.endpoint .v { display: flex; align-items: center; gap: 8px; }
.endpoint .v code { flex: 1; word-break: break-all; }

.empty { color: var(--dim); padding: 26px; text-align: center; }

/* --------------------------------------------------------------- charts */
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.legend { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; }
.legend i.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.legend .sw.down { background: var(--accent); }
.legend .sw.up { background: var(--blue); }

.chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 148px; padding: 16px 18px 8px;
}
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 4px; }
.chart .stack {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 3px 3px 0 0; overflow: hidden;
  background: linear-gradient(var(--panel-2), var(--panel-2)) bottom / 100% 2px no-repeat;
}
.chart .bar { width: 100%; min-height: 0; }
.chart .bar.down { background: var(--accent); }
.chart .bar.up { background: var(--blue); }
.chart .col:hover .bar.down { background: #57d268; }
.chart .col:hover .bar.up { background: #6fb2ff; }
.chart-axis {
  display: flex; justify-content: space-between;
  padding: 0 18px 14px; color: var(--dim); font-size: 11px;
}

/* ---------------------------------------------------------- cap meters */
.meter {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line); margin-top: 4px;
}
.meter .fill { height: 100%; background: var(--accent); }
.meter .fill.over { background: var(--red); }
