:root {
    --bg: #f5f7fb;
    --surface: rgba(255,255,255,0.88);
    --surface-strong: #ffffff;
    --text: #111827;
    --muted: #667085;
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 18px 60px rgba(15, 23, 42, 0.08);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #ea580c;
    --appointment: #7c3aed;
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 28%),
        radial-gradient(circle at top right, rgba(124, 58, 237, 0.10), transparent 25%),
        var(--bg);
    color: var(--text);
}
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell { width: 100%; max-width: 460px; }
.auth-card,
.calendar-card,
.tabs-card {
    background: var(--surface);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
}
.auth-card { padding: 28px; }
.auth-top h1, .topbar h1 { margin: 0; font-size: clamp(2rem, 4vw, 2.6rem); }
.eyebrow {
    margin: 0 0 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary);
    font-weight: 700;
}
.muted { color: var(--muted); margin: 8px 0 0; line-height: 1.55; }
.auth-form, .event-form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}
label { display: grid; gap: 8px; }
label span { font-size: 0.95rem; font-weight: 600; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    outline: none;
    transition: 0.22s ease;
}
input:focus, textarea:focus, select:focus {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.10);
}
.primary-btn, .ghost-btn, .month-nav, .icon-btn, .tab-btn {
    border: 0;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}
.primary-btn:hover, .ghost-btn:hover, .month-nav:hover, .icon-btn:hover, .tab-btn:hover { transform: translateY(-1px); }
.primary-btn {
    background: var(--primary);
    color: #fff;
    padding: 14px 18px;
    border-radius: 14px;
    font-weight: 700;
}
.primary-btn:hover { background: var(--primary-hover); }
.ghost-btn {
    background: rgba(255,255,255,0.75);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: 14px;
    font-weight: 600;
}
.full-width { width: 100%; text-align: center; }
.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-top: 18px;
    font-size: 0.95rem;
}
.alert-error { background: rgba(220, 38, 38, 0.08); color: #991b1b; }
.alert-success { background: rgba(22, 163, 74, 0.10); color: #166534; }
.foot-note { margin: 18px 0 0; color: var(--muted); font-size: 0.92rem; }

.app-shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px;
}
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}
.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.user-pill {
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
    padding: 12px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.92rem;
}
.calendar-card { padding: 20px; }
.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.calendar-head h2 { margin: 0; text-align: center; font-size: clamp(1.4rem, 3vw, 2rem); }
.month-nav, .icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 1.3rem;
}
.weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 10px;
    padding: 0 2px;
}
.weekday-row span { padding: 0 10px; }
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.fade-out { opacity: 0; transform: translateY(8px); }
.fade-in { opacity: 1; transform: translateY(0); }
.day-cell {
    min-height: 150px;
    background: rgba(255,255,255,0.85);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.day-cell.is-outside { opacity: 0.48; }
.day-cell.is-today {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.25);
}
.day-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.day-number {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-weight: 700;
}
.is-today .day-number { background: var(--primary); color: #fff; }
.day-add {
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    border-radius: 10px;
    padding: 6px 8px;
}
.day-events { display: grid; gap: 8px; }
.event-chip {
    border-radius: 14px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border);
    cursor: pointer;
}
.event-chip.payment.pending { border-left: 4px solid var(--primary); }
.event-chip.payment.paid { border-left: 4px solid var(--success); }
.event-chip.payment.overdue { border-left: 4px solid var(--warning); }
.event-chip.appointment { border-left: 4px solid var(--appointment); }
.event-chip h4 {
    margin: 0 0 4px;
    font-size: 0.92rem;
    line-height: 1.3;
}
.event-chip p {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}
.tabs-card { margin-top: 22px; padding: 20px; }
.tabs-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}
.tab-btn {
    padding: 12px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
    font-weight: 600;
}
.tab-btn.active { background: var(--text); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.event-list { display: grid; gap: 12px; }
.list-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.list-card-main h4 { margin: 0 0 6px; }
.list-card-meta { color: var(--muted); font-size: 0.93rem; line-height: 1.5; }
.list-card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.small-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 600;
    cursor: pointer;
}
.small-btn.success { color: #166534; border-color: rgba(22, 163, 74, 0.22); background: rgba(22, 163, 74, 0.06); }
.small-btn.danger { color: #991b1b; border-color: rgba(220, 38, 38, 0.22); background: rgba(220, 38, 38, 0.05); }
.empty-state {
    border: 1px dashed var(--border);
    border-radius: 18px;
    padding: 20px;
    color: var(--muted);
    background: rgba(255,255,255,0.65);
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 700;
}
.status-badge.pending { background: rgba(37, 99, 235, 0.12); color: var(--primary); }
.status-badge.paid { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.status-badge.overdue { background: rgba(234, 88, 12, 0.12); color: var(--warning); }
.status-badge.appointment { background: rgba(124, 58, 237, 0.12); color: var(--appointment); }
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 30;
}
.modal.open { display: flex; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(6px);
}
.modal-dialog {
    position: relative;
    width: min(100%, 620px);
    background: #fff;
    border-radius: 24px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.modal-dialog.small { width: min(100%, 560px); }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.modal-head h3 { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; }
.details-grid { display: grid; gap: 12px; }
.details-grid p { margin: 0; line-height: 1.55; }
.inline-stack { display: flex; flex-wrap: wrap; gap: 10px; }
.note { color: var(--muted); font-size: 0.9rem; }
.hidden { display: none !important; }

@media (max-width: 980px) {
    .calendar-grid { grid-template-columns: repeat(2, 1fr); }
    .weekday-row { display: none; }
    .day-cell { min-height: 180px; }
}

@media (max-width: 720px) {
    .app-shell { padding: 16px; }
    .topbar, .list-card { flex-direction: column; align-items: stretch; }
    .topbar-actions { justify-content: flex-start; }
    .calendar-grid { grid-template-columns: 1fr; }
    .day-cell.is-outside { display: none; }
    .tabs-head { flex-direction: column; }
}
