/* LagCore Hub design system.
 *
 * Dark only. This is a tool that gets left open on a second monitor next to a console, and
 * a light theme nobody asked for is a light theme at three in the morning.
 *
 * Two rules the rest of the file follows. Colour carries one meaning, severity, so an orange
 * number means the same thing everywhere it appears and nothing else is tinted for
 * decoration. And every figure is monospaced and tabular, because a column that shifts while
 * it updates is a column nobody can read at a glance.
 */

:root {
  --bg:        #0b0e14;
  --surface:   #121722;
  --surface-2: #19202e;
  --surface-3: #212a3b;
  --line:      #232c3d;
  --line-soft: #1a2130;

  --text:       #e3e9f2;
  --text-dim:   #94a1b8;
  --text-faint: #5f6c82;

  --accent:      #5b9dff;
  --accent-soft: #1d3a63;

  /* Severity. The only colours that carry meaning. */
  --ok:   #3fb950;
  --good: #86c440;
  --warn: #d9a12c;
  --high: #ef7d38;
  --crit: #f0503a;
  --dead: #4b5566;

  /* Map ramp, a separate scale so a dark country cannot be misread as a critical one. */
  --map-empty: #161d2a;
  --map-1: #123049;
  --map-2: #14496b;
  --map-3: #1a6791;
  --map-4: #2c8cb4;
  --map-5: #52bcd6;
  --map-stroke: #0b0e14;

  --r-sm: 5px;
  --r-md: 8px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --sidebar: 212px;
  --header: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* --- shell --------------------------------------------------------------- */

#shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: var(--header) 1fr;
  grid-template-areas: "brand header" "nav main";
  min-height: 100vh;
}

#brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  letter-spacing: 0.2px;
  color: var(--text);
}
#brand:hover { text-decoration: none; }
#brand .mark { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); flex: none; }

#topbar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

#crumbs { font-size: 13px; color: var(--text-dim); min-width: 0; }
#crumbs a { color: var(--text-dim); }
#crumbs a:hover { color: var(--accent); }
#crumbs .sep { color: var(--text-faint); margin: 0 7px; }
#crumbs strong { color: var(--text); font-weight: 600; }

#who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
#tick { color: var(--text-faint); font-size: 11.5px; font-family: var(--mono); min-width: 26px; text-align: right; }

#nav {
  grid-area: nav;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 12px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
#nav .nav-group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}
#nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 13.5px;
}
#nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
#nav a.on { background: var(--accent-soft); color: #cfe2ff; }
#nav a .ico { width: 15px; text-align: center; flex: none; opacity: 0.9; }
#nav .grow { flex: 1; }
#nav .foot { font-size: 11px; color: var(--text-faint); padding: 10px; line-height: 1.5; }

#main { grid-area: main; padding: 20px 24px 60px; min-width: 0; }

@media (max-width: 880px) {
  #shell { grid-template-columns: 1fr; grid-template-areas: "brand" "header" "main"; }
  #nav { display: none; }
  #main { padding: 16px; }
}

/* --- headings and containers --------------------------------------------- */

