/* =========================================================
   IS PPP — design tokens
   ========================================================= */
:root {
    --bg: #F1F2F1;
    --surface: #FFFFFF;
    --ink: #1C1B22;
    --muted: #6B6C76;
    --border: #E3E3E7;

    --brand: #4E1C47;
    --brand-dark: #34142F;
    --brand-tint: #F3E9F1;

    --accent: #1F8A57;
    --accent-tint: #E6F4EC;

    --danger: #C4392F;
    --danger-tint: #FBEAE8;

    --radius-s: 8px;
    --radius-m: 14px;
    --radius-l: 20px;

    --shadow-card: 0 1px 2px rgba(28, 27, 34, 0.04), 0 8px 24px rgba(28, 27, 34, 0.05);

    --font-display: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* =========================================================
   Reset
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: var(--font-display);
    margin: 0;
    color: var(--ink);
}

p { margin: 0; }

a { color: inherit; }

button {
    font-family: inherit;
    cursor: pointer;
}

input {
    font-family: inherit;
    font-size: 0.95rem;
}

img { max-width: 100%; display: block; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.3rem;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn--primary {
    background: var(--brand);
    color: #fff;
}
.btn--primary:hover { background: var(--brand-dark); }
.btn--primary:disabled { opacity: 0.6; cursor: default; }

.btn--secondary {
    background: var(--surface);
    color: var(--brand);
    border-color: var(--border);
}
.btn--secondary:hover { border-color: var(--brand); }

.btn--ghost {
    background: transparent;
    color: var(--brand);
    padding: 0.55rem 0.9rem;
}
.btn--ghost:hover { background: var(--brand-tint); }

.btn--block { width: 100%; }

/* =========================================================
   Form fields
   ========================================================= */
.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--ink);
}

.field input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-tint);
    outline: none;
}

.field__with-action {
    position: relative;
    display: flex;
    align-items: center;
}

.field__with-action input { padding-right: 4.5rem; }

.field__toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--brand);
    font-size: 0.8rem;
    font-weight: 600;
}

.stacked-form .btn { margin-top: 0.3rem; }

.form-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--danger-tint);
    color: var(--danger);
    border-radius: var(--radius-s);
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
}

.form-alert[hidden] {
    display: none;
}

/* =========================================================
   Login screen
   ========================================================= */
.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
}

.login-brand {
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 4rem 3rem;
}

.login-brand__inner { max-width: 360px; }

.login-brand__logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-s);
    margin-bottom: 1.5rem;
}

.login-brand h1 {
    font-size: 1.9rem;
    margin-bottom: 0.6rem;
}

.login-brand p {
    color: rgba(255, 255, 255, 0.78);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.login-brand__points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.login-brand__points li {
    position: relative;
    padding-left: 1.4rem;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.9);
}

.login-brand__points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    opacity: 0;
    transform: translateY(8px);
    animation: login-in 0.5s ease forwards;
}

@keyframes login-in {
    to { opacity: 1; transform: translateY(0); }
}

.login-card__head { margin-bottom: 1.6rem; }

.login-card__head h2 {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.login-card__head p {
    color: var(--muted);
    font-size: 0.92rem;
}

.login-card__footer {
    margin-top: 1.8rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

@media (max-width: 860px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-brand { padding: 2.5rem 1.75rem; }
    .login-brand__points { display: none; }
}

/* =========================================================
   App shell
   ========================================================= */
.shell {
    display: flex;
    min-height: 100vh;
}

.shell__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--brand-dark);
    color: #fff;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0 0.4rem 1.5rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}

.sidebar__logo {
    width: 32px;
    height: 32px;
    border-radius: 7px;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar__section {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    padding: 1.1rem 0.6rem 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.6rem;
    border-radius: var(--radius-s);
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background-color 0.15s ease;
}

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

.nav-link__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        inset: 0 25% 0 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 0 100vmax rgba(0,0,0,0);
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0,0,0,0.25);
    }
}

