:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-dark: #1e40af;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #ca8a04;
    --dark: #0f172a;
    --light: #f8fafc;
    --gray: #64748b;
    --text-main: var(--text);
    --sidebar: #0f172a;
    --admin: #dc2626;
    --blue: #2563eb;
    --red: #dc2626;
    --green: #16a34a;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
    --content-max: 1200px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

main,
.container,
.card,
.table-container,
.filter-card,
.scoreboard,
.court-area,
.footer-controls,
.login-card,
.header,
.hero,
.features,
.top-nav,
.split-container,
.table-panel {
    width: 100%;
}

main,
.container,
.header,
.filter-card,
.table-container,
.card,
.login-card {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
}

.card,
.login-card,
.filter-card,
.table-container,
.user-card,
.player-card,
.add-card,
.scoreboard,
.live-stats-card,
.table-panel,
.match-header,
.tab-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th,
td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: var(--surface-2);
    text-align: left;
    font-weight: 600;
    color: var(--text);
}

tr:last-child td {
    border-bottom: none;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: var(--primary);
}

button,
.btn,
.btn-add,
.btn-save,
.btn-login,
.btn-filter,
.btn-primary,
.btn-secondary,
.btn-settings,
.btn-profile,
.btn-view,
.btn-sm,
.btn-action,
.action-btn {
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

button:hover,
.btn:hover,
.btn-add:hover,
.btn-save:hover,
.btn-login:hover,
.btn-filter:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-settings:hover,
.btn-profile:hover,
.btn-view:hover,
.btn-sm:hover,
.btn-action:hover,
.action-btn:hover {
    text-decoration: none;
}

button:active,
.btn:active,
.btn-add:active,
.btn-save:active,
.btn-login:active,
.btn-filter:active,
.btn-primary:active,
.btn-secondary:active,
.btn-settings:active,
.btn-profile:active,
.btn-view:active,
.btn-sm:active,
.btn-action:active,
.action-btn:active {
    transform: translateY(1px);
}

.btn,
.btn-save,
.btn-add,
.btn-login,
.btn-filter,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: var(--primary);
    color: #fff;
    padding: 0.72rem 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.btn:hover,
.btn-save:hover,
.btn-add:hover,
.btn-login:hover,
.btn-filter:hover,
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-full {
    width: 100%;
}

.btn-secondary,
.btn-cancel,
.btn-sec {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text);
    padding: 0.72rem 1rem;
    border: 1px solid var(--border);
    font-weight: 600;
}

.btn-secondary:hover,
.btn-cancel:hover,
.btn-sec:hover {
    background: #e2e8f0;
}

.badge,
.badge.active,
.badge-admin,
.badge-coach,
.badge-player {
    border-radius: 999px;
}

aside {
    flex-shrink: 0;
}

body > aside + main,
body > main {
    padding: 1rem;
}

body:has(aside) {
    display: flex;
    align-items: stretch;
}

