:root {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --line: #e5e7ef;
    --line-strong: #d4d7e2;
    --ink: #161827;
    --ink-2: #3b3f52;
    --muted: #6d7186;
    --brand: #ff4d1c;
    --brand-2: #ff8a00;
    --brand-soft: #fff0ea;
    --ok: #16a34a;
    --ok-soft: #e8f7ee;
    --warn: #d97706;
    --warn-soft: #fff5e1;
    --bad: #dc2626;
    --bad-soft: #fdeceb;
    --info: #2563eb;
    --info-soft: #e9f0ff;
    --side: #12131c;
    --side-2: #1b1d29;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(22, 24, 39, 0.05), 0 4px 16px rgba(22, 24, 39, 0.05);
    --shadow-lg: 0 10px 40px rgba(22, 24, 39, 0.16);
    --side-w: 252px;
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body.adm {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
body.is-loading { visibility: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.86em;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 6px;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.logo {
    font-family: "Black Ops One", "Inter", sans-serif;
    font-size: 22px;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- icons ---------- */
i[data-icon] {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex: none;
}
i[data-icon] svg { width: 100%; height: 100%; }

/* ---------- buttons ---------- */
.btn, .cta, .text-btn, .icon-btn {
    font: inherit;
    cursor: pointer;
    border: 0;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}
.btn, .cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none !important;
}
.btn-primary, .cta {
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 4px 14px rgba(255, 77, 28, 0.28);
}
.btn-primary:hover, .cta:hover { box-shadow: 0 6px 20px rgba(255, 77, 28, 0.38); }
.btn-primary:active, .cta:active { transform: translateY(1px); }
.btn-ghost, .cta.cta-ghost {
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: none;
}
.btn-ghost:hover, .cta.cta-ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn:disabled, .cta:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    color: var(--brand);
    font-weight: 600;
    white-space: nowrap;
}
.text-btn:hover { background: var(--brand-soft); }
.text-btn:disabled { color: var(--muted); background: transparent; cursor: not-allowed; }
.text-btn.is-danger { color: var(--bad); }
.text-btn.is-danger:hover { background: var(--bad-soft); }
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    color: inherit;
}
.icon-btn:hover { background: rgba(127, 127, 160, 0.14); }

/* ---------- forms ---------- */
.card-form label, .fld {
    display: grid;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
}
input, select, textarea {
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(255, 77, 28, 0.14);
}
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    padding: 0;
    accent-color: var(--brand);
    cursor: pointer;
}
input[type="file"] {
    padding: 8px;
    background: var(--surface-2);
    border-style: dashed;
    cursor: pointer;
}
input[type="file"]::file-selector-button {
    font: inherit;
    font-weight: 600;
    margin-right: 12px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--ink);
    cursor: pointer;
}
.card-form label.check, label.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}
.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    align-items: end;
}
.form-error {
    margin: 0;
    color: var(--bad);
    font-weight: 600;
    min-height: 0;
}
.form-error:empty { display: none; }
.note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.hero-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---------- login ---------- */
.adm-login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--surface);
}
.login-art {
    position: relative;
    overflow: hidden;
    background: radial-gradient(120% 90% at 0% 0%, #2a1a3e 0%, #12131c 60%);
    display: flex;
    align-items: flex-end;
    padding: 48px;
}
.login-glow {
    position: absolute;
    width: 520px;
    height: 520px;
    right: -160px;
    top: -140px;
    background: radial-gradient(closest-side, rgba(255, 77, 28, 0.55), transparent);
    filter: blur(20px);
    animation: glow 8s ease-in-out infinite alternate;
}
@keyframes glow { to { transform: translate(-80px, 60px) scale(1.15); } }
.login-posters {
    position: absolute;
    inset: -40px -60px auto auto;
    width: 130%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    transform: rotate(-12deg) translate(4%, -6%);
    opacity: 0.55;
}
.login-posters img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: drift 14s ease-in-out infinite alternate;
}
.login-posters img:nth-child(2n) { animation-delay: -4s; margin-top: 40px; }
.login-posters img:nth-child(3n) { animation-delay: -8s; }
@keyframes drift { to { transform: translateY(-26px); } }
.login-pitch {
    position: relative;
    z-index: 1;
    max-width: 420px;
    padding: 24px 26px;
    border-radius: 18px;
    background: rgba(18, 19, 28, 0.72);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.login-pitch .logo { font-size: 34px; }
.login-pitch p { margin: 8px 0 0; color: #c9cbe0; font-size: 15px; }
.login-side {
    display: grid;
    place-items: center;
    padding: 32px 20px;
    background: linear-gradient(180deg, #fff, var(--bg));
}
.login-card {
    width: min(400px, 100%);
    display: grid;
    gap: 16px;
}
.login-card .logo { font-size: 26px; }
.login-card h1 { font-size: 28px; font-weight: 800; margin-top: 8px; }
.login-card .muted { margin: -8px 0 4px; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px; }
.pw-eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 4px 9px;
    cursor: pointer;
}
.back-link { justify-self: center; color: var(--muted); }

/* ---------- shell ---------- */
.adm-shell {
    display: grid;
    grid-template-columns: var(--side-w) 1fr;
    min-height: 100vh;
}
.side {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--side), var(--side-2));
    color: #c7c9da;
    padding: 18px 14px;
    z-index: 30;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 18px; }