/* ---- Topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    height: 68px;
    padding: 0 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar__spacer { flex: 1; }

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 0.4rem;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
}

@media (max-width: 960px) {
    .menu-toggle { display: flex; }
}

.user-menu { position: relative; }

.user-menu__trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: none;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-s);
}

.user-menu__trigger:hover { background: var(--bg); }

.user-menu__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.user-menu__name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-menu__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-card);
    padding: 0.6rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 30;
}

.user-menu.is-open .user-menu__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu__dropdown-head {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.4rem;
}

.user-menu__dropdown-head span {
    font-size: 0.78rem;
    color: var(--muted);
}

.user-menu__logout {
    display: block;
    padding: 0.55rem 0.6rem;
    border-radius: var(--radius-s);
    font-size: 0.88rem;
    text-decoration: none;
    color: var(--danger);
}

.user-menu__logout:hover { background: var(--danger-tint); }

/* ---- Main content ---- */
.main {
    flex: 1;
    padding: 2rem 2.5rem 3rem;
    overflow-y: auto;
}

.page-head { margin-bottom: 1.75rem; }

.page-head h1 {
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
}

.page-head p { color: var(--muted); }

@media (max-width: 600px) {
    .main { padding: 1.5rem 1.1rem 2.5rem; }
}

/* =========================================================
   Cards & dashboard grid
   ========================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-card);
    padding: 1.6rem;
}

.card--wide { grid-column: 1 / -1; }

.card__title {
    font-size: 1.05rem;
    margin-bottom: 1.2rem;
}

.card__head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}

.card__head-row .card__title { margin-bottom: 0; }

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

/* ---- Payment card ---- */
.payment {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.payment__qr {
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-m);
    margin-bottom: 1.2rem;
}

.payment__amount { margin-bottom: 1.3rem; }

.payment__amount-value {
    display: block;
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--brand);
}

.payment__amount-label {
    font-size: 0.82rem;
    color: var(--muted);
}

.payment__details {
    width: 100%;
    margin: 0;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.payment__details > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.9rem;
}

.payment__details dt { color: var(--muted); }
.payment__details dd { margin: 0; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge--success { background: var(--accent-tint); color: var(--accent); }
.badge--pending { background: var(--danger-tint); color: var(--danger); }

/* ---- Roster ---- */
.roster-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.roster-row {
    display: grid;
    grid-template-columns: auto 2fr 1fr 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.roster-row--unsaved {
    background: var(--brand-tint);
    border-color: #E3C9DD;
}

.roster-row__badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.roster-row input {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    background: var(--surface);
    width: 100%;
}

.roster-row input:focus {
    border-color: var(--brand);
    outline: none;
}

.roster-row__remove {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--danger);
    font-size: 1.1rem;
    line-height: 1;
}

.roster-row__remove:hover { background: var(--danger-tint); border-color: var(--danger-tint); }

@media (max-width: 640px) {
    .roster-row {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "badge name remove"
            "year year number";
    }
    .roster-row__badge { grid-area: badge; }
    .roster-row__name { grid-area: name; }
    .roster-row__remove { grid-area: remove; }
    .roster-row__year { grid-area: year; }
    .roster-row__number { grid-area: number; }
}

/* =========================================================
   Alerts (toast)
   ========================================================= */
.alerts {
    position: fixed;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.alert-window {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 260px;
    max-width: 360px;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-s);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    font-size: 0.88rem;
    border-left: 4px solid var(--muted);
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.alert-window.is-visible { opacity: 1; transform: translateX(0); }
.alert-window.is-leaving { opacity: 0; transform: translateX(12px); }

.alert-window--success { border-left-color: var(--accent); }
.alert-window--error { border-left-color: var(--danger); }

.alert-window span { flex: 1; }

.alert-window__close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--muted);
    line-height: 1;
}

/* =========================================================
   Overlays (login success / logout)
   ========================================================= */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 27, 34, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
    z-index: 200;
}

.overlay.is-visible { opacity: 1; visibility: visible; }

.overlay__box {
    background: var(--surface);
    border-radius: var(--radius-m);
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    font-size: 0.92rem;
    color: var(--ink);
}

.overlay__spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay__check {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-tint);
    position: relative;
}

.overlay__check::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 9px;
    width: 8px;
    height: 14px;
    border-right: 3px solid var(--accent);
    border-bottom: 3px solid var(--accent);
    transform: rotate(45deg);
}
