:root {
    --brand: #247d22;
    --brand-dark: #176617;
    --brand-soft: #eef8ee;
    --ink: #121417;
    --muted: #626873;
    --panel: #ffffff;
    --surface: #f8f8f7;
    --sidebar: #f5f1f7;
    --field: #f3eef4;
    --line: #d4d2d7;
    --line-soft: #ece9ee;
    --warning-bg: #fff0a8;
    --warning-ink: #8a4d00;
    --info-bg: #bfeff5;
    --info-ink: #0b6170;
    --shadow: 0 12px 28px rgba(18, 20, 23, .08);
}

* {
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    background: var(--surface);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--brand-dark);
}

.admin-frame {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 246px minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--sidebar);
}

.brand-lockup {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    color: var(--ink);
    text-decoration: none;
}

.brand-lockup strong {
    display: block;
    line-height: 1.05;
    font-size: 1.05rem;
}

.brand-lockup small {
    color: var(--muted);
    font-size: .72rem;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    border-radius: 7px;
    background: var(--brand);
    color: #fff;
}

.brand-mark svg,
.side-nav-link svg,
.btn svg,
.icon-button svg,
.search-pill svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.25;
}

.side-nav {
    display: grid;
    gap: 8px;
    padding: 24px 22px;
}

.side-nav-link {
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    border-radius: 7px;
    color: #2c2e33;
    text-decoration: none;
    border-right: 3px solid transparent;
}

.side-nav-link:hover,
.side-nav-link.active {
    background: var(--brand-soft);
    color: #08620d;
}

.side-nav-link.active {
    border-right-color: var(--brand);
    font-weight: 700;
}

.side-nav-link.is-disabled {
    color: #8a8790;
    opacity: .68;
}

.sidebar-action {
    margin-top: auto;
    padding: 22px;
    border-top: 1px solid var(--line);
}

.app-workspace {
    min-width: 0;
}

.app-topbar,
.public-topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: #fbfafb;
}

.app-topbar {
    justify-content: space-between;
    gap: 18px;
    padding: 0 32px;
}

.public-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
}

.search-pill {
    width: min(370px, 44vw);
    height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid #c9c5ce;
    border-radius: 22px;
    background: #f4f0f5;
    color: #68707b;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
}

.icon-button:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.user-chip {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #d7ecef;
    color: var(--ink);
    font-weight: 800;
}

.app-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 26px 32px 32px;
}

.public-shell .container {
    max-width: 1120px;
}

.page-title,
.admin-shell h1.h3 {
    font-size: clamp(1.7rem, 3vw, 2.05rem);
    line-height: 1.08;
    font-weight: 800;
}

.hero {
    min-height: 300px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(28px, 5vw, 56px);
    margin-bottom: 28px;
    display: flex;
    align-items: flex-end;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(12, 20, 14, .86), rgba(12, 20, 14, .38)),
        url('https://images.unsplash.com/photo-1622279457486-62dcc4a431d6?auto=format&fit=crop&w=1600&q=80') center/cover;
    box-shadow: var(--shadow);
}

.hero h1 {
    max-width: 760px;
    font-size: clamp(2rem, 4vw, 3.7rem);
    font-weight: 850;
}

.panel,
.championship-card,
.championship-head,
.empty-state {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    overflow: hidden;
}

.admin-shell .panel,
form.panel,
.panel.padded {
    padding: 24px;
}

.table-responsive.panel {
    padding: 0;
}

.panel-titlebar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: #f6f2f7;
}

