:root {
    /* light / neutral palette */
    --bg: #f4f6f9;
    --panel: #ffffff;
    --surface-2: #f6f8fb;
    --line: #e4e8ee;
    --text: #1f2733;
    --muted: #687184;
    --accent: #2f6fed;
    --accent-weak: #eaf1fe;
    --danger: #d64545;
    --success: #2e9e6b;
    --warn: #b9791b;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-lg: 0 8px 28px rgba(16, 24, 40, .14);
    --radius: 10px;
    --appbar-h: 56px;
    --sidebar-w: 240px;
}

* { box-sizing: border-box; }

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

/* ── App shell ─────────────────────────────────────────────────────────── */
.od-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.appbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--appbar-h);
    display: flex; align-items: center; gap: 14px; padding: 0 16px;
    background: var(--panel); border-bottom: 1px solid var(--line); z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .2px; }
.brand-dot { width: 11px; height: 11px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.appbar .spacer { flex: 1; }

.iconbtn { background: transparent; border: 0; color: var(--muted); padding: 7px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.hamburger { display: inline-flex; } /* always shown: collapses the rail on desktop, opens the drawer on mobile */

.sidebar {
    position: fixed; top: var(--appbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; z-index: 20;
    transition: transform .2s ease;
}
.nav { padding: 14px 10px 28px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 10px; font-weight: 700; }
.nav-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 1px 0;
    border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-weak); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

.usermenu { position: relative; }
.usermenu-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent; border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; color: var(--text); }
.usermenu-btn:hover { background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.uname { font-size: 13px; font-weight: 500; }
.chev { color: var(--muted); transition: transform .15s ease; }
.usermenu.open .chev { transform: rotate(180deg); }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 168px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.usermenu.open .usermenu-pop { display: block; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 9px; background: transparent; color: var(--text); border: 0; border-radius: 8px; padding: 9px 10px; font-size: 13px; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); }

.backdrop { display: none; position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 15; }
body.nav-open .backdrop { display: block; }

/* content offset applies ONLY when the shell fragment is present (login/error pages stay full-width) */
.appshell-nav ~ .content { margin-left: var(--sidebar-w); margin-top: var(--appbar-h); }

@media (max-width: 900px) {
    .hamburger { display: inline-flex; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    .appshell-nav ~ .content { margin-left: 0; }
    .uname { display: none; }
}

/* ── Buttons / links ───────────────────────────────────────────────────── */
button {
    background: var(--accent); color: #fff; border: 0; border-radius: 8px;
    padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
button:hover { filter: brightness(1.05); }
.btn-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.actions { display: flex; gap: 14px; align-items: center; margin: 8px 0; }
a { color: var(--accent); }

/* ── Content ───────────────────────────────────────────────────────────── */
/* full-width content for the data-grid views; narrow surfaces (.card, dl.kv, form labels,
   .timeline) keep their own max-width, so only grids + quick-actions stretch to the viewport. */
.content { padding: 26px 28px; }
.muted { color: var(--muted); line-height: 1.55; }
h1 { font-size: 21px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 4px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px 32px; width: 340px; text-align: center; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; text-align: left; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.login-card button { padding: 10px; font-size: 14px; }

/* ── Inputs ────────────────────────────────────────────────────────────── */
input, select, textarea {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
    padding: 8px 10px; color: var(--text); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.alert { background: #fdecec; color: var(--danger); border: 1px solid #f5cccc; padding: 9px 12px; border-radius: 8px; margin-top: 12px; font-size: 13px; }
.notice { background: var(--accent-weak); color: var(--accent); border: 1px solid #cfe0fd; padding: 9px 12px; border-radius: 8px; margin-top: 12px; font-size: 13px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; margin: 14px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.grid thead th { position: sticky; top: var(--appbar-h); background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .2px; z-index: 1; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid a { color: var(--accent); text-decoration: none; font-weight: 500; }
table.grid a:hover { text-decoration: underline; }

/* ── Cards / detail ────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; max-width: 680px; box-shadow: var(--shadow); }
.card h2 { font-size: 12px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }

form.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
form.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); width: 100%; max-width: 380px; font-weight: 500; }
form.stack input, form.stack textarea { width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
legend { color: var(--muted); font-size: 12px; padding: 0 6px; font-weight: 600; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; }

dl.kv { display: grid; grid-template-columns: 210px 1fr; gap: 8px 18px; margin: 14px 0; max-width: 780px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
dl.kv dt { color: var(--muted); font-size: 12px; font-weight: 500; }
dl.kv dd { margin: 0; font-size: 13px; word-break: break-all; }
/* player card: pack the 8 info fields into 2 columns (4 rows) — wide + short instead of tall */
.kv-grid dl.kv { grid-template-columns: max-content 1fr max-content 1fr; max-width: none; }

/* ── Badges (semantic status pills) ────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface-2); letter-spacing: .2px; vertical-align: middle; }
.badge-ok { color: #1c7a4f; background: #e7f6ee; border-color: #c5ead5; }
.badge-fail { color: #b23535; background: #fdecec; border-color: #f5cccc; }
.badge-warn { color: #9a6612; background: #fbf3e2; border-color: #f0dcb8; }
.badge-muted { color: var(--muted); background: var(--surface-2); }
.badge-freebet { color: #4b3b8f; background: #ece9fb; border-color: #d4ccf2; }

/* ── Tabs (player card) ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs .tab { appearance: none; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; cursor: pointer; margin-bottom: -1px; }
.tabs .tab:hover { color: #111; }
.tabs .tab.active { color: #111; border-bottom-color: #4b3b8f; }
.tab-panel { min-height: 60px; padding-top: 4px; }
/* timeline tab scrolls inside the card (height sized in JS) so the page itself doesn't scroll */
#t-timeline { overflow-y: auto; max-width: none; }

/* ── Timeline ──────────────────────────────────────────────────────────── */
.timeline { list-style: none; padding: 0; max-width: 860px; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline .t-time { color: var(--muted); width: 165px; flex: none; }
.timeline .t-type { width: 84px; flex: none; color: var(--accent); font-weight: 600; }

/* ── Reconciliation cards ──────────────────────────────────────────────── */
.recon-cards { display: flex; gap: 14px; flex-wrap: wrap; }
.recon-cards .card { min-width: 190px; }
.recon-cards .num { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }

/* ── Collapsible sidebar → icon rail (desktop; the app-bar menu button toggles it) ── */
@media (min-width: 901px) {
    .sidebar-collapsed { --sidebar-w: 66px; }
    .sidebar-collapsed .nav-link { justify-content: center; padding: 9px; position: relative; }
    .sidebar-collapsed .nav-link span { display: none; }
    .sidebar-collapsed .nav-group-label { height: 0; padding: 0; margin: 0; overflow: hidden; opacity: 0; }
    .sidebar-collapsed .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
    .sidebar-collapsed .nav-link:hover::after {
        content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
        background: #1f2733; color: #fff; padding: 5px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap;
        box-shadow: var(--shadow-lg); z-index: 40; pointer-events: none;
    }
}

/* ── Buttons (variants), page toolbar (ribbon) + quick-action cards ───────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; border: 1px solid transparent; line-height: 1; }
.btn .ico-sm { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: #fdecec; color: var(--danger); border-color: #f5cccc; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.page-head .ph-title { margin-right: auto; display: flex; flex-direction: column; gap: 3px; }
.page-head .ph-title h1 { margin: 0; }
.page-head .ph-sub { color: var(--muted); font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
.qa-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s ease, transform .05s ease; }
.qa-card:hover { border-color: var(--accent); }
.qa-card:active { transform: translateY(1px); }
.qa-ico { width: 40px; height: 40px; flex: none; border-radius: 11px; background: var(--accent-weak); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.qa-text { display: flex; flex-direction: column; gap: 2px; }
.qa-title { font-weight: 600; font-size: 14px; }
.qa-sub { color: var(--muted); font-size: 12px; }

/* ── Toasts (surface API/search failures prominently, not just as a table row) ── */
.od-toasts { position: fixed; top: 68px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 32px)); }
.od-toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: od-toast-in .18s ease; }
.od-toast .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.od-toast.err { border-left: 3px solid var(--danger); }
.od-toast.err .ico { color: var(--danger); }
.od-toast.ok { border-left: 3px solid var(--ok); }
.od-toast.ok .ico { color: var(--ok); }
.od-toast-body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.45; }
.od-toast-title { font-weight: 600; margin-bottom: 2px; }
.od-toast-msg { color: var(--muted); word-break: break-word; }
.od-toast-close { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.od-toast-close:hover { color: var(--text); }
@keyframes od-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ── DataTables theming (server-side list grids) ── */
.dataTables_wrapper { margin: 14px 0; }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info { color: var(--muted); font-size: 12px; }
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; margin: 0 6px;
    background: var(--panel); color: var(--text); }
.dataTables_wrapper .dataTables_info { padding-top: 12px; }
.dataTables_wrapper .dataTables_paginate { padding-top: 10px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    box-sizing: border-box; min-width: 34px; padding: 6px 11px !important; margin-left: 4px;
    border: 1px solid var(--line) !important; border-radius: 8px !important;
    background: var(--panel) !important; color: var(--text) !important; cursor: pointer; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background: transparent !important; color: var(--muted) !important;
    border-color: transparent !important; cursor: default; opacity: .5; }
.dataTables_wrapper .dataTables_processing {
    border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
    box-shadow: var(--shadow); color: var(--muted); }
table.grid.dataTable { margin-top: 8px; }
table.grid.dataTable thead th { cursor: pointer; padding-right: 26px; }
table.grid.dataTable tbody tr:hover { background: var(--surface-2); }

/* scrollY mode: header pane + scrolling body form one bordered panel. Override the page-level
   sticky header (top: appbar-h) that otherwise pushes the header down over the rows. */
.dataTables_scroll { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); background: var(--panel); }
.dataTables_scrollHead { background: var(--surface-2); }
.dataTables_scrollBody { background: var(--panel); }
.dataTables_scroll table.grid.dataTable { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.dataTables_scroll table.grid thead th { position: relative; top: auto; z-index: auto; }
