:root {
    --primary: #111111;
    --ink: #171717;
    --muted: #5B6472;
    --surface: #FFFFFF;
    --soft: #F6F7F4;
    --sport: #EEF5EF;
    --line: #D9DED7;
    --green: #0E7C3A;
    --blue: #1976D2;
    --sand: #D69A32;
    --danger: #C83232;
    --gray-100: #F5F5F5;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
    font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    min-height: 44px;
    padding: 10px 16px;
    color: #fff;
    background: var(--ink);
    border: 0;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.osa-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px minmax(0, 1fr);
}

.osa-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    margin-bottom: 14px;
}

.brand img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
}

.brand strong {
    display: block;
    color: var(--ink);
    font-size: 18px;
}

.brand span {
    color: var(--muted);
    font-size: 13px;
}

.menu {
    display: grid;
    gap: 10px;
}

.menu-group {
    display: grid;
    gap: 4px;
}

.menu-group-title {
    justify-content: start;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    color: var(--muted);
    background: transparent;
    text-align: left;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    cursor: default;
}

.menu-group-items {
    display: grid;
    gap: 3px;
}

.menu-item {
    justify-content: start;
    width: 100%;
    color: var(--ink);
    background: transparent;
    border-radius: 8px;
    text-align: left;
    font-size: 15px;
}

.menu-item:hover,
.menu-item.active {
    color: #fff;
    background: var(--ink);
}

.osa-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px 20px;
    background: rgba(246, 247, 244, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 900;
}

.topbar p {
    margin: 2px 0 0;
    color: var(--muted);
}

.icon-button,
.ghost-button {
    color: var(--ink);
    background: var(--sport);
}

.icon-button {
    display: none;
    width: 44px;
    padding: 0;
    font-size: 22px;
}

.user-box {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--muted);
    font-weight: 700;
}

.login-panel {
    display: grid;
    min-height: calc(100vh - 85px);
    place-items: center;
    padding: 24px;
}

.view#view-login {
    min-height: calc(100vh - 85px);
    padding: 24px;
    place-items: center;
}

.view#view-login.active {
    display: grid;
}

