/* GgPlay Hub — dashboard shell.
   Categorical palette is the validated default (see dataviz reference):
   blue, orange, aqua, yellow, magenta, green — assigned in fixed order,
   never cycled. Every colored mark carries a visible numeric label, which
   is what discharges the sub-3:1 contrast warning on the lighter slots. */

:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --line:      #e2e2dd;
  --line-soft: #eeeeea;

  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #83827c;

  --series-1: #2a78d6;  /* blue    */
  --series-2: #eb6834;  /* orange  */
  --series-3: #1baf7a;  /* aqua    */
  --series-4: #eda100;  /* yellow  */
  --series-5: #e87ba4;  /* magenta */
  --series-6: #008300;  /* green   */

  --good:     #1baf7a;
  --warning:  #eda100;
  --critical: #e34948;
  --idle:     #b8b7b0;

  --radius: 10px;
  --sidebar: 208px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #212120;
    --line:      #33332f;
    --line-soft: #292927;

    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #8d8c83;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;

    --good:     #199e70;
    --warning:  #c98500;
    --critical: #e66767;
    --idle:     #4c4b46;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #212120;
  --line:      #33332f;
  --line-soft: #292927;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #8d8c83;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --good: #199e70; --warning: #c98500; --critical: #e66767; --idle: #4c4b46;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 16px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  background: var(--series-1);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.brand-name { font-weight: 650; letter-spacing: -0.01em; }

nav { display: flex; flex-direction: column; gap: 1px; }
nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px;
  color: var(--text-secondary); text-decoration: none;
  font-size: 13.5px;
}
nav a:hover { background: var(--surface-2); color: var(--text-primary); }
nav a.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
nav a .ico { width: 15px; text-align: center; opacity: .8; font-size: 13px; }
nav a .count {
  margin-left: auto; font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); padding: 16px 9px 5px; font-weight: 600;
}

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: var(--surface-1); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }

.content { padding: 22px 26px 70px; max-width: 1280px; }

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

.page-intro { color: var(--text-secondary); font-size: 13.5px; margin: -4px 0 20px; max-width: 70ch; }

/* ----------------------------------------------------------- components */

.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card > h3 {
  font-size: 13px; margin: 0 0 12px; font-weight: 650;
  letter-spacing: -0.005em;
}
.card > h3 .sub { font-weight: 400; color: var(--text-muted); margin-left: 8px; }

.grid { display: grid; gap: 12px; }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }

