/* Ball Clash dashboard — responsive, dark by default, light theme toggle. */
:root {
  --bg: #0c0b14;
  --bg-2: #13121e;
  --panel: #1a1828;
  --panel-2: #221f33;
  --line: #2e2a44;
  --text: #ece9f7;
  --muted: #9a94b8;
  --accent: #ffd646;
  --accent-2: #4fd1ff;
  --good: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5a5f;
  --info: #7c8cff;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar: 236px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f4f3fa;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1effa;
  --line: #e2dff0;
  --text: #1c1830;
  --muted: #6c6788;
  --accent: #c99700;
  --accent-2: #0b8fc4;
  --shadow: 0 6px 20px rgba(40, 30, 90, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .2px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--bg-2); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px 24px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6, transparent 40%),
    radial-gradient(circle, #ffd646, #ff8a3d); border: 3px solid #120f1d; box-shadow: 0 0 0 2px #ffd64655;
}
.brand b { font-size: 16px; letter-spacing: .5px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.nav-group { margin-top: 14px; }
.nav-group h4 { margin: 0 8px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text);
  font-size: 13.5px; margin-bottom: 2px;
}
.nav a:hover { background: var(--panel); text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, #ffd64622, transparent); color: var(--accent); font-weight: 600; }
.nav a .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.nav a.active .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .grow { flex: 1; }
.content { padding: 22px; max-width: 1480px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 6px 10px; font-size: 16px; }
.scrim { display: none; }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); min-width: 0;
}
.card.tight { padding: 12px 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.kpi .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.accent .value { color: var(--accent); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .04em; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.good, .badge.READY, .badge.PUBLISHED, .badge.COMPLETED, .badge.published { background: #3ddc8422; color: var(--good); border-color: #3ddc8455; }
.badge.warn, .badge.UPLOADING, .badge.RENDERED, .badge.REJECTED, .badge.scheduled { background: #ffb02022; color: var(--warn); border-color: #ffb02055; }
.badge.bad, .badge.FAILED, .badge.failed { background: #ff5a5f22; color: var(--bad); border-color: #ff5a5f55; }
.badge.info, .badge.SIMULATING, .badge.ANALYZING, .badge.APPROVED, .badge.RENDERING, .badge.PROCESSING { background: #7c8cff22; color: var(--info); border-color: #7c8cff55; }
.badge.QUEUED { background: #4fd1ff1c; color: var(--accent-2); border-color: #4fd1ff44; }
.pulse::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: .25; } 100% { opacity: 1; } }
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid #0006; vertical-align: -2px; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .05s, background .15s;
}
.btn:hover { background: var(--line); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #1a1400; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: #3ddc84; color: #04220f; border-color: transparent; }
.btn.danger { background: #ff5a5f; color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
form.inline { display: inline; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 9px 11px;
  border-radius: 10px; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px #4fd1ff22; }
input[type=color] { width: 44px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 2px; }
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--text); font-weight: 500; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 140px; }

/* ---------- alerts ---------- */
.flash { padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; font-weight: 600; }
.flash.ok { background: #3ddc8418; border-color: #3ddc8455; color: var(--good); }
.flash.err { background: #ff5a5f18; border-color: #ff5a5f55; color: var(--bad); }
.flash.warn { background: #ffd64618; border-color: #ffd64655; color: var(--warn, #ffd646); }
.flash a { color: inherit; text-decoration: underline; }
.alert { padding: 10px 14px; border-radius: 12px; background: #ffb0201a; border: 1px solid #ffb02055; color: var(--warn); }

/* ---------- bars ---------- */
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 999px; }
.bar.hp > span { background: linear-gradient(90deg, #ff5a5f, #ffd646 45%, #3ddc84); }
.bar.shield > span { background: linear-gradient(90deg, #3a7bff, #4fd1ff); }
.bar.big { height: 14px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 240px; position: relative; }
.chart.sm { height: 150px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 10.5px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line); padding: 6px 9px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(10px, 1fr)); gap: 2px; font-size: 10px; }
.heat div { height: 20px; border-radius: 3px; background: var(--panel-2); }
.heat .lbl { background: none; color: var(--muted); display: flex; align-items: center; }

/* ---------- media ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.video-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.video-card .thumb { aspect-ratio: 9 / 16; background: #000 center/cover no-repeat; display: block; position: relative; }
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-card .meta { padding: 10px 12px; }
.video-card .meta b { display: block; font-size: 13px; line-height: 1.3; }
video.player { width: 100%; max-height: 72vh; background: #000; border-radius: 12px; }
.map-card img { width: 100%; border-radius: 10px; display: block; aspect-ratio: 7 / 12; object-fit: cover; background: var(--bg); }

/* ---------- live ---------- */
.live-wrap { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; }
.minimap { width: 100%; aspect-ratio: 7 / 12; background: #07060d; border-radius: 12px; border: 1px solid var(--line); }
.feed-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--panel-2); border-radius: 10px; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.player-row .name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.player-row.dead { opacity: .45; }
.gauge { font-size: 34px; font-weight: 800; color: var(--accent); }
.log-view { background: #07060d; color: #d6d2ea; border-radius: 12px; padding: 12px; max-height: 70vh; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.log-view .ERROR, .log-view .CRITICAL { color: #ff7b7f; }
.log-view .WARNING { color: #ffc15a; }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, #ffd64622, transparent), radial-gradient(900px 500px at 110% 110%, #4fd1ff22, transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .live-wrap { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: #0008; z-index: 25; }
  .menu-btn { display: inline-flex; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
}
@media (max-width: 560px) {
  .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 22px; }
  .topbar .hide-sm { display: none; }
  th, td { padding: 8px 7px; }
  .btn { padding: 8px 11px; }
}
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); min-width: 0; }
dl.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-card img { height: auto; }