.login-card {
    display: grid;
    width: min(100%, 420px);
    gap: 14px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-card img {
    width: 180px;
    justify-self: center;
}

.login-card h2 {
    margin: 0;
    text-align: center;
    font-size: 30px;
}

.login-card p,
.login-card small {
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.app-panel {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.panel,
.selectors,
.hero-card,
.match-card,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.selectors {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    padding: 18px;
}

.app-selectors {
    border: 0;
    padding: 0;
}

.compact-selectors {
    grid-template-columns: minmax(160px, 320px);
    padding: 0;
    margin: 12px 0;
    border: 0;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: center;
    padding: 22px;
    color: #fff;
    background: var(--ink);
    border-color: var(--ink);
}

.hero-card h2 {
    margin: 0;
    font-size: 30px;
    font-weight: 900;
}

.hero-card p {
    max-width: 720px;
    color: var(--gray-300);
    line-height: 1.6;
}

.hero-card img {
    width: 260px;
    max-width: 32vw;
    background: #fff;
    border-radius: 14px;
}

.metric-grid,
.stats-grid,
.registry-grid {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.stat-card {
    padding: 18px;
}

.metric-card strong,
.stat-card strong {
    display: block;
    font-size: 28px;
    line-height: 1;
}

.metric-card span,
.stat-card span {
    color: var(--muted);
    font-weight: 700;
}

.stats-panel {
    display: grid;
    gap: 16px;
    margin-top: 14px;
}

.stats-selector-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats-select {
    text-transform: uppercase;
}

.stats-summary-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(135deg, #FFFFFF 0%, #F3F7F0 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 22px rgba(23, 23, 23, .06);
}

.stats-dashboard-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.stats-summary-card h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.05;
    font-weight: 900;
}

.stats-summary-card p {
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.stats-kicker,
.stats-summary-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.stats-highlight {
    display: grid;
    min-width: 150px;
    gap: 4px;
    justify-items: end;
    padding: 14px 16px;
    color: #fff;
    background: var(--ink);
    border-radius: 8px;
}

.stats-highlight span {
    color: rgba(255, 255, 255, .72);
}

.stats-highlight strong {
    color: #fff;
    font-size: 42px;
    line-height: 1;
    font-weight: 900;
}

.stats-metric-list,
.stats-ranking-list {
    display: grid;
    gap: 10px;
}

.stats-metric-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-metric-row,
.stats-list-row {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(23, 23, 23, .04);
}

.stats-list-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
}

.stats-metric-row {
    display: grid;
    min-height: 108px;
    align-content: space-between;
}

.stats-metric-row div:first-child {
    display: grid;
    gap: 6px;
}

.stats-metric-row strong {
    font-size: 30px;
    line-height: 1;
    font-weight: 900;
}

.stats-metric-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.stats-list-row {
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.stats-list-row:hover {
    border-color: rgba(14, 124, 58, .45);
    box-shadow: 0 12px 24px rgba(23, 23, 23, .08);
    transform: translateY(-1px);
}

.stats-list-row i {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--green);
    background: var(--sport);
    border-radius: 8px;
    font-style: normal;
    font-weight: 900;
}

.stats-list-row span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.stats-list-row strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-list-row b {
    min-width: 72px;
    padding: 8px 10px;
    color: var(--ink);
    background: var(--sport);
    border-radius: 8px;
    text-align: center;
    font-size: 24px;
    line-height: 1;
    font-weight: 900;
}

.stats-progress {
    width: 100%;
    height: 10px;
    overflow: hidden;
    background: #E8ECE6;
    border-radius: 999px;
}

.stats-progress span {
    display: block;
    min-width: 6px;
    height: 100%;
    background: linear-gradient(90deg, var(--green), #36A968);
    border-radius: inherit;
}

.stats-histogram {
    display: grid;
    grid-template-columns: repeat(14, minmax(12px, 1fr));
    gap: 8px;
    align-items: end;
    min-height: 190px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(23, 23, 23, .04);
}

.histogram-bar {
    display: grid;
    grid-template-rows: auto minmax(90px, 1fr) auto;
    gap: 6px;
    align-items: end;
    height: 158px;
    text-align: center;
}

.histogram-bar b {
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
}

.histogram-bar span {
    display: block;
    width: 100%;
    min-height: 6px;
    background: linear-gradient(180deg, #36A968, var(--green));
    border-radius: 6px 6px 2px 2px;
}

.histogram-bar small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.panel {
    padding: 18px;
}

.nested-panel {
    padding: 18px 0 0;
    margin-top: 18px;
    border-top: 1px solid var(--line);
}

.panel-heading,
.panel-toolbar,
.stats-toolbar,
.view-actions {
    display: flex;
    gap: 12px;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 14px;
}

.view-actions {
    justify-content: flex-start;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.panel-heading h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 12px;
}

.tab,
.secondary-action {
    color: var(--muted);
    background: transparent;
    border-radius: 8px;
}

.tab.active,
.secondary-action.active {
    color: var(--green);
    background: var(--sport);
}

.round-tab {
    display: none;
}

.round-tab.active {
    display: block;
}

.match-list {
    display: grid;
    gap: 12px;
}

.select-list {
    display: grid;
    gap: 10px;
}

.select-row {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-transform: none;
}

.select-row input {
    width: 24px;
    min-height: 24px;
}

.match-card {
    padding: 14px;
}

.match-header {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
}

.team-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
}

.team-logo {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    overflow: hidden;
    background: var(--sport);
    border-radius: 12px;
}

.team-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.score-pill {
    min-width: 48px;
    padding: 8px 14px;
    color: #fff;
    background: var(--ink);
    border-radius: 14px;
    text-align: center;
    font-size: 20px;
    font-weight: 900;
}

.match-detail {
    color: var(--muted);
    font-size: 13px;
}

.match-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.report-shell {
    display: grid;
    gap: 14px;
    padding: 20px;
}

.report-score {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 16px;
    color: #fff;
    background: var(--ink);
    border-radius: 8px;
}

.report-team {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    color: #fff;
    background: transparent;
    text-align: left;
}

.report-team:last-child {
    grid-template-columns: auto minmax(0, 1fr);
    text-align: right;
}

.report-team.active {
    color: var(--green);
    background: #fff;
}

.report-team span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 20px;
    font-weight: 900;
}

.report-team strong {
    font-size: 28px;
}

.score-separator {
    color: var(--gray-300);
    font-size: 28px;
    font-weight: 900;
}

.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.report-list {
    display: grid;
    gap: 8px;
}

.report-player {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.report-player.warn {
    background: #FFF7CF;
}

.report-player.danger {
    color: #fff;
    background: var(--danger);
}

.report-presence {
    display: block;
}

.report-presence input {
    width: 24px;
    min-height: 24px;
}

.report-player-main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.report-player-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-end;
}

.stat-icon {
    position: relative;
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
}

.stat-icon img,
.icon-action img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.stat-icon small {
    position: absolute;
    right: -8px;
    bottom: -5px;
    min-width: 18px;
    padding: 1px 4px;
    color: #fff;
    background: var(--ink);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 900;
    text-align: center;
}

.icon-action {
    display: grid;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 7px;
    place-items: center;
    background: transparent;
}

.danger-action {
    background: transparent;
}

.table-wrap {
    overflow-x: auto;
}

.table-wrap td img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    vertical-align: middle;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    text-transform: uppercase;
}

td {
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

td:first-child {
    border-left: 1px solid var(--line);
    border-radius: 14px 0 0 14px;
}

td:last-child {
    border-right: 1px solid var(--line);
    border-radius: 0 14px 14px 0;
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.row-actions button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
}

.danger-button {
    background: var(--danger);
}

.empty-state {
    padding: 22px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    text-align: center;
}

.registry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.registry-grid .wide {
    grid-column: 1 / -1;
}

.edit-dialog {
    width: min(720px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 0;
    border-radius: 18px;
}

.edit-dialog::backdrop {
    background: rgba(17, 17, 17, .5);
}

.edit-dialog form {
    display: grid;
    max-height: calc(100vh - 24px);
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.edit-dialog header,
.edit-dialog footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.edit-dialog footer {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.edit-dialog h2 {
    margin: 0;
    font-size: 22px;
}

.dialog-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
}

.dialog-fields label.full,
.dialog-fields .full {
    grid-column: 1 / -1;
}

.message {
    color: var(--muted);
}

@media (max-width: 980px) {
    .osa-shell {
        grid-template-columns: 1fr;
    }

    .osa-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: 280px;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .osa-sidebar.open {
        transform: translateX(0);
    }

    .icon-button {
        display: inline-grid;
        place-items: center;
    }

    .selectors,
    .metric-grid,
    .stats-metric-list,
    .stats-selector-bar,
    .registry-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 620px) {
    .topbar {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .user-box {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    .app-panel {
        padding: 12px;
    }

    .selectors,
    .metric-grid,
    .stats-metric-list,
    .stats-selector-bar,
    .registry-grid,
    .dialog-fields {
        grid-template-columns: 1fr;
    }

    .stats-dashboard-card {
        grid-template-columns: 1fr;
    }

    .stats-highlight {
        justify-items: start;
    }

    .stats-list-row {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .stats-list-row b {
        grid-column: 2;
        justify-self: start;
    }

    .stats-histogram {
        grid-template-columns: repeat(7, minmax(12px, 1fr));
    }

    .hero-card {
        grid-template-columns: 1fr;
    }

    .hero-card img {
        width: 180px;
        max-width: 100%;
    }

    .panel-heading,
    .panel-toolbar,
    .stats-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}
