:root {
    /* TREI brand palette, sampled from the logo */
    --csm-maroon: #a73538;
    --csm-red: #e2582f;
    --csm-orange: #f47a30;
    --csm-gold: #fdb72e;
    --csm-lime: #dcdc37;
    --csm-charcoal: #373435;

    /* Mapped onto the existing theme roles so the rest of this file
       (and the components that consume these vars) needs no changes */
    --csm-navy: var(--csm-charcoal);
    --csm-navy-light: #464142;
    --csm-green: var(--csm-orange);
    --csm-green-dark: #d9631f;
    --csm-white: #ffffff;
    --csm-gray: #6c757d;
    --csm-bg: #f6f5f3;
}

body {
    background: var(--csm-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Auth pages (login) ---------- */
.csm-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--csm-charcoal) 0%, var(--csm-maroon) 35%, var(--csm-orange) 75%, var(--csm-gold) 130%);
}

.csm-auth-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../images/cricket-ground-bg.svg') center center / 900px auto no-repeat;
    opacity: 0.2;
}

.csm-auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--csm-white);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    padding: 2.5rem 2rem;
}

.csm-auth-card .csm-logo {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--csm-navy);
}

.csm-auth-card .csm-logo span {
    color: var(--csm-green);
}

/* ---------- Top bar ---------- */
.csm-topbar {
    background: var(--csm-navy);
    z-index: 1040;
    height: 58px;
}

.csm-topbar .navbar-brand {
    color: var(--csm-white) !important;
}

.csm-role-badge {
    background: var(--csm-green);
    color: var(--csm-white);
    font-weight: 500;
}

/* ---------- Sidebar ---------- */
.csm-sidebar {
    background: var(--csm-navy-light);
    width: 230px;
    top: 58px;
    height: calc(100vh - 58px);
    border: none;
}

/* Bootstrap's .offcanvas-lg switches to position:static/display:block at
   >=992px, which drops the sidebar into normal document flow ABOVE <main>
   instead of pinning it to the left - that's what caused the blank bar at
   the top of every dashboard page. Force it back to a fixed left column. */
@media (min-width: 992px) {
    .csm-sidebar {
        position: fixed !important;
        left: 0;
        top: 58px;
        bottom: 0;
        height: auto;
        visibility: visible !important;
        transform: none !important;
        z-index: 1030;
        /* Bootstrap's responsive offcanvas CSS sets
           background-color: transparent !important at this breakpoint -
           it has to be beaten with !important here too, or the sidebar
           shows the page's light background instead of the theme. */
        background-color: var(--csm-navy-light) !important;
    }
}

.csm-sidebar-brand {
    color: var(--csm-white);
    font-weight: 700;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.csm-nav {
    padding: .75rem;
}

.csm-nav .nav-link {
    color: rgba(255,255,255,.75);
    border-radius: 8px;
    margin-bottom: 4px;
    padding: .6rem .9rem;
}

.csm-nav .nav-link i {
    width: 22px;
    display: inline-block;
}

.csm-nav .nav-link:hover {
    background: rgba(255,255,255,.08);
    color: var(--csm-white);
}

.csm-nav .nav-link.active {
    background: var(--csm-green);
    color: var(--csm-white);
}

/* ---------- Main content offset ---------- */
body.has-sidebar .csm-main {
    margin-top: 58px;
    padding: 1.5rem;
}

@media (min-width: 992px) {
    body.has-sidebar .csm-main {
        margin-left: 230px;
    }
}

/* ---------- Dashboard cards ---------- */
.csm-stat-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    border-left: 4px solid var(--csm-green);
}

.csm-stat-card .csm-stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--csm-navy);
}

/* ---------- Buttons ---------- */
.btn-csm-primary {
    background: var(--csm-green);
    border-color: var(--csm-green);
    color: var(--csm-white);
}

.btn-csm-primary:hover {
    background: var(--csm-green-dark);
    border-color: var(--csm-green-dark);
    color: var(--csm-white);
}

/* ---------- Scoring buttons (used from Stage 3 onward) ---------- */
.csm-score-btn {
    min-width: 64px;
    min-height: 64px;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 12px;
}

/* =====================================================================
   Public site (Home / Teams / Schedule / Live Scores / Scorecard) -
   no login required for any of this.
   ===================================================================== */

.csm-public-body {
    background: var(--csm-bg);
}

