/* ============================================================================
   Palworld Dashboard — design system
   Palette from the validated data-viz reference (dark-first, theme-aware).
   ========================================================================== */
:root {
  --bg:            #0d0d0d;
  --surface-1:     #1a1a19;
  --surface-2:     #201f1e;
  --surface-3:     #272624;
  --inset:         #141413;
  --border:        rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --text:          #ffffff;
  --text-2:        #c3c2b7;
  --muted:         #8f8d86;
  --grid:          #2c2c2a;
  --axis:          #383835;

  --series-1: #3987e5;  /* blue  */
  --series-2: #199e70;  /* aqua  */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --accent:   #3987e5;
  --accent-2: #5598e7;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:#f4f3ef; --surface-1:#ffffff; --surface-2:#faf9f6; --surface-3:#f0efea;
    --inset:#f6f5f1; --border:rgba(11,11,11,.10); --border-strong:rgba(11,11,11,.16);
    --text:#0b0b0b; --text-2:#52514e; --muted:#77756f; --grid:#e6e5df; --axis:#c9c8c0;
    --series-1:#2a78d6; --series-2:#1baf7a; --accent:#2a78d6; --accent-2:#256abf;
    --shadow:0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  }
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(57,135,229,.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(25,158,112,.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
::selection { background: rgba(57,135,229,.35); }
a { color: var(--accent-2); text-decoration: none; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---- app frame --------------------------------------------------------- */
.app { max-width: 1360px; margin: 0 auto; padding: 22px clamp(14px,3vw,34px) 60px; }

.topbar {
  display:flex; align-items:center; gap:18px; flex-wrap:wrap;
  padding: 14px 18px; margin-bottom: 20px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand { display:flex; align-items:center; gap:14px; min-width:0; }
.logo {
  width:42px; height:42px; border-radius:12px; flex:none;
  display:grid; place-items:center; font-size:22px;
  background: radial-gradient(circle at 30% 25%, #2b6fc4, #143a6b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 4px 14px rgba(41,111,196,.35);
}
.brand-txt { min-width:0; }
.brand-txt h1 {
  margin:0; font-size:17px; font-weight:650; letter-spacing:.2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:44vw;
}
.brand-sub { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12px; margin-top:2px; }
.chip {
  display:inline-flex; align-items:center; gap:6px;
  padding:2px 9px; border-radius:999px; font-size:11.5px; font-weight:600;
  background: var(--surface-3); color: var(--text-2); border:1px solid var(--border);
}
.chip.src { text-transform:uppercase; letter-spacing:.4px; }
.spacer { flex:1 1 auto; }

.status-pill {
  display:inline-flex; align-items:center; gap:9px;
  padding:8px 15px; border-radius:999px; font-weight:650; font-size:13px;
  border:1px solid var(--border);
}
.status-pill.up    { background: rgba(12,163,12,.12);  color:#3ddc5f; border-color: rgba(12,163,12,.35); }
.status-pill.down  { background: rgba(208,59,59,.12);  color:#ff6b6b; border-color: rgba(208,59,59,.35); }
.dot { width:9px; height:9px; border-radius:50%; flex:none; }
.dot.up   { background:#2fe25a; box-shadow:0 0 0 0 rgba(47,226,90,.7); animation: pulse 2s infinite; }
.dot.down { background:#ff5252; }
@keyframes pulse {
  0%{box-shadow:0 0 0 0 rgba(47,226,90,.55);} 70%{box-shadow:0 0 0 8px rgba(47,226,90,0);} 100%{box-shadow:0 0 0 0 rgba(47,226,90,0);}
}
.topmeta { display:flex; align-items:center; gap:16px; color:var(--muted); font-size:12px; }
.topmeta b { color:var(--text-2); font-weight:600; }

/* ---- KPI strip --------------------------------------------------------- */
.kpis {
  display:grid; grid-template-columns: repeat(6, 1fr); gap:14px; margin-bottom:20px;
}
.kpi {
  position:relative; overflow:hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border:1px solid var(--border); border-radius: var(--radius);
  padding:15px 16px; box-shadow: var(--shadow); min-height:104px;
}
.kpi .k-label { color:var(--muted); font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; }
.kpi .k-val { font-size:28px; font-weight:700; letter-spacing:-.5px; margin-top:6px; line-height:1.05; }
.kpi .k-val small { font-size:15px; font-weight:600; color:var(--muted); }
.kpi .k-foot { color:var(--muted); font-size:11.5px; margin-top:4px; }
.kpi .k-foot .up   { color:#3ddc5f; }
.kpi .k-foot .down { color:#ff6b6b; }
.kpi .spark { position:absolute; right:10px; bottom:8px; opacity:.9; }
.kpi.accent::before {
  content:""; position:absolute; inset:0 auto 0 0; width:3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

/* ---- grid & cards ------------------------------------------------------ */
.grid { display:grid; grid-template-columns: 1.55fr 1fr; gap:18px; align-items:start; }
.col { display:flex; flex-direction:column; gap:18px; min-width:0; }
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border:1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow:hidden;
}
.card-head {
  display:flex; align-items:center; gap:10px; padding:14px 16px 10px;
}
.card-head h2 { margin:0; font-size:14px; font-weight:650; letter-spacing:.2px; }
.card-head .hint { color:var(--muted); font-size:12px; }
.card-body { padding: 4px 16px 16px; }

.seg { display:inline-flex; background:var(--inset); border:1px solid var(--border); border-radius:999px; padding:3px; gap:2px; }
.seg button {
  border:0; background:transparent; color:var(--muted); font-weight:600; font-size:12px;
  padding:4px 11px; border-radius:999px; cursor:pointer; font-family:inherit;
}
.seg button.on { background:var(--surface-3); color:var(--text); box-shadow:var(--shadow); }
.seg button:hover:not(.on){ color:var(--text-2); }

/* ---- live players ------------------------------------------------------ */
.plist { display:flex; flex-direction:column; }
.prow {
  display:flex; align-items:center; gap:13px; padding:11px 6px;
  border-top:1px solid var(--border); cursor:pointer; border-radius:8px;
  transition: background .12s;
}
.prow:first-child { border-top:0; }
.prow:hover { background: var(--surface-3); }
.avatar {
  width:38px; height:38px; border-radius:11px; flex:none; display:grid; place-items:center;
  font-weight:700; font-size:16px; color:#fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.p-main { flex:1 1 auto; min-width:0; }
.p-name { font-weight:640; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.p-sub { color:var(--muted); font-size:12px; display:flex; gap:10px; align-items:center; margin-top:1px; }
.lvl { background:var(--surface-3); border:1px solid var(--border); border-radius:6px; padding:0 6px; font-size:11px; font-weight:600; color:var(--text-2); }
.ping { display:inline-flex; align-items:center; gap:5px; }
.ping i { width:6px; height:6px; border-radius:50%; display:inline-block; }
.p-right { text-align:right; flex:none; }
.p-timer { font-weight:700; font-size:15px; font-variant-numeric: tabular-nums; }
.p-total { color:var(--muted); font-size:11.5px; margin-top:1px; }

.empty { text-align:center; color:var(--muted); padding:34px 10px; }
.empty .big { font-size:34px; opacity:.5; }
.empty .msg { margin-top:8px; font-size:13.5px; }

/* ---- leaderboard ------------------------------------------------------- */
.lrow { display:flex; align-items:center; gap:12px; padding:9px 6px; border-radius:8px; cursor:pointer; }
.lrow:hover { background: var(--surface-3); }
.rank { width:22px; text-align:center; font-weight:700; color:var(--muted); font-size:13px; flex:none; }
.rank.m1{ color:#ffd24a; } .rank.m2{ color:#cdd3da; } .rank.m3{ color:#e0955a; }
.lb-main { flex:1 1 auto; min-width:0; }
.lb-top { display:flex; justify-content:space-between; gap:10px; align-items:baseline; }
.lb-name { font-weight:600; font-size:13.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.lb-val { font-weight:700; font-size:13px; color:var(--text); flex:none; font-variant-numeric:tabular-nums; }
.lb-bar { height:7px; background:var(--inset); border-radius:999px; margin-top:6px; overflow:hidden; }
.lb-fill { height:100%; border-radius:999px; background:linear-gradient(90deg, var(--series-1), var(--accent-2)); transition:width .5s; }
.lb-online { width:7px; height:7px; border-radius:50%; background:#2fe25a; flex:none; box-shadow:0 0 6px #2fe25a; }

/* ---- events feed ------------------------------------------------------- */
.feed { display:flex; flex-direction:column; }
.ev { display:flex; align-items:center; gap:11px; padding:8px 6px; border-top:1px solid var(--border); font-size:13px; }
.ev:first-child { border-top:0; }
.ev-dot { width:8px; height:8px; border-radius:50%; flex:none; }
.ev .who { font-weight:600; }
.ev .txt { color:var(--text-2); flex:1 1 auto; min-width:0; }
.ev .ago { color:var(--muted); font-size:12px; flex:none; }

/* ---- charts ------------------------------------------------------------ */
.chart-wrap { position:relative; width:100%; }
.chart-svg { display:block; width:100%; }
.axis-txt { fill:var(--muted); font-size:11px; }
.tt {
  position:absolute; pointer-events:none; z-index:5;
  background: rgba(20,20,19,.96); border:1px solid var(--border-strong);
  border-radius:10px; padding:8px 11px; font-size:12px; box-shadow: var(--shadow-lg);
  transform: translate(-50%, -112%); white-space:nowrap; color:var(--text);
}
.tt .tt-h { color:var(--muted); font-size:11px; margin-bottom:3px; }
.tt b { font-variant-numeric: tabular-nums; }

/* ---- heatmap ----------------------------------------------------------- */
.hm { width:100%; overflow-x:auto; }
.hm-grid { display:grid; grid-template-columns:34px repeat(24, 1fr); gap:3px; min-width:520px; }
.hm-cell { aspect-ratio:1/1; border-radius:4px; background:var(--inset); position:relative; }
.hm-cell.has:hover { outline:2px solid var(--accent); outline-offset:1px; }
.hm-lbl { color:var(--muted); font-size:10.5px; display:flex; align-items:center; height:100%; }
.hm-hours { display:grid; grid-template-columns:34px repeat(24,1fr); gap:3px; margin-top:5px; }
.hm-hours span { color:var(--muted); font-size:10px; text-align:center; }
.hm-legend { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:11px; margin-top:10px; }
.hm-legend .scale { display:flex; gap:2px; }
.hm-legend .scale i { width:14px; height:10px; border-radius:2px; }

/* ---- modal (player detail) -------------------------------------------- */
.overlay { position:fixed; inset:0; background:rgba(0,0,0,.55); backdrop-filter:blur(3px); z-index:50; display:grid; place-items:center; padding:20px; }
.modal {
  width:min(560px, 96vw); max-height:88vh; overflow:auto;
  background: var(--surface-1); border:1px solid var(--border-strong);
  border-radius:18px; box-shadow: var(--shadow-lg);
}
.modal-head { display:flex; align-items:center; gap:14px; padding:18px 20px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface-1); }
.modal-head .close { margin-left:auto; background:var(--surface-3); border:1px solid var(--border); color:var(--text-2); width:32px; height:32px; border-radius:9px; cursor:pointer; font-size:16px; }
.modal-body { padding:16px 20px 22px; }
.stat-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:16px; }
.mini { background:var(--surface-2); border:1px solid var(--border); border-radius:12px; padding:11px 12px; }
.mini .l { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.4px; }
.mini .v { font-size:19px; font-weight:700; margin-top:3px; }
.sess-list { display:flex; flex-direction:column; }
.sess { display:flex; align-items:center; gap:10px; padding:8px 4px; border-top:1px solid var(--border); font-size:12.5px; }
.sess:first-child{border-top:0;} .sess .when{color:var(--text-2);flex:1;} .sess .dur{font-weight:600; font-variant-numeric:tabular-nums;}
.sess .live{color:#3ddc5f; font-weight:600;}

/* ---- misc -------------------------------------------------------------- */
.footer { color:var(--muted); font-size:12px; text-align:center; margin-top:34px; line-height:1.7; }
.loadbar { position:fixed; top:0; left:0; height:2px; background:linear-gradient(90deg,var(--accent),var(--series-2)); z-index:99; transition:width .3s, opacity .4s; }
.err-banner { background:rgba(208,59,59,.12); border:1px solid rgba(208,59,59,.35); color:#ff8f8f; padding:10px 14px; border-radius:12px; margin-bottom:16px; font-size:13px; }
.skel { background:linear-gradient(90deg,var(--surface-2),var(--surface-3),var(--surface-2)); background-size:200% 100%; animation:sh 1.3s infinite; border-radius:8px; }
@keyframes sh { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 1080px){ .kpis{ grid-template-columns:repeat(3,1fr);} .grid{ grid-template-columns:1fr; } }
@media (max-width: 620px){ .kpis{ grid-template-columns:repeat(2,1fr);} .brand-txt h1{max-width:60vw;} .topmeta{gap:10px;} }
