:root {
    --bg-main: #f4f6f8;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #4686e5;
    --primary-hover: #3869ca;
    --primary-light: #eff6ff;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-soft: 0 8px 30px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

#app-root { max-width: 600px; margin: 0 auto; min-height: 100vh; position: relative; background: var(--bg-main); overflow-x: hidden; }

/* UTILS */
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-8 { margin-top: 32px; } .mt-12 { margin-top: 48px; }
.mb-8 { margin-bottom: 32px; } .mb-0 { margin-bottom: 0 !important; }
.ml-2 { margin-left: 12px; } .p-4 { padding: 16px; }
.w-100 { width: 100%; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* TYPOGRAPHY */
h1, h2, h3, h4, h5 { font-weight: 700; color: var(--text-main); letter-spacing: -0.02em; padding: 0.5em}
h3 { font-size: 18px; } h2 { font-size: 24px; }

/* HEADER */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 24px 20px 16px; border-bottom: 1px solid rgba(0,0,0,0.03); }
.app-brand { display: flex; align-items: center; gap: 12px; }
.app-brand .logo { width: 32px; height: 32px; background: var(--primary); border-radius: 10px; color: white; display: flex; align-items: center; justify-content: center; font-weight: 800; }

.avatar-sm { width: 64px; height: 64px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; box-shadow: 0 4px 12px rgba(70, 134, 229, 0.25); }

/* MAIN CONTENT */
.content { padding: 0 20px 100px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header p { font-size: 13px; margin-top: 2px; }

/* HIGHLIGHT CARDS */
.stats-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--bg-card); padding: 20px; border-radius: 20px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; gap: 8px; }
.stat-card .label { font-size: 13px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; }

.detail-card { background: var(--bg-card); border-radius: 20px; padding: 24px; box-shadow: var(--shadow-soft); display: flex; flex-direction: column; }
.detail-card .card-header { display: flex; justify-content: space-between; align-items: center; }