.csm-public-main {
    min-height: calc(100vh - 64px);
}

/* Original stylized cricket-ground illustration, fixed behind the page
   content at low opacity - decorative only, never behind readable text
   at full strength. */
body.csm-ground-bg {
    position: relative;
}

body.csm-ground-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url('../images/cricket-ground-bg.svg') center top / 1100px auto no-repeat;
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
}

body.csm-ground-bg > * {
    position: relative;
    z-index: 1;
}

/* ---------- Public navbar ---------- */
.csm-public-navbar {
    background: var(--csm-white);
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

.csm-public-navbar .navbar-brand {
    color: var(--csm-charcoal);
}

.csm-public-navbar .nav-link {
    color: var(--csm-charcoal);
    font-weight: 500;
    padding: .5rem .9rem;
    border-radius: 8px;
}

.csm-public-navbar .nav-link:hover {
    background: var(--csm-bg);
}

.csm-public-navbar .nav-link.active {
    color: var(--csm-orange);
}

/* ---------- Hero ---------- */
.csm-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--csm-charcoal) 0%, var(--csm-maroon) 45%, var(--csm-orange) 100%);
    color: var(--csm-white);
}

.csm-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url('../images/cricket-ground-bg.svg') center 15% / 900px auto no-repeat;
    opacity: 0.3;
}

.csm-hero .container {
    position: relative;
    z-index: 1;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

@media (min-width: 768px) {
    .csm-hero .container {
        padding-top: 5rem;
        padding-bottom: 5rem;
    }
}

.csm-hero h1 {
    color: var(--csm-white);
}

.csm-hero .lead {
    color: rgba(255,255,255,.85) !important;
}

.csm-hero img {
    filter: drop-shadow(0 6px 14px rgba(0,0,0,.35));
}

/* ---------- Team & live-match cards ---------- */
.csm-team-card {
    border: none;
    border-top: 4px solid var(--csm-orange);
    border-radius: 12px;
    background: linear-gradient(160deg, #ffffff 0%, #fdf1e4 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    overflow: hidden;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease, border-color .3s ease;
}

.csm-team-card img {
    transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}

.csm-team-card .bi-shield {
    transition: transform .35s cubic-bezier(.34,1.56,.64,1), color .3s ease;
}

.csm-team-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-top-color: var(--csm-maroon);
    box-shadow: 0 14px 28px rgba(167,53,56,.22);
}

.csm-team-card:hover img {
    transform: scale(1.12) rotate(-4deg);
}

.csm-team-card:hover .bi-shield {
    transform: scale(1.15) rotate(-4deg);
    color: var(--csm-orange) !important;
}

.csm-live-card {
    border: none;
    border-radius: 12px;
    border-left: 4px solid var(--csm-maroon);
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}

.csm-live-card:hover {
    transform: translateY(-5px) scale(1.015);
    box-shadow: 0 10px 24px rgba(0,0,0,.14);
}

/* ---------- Player cards (team roster) ---------- */
.csm-player-card {
    border: none;
    border-top: 3px solid var(--csm-gold);
    border-radius: 12px;
    background: linear-gradient(160deg, #ffffff 0%, #f8f3e8 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease, border-color .3s ease;
}

.csm-player-card img,
.csm-player-card .bi-person-circle {
    transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}

.csm-player-card:hover {
    transform: translateY(-6px) scale(1.04);
    border-top-color: var(--csm-orange);
    background: linear-gradient(160deg, #ffffff 0%, #fdf1e4 100%);
    box-shadow: 0 14px 26px rgba(244,122,48,.28);
}

.csm-player-card:hover img,
.csm-player-card:hover .bi-person-circle {
    transform: scale(1.12) rotate(3deg);
}

.csm-clickable-row {
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease;
}

.csm-clickable-row:hover {
    background: var(--csm-bg);
    box-shadow: inset 4px 0 0 var(--csm-orange);
}

/* ---------- Schedule / results list rows (Home page) ---------- */
.csm-schedule-row {
    transition: background .25s ease, padding-left .25s ease, box-shadow .25s ease;
    border-left: 4px solid transparent;
}

.csm-schedule-row:hover {
    background: linear-gradient(90deg, #fdf1e4 0%, transparent 100%);
    padding-left: 1.25rem !important;
    border-left-color: var(--csm-orange);
}

.csm-schedule-row:hover .fw-semibold {
    color: var(--csm-maroon);
}