/* Stat tile — a hero number is the right form here; no chart needed. */
.tile {
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.tile .n {
  font-size: 27px; font-weight: 650; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.tile .l {
  color: var(--text-muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .055em; margin-top: 3px; font-weight: 600;
}
.tile .hint { color: var(--text-secondary); font-size: 12px; margin-top: 5px; }
.tile.accent .n { color: var(--series-1); }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px; vertical-align: middle;
}
thead th {
  color: var(--text-muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface-1);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-scroll { overflow-x: auto; }

/* Bar mark: 4px rounded data-end, anchored to baseline, always with a
   visible numeric label beside it. */
.bar {
  position: relative; height: 8px; border-radius: 4px;
  background: var(--line); overflow: hidden; min-width: 70px;
}
.bar > i {
  position: absolute; inset: 0 auto 0 0;
  border-radius: 4px; background: var(--series-1);
  display: block;
}
.barrow { display: flex; align-items: center; gap: 9px; }
.barrow .val {
  font-variant-numeric: tabular-nums; font-size: 12px;
  color: var(--text-secondary); min-width: 42px; text-align: right;
}

.pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.p-good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.p-warn { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.p-bad  { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }
.p-info { background: color-mix(in srgb, var(--series-1) 15%, transparent); color: var(--series-1); }
.p-idle { background: color-mix(in srgb, var(--text-muted) 15%, transparent); color: var(--text-muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: block; }

.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.empty { color: var(--text-muted); padding: 26px; text-align: center; font-size: 13px; }
.mono, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
code { background: color-mix(in srgb, var(--text-muted) 14%, transparent); padding: 1px 5px; border-radius: 4px; }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
select, input[type="search"], button {
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 10px; font-size: 12.5px; font-family: inherit;
}
button { cursor: pointer; }
button:hover, select:hover { border-color: var(--series-1); }
label.fld { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

a { color: var(--series-1); }

/* Tooltip on hover for bar marks. */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: calc(100% + 6px);
  background: var(--text-primary); color: var(--surface-1);
  padding: 5px 8px; border-radius: 6px; font-size: 11.5px;
  white-space: nowrap; z-index: 10; pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

@media (max-width: 860px) {
  :root { --sidebar: 60px; }
  .brand-name, nav a span.lbl, nav a .count, .nav-group { display: none; }
  nav a { justify-content: center; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}

/* ---------------------------------------------------- MultiSelect (select2-style) */

.ms { position: relative; min-width: 190px; }

.ms-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 3px 6px; min-height: 30px; cursor: text;
}
.ms-control:focus-within { border-color: var(--series-1); outline: none; }

.ms-chips { display: contents; }

.ms-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--series-1) 15%, transparent);
  color: var(--series-1);
  border-radius: 5px; padding: 1px 4px 1px 7px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  max-width: 100%; overflow: hidden;
}
.ms-x {
  background: none; border: none; padding: 0 2px; cursor: pointer;
  color: inherit; font-size: 14px; line-height: 1; opacity: .65;
  border-radius: 3px;
}
.ms-x:hover { opacity: 1; background: color-mix(in srgb, var(--series-1) 22%, transparent); }

.ms-input {
  flex: 1; min-width: 70px; border: none; background: none; outline: none;
  padding: 3px 2px; font: inherit; font-size: 12.5px; color: var(--text-primary);
}
.ms-input::placeholder { color: var(--text-muted); }

.ms-menu {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 100%; max-width: 340px; max-height: 268px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .16);
}
.ms-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
  white-space: nowrap;
}
.ms-opt.ms-active { background: color-mix(in srgb, var(--series-1) 13%, transparent); }
.ms-opt.ms-on .ms-label { font-weight: 600; }
.ms-tick { width: 11px; color: var(--series-1); font-size: 11px; flex: none; }
.ms-label { overflow: hidden; text-overflow: ellipsis; }
.ms-count { margin-left: auto; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ms-empty { padding: 10px; color: var(--text-muted); font-size: 12px; text-align: center; }

.fld-ms { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

/* --------------------------------------------------------------- auth */
/* .login-card is shared with the standalone /login page (its own document,
   not an overlay on this one — see login.html for why). */

.login-card {
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px 30px; width: min(94vw, 360px);
}
.login-card h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; }
.login-card p.hint { color: var(--text-muted); font-size: 12.5px; margin: 0 0 18px; }
.login-card label { display: block; font-size: 12px; color: var(--text-muted); margin: 0 0 4px; }
.login-card input {
  width: 100%; padding: 8px 10px; margin-bottom: 13px;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 13.5px;
}
.login-card button { width: 100%; padding: 9px; font-weight: 600; font-size: 13.5px; }
.login-err { color: var(--critical); font-size: 12.5px; margin: 4px 0 10px; min-height: 17px; }

.whoami { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.whoami .u { font-weight: 600; }

/* Hide anything the current role cannot use, rather than letting it 403. */
[data-perm].perm-hidden { display: none !important; }

/* ------------------------------------------------------------- gallery */

.thumb {
  width: 36px; height: 36px; border-radius: 8px; display: block;
  background: var(--line); cursor: zoom-in; border: none; padding: 0;
}
.thumb:hover { outline: 2px solid var(--series-1); outline-offset: 1px; }

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .82);
  display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
  padding: 18px 20px 24px;
}
.lightbox[hidden] { display: none; }   /* class display beats UA [hidden] */

.lb-head { display: flex; align-items: baseline; gap: 12px; color: #fff; }
.lb-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.lb-head .meta { color: rgba(255,255,255,.62); font-size: 12.5px; }
.lb-head .spacer { flex: 1; }
.lb-head a { color: #8ec0ff; font-size: 12.5px; }
.lb-close {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 16px;
}
.lb-close:hover { background: rgba(255,255,255,.24); }

/* Horizontal strip: Play screenshots are portrait, so scrolling sideways
   shows more of them at a readable size than a wrapped grid would. */
.lb-strip {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  align-items: center; padding: 4px 2px 14px;
  scroll-snap-type: x mandatory;
}
.lb-strip img {
  height: min(72vh, 720px); width: auto; border-radius: 10px;
  scroll-snap-align: center; background: #111; flex: none;
}
.lb-foot { color: rgba(255,255,255,.55); font-size: 12px; text-align: center; }