/* LISTS & CARDS */
.student-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.student-card { display: flex; align-items: center; justify-content: space-between; padding: 18px; border-radius: 20px; background: var(--bg-card); box-shadow: var(--shadow-soft); transition: transform 0.2s, box-shadow 0.2s; }
.student-card:active { transform: scale(0.98); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.sc-info { flex: 1; min-width: 0; }
.sc-info strong { display: block; font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-info span:not(.time-label):not(.status-pill) { font-size: 13px; color: var(--text-muted); font-weight: 500; display: block; }
.sc-action { display: flex; gap: 8px; align-items: center; }

/* CARD HIGHLIGHTS */
.student-card.highlight .time-label { color: var(--primary); font-weight: 700; font-size: 12px; margin-bottom: 6px; display: inline-block; padding: 4px 10px; background: var(--primary-light); border-radius: 12px; }
.student-card.warning-card { position: relative; }
.student-card.warning-card::before { content: ''; position: absolute; left: 18px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.student-card.warning-card .sc-info { margin-left: 14px; }
.student-card.danger-card { position: relative; }
.student-card.danger-card::before { content: ''; position: absolute; left: 18px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.student-card.danger-card .sc-info { margin-left: 14px; }

.danger-text .card-name-label { color: var(--danger) !important; font-weight: 800; }
.warning-text .card-name-label { color: var(--warning) !important; font-weight: 800; }

/* BADGES & STATUS PILLS */
.badge { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; min-width: 80px; text-align: center; }
.badge.paid { background-color: var(--success-light); color: var(--success); }
.badge.unpaid { background-color: var(--danger-light); color: var(--danger); }

.status-pill { display: inline-block; font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 12px; margin-left: 8px; vertical-align: middle; letter-spacing: 0.05em; }
.status-pill.done { color: var(--success); background: var(--success-light); }
.status-pill.ongoing { color: var(--primary); background: var(--primary-light); }
.status-pill.manual { color: var(--warning); background: var(--warning-light); }
.status-pill.auto { color: var(--text-muted); background: var(--border-light); }
.tag-auto { background: var(--border-light); color: var(--text-muted); font-size: 10px; padding: 4px 8px; border-radius: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* BUTTONS */
.btn { display: inline-block; width: 100%; padding: 16px; border-radius: 16px; font-size: 15px; font-weight: 700; text-align: center; border: none; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.btn.primary { background: var(--primary); color: white; box-shadow: 0 8px 20px rgba(70, 134, 229, 0.25); }
.btn.primary:active { background: var(--primary-hover); transform: translateY(2px); }
.btn.outline { background: white; border: 2px solid var(--border); color: var(--text-main); box-shadow: none; }
.btn.outline.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn.small { padding: 8px 16px; font-size: 13px; width: auto; border-radius: 12px; }

.icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: var(--bg-card); border: none; color: var(--text-main); cursor: pointer; box-shadow: var(--shadow-soft); transition: 0.2s; }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.primary { background: var(--primary); color: white; }

.action-btn { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--bg-main); color: var(--text-muted); border: none; transition: 0.2s; }
.action-btn:active { background: var(--border); color: var(--text-main); }

/* FORMS */
.form-container { display: flex; flex-direction: column; }
.row { display: flex; gap: 16px; }
.col { flex: 1; min-width: 0; }
.input-field { display: flex; flex-direction: column; }
.input-field label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.input-field input, .input-field select { padding: 16px; border-radius: 16px; border: none; background: #e2e8f0; font-size: 16px; font-family: inherit; color: var(--text-main); width: 100%; transition: box-shadow 0.2s; }
.input-field input:focus, .input-field select:focus { outline: none; box-shadow: 0 0 0 2px var(--primary-light); background: #fff; }

.checkbox-group label { transition: 0.2s; }
.checkbox-group input[type="checkbox"]:checked + span { background: var(--primary); color: white; }

/* CALENDAR */
.calendar-container { width: 100%; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.calendar-day-header { text-align: center; font-size: 12px; font-weight: 700; color: var(--text-muted); padding-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.calendar-cell { padding-bottom: 6px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; border-radius: 50%; background: transparent; transition: 0.2s; position: relative; cursor: pointer; user-select: none; }
.calendar-cell.muted { color: transparent; background: transparent; pointer-events: none; }
.calendar-cell.active-month { color: var(--text-main); }
.calendar-cell.active-month:active { transform: scale(0.9); }
.calendar-cell.today { font-weight: 800; color: var(--primary); }

/* CALENDAR DOTS */
.cal-dot-container { display:flex; gap:3px; position:absolute; bottom:2px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; opacity: 0.8; }
.cal-dot.done { background: var(--success); opacity: 1; }
.cal-dot.auto { background: var(--primary); }

/* BOTTOM NAV */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 600px; margin: 0 auto; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px); border-top: 1px solid rgba(0,0,0,0.03); display: flex; justify-content: space-around; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); z-index: 100; box-shadow: 0 -10px 30px rgba(0,0,0,0.03); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); background: none; border: none; font-size: 11px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.nav-item.active { color: var(--primary); }
.nav-item:active { transform: scale(0.9); }

/* OVERLAY MAP */
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(8px); z-index: 500; display: flex; flex-direction: column; justify-content: flex-end; opacity: 0; pointer-events: none; transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.overlay.active { opacity: 1; pointer-events: auto; }
.overlay-content { background: var(--bg-main); width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; transform: translateY(100%); transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); overflow-y: auto; box-shadow: none; pointer-events: auto; }
.overlay.active .overlay-content { transform: translateY(0); }
.overlay header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }

/* BOTTOM SHEET */
.overlay.bottom-sheet { justify-content: flex-end; }
.overlay.bottom-sheet .overlay-content { height: auto; max-height: 90vh; border-top-left-radius: 32px; border-top-right-radius: 32px; padding: 32px 24px max(32px, env(safe-area-inset-bottom)); box-shadow: 0 -20px 40px rgba(0,0,0,0.1); }

/* VIEW LOGIC */
.view { display: none; width: 100%; min-height: 100vh; animation: fadeIn 0.15s ease-out forwards; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* TOAST */
#toast-container { position: fixed; top: max(20px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: 90vw; max-width: 400px; align-items: center; }
.toast { background: var(--text-main); color: white; padding: 16px 24px; border-radius: 100px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: auto; text-align: center; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideDown { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* SETTINGS LIST */
.setting-list { background: var(--bg-card); border-radius: 20px; box-shadow: var(--shadow-soft); overflow: hidden; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border-light); font-weight: 500; cursor: pointer; }
.setting-item:last-child { border-bottom: none; }
.setting-item:active { background: var(--bg-main); }
.setting-item.danger { color: var(--danger); font-weight: 600; }
#btn-biometric {
    padding: 10px;
}