* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f9;
    color: #1c1e21;
}

/* --- Login page --- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6f9;
}

.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 360px;
    padding: 32px 24px;
}

.login-logo {
    display: block;
    object-fit: contain;
}

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form label {
    font-size: 14px;
    font-weight: 600;
    color: #3a3f47;
}

.login-form input {
    padding: 10px 12px;
    border: 1px solid #cfd7df;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}

.login-form input:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

.login-error {
    margin: 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: #ffefef;
    border: 1px solid #ffc2c2;
    color: #8b1a1a;
    font-size: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-primary,
button.btn-primary {
    background: #1c1e21;
    color: #fff;
}

.btn-primary:hover,
button.btn-primary:hover {
    background: #33363d;
}

.login-form .btn-primary {
    margin-top: 4px;
    width: 100%;
}

/* --- App layout (20 / 80) --- */

.app-body {
    overflow: hidden;
}

.app-layout {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: #1c1e21;
    color: #e8eaed;
    padding: 20px 0;
}

.sidebar-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
}

.sidebar-logo {
    display: block;
    object-fit: contain;
    filter: invert(1);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.sidebar-link {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: #e8eaed;
    text-decoration: none;
    font-size: 15px;
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.14);
    font-weight: 600;
}

.sidebar-logout {
    margin: 0;
    padding: 16px 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-link--logout {
    color: #b0b5bd;
}

.main-content {
    padding: 28px 32px 40px;
    overflow-y: auto;
    max-height: 100vh;
}

/* --- Dashboard --- */

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

h1, h2 {
    margin: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-bottom: 10px;
}

.week-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

select {
    padding: 8px;
    border: 1px solid #cfd7df;
    border-radius: 8px;
    background: #fff;
}

.kpi-grid,
.charts-grid {
    display: grid;
    gap: 12px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 12px;
}

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

.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecf1;
}

.value {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
}

.muted {
    margin: 0;
    color: #697483;
}

.alerts {
    margin-bottom: 12px;
}

.alerts ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.alert {
    border-radius: 8px;
    padding: 10px;
}

.alert.warning {
    background: #fff7e6;
    border: 1px solid #ffe2a8;
}

.alert.critical {
    background: #ffefef;
    border: 1px solid #ffc2c2;
}

.alert.info {
    background: #ebf5ff;
    border: 1px solid #bfdeff;
}

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

canvas {
    width: 100% !important;
    max-height: 260px;
}

/* --- Pages: team, forms --- */

.page-header-block {
    margin-bottom: 20px;
}

.page-header-block--sub {
    margin-bottom: 24px;
}

.page-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.page-title-row h1 {
    line-height: 1.2;
}

.page-actions-row {
    display: flex;
    justify-content: flex-start;
}

.page-lead {
    margin: 0;
    font-size: 14px;
    color: #697483;
    line-height: 1.5;
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #4a6fa5;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: #e8ecf1;
    color: #4a4f57;
    font-size: 13px;
    font-weight: 600;
}

.btn-secondary {
    background: #fff;
    color: #1c1e21;
    border: 1px solid #cfd7df;
}

.btn-secondary:hover {
    background: #f0f2f5;
    border-color: #b8c4d0;
    color: #1c1e21;
}

.form-notice {
    margin: 0 0 16px 0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.form-notice--success {
    background: #e8f7ee;
    border: 1px solid #b8e6c8;
    color: #1f5c33;
}

.form-notice--error {
    background: #ffefef;
    border: 1px solid #ffc2c2;
    color: #8b1a1a;
}

.team-list-card {
    padding: 0;
    overflow: hidden;
}

.team-list-card .data-table {
    table-layout: fixed;
}

.team-list-card .data-table th,
.team-list-card .data-table td {
    padding: 12px 16px;
    vertical-align: middle;
    line-height: 1.35;
    box-sizing: border-box;
}

.team-list-card .data-table th:first-child,
.team-list-card .data-table td:first-child {
    padding-left: 20px;
    width: 32%;
}

.team-list-card .data-table th:nth-child(2),
.team-list-card .data-table td:nth-child(2) {
    width: 18%;
}

.team-list-card .data-table th.col-num,
.team-list-card .data-table td.col-num {
    width: 56px;
    padding-left: 12px;
    padding-right: 12px;
}

.team-list-card .data-table th:last-child,
.team-list-card .data-table td:last-child {
    padding-right: 20px;
}

.data-table__empty-row td {
    padding: 32px 20px !important;
    text-align: center;
    color: #697483;
    font-size: 14px;
    background: #fafbfc;
}

.data-table__empty-row:hover {
    background: #fafbfc !important;
}

.col-num {
    text-align: center;
}

.data-table .col-num {
    text-align: center;
}

.col-social {
    vertical-align: middle;
}

/* --- Add member form --- */

.form-card {
    max-width: 800px;
    padding: 28px 32px;
}

.member-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1c1e21;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8ecf1;
}

