/* ─── RESET & BASE ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f9;
    color: #1a2c3e;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#app {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background: #ffffff;
    position: relative;
    box-shadow: 0 0 30px rgba(26, 44, 62, 0.06);
    display: flex;
    flex-direction: column;
}

/* ─── PAGES ─── */
.page {
    display: none !important;
    flex-direction: column;
    padding: 16px 16px 80px 16px;
    animation: fadeUp 0.25s ease;
    overflow-y: auto;
}
.page.active {
    display: flex !important;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── HEADER ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 16px 0;
    border-bottom: 1px solid #e6edf4;
    margin-bottom: 16px;
}
.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #1a2c3e;
    letter-spacing: -0.3px;
}
.header-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #1a73e8;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-weight: 500;
}
.header-btn:hover {
    background: #e8f0fe;
}
.header-btn.logout-btn {
    color: #d93025;
}

/* ─── BOTTOM NAV ─── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-top: 1px solid #e6edf4;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 env(safe-area-inset-bottom, 6px) 0;
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}
.bottom-nav.visible {
    display: flex;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    color: #8899aa;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
    min-width: 56px;
}
.nav-item .nav-icon {
    font-size: 22px;
    line-height: 1.2;
}
.nav-item.active {
    color: #1a73e8;
}
.nav-item.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: #1a73e8;
    border-radius: 0 0 4px 4px;
}
.nav-item .badge {
    position: absolute;
    top: -2px;
    right: 2px;
    background: #d93025;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.badge.hidden {
    display: none;
}

/* ─── LOGIN ─── */
#page-login {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f0f7ff;
}
.auth-card {
    width: 100%;
    max-width: 360px;
    background: #ffffff;
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(26, 115, 232, 0.10);
}
.auth-card .logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-card .logo h2 {
    font-size: 26px;
    font-weight: 700;
    color: #1a2c3e;
}
.auth-card .logo h2 span {
    color: #1a73e8;
}
.auth-card .logo p {
    color: #5f6b7a;
    font-size: 14px;
    margin-top: 2px;
}
.auth-error, .auth-success {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}
.auth-error.show {
    display: block;
    background: #fce8e6;
    color: #d93025;
}
.auth-success.show {
    display: block;
    background: #e6f4ea;
    color: #1e8e3e;
}
.auth-btn {
    width: 100%;
    padding: 14px;
    background: #1a73e8;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 8px;
}
.auth-btn:active { transform: scale(0.97); }
.auth-btn:hover { background: #1557b0; }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #5f6b7a;
}
.auth-switch button {
    background: none;
    border: none;
    color: #1a73e8;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
}