.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 19px; letter-spacing: -0.2px; }
.page-head .sub { font-size: 13px; color: var(--text-dim); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel > h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.panel > h3 .right { margin-left: auto; text-transform: none; letter-spacing: 0; }

.grid2 { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1150px) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* --- controls ------------------------------------------------------------ */

button, select, input[type=text], input[type=number] {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 10px;
}
button { cursor: pointer; }
button:hover, select:hover { border-color: var(--text-faint); }
input:focus, select:focus, button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #05152e; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--crit); border-color: #4a2320; background: #2a1613; }
button.danger:hover { background: #3a1c18; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.small { padding: 3px 8px; font-size: 12px; }

.tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 7px;
  white-space: nowrap;
}
.tag.role { text-transform: capitalize; }
.tag.ok { color: var(--ok); border-color: #1d3a24; background: #10200f; }
.tag.warn { color: var(--warn); border-color: #423318; background: #221b0d; }
.tag.crit { color: var(--crit); border-color: #4a2320; background: #2a1613; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dead); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.14); }

.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--r-md);
  padding: 13px 16px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.notice.bad { border-left-color: var(--crit); }
.notice.good { border-left-color: var(--ok); }
.notice strong { display: block; margin-bottom: 3px; }
.notice p { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }

.center { max-width: 440px; margin: 16vh auto; text-align: center; }
.center h1 { font-size: 21px; margin-bottom: 10px; }
.center p { color: var(--text-dim); margin: 0 0 20px; }

/* --- stat strip ---------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--text-faint); margin-bottom: 6px; }
.stat .v { font-family: var(--mono); font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--text-dim); margin-left: 4px; font-family: var(--sans); }
.stat.sev-ok .v { color: var(--ok); }
.stat.sev-good .v { color: var(--good); }
.stat.sev-warn .v { color: var(--warn); }
.stat.sev-high .v { color: var(--high); }
.stat.sev-crit .v { color: var(--crit); }

/* --- server cards -------------------------------------------------------- */

.group { margin-bottom: 24px; }
.group > h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.group > h2 .count { text-transform: none; letter-spacing: 0; font-weight: 400; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.srv {
  display: block;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px 12px;
  color: inherit;
  overflow: hidden;
}
.srv::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--dead); }
.srv:hover { text-decoration: none; border-color: var(--text-faint); background: var(--surface-2); }
.srv.sev-ok::before { background: var(--ok); }
.srv.sev-good::before { background: var(--good); }
.srv.sev-warn::before { background: var(--warn); }
.srv.sev-high::before { background: var(--high); }
.srv.sev-crit::before { background: var(--crit); }
.srv.sev-off { opacity: 0.55; }

.srv .name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.srv .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv .sub { color: var(--text-faint); font-size: 11.5px; margin: 1px 0 10px; }
.srv .big { font-family: var(--mono); font-size: 25px; line-height: 1; font-variant-numeric: tabular-nums; }
.srv .big u { text-decoration: none; font-size: 11px; color: var(--text-dim); margin-left: 4px; font-family: var(--sans); }
.srv .foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* --- charts -------------------------------------------------------------- */

.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1px; }
.chart-head .label { font-size: 11.5px; color: var(--text-dim); }
.chart-head .now { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: 118px; display: block; margin-bottom: 10px; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.chart .area { fill: var(--accent); opacity: 0.09; }
.chart text { fill: var(--text-faint); font-size: 9.5px; font-family: var(--mono); }

/* --- timeline ------------------------------------------------------------ */

.events { list-style: none; margin: 0; padding: 0; }
.events li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  padding: 8px 0 8px 9px;
  border-top: 1px solid var(--line-soft);
  border-left: 2px solid var(--line);
  font-size: 13px;
}
.events li:first-child { border-top: none; }
.events li.sev-warning { border-left-color: var(--warn); }
.events li.sev-high { border-left-color: var(--high); }
.events li.sev-critical { border-left-color: var(--crit); }
.events time { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
.events .what { font-weight: 550; }
.events .detail { color: var(--text-dim); font-size: 11.5px; font-family: var(--mono); word-break: break-word; }
.events .where { color: var(--text-faint); font-size: 11.5px; }

/* --- tables -------------------------------------------------------------- */

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid var(--line);
  padding: 6px 14px 6px 0;
  white-space: nowrap;
}
table.grid td {
  padding: 7px 14px 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
table.grid td.txt { font-family: var(--sans); font-size: 13px; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid td.right, table.grid th.right { text-align: right; padding-right: 0; }

/* --- panel navigation ---------------------------------------------------- */

.panel-layout { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .panel-layout { grid-template-columns: 1fr; } }

.panel-nav { display: flex; flex-direction: column; gap: 1px; }
.panel-nav .h {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  padding: 13px 8px 5px;
}
.panel-nav .h:first-child { padding-top: 0; }
.panel-nav button {
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  color: var(--text-dim);
  padding: 5px 9px;
  font-size: 13px;
  border-radius: var(--r-sm);
}
.panel-nav button:hover { background: var(--surface-2); color: var(--text); }
.panel-nav button.on { background: var(--accent-soft); color: #cfe2ff; }

.panel-body { min-height: 120px; overflow-x: auto; }
.panel-body > p:first-child { margin-top: 0; }

.tree { margin: 3px 0; }
.tree > summary { cursor: pointer; color: var(--text); font-size: 13px; padding: 3px 0; }
.tree > summary:hover { color: var(--accent); }
.tree > summary::marker { color: var(--text-faint); }
.tree-list { list-style: none; margin: 4px 0 4px 14px; padding: 0; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 16px; font-size: 13px; align-items: baseline; }
.kv dt { color: var(--text-dim); white-space: nowrap; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
.kv dt.full { grid-column: 1 / -1; }

pre.console {
  margin: 0;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- bar lists ----------------------------------------------------------- */

.bars { list-style: none; margin: 0; padding: 0; }
.bars li {
  display: grid;
  grid-template-columns: 22px minmax(90px, 1fr) minmax(70px, 2fr) 56px 52px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
}
.bars .flag { font-size: 15px; line-height: 1; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { background: var(--surface-2); border-radius: 3px; height: 7px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--map-4); }
.bars .n, .bars .p { font-family: var(--mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.bars .p { color: var(--text-dim); }

/* --- world map ----------------------------------------------------------- */

.worldmap { width: 100%; height: auto; display: block; margin-bottom: 14px; }
.worldmap .country { stroke: var(--map-stroke); stroke-width: 0.4; }
.worldmap .pin { fill: var(--map-5); stroke: var(--map-stroke); stroke-width: 0.8; }
.worldmap .pin:hover, .worldmap .country.has:hover { fill: var(--accent); }

.legend { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-faint); }
.legend i { width: 22px; height: 8px; border-radius: 2px; display: block; }

/* --- admin --------------------------------------------------------------- */

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-bottom: 10px; }
.form-row input, .form-row select { width: 100%; }

.secret {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  word-break: break-all;
  user-select: all;
  margin: 8px 0 4px;
}