h1,
h2,
h3,
h4,
h5 {
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

p {
    margin: 0 0 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    :root {
        --content-max: 100%;
    }

    body:has(aside) {
        display: block;
    }

    aside {
        width: 100% !important;
        min-height: auto !important;
        position: static !important;
    }

    body > aside + main,
    body > main {
        padding: 0.9rem;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 15px;
    }

    .leader-grid,
    .dashboard-grid,
    .roster-grid,
    .feature-grid,
    .split-container,
    .actions,
    .player-grid {
        grid-template-columns: 1fr !important;
    }

    table {
        font-size: 0.88rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .top-nav,
    .header,
    .team-header,
    .match-header {
        padding: 0.85rem !important;
    }
}

@media (max-width: 480px) {
    body > aside + main,
    body > main,
    .container,
    .card,
    .table-container,
    .filter-card,
    .login-card {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    th,
    td {
        padding: 0.55rem 0.5rem;
    }
}

body.settings-page {
    padding: 1.25rem;
    display: flex;
    justify-content: center;
}

.settings-card {
    width: 100%;
    max-width: 450px;
    padding: 1.75rem;
}

.settings-back-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.settings-back-link:hover {
    text-decoration: underline;
}

.settings-title {
    margin-top: 0.95rem;
    font-size: 1.4rem;
}

.settings-card label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.settings-card input[type="text"],
.settings-card input[type="password"] {
    margin-bottom: 0.95rem;
}

.logo-preview {
    width: 80px;
    height: 80px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-bottom: 0.65rem;
    display: block;
}

.logo-preview.placeholder {
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.8rem;
}

.file-input {
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
}

.alert {
    padding: 0.65rem 0.8rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert.success {
    background: #dcfce7;
    color: var(--success);
    border-color: #bbf7d0;
}

.alert.error {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fecaca;
}

.section-break {
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
    padding-top: 1rem;
}

.settings-emphasis-label {
    color: var(--dark) !important;
}

.settings-help-text {
    margin-top: 0;
    margin-bottom: 0.65rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.settings-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0 0 1rem;
}

@media (max-width: 480px) {
    body.settings-page {
        padding: 0.85rem;
    }

    .settings-card {
        padding: 1rem;
    }
}

.text-primary {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

.text-subtle {
    color: #94a3b8;
}

.text-danger {
    color: #ef4444;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.85rem;
}

.mb-15 {
    margin-bottom: 15px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mb-25 {
    margin-bottom: 25px;
}

.mt-5 {
    margin-top: 5px;
}

.mt-15 {
    margin-top: 15px;
}

.mt-20 {
    margin-top: 20px;
}

.px-50 {
    padding: 50px;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.inline-flex {
    display: inline-flex;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-10 {
    gap: 10px;
}

.gap-12 {
    gap: 12px;
}

.gap-15 {
    gap: 15px;
}

.w-60 {
    width: 60px;
}

.link-muted {
    text-decoration: none;
    color: var(--text-muted);
}

.link-muted:hover {
    text-decoration: underline;
}

.link-light-strong {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.link-light-strong:hover {
    text-decoration: underline;
}

.results-kicker {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.7;
    letter-spacing: 1px;
}

.results-opponent {
    font-size: 1.2rem;
    margin-top: 5px;
}

.results-date {
    font-size: 0.85rem;
    opacity: 0.8;
}

.set-summary {
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.is-open {
    display: block;
}

.empty-state-msg {
    padding: 20px;
    color: #94a3b8;
}

.empty-state-cell {
    padding: 50px;
    color: #94a3b8;
}

.top-nav-set {
    color: #38bdf8;
}

.manual-controls {
    margin-top: 20px;
    text-align: center;
}

.manual-controls .btn-sec {
    font-size: 0.8rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.flex-1 {
    flex: 1;
}

.btn-blue {
    background: var(--blue);
    color: #fff;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-link {
    color: #94a3b8;
    text-decoration: none;
    margin: 0 10px;
}

.footer-link:hover {
    text-decoration: underline;
}

.dashboard-signout {
    margin-top: auto;
    color: #f87171;
}

.leader-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.85rem;
}

.roster-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f9fafb;
}

.roster-player-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.admin-empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px;
}

.joined-meta {
    font-size: 0.75rem;
    opacity: 0.7;
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--danger);
}

.live-mini-empty {
    text-align: center;
    padding: 10px;
    color: #94a3b8;
    font-size: 0.8rem;
}

.live-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.live-mini-head {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.live-mini-th {
    padding: 6px 2px;
    color: #64748b;
    font-size: 0.65rem;
    text-align: center;
}

.live-mini-th-player {
    text-align: left;
    padding: 6px 4px;
}

.live-mini-row {
    border-bottom: 1px solid #f1f5f9;
}

.live-mini-player {
    padding: 6px 4px;
    font-weight: 700;
    white-space: nowrap;
}

.live-mini-name {
    font-weight: 400;
    font-size: 0.7rem;
    color: #64748b;
}

.live-mini-stat {
    text-align: center;
    padding: 6px 2px;
    font-weight: 600;
}

.live-mini-stat-strong {
    font-weight: 800;
}

.live-mini-err {
    color: var(--danger);
}

.live-mini-ace {
    color: var(--warning);
}

.live-mini-dig {
    color: #64748b;
}

.live-mini-pass {
    color: var(--primary);
}

.live-mini-eff-pos {
    color: var(--success);
}

.live-mini-eff-neg {
    color: var(--danger);
}

body.new-match-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.new-match-card {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}

.new-match-cancel {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.new-match-title {
    margin-top: 0.8rem;
}

.new-match-card label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
}

.new-match-card input {
    margin-bottom: 1rem;
}