/* ─── FORM ELEMENTS ─── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #2d4b66;
    margin-bottom: 5px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e6edf4;
    border-radius: 12px;
    font-size: 15px;
    background: #fafcff;
    transition: border 0.2s, box-shadow 0.2s;
    outline: none;
    color: #1a2c3e;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12);
    background: #ffffff;
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235f6b7a' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

/* ─── BUTTONS ─── */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:hover { background: #1557b0; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-danger {
    width: 100%;
    padding: 14px;
    background: #d93025;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-danger:active { transform: scale(0.97); }
.btn-danger:hover { background: #b3261e; }

.btn-outline {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: #1a73e8;
    border: 2px solid #1a73e8;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-outline:active { transform: scale(0.97); }
.btn-outline:hover { background: #e8f0fe; }

.btn-group { display: flex; gap: 10px; margin-top: 8px; }
.btn-group .btn-primary, .btn-group .btn-danger, .btn-group .btn-outline { flex: 1; }

/* ─── STATS ─── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}
.stat-card {
    background: #f8faff;
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
    border: 1px solid #e6edf4;
}
.stat-card .stat-number {
    font-size: 28px;
    font-weight: 800;
    color: #1a2c3e;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 11px;
    color: #5f6b7a;
    font-weight: 500;
    margin-top: 2px;
}
.stat-card.paid .stat-number { color: #1e8e3e; }
.stat-card.unpaid .stat-number { color: #d93025; }
.stat-card.total .stat-number { color: #1a73e8; }

/* ─── STUDENT LIST ─── */
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a2c3e;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-title .see-all {
    font-size: 13px;
    font-weight: 500;
    color: #1a73e8;
    background: none;
    border: none;
    cursor: pointer;
}
.student-list { display: flex; flex-direction: column; gap: 10px; }
.student-item {
    background: #f8faff;
    border-radius: 16px;
    padding: 14px 16px;
    border: 1px solid #e6edf4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.student-item:active { transform: scale(0.98); background: #e8f0fe; }
.student-item .info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.student-item .info .name {
    font-weight: 600;
    font-size: 15px;
    color: #1a2c3e;
}
.student-item .info .mobile {
    font-size: 13px;
    color: #5f6b7a;
}
.student-item .info .profile-tag {
    font-size: 11px;
    background: #e8f0fe;
    color: #1a73e8;
    padding: 2px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.student-item .fee-status {
    flex-shrink: 0;
    margin-left: 10px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}
.student-item .fee-status.paid {
    background: #e6f4ea;
    color: #1e8e3e;
}
.student-item .fee-status.unpaid {
    background: #fce8e6;
    color: #d93025;
}

/* ─── PROFILE ─── */
.profile-card {
    background: #f8faff;
    border-radius: 20px;
    padding: 20px;
    border: 1px solid #e6edf4;
    margin-bottom: 16px;
}
.profile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e6edf4;
}
.profile-row:last-child { border-bottom: none; }
.profile-row .label {
    color: #5f6b7a;
    font-size: 14px;
    flex-shrink: 0;
}
.profile-row .value {
    font-weight: 500;
    font-size: 14px;
    color: #1a2c3e;
    text-align: right;
    word-break: break-word;
    flex: 1;
    margin-left: 12px;
}
#nameRow .value {
    flex: 1;
}
#editNameSection {
    padding: 12px 0;
}
#editNameSection .form-group {
    margin-bottom: 8px;
}

/* ─── FEE HISTORY ─── */
.fee-history { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.fee-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e6edf4;
}
.fee-item .fee-month { font-weight: 500; font-size: 14px; color: #1a2c3e; }
.fee-item .fee-status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
}
.fee-item .fee-status-badge.paid { background: #e6f4ea; color: #1e8e3e; }
.fee-item .fee-status-badge.unpaid { background: #fce8e6; color: #d93025; }
.fee-item .fee-action-btn {
    background: #1a73e8;
    color: #fff;
    border: none;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.fee-item .fee-action-btn:active { transform: scale(0.95); }
.fee-item .fee-action-btn:hover { background: #1557b0; }
.fee-item .fee-action-btn.paid-btn { background: #1e8e3e; }
.fee-item .fee-action-btn.paid-btn:hover { background: #166b34; }

/* ─── SEARCH ─── */
.search-bar {
    position: relative;
    margin-bottom: 12px;
}
.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 2px solid #e6edf4;
    border-radius: 12px;
    font-size: 15px;
    background: #fafcff;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
    color: #1a2c3e;
}
.search-bar input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12);
    background: #ffffff;
}
.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #8899aa;
}

/* ─── MONTH PICKER ─── */
.month-picker {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.month-picker .month-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid #e6edf4;
    background: #ffffff;
    font-size: 13px;
    font-weight: 500;
    color: #2d4b66;
    cursor: pointer;
    transition: all 0.15s;
}
.month-picker .month-btn.active {
    border-color: #1a73e8;
    background: #e8f0fe;
    color: #1a73e8;
}
.month-picker .month-btn:active { transform: scale(0.95); }

/* ─── SUBSCRIPTION BANNER ─── */
.sub-banner {
    background: #fef7e0;
    border: 1px solid #f9e6b0;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #b06000;
}
.sub-banner .sub-icon { font-size: 20px; font-weight: 700; }
.sub-banner .sub-text strong { display: block; }

/* ─── EMPTY STATE ─── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #5f6b7a;
}
.empty-state h3 {
    font-size: 18px;
    color: #1a2c3e;
    margin-bottom: 4px;
}
.empty-state p { font-size: 14px; }

/* ─── TOAST ─── */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a2c3e;
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    max-width: 90%;
    width: 400px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.toast.success { background: #1e8e3e; }
.toast.error { background: #d93025; }

/* ─── LOADING ─── */
.loading-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(4px);
    z-index: 300;
    justify-content: center;
    align-items: center;
}
.loading-overlay.hidden {
    display: none;
}
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(26, 115, 232, 0.2);
    border-radius: 50%;
    border-top-color: #1a73e8;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── MODAL ─── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(3px);
    z-index: 400;
    justify-content: center;
    align-items: center;
}
.modal-overlay.show {
    display: flex;
}
.modal-box {
    background: #ffffff;
    border-radius: 20px;
    padding: 24px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}
.modal-box h3 {
    font-size: 18px;
    color: #1a2c3e;
    margin-bottom: 8px;
}
.modal-box p {
    font-size: 14px;
    color: #5f6b7a;
    margin-bottom: 20px;
    line-height: 1.4;
}
.modal-actions {
    display: flex;
    gap: 10px;
}
.modal-actions .btn-outline,
.modal-actions .btn-danger {
    padding: 10px;
    font-size: 14px;
    width: 50%;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .auth-card { padding: 24px 16px; }
    .page { padding: 12px 12px 80px 12px; }
}