.table {
    --bs-table-color: var(--ink);
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table thead th {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    color: #303238;
    font-size: .78rem;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.table tbody td {
    padding: 22px 24px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table-sm thead th,
.table-sm tbody td {
    padding: 12px 16px;
}

.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 7px;
    font-weight: 700;
}

.btn-sm {
    min-height: 32px;
    font-size: .82rem;
}

.btn-primary,
.btn-success {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-dark);
    --bs-btn-border-color: #b9c7b8;
    --bs-btn-hover-bg: var(--brand-soft);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.btn-outline-secondary {
    --bs-btn-color: #2d3035;
    --bs-btn-border-color: #c7c5ca;
    --bs-btn-hover-bg: #f4f0f5;
    --bs-btn-hover-border-color: #bdb8c2;
    --bs-btn-hover-color: #111;
}

.form-label {
    margin-bottom: 8px;
    color: #33363b;
    font-size: .82rem;
    text-transform: uppercase;
}

.form-control,
.form-select {
    min-height: 42px;
    border-color: #c9c5ce;
    border-radius: 7px;
    background-color: var(--field);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .18rem rgba(36, 125, 34, .12);
}

.badge {
    border-radius: 999px;
    padding: .48em .72em;
    font-size: .68rem;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.text-bg-secondary {
    background: #e4e1e7 !important;
    color: #3d3b42 !important;
}

.text-bg-warning {
    background: var(--warning-bg) !important;
    color: var(--warning-ink) !important;
}

.text-bg-info {
    background: var(--info-bg) !important;
    color: var(--info-ink) !important;
}

.text-bg-success,
.text-bg-primary {
    background: #dff4df !important;
    color: #09660f !important;
}

.championship-card {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
    text-decoration: none;
    color: inherit;
    transition: transform .16s ease, box-shadow .16s ease;
}

.championship-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 34px rgba(18, 20, 23, .13);
}

.championship-card h3 {
    margin-top: 18px;
    font-size: 1.18rem;
    font-weight: 800;
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.championship-head {
    padding: 28px;
    margin-bottom: 22px;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
}

.championship-head::after,
.metric-card::after,
.preview-panel::after {
    content: "";
    position: absolute;
    right: -28px;
    bottom: -38px;
    width: 130px;
    height: 130px;
    border: 18px solid rgba(18, 20, 23, .055);
    border-radius: 50%;
    pointer-events: none;
}

.championship-head h1 {
    margin-top: 10px;
    font-weight: 850;
}

.head-meta {
    min-width: 220px;
    display: grid;
    gap: 8px;
    align-content: start;
}

.head-meta span,
.head-meta strong {
    padding: 9px 11px;
    background: #f4f0f5;
    border: 1px solid var(--line-soft);
    border-radius: 7px;
}

.rule-chips {
    min-width: min(320px, 100%);
    gap: 10px;
}

.head-meta.rule-chips span,
.head-meta.rule-chips strong {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.rule-chip {
    display: grid;
    grid-template-columns: 38px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #f4f0f5;
}

.rule-chip svg {
    grid-row: 1 / 3;
    width: 22px;
    height: 22px;
    align-self: center;
    justify-self: center;
    color: rgb(41 122 36);
}

.rule-chip span {
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.rule-chip strong {
    color: var(--ink);
    font-size: .96rem;
    line-height: 1.15;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(300px, .9fr);
    gap: 24px;
}

.admin-dashboard-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-dashboard-head h1 {
    margin: 4px 0 6px;
    font-size: clamp(2rem, 3vw, 2.6rem);
    line-height: 1;
    font-weight: 900;
}

.admin-dashboard-head p {
    margin: 0;
    color: var(--muted);
}

.section-kicker {
    color: rgb(41 122 36);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.summary-card {
    position: relative;
    min-height: 126px;
    padding: 20px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.summary-card::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -42px;
    width: 112px;
    height: 112px;
    border: 16px solid rgba(18, 20, 23, .055);
    border-radius: 50%;
}

.summary-card span {
    display: block;
    color: #303238;
    font-size: .78rem;
    text-transform: uppercase;
}

.summary-card strong {
    display: block;
    margin-top: 12px;
    font-size: 2.25rem;
    line-height: 1;
    font-weight: 900;
}

.summary-card small {
    display: block;
    margin-top: 8px;
    color: rgb(41 122 36);
    font-weight: 800;
}

.dashboard-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

.dashboard-side {
    display: grid;
    gap: 22px;
}

.dashboard-side .panel,
.tournament-panel.panel {
    padding: 0;
}

.tournament-panel {
    padding: 0;
}

.table-count {
    min-width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 7px;
    background: var(--brand-soft);
    color: rgb(41 122 36);
    font-weight: 900;
}

.tournament-list {
    display: grid;
}

.tournament-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(150px, .6fr) 120px minmax(150px, .65fr) auto;
    gap: 18px;
    align-items: center;
    min-height: 94px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line-soft);
}

.tournament-row:last-child {
    border-bottom: 0;
}

.tournament-row:hover {
    background: #fbfafa;
}

.tournament-name {
    display: grid;
    gap: 4px;
}

.tournament-name strong {
    font-size: 1rem;
    line-height: 1.2;
}

.tournament-name span,
.tournament-date,
.tournament-format {
    color: #333940;
}

.tournament-name span {
    color: var(--muted);
    font-size: .86rem;
}

.tournament-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.tournament-actions form {
    display: inline-flex;
}

.icon-action {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #bec9bd;
    border-radius: 7px;
    background: #fff;
    color: rgb(41 122 36);
    text-decoration: none;
}

.icon-action svg {
    width: 17px;
    height: 17px;
}

.icon-action:hover {
    background: var(--brand-soft);
    border-color: rgb(41 122 36);
    color: rgb(41 122 36);
}

.icon-action.danger {
    color: #e11d31;
    border-color: #f0a5ad;
}

.icon-action.danger:hover {
    background: #fff1f2;
    border-color: #e11d31;
    color: #e11d31;
}

.quick-panel {
    padding: 0;
    overflow: hidden;
}

.quick-panel a {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    color: var(--ink);
    text-decoration: none;
    border-top: 1px solid var(--line-soft);
}

.quick-panel a:hover {
    background: var(--brand-soft);
    color: rgb(41 122 36);
}

.championship-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 18px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(18, 20, 23, .05);
}

.championship-actions form {
    display: inline-flex;
}

.metric-stack {
    display: grid;
    gap: 22px;
}

.metric-card {
    min-height: 126px;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.metric-label {
    margin-bottom: 12px;
    color: #25282d;
    text-transform: uppercase;
}

.metric-value {
    font-size: 2.3rem;
    line-height: 1;
    font-weight: 850;
}

.metric-note {
    color: #0d7515;
    font-weight: 800;
}

.matches-card {
    min-height: 300px;
}

.match-item {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
}

.match-item + .match-item {
    border-top: 1px solid var(--line-soft);
}

.date-tile {
    min-height: 42px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: #f0edf2;
    font-size: .78rem;
    font-weight: 800;
}

.standing-qualified td {
    background: #e6f5e4 !important;
}

.standing-qualified td:first-child {
    border-left: 4px solid rgb(41 122 36);
    color: rgb(41 122 36);
    font-weight: 850;
}

.bracket {
    display: flex;
    align-items: flex-start;
    gap: 56px;
    overflow-x: auto;
    padding: 24px 18px 30px;
}

.bracket-board {
    position: relative;
    min-height: 300px;
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    background:
        linear-gradient(180deg, #ffffff 0 72px, transparent 72px),
        #fff;
}

.bracket-board::before {
    content: "CHAMPIONSHIP";
    position: absolute;
    top: 10px;
    left: 18px;
    color: rgb(41 122 36);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 900;
    line-height: 1;
    opacity: .08;
    pointer-events: none;
}

.bracket-round {
    position: relative;
    min-width: 230px;
    flex: 0 0 250px;
    padding-top: 10px;
}

.bracket-round h3 {
    min-height: 28px;
    margin: 0;
    color: rgb(41 122 36);
    font-size: .72rem;
    font-weight: 900;
    line-height: 1.05;
    text-transform: uppercase;
}

.bracket-round:not(:first-child) {
    padding-top: 10px;
}

.bracket-matches {
    display: flex;
    flex-direction: column;
    gap: var(--round-gap, 24px);
    margin-top: calc(14px + var(--round-offset, 0px));
}

.bracket-match {
    position: relative;
    z-index: 1;
    height: 58px;
    border-radius: 3px;
    box-shadow: 0 8px 16px rgba(12, 20, 14, .12);
}

.bracket-round:not(:first-child) .bracket-match::before {
    display: none;
}

.bracket-output {
    display: none;
}

.bracket-match:nth-child(odd) .bracket-output::after {
    display: none;
}

.bracket-match:nth-child(even) .bracket-output::after {
    display: none;
}

.bracket-player {
    height: 29px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: 1px solid #b7c9b5;
    background: #fff;
    color: #1e2a1e;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.05;
    text-transform: uppercase;
}

.bracket-player:first-child {
    border-radius: 3px 3px 0 0;
}

.bracket-player:last-child {
    border-top: 0;
    border-radius: 0 0 3px 3px;
}

.bracket-player span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bracket-player strong {
    min-height: 19px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    background: #f0f4ef;
    color: #1e2a1e;
    font-size: .74rem;
}

.bracket-player.winner {
    border-color: #164d14;
    background: rgb(41 122 36);
    color: #fff;
}

.bracket-player.winner strong {
    background: #fff;
    color: rgb(41 122 36);
}

.nav-tabs {
    border-bottom-color: var(--line);
}

.nav-tabs .nav-link {
    color: var(--muted);
    border-radius: 7px 7px 0 0;
    font-weight: 700;
}

.nav-tabs .nav-link.active {
    color: var(--brand-dark);
    background: #fff;
    border-color: var(--line) var(--line) #fff;
}

.login-panel {
    max-width: 430px;
    margin: 52px auto;
}

@media (max-width: 1080px) {
    .admin-frame {
        grid-template-columns: 86px minmax(0, 1fr);
    }

    .brand-lockup span:last-child,
    .side-nav-link span,
    .sidebar-action .btn span {
        display: none;
    }

    .side-nav-link,
    .brand-lockup {
        justify-content: center;
        padding-inline: 12px;
    }
}

@media (max-width: 820px) {
    .admin-frame {
        display: block;
    }

    .app-sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .side-nav {
        grid-template-columns: repeat(5, minmax(46px, 1fr));
        padding: 10px;
    }

    .sidebar-action {
        display: none;
    }

    .app-topbar {
        padding: 12px 16px;
    }

    .search-pill {
        width: 100%;
    }

    .app-container {
        padding: 20px 14px 28px;
    }

    .dashboard-grid,
    .dashboard-main,
    .championship-head {
        display: block;
    }

    .dashboard-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-dashboard-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .tournament-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .tournament-actions {
        justify-content: flex-start;
    }

    .metric-stack {
        margin-top: 18px;
    }

    .head-meta {
        margin-top: 18px;
    }

    .table thead th,
    .table tbody td {
        padding: 14px 12px;
    }
}

@media (max-width: 1180px) {
    .dashboard-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-main {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .dashboard-summary {
        grid-template-columns: 1fr;
    }
}
