/* ============================================================
   Handball Stats Pro — global theme
   Updated with Kenya Handball Federation palette.
   ============================================================ */

:root {
    --ink:        #FFFFFF;
    --ink-2:      #F8F5F7;
    --panel:      #FFFFFF;
    --panel-2:    #F8F5F7;
    --line:       #E6DAC0;
    --text:       #1A1A1A;
    --muted:      #6B5E66;
    --brand:      #5A0D33;   /* Deep Maroon */
    --brand-2:    #D4A017;   /* Warm Gold */
    --accent:     #006B3F;   /* Kenya Green */
    --purple:     #6F42C1;
    --danger:     #B3302E;
    --ok:         #006B3F;
    --brand-soft: rgba(90,13,51,.14);
    --radius:     14px;
    --shadow:     0 10px 30px rgba(26,26,26,.08);
    --font:       "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(90,13,51,.12), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(0,107,63,.10), transparent 55%),
        var(--ink);
    min-height: 100vh;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top navigation ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: 1240px; margin: 0 auto;
    display: flex; align-items: center; gap: 22px;
    padding: 14px 22px;
}
.brand {
    display: flex; align-items: center; gap: 12px;
    font-weight: 800; font-size: 20px; letter-spacing: -.4px; color: var(--text);
}
.brand .dot {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: grid; place-items: center; font-size: 18px;
    box-shadow: 0 6px 18px rgba(90,13,51,.35);
}
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 6px; margin-left: 8px; flex-wrap: wrap; }
.nav-links a {
    color: var(--muted); font-weight: 600; font-size: 14px;
    padding: 8px 14px; border-radius: 10px; transition: .15s;
}
.nav-links a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--panel-2); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip {
    display: flex; align-items: center; gap: 9px;
    background: var(--panel); border: 1px solid var(--line);
    padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted);
}
.user-chip .avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--accent));
    display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 12px;
}

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 30px 22px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 30px; letter-spacing: -.6px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.eyebrow {
    text-transform: uppercase; letter-spacing: 2px; font-size: 12px;
    color: var(--brand); font-weight: 700; margin-bottom: 4px;
}

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card {
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.card h2, .card h3 { margin-top: 0; }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 14px; font-weight: 700; }

/* Stat tiles */
.stat {
    position: relative; overflow: hidden;
    background: linear-gradient(160deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.stat .num { font-size: 40px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 8px; text-transform: uppercase; letter-spacing: 1px; }
.stat .spark { position: absolute; right: -10px; bottom: -14px; font-size: 78px; opacity: .07; }
.stat.brand .num { color: var(--brand); }
.stat.teal  .num { color: var(--accent); }
.stat.amber .num { color: var(--brand-2); }
.stat.purple .num { color: var(--purple); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; }
table.data thead th {
    background: var(--panel-2); color: var(--muted);
    text-transform: uppercase; letter-spacing: 1px; font-size: 11.5px; font-weight: 700;
    border-bottom: 1px solid var(--line);
}
table.data tbody tr { border-top: 1px solid var(--line); background: var(--panel); }
table.data tbody tr:hover { background: var(--panel-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.badge.live { background: rgba(179,48,46,.12); color: #B3302E; border-color: rgba(179,48,46,.35); }
.badge.live::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--danger); animation:pulse 1.2s infinite; }
.badge.done { background: rgba(0,107,63,.14); color: var(--accent); border-color: rgba(0,107,63,.35); }
.badge.sched{ background: var(--panel-2); color: var(--muted); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.pos-pill { font-size: 11px; font-weight: 800; letter-spacing: .5px; padding: 3px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--brand-2); }

/* ---------- Buttons & forms ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    font-family: var(--font); font-weight: 700; font-size: 14px; cursor: pointer;
    padding: 11px 18px; border-radius: 11px; border: 1px solid transparent;
    transition: .15s; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #1a0e08; }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: rgba(179,48,46,.14); border-color: rgba(179,48,46,.4); color: #B3302E; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.form-control, select.form-control, textarea.form-control {
    width: 100%; padding: 12px 14px; border-radius: 11px;
    background: var(--panel); border: 1px solid var(--line); color: var(--text);
    font-family: var(--font); font-size: 15px; transition: .15s;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(90,13,51,.18); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Flash ---------- */
.flash { padding: 13px 18px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; border: 1px solid; }
.flash.success { background: rgba(56,217,150,.12); border-color: rgba(56,217,150,.4); color: #7ef0bb; }
.flash.error   { background: rgba(179,48,46,.12); border-color: rgba(179,48,46,.35); color: #B3302E; }
.flash.info    { background: rgba(0,107,63,.12); border-color: rgba(0,107,63,.35); color: #006B3F; }

/* ---------- Auth screens ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 8px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.mono  { font-variant-numeric: tabular-nums; }
.mt-0{margin-top:0}.mb-0{margin-bottom:0}
.text-center{text-align:center}
.divider { height:1px; background:var(--line); margin:20px 0; border:0; }
.empty { text-align:center; padding:50px 20px; color:var(--muted); }
.empty .big { font-size:44px; margin-bottom:10px; opacity:.5; }
.vs { color: var(--muted); font-weight: 700; padding: 0 8px; }
.score-big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ============ Sidebar layout ============ */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 60;
    background: rgba(255,255,255,.98); backdrop-filter: blur(12px);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto;
}
.sidebar .brand { margin: 4px 6px 20px; font-size: 18px; }
.sidebar .brand .dot { width: 30px; height: 30px; font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a {
    display: flex; align-items: center; gap: 11px;
    color: var(--muted); font-weight: 600; font-size: 14px;
    padding: 10px 13px; border-radius: 10px; transition: .15s;
}
.side-nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.side-nav a.active { color: var(--text); background: var(--panel-2); }
.side-nav a .ic { width: 20px; text-align: center; font-size: 15px; }
.side-nav a.side-sep { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 14px; border-radius: 0 0 10px 10px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

.app-main { margin-left: 240px; min-height: 100vh; display: flex; flex-direction: column; }
.app-main .wrap { flex: 1; }

/* mobile */
.mobile-topbar, .side-backdrop { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; width: 264px; box-shadow: 0 0 50px rgba(0,0,0,.6); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 55;
        background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--line); padding: 10px 14px;
    }
    .side-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.22); z-index: 59; }
    body.sidebar-open .side-backdrop { display: block; }
}