.side-brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.badge-admin {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffb59c;
    background: rgba(255, 77, 28, 0.16);
    border: 1px solid rgba(255, 77, 28, 0.35);
    padding: 2px 7px;
    border-radius: 999px;
}
.side-close { display: none; color: #fff; }
.side-nav { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.side-group {
    margin: 16px 10px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #6f7290;
}
.side-group:first-child { margin-top: 0; }
.side-nav a, .side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #c7c9da;
    font-weight: 500;
    text-decoration: none !important;
    transition: background 0.15s, color 0.15s;
}
.side-nav a:hover, .side-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-nav a.is-on {
    color: #fff;
    background: linear-gradient(90deg, rgba(255, 77, 28, 0.22), rgba(255, 77, 28, 0.04));
}
.side-nav a.is-on::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand);
}
.side-nav a.is-on i { color: var(--brand); }
.side-nav em {
    margin-left: auto;
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--ok);
    border-radius: 999px;
    padding: 0 7px;
    line-height: 18px;
}
.side-nav em:empty { display: none; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; display: grid; gap: 2px; }
.side-me {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}
.side-me-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.side-me-text strong { color: #fff; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me-text small { color: #8a8da8; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me .icon-btn { color: #c7c9da; }
.avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    overflow: hidden;
    text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.side-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 32px;
    background: rgba(244, 245, 249, 0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.crumb { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.topbar h1 { font-size: 22px; font-weight: 800; line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--ok-soft);
    color: #13703a;
    font-weight: 600;
    font-size: 13px;
}
.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
    animation: pulse 1.8s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
#desk-error { margin: 16px 32px 0; }
.content { padding: 24px 32px 48px; }
.panel { display: grid; gap: 18px; animation: rise 0.28s ease; max-width: 1360px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- cards ---------- */
.card-form {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-form > h3, .card-head h3 { font-size: 16px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head .note { margin-top: 2px; }
.stack { display: grid; gap: 10px; }

.player-counts, .kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}
.player-counts > div, .kpi {
    position: relative;
    display: grid;
    gap: 2px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.player-counts strong, .kpi strong { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.player-counts span, .kpi span { color: var(--muted); font-size: 13px; font-weight: 500; }
.player-counts > div::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--line-strong);
}
.player-counts > div:nth-child(1)::after { background: var(--brand); }
.player-counts > div:nth-child(2)::after { background: var(--ok); }
.player-counts > div:nth-child(3)::after { background: var(--info); }
.player-counts > div:nth-child(4)::after { background: var(--warn); }

.kpi { padding: 18px; grid-template-columns: 1fr auto; align-items: start; text-decoration: none !important; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-icon {
    grid-row: span 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    color: var(--tone, var(--brand));
    background: color-mix(in srgb, var(--tone, var(--brand)) 13%, white);
}
.kpi-icon i { width: 20px; height: 20px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi small b { color: var(--ok); font-weight: 700; }

/* ---------- toolbars and chips ---------- */
.player-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.player-tools input { max-width: 300px; }
.player-tools .hero-actions { flex-wrap: nowrap; }
.player-tools .hero-actions input { width: 260px; }
.player-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.player-filters button {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    height: 32px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    transition: all 0.15s;
}
.player-filters button:hover { border-color: var(--ink-2); }
.player-filters button.is-on {
    color: #fff;
    border-color: var(--ink);
    background: var(--ink);
}
.machine-chips button { display: inline-flex; align-items: center; gap: 7px; }
.machine-chips button::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chip, var(--line-strong));
}

/* ---------- tables ---------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.player-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.player-table th {
    position: sticky;
    top: 0;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.player-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.player-table tbody tr:last-child td { border-bottom: 0; }
.player-table tbody tr:hover td { background: #fbfbfd; }
.player-table td.note { text-align: center; padding: 28px; }
.import-table td { vertical-align: top; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who strong { display: block; font-weight: 600; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.role-tag {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    color: var(--ink-2);
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.role-tag.is-admin { color: #b2380f; background: var(--brand-soft); border-color: #ffd3c2; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: #b6b9c8;
    vertical-align: middle;
}
.status-dot.is-online { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.is-playing { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.status-dot.is-disabled { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.status-dot.is-offline { background: #b6b9c8; }

.user-edit-row td { background: var(--surface-2) !important; }
.user-editor {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    align-items: end;
}
.user-editor label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.user-editor label.check { display: flex; height: 40px; }
.user-editor .hero-actions { grid-column: 1 / -1; }

.card-form.new-player { padding: 0 !important; gap: 0; }
.new-player summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.new-player summary::-webkit-details-marker { display: none; }
.new-player summary::before {
    content: "+";
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    color: #fff;
    background: var(--ink);
    font-weight: 700;
}
.new-player[open] summary::before { content: "−"; }
.new-player form { display: grid; gap: 14px; padding: 0 20px 20px; }

/* ---------- uploads ---------- */
.rom-upload {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 500;
}
progress {
    width: 100%;
    height: 8px;
    appearance: none;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: #d6e0fb;
}
progress::-webkit-progress-bar { background: #d6e0fb; border-radius: 999px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--info), #60a5fa); border-radius: 999px; transition: width 0.2s; }
progress::-moz-progress-bar { background: var(--info); }

.bios-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--warn-soft);
    border-color: #f7dfae;
}
.bios-bar > span:nth-child(2) { flex: 1; min-width: 220px; }

/* ---------- covers ---------- */
.cover-cell { width: 72px; }
.cover-thumb {
    position: relative;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
}
.cover-thumb:hover { border-color: var(--brand); color: var(--brand); }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cover-auto {
    position: absolute;
    left: 3px;
    bottom: 3px;
    font-style: normal;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: rgba(22, 24, 39, 0.75);
    padding: 0 5px;
    border-radius: 5px;
}
.comment-cell { max-width: 460px; white-space: pre-wrap; word-break: break-word; }

/* ---------- game rows (cabinets, ads) ---------- */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.game-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 4px 14px;
    align-items: center;
    padding: 14px;
}
.game-row .thumb {
    grid-row: span 3;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--surface-2) center / cover;
    border: 1px solid var(--line);
}
.game-row strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row .row-actions { display: flex; gap: 4px; margin-left: -10px; }
.ad-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; }
.ad-row > div { flex: 1; min-width: 200px; display: grid; }
.ad-row span { color: var(--muted); font-size: 12.5px; }
.tag {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
}
.tag.is-on { color: #13703a; background: var(--ok-soft); }
.tag.is-off { color: var(--muted); background: var(--surface-2); }
.tag.is-soon { color: #92400e; background: var(--warn-soft); }

/* ---------- dashboard ---------- */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }
.welcome {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 24px 26px;
    border-radius: var(--radius);
    color: #fff;
    background: radial-gradient(120% 140% at 100% 0%, #ff8a00 0%, #ff4d1c 38%, #7a1fa2 100%);
    box-shadow: 0 12px 30px rgba(255, 77, 28, 0.25);
}
.welcome h2 { font-size: 24px; font-weight: 800; }
.welcome p { margin: 4px 0 0; opacity: 0.9; }
.welcome .hero-actions .btn { background: rgba(255, 255, 255, 0.16); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); }
.welcome .hero-actions .btn:hover { background: rgba(255, 255, 255, 0.28); }
.welcome .hero-actions .btn.solid { background: #fff; color: var(--brand); border-color: #fff; }

.bars {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    align-items: end;
    gap: 8px;
    height: 180px;
    padding-top: 10px;
}
.bar {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    gap: 6px;
}
.bar b {
    width: 100%;
    max-width: 30px;
    min-height: 4px;
    border-radius: 7px 7px 3px 3px;
    background: linear-gradient(180deg, var(--brand-2), var(--brand));
    transform-origin: bottom;
    animation: grow 0.6s cubic-bezier(.2,.8,.2,1) both;
}
.bar.is-zero b { background: var(--line); }
.bar span { font-size: 11px; color: var(--muted); }
.bar em {
    position: absolute;
    top: -2px;
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-2);
    opacity: 0;
    transition: opacity 0.15s;
}
.bar:hover em { opacity: 1; }
@keyframes grow { from { transform: scaleY(0); } }

.machine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 28px; }
.machine-item {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin: 0 -10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none !important;
}
.machine-item:hover { background: var(--surface-2); }
.machine-item img { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; }
.machine-item strong { display: block; font-weight: 600; font-size: 13.5px; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin-top: 5px; }
.meter i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent, var(--brand)) 28%, white);
    min-width: 3px;
    overflow: hidden;
}
.meter b { display: block; height: 100%; border-radius: 999px; background: var(--accent, var(--brand)); }
.machine-item small { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.machine-item small b { color: var(--ink); font-size: 13px; }

.feed { display: grid; gap: 2px; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item > div { min-width: 0; flex: 1; }
.feed-item p { margin: 2px 0 0; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-item small { color: var(--muted); font-size: 12px; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick a {
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none !important;
    transition: border-color 0.15s, transform 0.15s;
}
.quick a:hover { border-color: var(--brand); transform: translateY(-1px); }
.quick a i { color: var(--brand); }
.quick a small { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- shared bits ---------- */
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.text-btn i[data-icon] { width: 15px; height: 15px; }
.btn i[data-icon] { width: 16px; height: 16px; }
.btn-ghost.danger { color: var(--bad); border-color: #f3c3bf; }
.btn-ghost.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.side-nav em.is-blue { background: var(--info); }
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.small-check { font-size: 13px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.pager { justify-content: center; }
.flag {
    display: inline-block;
    width: 22px;
    height: 15px;
    margin-right: 8px;
    border-radius: 3px;
    object-fit: cover;
    vertical-align: -2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    background: var(--surface-2);
}
.flag-none { display: inline-grid; place-items: center; color: var(--muted); box-shadow: none; background: none; }
.flag-none i[data-icon] { width: 15px; height: 15px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 15;
    min-width: 250px;
    display: grid;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.menu-pop button {
    font: inherit;
    text-align: left;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    cursor: pointer;
}
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.is-danger { color: var(--bad); }
.menu-pop button.is-danger:hover { background: var(--bad-soft); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--line-strong);
    transition: background 0.2s;
}
.switch span::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2); }

/* ---------- analytics ---------- */
.traffic {
    display: grid;
    gap: 3px;
    height: 220px;
    align-items: stretch;
}
.tcol { display: grid; grid-template-rows: 1fr auto; gap: 6px; min-width: 0; }
.tbars {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s;
}
.tcol:hover .tbars { background: var(--surface-2); }
.tbars b {
    position: absolute;
    bottom: 0;
    width: 72%;
    max-width: 28px;
    min-height: 2px;
    border-radius: 5px 5px 2px 2px;
    transform-origin: bottom;
    animation: grow 0.5s cubic-bezier(.2,.8,.2,1) both;
}
.tbars b.tv { background: #c7d7fe; }
.tbars b.tu { width: 44%; max-width: 16px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.tcol span { font-size: 10.5px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; height: 14px; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; }
.legend i.tv { background: #c7d7fe; }
.legend i.tu { background: var(--brand); }

.top-list { display: grid; gap: 4px; }
.top-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    overflow: hidden;
    font: inherit;
    color: inherit;
    text-align: left;
    border: 0;
    background: none;
    width: 100%;
}
.top-row.is-link { cursor: pointer; }
.top-row.is-link:hover { background: var(--surface-2); }
.top-row.is-on { box-shadow: inset 0 0 0 2px var(--brand); }
.top-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255, 77, 28, 0.13), rgba(255, 138, 0, 0.06));
    border-radius: 9px;
    pointer-events: none;
}
.top-name { position: relative; flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; }
.top-name a { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.top-num { position: relative; font-weight: 700; font-size: 13px; white-space: nowrap; }
.top-num small { margin-left: 6px; color: var(--muted); font-weight: 500; font-size: 11.5px; }

.visit-table td { font-size: 13px; }
.visit-table .row-actions, .player-table td.row-actions { flex-wrap: nowrap; }
.player-table td.row-actions { display: table-cell; }
.visit-table tr.is-bot td { background: #fffbf3; }
.path-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-cell a { color: var(--ink-2); }
.ip-link {
    font: inherit;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12.5px;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
}
.ip-link:hover { border-color: var(--brand); color: var(--brand); }

.comment-edit { display: grid; gap: 8px; min-width: 260px; }

/* ---------- drawer ---------- */
.drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(18, 19, 28, 0.4);
    opacity: 0;
    transition: opacity 0.2s;
}
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    width: min(460px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(104%);
    transition: transform 0.22s ease;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-scrim { opacity: 1; }
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 18px; font-weight: 800; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.drawer-body h4 { margin: 6px 0 -6px; font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.profile-head { display: flex; gap: 14px; align-items: center; }
.profile-head strong { font-size: 18px; }
.profile-head p { margin: 2px 0 0; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.bio { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stats div { display: grid; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.mini-stats strong { font-size: 16px; font-weight: 800; }
.mini-stats span { color: var(--muted); font-size: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }
.thumb-sm { flex: none; width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2) center / cover; border: 1px solid var(--line); }
.drawer-actions { display: flex; gap: 10px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }

/* ---------- toasts ---------- */
.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 40px));
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    animation: toast-in 0.25s ease;
}
.toast::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--ok);
}
.toast.is-error::before { background: #ff6b6b; }
.toast.is-out { opacity: 0; transform: translateY(8px); transition: all 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .span-8, .span-4, .span-6 { grid-column: span 12; }
}
@media (max-width: 900px) {
    .adm-login { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .adm-shell { grid-template-columns: 1fr; }
    .side {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(290px, 84vw);
        transform: translateX(-102%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    body.side-open .side { transform: none; }
    .side-close { display: inline-grid; }
    .side-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(18, 19, 28, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }
    body.side-open .side-scrim { opacity: 1; pointer-events: auto; }
    .menu-btn { display: inline-grid; }
    .topbar { padding: 12px 16px; }
    .topbar h1 { font-size: 19px; }
    .topbar-actions .btn span { display: none; }
    .topbar-actions .btn { padding: 0 11px; }
    .content { padding: 16px 14px 40px; }
    #desk-error { margin: 12px 16px 0; }
    .card-form { padding: 16px; }
    .player-tools input { max-width: none; }
    .player-counts, .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .player-counts strong, .kpi strong { font-size: 22px; }
    .bars { gap: 4px; height: 150px; }
    .bar span { font-size: 9.5px; }
    .welcome { padding: 20px; }
    .welcome h2 { font-size: 20px; }
}
@media (max-width: 520px) {
    .live-pill span { display: none; }
    .live-pill { padding: 0 11px; }
    .kpi { grid-template-columns: 1fr; }
    .kpi-icon { display: none; }
}