.form-section__hint {
    margin: -8px 0 0 0;
    font-size: 13px;
    color: #697483;
}

.form-grid {
    display: grid;
    gap: 16px 20px;
}

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

.form-field--full {
    grid-column: 1 / -1;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #3a3f47;
}

.form-field .req {
    color: #c44;
    font-weight: 400;
}

.form-field input,
.form-field select {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #cfd7df;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: #1c1e21;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input::placeholder {
    color: #9aa3af;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.form-field select {
    cursor: pointer;
    appearance: auto;
}

.form-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #e8ecf1;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #e8ecf1;
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: #f8f9fb;
}

.data-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #697483;
    font-weight: 600;
    background: #f8f9fb;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.badge--player {
    background: #e8f7ee;
    color: #1f5c33;
}

.badge--management {
    background: #ebf0ff;
    color: #2a4080;
}

.badge--staff {
    background: #f3e8ff;
    color: #5c3480;
}

.badge--media {
    background: #fff4e6;
    color: #8a5a00;
}

.badge--other {
    background: #f0f2f5;
    color: #4a4f57;
}

.social-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}

.social-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f0f2f5;
    font-size: 12px;
    line-height: 1.2;
}

.social-chip a {
    color: #2a4080;
    text-decoration: none;
    font-weight: 600;
}

.social-chip a:hover {
    text-decoration: underline;
}

/* --- Merch --- */

.list-card {
    padding: 0;
    overflow: hidden;
}

.merch-list-card .data-table {
    table-layout: fixed;
}

.merch-list-card .data-table th,
.merch-list-card .data-table td {
    padding: 12px 16px;
    vertical-align: middle;
    line-height: 1.35;
    box-sizing: border-box;
}

.merch-list-card .data-table th:first-child,
.merch-list-card .data-table td:first-child {
    padding-left: 20px;
}

.merch-list-card .data-table th:last-child,
.merch-list-card .data-table td:last-child {
    padding-right: 20px;
}

.merch-list-card .col-photo {
    width: 88px;
}

.merch-list-card .col-price {
    width: 96px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.merch-list-card .col-stacked-h {
    width: 90px;
}

.merch-list-card .col-actions {
    width: 130px;
    text-align: right;
}

.merch-thumb {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    background: #f0f2f5;
}

.merch-thumb--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa3af;
    font-size: 13px;
}

.col-stacked .stack-line {
    display: block;
    line-height: 1.6;
}

.col-stacked--qty .stack-line {
    font-weight: 600;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
}

.merch-writeoff-panel td {
    padding: 0 !important;
    background: #f8f9fb;
    border-bottom: 1px solid #e8ecf1;
}

.merch-writeoff-panel[hidden] {
    display: none;
}

.writeoff-panel__inner {
    padding: 16px 20px 20px;
}

.writeoff-form__grid {
    display: grid;
    grid-template-columns: 160px 120px 1fr;
    gap: 14px 16px;
    align-items: end;
    margin-bottom: 12px;
}

.writeoff-form .form-field--wide {
    grid-column: auto;
}

.writeoff-history {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e3e8ef;
}

.writeoff-history__title {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 700;
    color: #4a4f57;
}

.writeoff-history__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.writeoff-history__list li {
    font-size: 13px;
    color: #4a4f57;
    line-height: 1.45;
}

.writeoff-history__list time {
    color: #697483;
    font-weight: 600;
}

.size-qty-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 16px;
}

.form-hint {
    margin: 6px 0 0 0;
    font-size: 12px;
    color: #697483;
}

.form-field input[type="file"] {
    display: block;
    width: 100%;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: minmax(180px, 220px) 1fr;
    }

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

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 12px;
        gap: 8px;
    }

    .sidebar-brand {
        padding: 0;
        border: none;
        margin: 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex: 1;
        padding: 0;
    }

    .sidebar-logout {
        padding: 0;
        border: none;
        margin: 0;
    }

    .main-content {
        max-height: none;
        padding: 20px 16px 32px;
    }

    .page-actions-row .btn {
        width: 100%;
    }

    .charts-grid,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 24px;
    }

    .form-grid--2 {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 20px 16px;
    }

    .writeoff-form__grid {
        grid-template-columns: 1fr;
    }

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

    .merch-list-card .col-actions {
        text-align: left;
    }
}
