:root { --bg:#0f1420; --card:#1a2233; --panel:#141b29; --fg:#e6ecff; --mut:#8fa0c0; --acc:#4f8cff; --ok:#37d67a; --warnc:#f0b429; --err:#ff5c6c; --line:#263049; }
* { box-sizing: border-box; }
body { margin:0; font:15px/1.5 system-ui,Segoe UI,Roboto,sans-serif; background:var(--bg); color:var(--fg); }
header { padding:14px 24px; background:var(--card); display:flex; align-items:center; gap:12px; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10; }
header h1 { font-size:17px; margin:0; }
header .tag { font-size:12px; color:var(--mut); border:1px solid #2c3a5a; padding:2px 8px; border-radius:99px; }
.spacer { flex:1; }
#who { color:var(--mut); font-size:13px; }

.layout { display:flex; align-items:flex-start; gap:0; min-height:calc(100vh - 57px); }
.sidebar { width:210px; flex:none; background:var(--panel); border-right:1px solid var(--line); padding:14px 10px; position:sticky; top:57px; height:calc(100vh - 57px); }
.nav { display:flex; flex-direction:column; gap:2px; }
.nav button { text-align:left; background:transparent; border:none; color:var(--mut); padding:10px 14px; border-radius:8px; cursor:pointer; font-size:14px; }
.nav button:hover { background:#1c2436; color:var(--fg); filter:none; }
.nav button.active { background:var(--acc); color:#fff; }
main { flex:1; padding:22px 26px; max-width:1100px; }

.card { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:20px; margin-bottom:18px; }
.card h2 { margin:0 0 4px; font-size:16px; }
.card h3 { margin:16px 0 6px; font-size:13px; color:var(--mut); text-transform:uppercase; letter-spacing:.05em; }
.card .sub { color:var(--mut); font-size:13px; margin-bottom:14px; }

.view { display:none; }
.view.active { display:block; }

.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:14px; margin-bottom:18px; }
.stat { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 18px; }
.stat .n { font-size:28px; font-weight:700; }
.stat .l { color:var(--mut); font-size:12px; text-transform:uppercase; letter-spacing:.05em; margin-top:4px; }

input,select,button { font:inherit; padding:9px 12px; border-radius:8px; border:1px solid #2c3a5a; background:#0d1220; color:var(--fg); }
button { background:var(--acc); border-color:var(--acc); color:#fff; cursor:pointer; }
button.ghost { background:transparent; color:var(--fg); }
button.sm { padding:5px 10px; font-size:12px; }
button:hover { filter:brightness(1.1); }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
.chip { display:inline-block; background:#0d1220; border:1px solid #2c3a5a; color:var(--acc); padding:3px 10px; border-radius:99px; margin:2px; font-size:12px; }
.chip.ok { color:var(--ok); border-color:#1f5a3a; }
.chip.warn { color:var(--warnc); border-color:#5a4a1f; }
.chip.bad { color:var(--err); border-color:#5a2c2c; }
.muted { color:var(--mut); font-size:13px; }

#flash { min-height:20px; font-size:13px; margin-bottom:8px; }
#flash.ok { color:var(--ok); } #flash.err { color:var(--err); }
table { width:100%; border-collapse:collapse; font-size:13px; }
th,td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
th { color:var(--mut); font-weight:600; }
tbody tr:hover { background:#151d2c; }
tr.clickable { cursor:pointer; }
select[multiple] { min-height:120px; }
.mono { font-family:ui-monospace,Menlo,monospace; font-size:12px; color:var(--mut); }

#login { max-width:360px; margin:60px auto; }

#loginError { color:var(--err); min-height:18px; margin-bottom:10px; }

/* Above the modal layer (60), not below it: the ban button and the mute button now live INSIDE a modal, and a
   confirmation drawn underneath the thing that raised it is a dialog nobody can answer. */
.confirm-backdrop { position:fixed; inset:0; z-index:70; display:flex; align-items:center; justify-content:center; background:rgba(6,10,18,.62); }
.confirm { max-width:460px; margin:0; box-shadow:0 18px 48px rgba(0,0,0,.45); }
.confirm h3 { margin:0 0 6px; font-size:16px; color:var(--fg); text-transform:none; letter-spacing:0; }
.confirm .sub { margin-bottom:14px; }
.confirm .confirm-actions { justify-content:flex-end; margin-bottom:0; }
.confirm input { width:100%; }
button.danger { background:var(--err); border-color:var(--err); color:#2a0b0f; font-weight:600; }
button.danger[disabled] { opacity:.4; cursor:not-allowed; filter:none; }

/* Metrics area: a sub-navigation inside one view, plus cards that can say "not measured". */
.metrics-bar { display:flex; gap:10px; flex-wrap:wrap; align-items:center; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px 16px; margin-bottom:14px; }
.metrics-bar .grow { flex:1; }
.metrics-bar label { color:var(--mut); font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.subnav { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:16px; border-bottom:1px solid var(--line); }
.subnav button { background:transparent; border:none; border-bottom:2px solid transparent; color:var(--mut); border-radius:8px 8px 0 0; padding:9px 14px; cursor:pointer; font-size:14px; }
.subnav button:hover { background:#1c2436; color:var(--fg); filter:none; }
.subnav button.active { color:var(--fg); border-bottom-color:var(--acc); background:transparent; }
.subview { display:none; }
.subview.active { display:block; }

.stat .delta { font-size:12px; margin-top:6px; }
.stat .delta.up { color:var(--ok); }
.stat .delta.down { color:var(--err); }
.stat .delta.flat { color:var(--mut); }
.stat .src { font-size:11px; color:var(--mut); margin-top:4px; opacity:.85; }
.donut-wrap { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
.legend-list { display:flex; flex-direction:column; gap:6px; }
.legend { font-size:13px; color:var(--mut); display:flex; align-items:center; gap:8px; }
.legend i { width:12px; height:12px; border-radius:3px; display:inline-block; }
.funnel-drop { color:var(--mut); font-size:12px; }
.rowlink { cursor:pointer; }
.rowlink:hover td { background:var(--line); }
tr.rowlink.sel td { background:var(--line); }
.stat .note { color:var(--mut); font-size:11px; margin-top:6px; line-height:1.35; }
.stat.missing .n { color:var(--mut); font-size:20px; font-weight:600; }
.stat.partial { border-color:#5a4a1f; }
.stat.alarm { border-color:var(--err); }
.stat.alarm .n { color:var(--err); }
.stat .spark { margin-top:10px; display:block; width:100%; height:34px; }

.freshness { color:var(--mut); font-size:12px; margin-bottom:12px; display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.badge { display:inline-block; padding:2px 8px; border-radius:99px; font-size:11px; border:1px solid #2c3a5a; }
.badge.warn { color:var(--warnc); border-color:#5a4a1f; }
.badge.info { color:var(--mut); }

.chart { width:100%; height:180px; display:block; }
.chart-legend { display:flex; gap:14px; flex-wrap:wrap; color:var(--mut); font-size:12px; margin-top:8px; }
.chart-legend i { display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:6px; }
.bar-track { background:#0d1220; border-radius:4px; height:8px; overflow:hidden; min-width:80px; }
.bar-fill { background:var(--acc); height:100%; display:block; }

/* ---------------------------------------------------------------------------------------------------
   Modals. Every edit form and every detail view opens here instead of unfolding at the bottom of the
   page: on a list of a hundred items the "edit" click used to scroll the operator away from the row they
   clicked, and the form they were typing into was a page-length away from the table it changed.

   A form is not re-implemented for the modal — the section is MOVED into it and moved back on close, so
   its ids, its listeners and the permission gating it already carries keep working unchanged. That is
   what .modal-source is for: hidden in the page, shown only while it is inside a modal, and still hidden
   there when permission gating has hidden it. */
.modal-backdrop { position:fixed; inset:0; z-index:60; display:flex; align-items:flex-start; justify-content:center;
  background:rgba(6,10,18,.66); padding:40px 20px; overflow-y:auto; }
.modal { width:min(920px,100%); margin:0; padding:0; box-shadow:0 24px 64px rgba(0,0,0,.5); max-height:none; }
.modal-head { display:flex; align-items:center; gap:12px; padding:16px 20px; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:var(--card); border-radius:12px 12px 0 0; z-index:1; }
.modal-title { margin:0; font-size:16px; flex:1; overflow-wrap:anywhere; }
.modal-close { background:transparent; border-color:#2c3a5a; color:var(--mut); }
.modal-body { padding:18px 20px 20px; }
.modal-body > .card { background:transparent; border:none; padding:0; margin:0; }
/* The modal's own head already names what is open, so the section's own first heading would say it twice. */
.modal-body > .card > h2:first-child,
.modal-body > .modal-source > h3:first-child { display:none; }
.modal-source { display:none !important; }
.modal-body > .modal-source { display:block !important; }
.modal-body > .modal-source[hidden] { display:none !important; }
.modal-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:flex-end;
  border-top:1px solid var(--line); margin-top:16px; padding-top:14px; }
.modal-actions .grow { flex:1; }
.kv { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:10px 18px; margin-bottom:6px; }
.kv div { min-width:0; }
.kv .k { color:var(--mut); font-size:11px; text-transform:uppercase; letter-spacing:.05em; }
.kv .v { font-size:14px; overflow-wrap:anywhere; }
.quote { background:#0d1220; border:1px solid var(--line); border-radius:8px; padding:12px 14px; margin:12px 0;
  white-space:pre-wrap; overflow-wrap:anywhere; }
.rank { font-weight:700; color:var(--warnc); }

/* ---------------------------------------------------------------------------------------------------
   Long values. A card is ~190px wide and a platform-wide coin total is sixteen characters, so the number
   that mattered most was the one that ran out of its own box. The width never grows to fit — the shrink
   steps and the wrap below are what keep a figure inside the card that is supposed to state it. */
.grid > * { min-width:0; }
.stat { min-width:0; overflow:hidden; }
.stat .n { overflow-wrap:anywhere; line-height:1.15; }
.stat .n.long { font-size:22px; }
.stat .n.xlong { font-size:18px; }
.stat .l, .stat .note, .stat .src, .stat .delta { overflow-wrap:anywhere; }
/* break-word, NOT anywhere: `anywhere` also shrinks a cell's min-content width, which let a column narrow
   until "filtered" was drawn down the page one syllable per line. This breaks a word only when it genuinely
   does not fit, and leaves column sizing alone. */
th, td { overflow-wrap:break-word; }
/* Free text a player typed, which is under nobody's control: one 300-character word with no spaces in it
   stretched the chat table to 2772px inside a 1046px card and put a horizontal scrollbar on the whole
   console. This is the one place `anywhere` is right — the column may shrink, because the alternative is a
   column that cannot. */
td.txt { overflow-wrap:anywhere; }
/* A last line of defence for the tables that still cannot fit: they scroll inside their own card rather than
   dragging the page sideways with them. */
.card { overflow-x:auto; }
