:root {
    --primary: #1e40af; --primary-dark: #1e3a8a; --primary-light: #3b82f6;
    --navy: #0f172a; --navy-light: #1e293b; --slate: #334155;
    --red: #dc2626; --green: #059669; --amber: #d97706; --blue: #3b82f6; --purple: #7c3aed;
    --bg: #f1f5f9; --card: #ffffff; --border: #e2e8f0;
    --text: #0f172a; --text2: #64748b; --text3: #94a3b8;
    --radius: 12px; --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
#app { height: 100%; overflow: hidden; }

/* Splash */
.splash { position: fixed; inset: 0; background: linear-gradient(145deg, var(--navy) 0%, var(--primary-dark) 50%, var(--navy) 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.splash-logo { width: 90px; height: 90px; border-radius: 20px; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.splash-logo img { width: 80px; height: 80px; border-radius: 16px; object-fit: cover; }
.splash-logo-text { font-size: 2rem; font-weight: 700; color: #fff; }
.splash-name { color: #fff; font-size: 1.2rem; font-weight: 700; margin-top: 16px; }
.splash-motto { color: rgba(255,255,255,0.5); font-size: 0.75rem; margin-top: 4px; }
.splash-loader { margin-top: 32px; width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.15); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.splash-fade { animation: fadeOut 0.4s ease forwards; }
@keyframes fadeOut { to { opacity: 0; pointer-events: none; } }

/* Login */
.login-page { height: 100%; display: flex; flex-direction: column; background: linear-gradient(160deg, var(--navy) 0%, var(--primary-dark) 40%, var(--navy) 100%); }
.login-header { flex-shrink: 0; padding: calc(var(--safe-top) + 36px) 32px 20px; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.login-logo img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; }
.login-title { color: #fff; font-size: 1.3rem; font-weight: 700; }
.login-subtitle { color: rgba(255,255,255,0.5); font-size: 0.78rem; margin-top: 4px; }
.login-form-wrap { flex: 1; background: var(--card); border-radius: 20px 20px 0 0; padding: 28px 24px calc(var(--safe-bottom) + 24px); overflow-y: auto; }
.login-welcome { font-size: 1.05rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-welcome-sub { font-size: 0.78rem; color: var(--text2); margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.92rem; font-family: inherit; color: var(--text); background: #f8fafc; transition: all 0.2s; outline: none; }
.form-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }
.form-input::placeholder { color: var(--text3); }
.form-input.error { border-color: var(--red); }
.form-input-wrap { position: relative; }
.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px; }
.password-toggle svg { width: 18px; height: 18px; }
.form-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.checkbox-wrap { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox-wrap input { width: 16px; height: 16px; accent-color: var(--primary); }
.checkbox-wrap span { font-size: 0.78rem; color: var(--text2); }
.forgot-link { font-size: 0.78rem; color: var(--primary); font-weight: 600; text-decoration: none; }
.form-error { color: var(--red); font-size: 0.75rem; margin-top: 6px; font-weight: 500; }
.form-msg { background: #fef2f2; border: 1px solid #fecaca; color: var(--red); padding: 10px; border-radius: var(--radius-sm); font-size: 0.78rem; margin-bottom: 14px; text-align: center; }
.form-msg.success { background: #ecfdf5; border-color: #a7f3d0; color: var(--green); }

.btn { width: 100%; padding: 13px; border: none; border-radius: var(--radius-sm); font-size: 0.92rem; font-weight: 700; font-family: inherit; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); margin-top: 10px; padding: 10px; font-size: 0.78rem; font-weight: 600; }
.btn-outline svg { width: 14px; height: 14px; }
.btn-spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }

/* App Shell */
.app-shell { height: 100%; display: flex; flex-direction: column; }
.app-header { flex-shrink: 0; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); padding: calc(var(--safe-top) + 12px) 16px 12px; display: flex; align-items: center; justify-content: space-between; z-index: 10; }
.app-header-left { display: flex; align-items: center; gap: 10px; }
.app-header-avatar { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.85rem; }
.app-header-name { color: #fff; font-size: 0.85rem; font-weight: 600; }
.app-header-role { color: rgba(255,255,255,0.5); font-size: 0.65rem; }
.app-header-btn { background: rgba(255,255,255,0.08); border: none; color: rgba(255,255,255,0.7); padding: 7px; border-radius: 7px; cursor: pointer; }
.app-header-btn svg { width: 18px; height: 18px; }
.app-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--safe-bottom) + 64px); }

/* Tab Bar */
.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); display: flex; padding: 4px 6px calc(var(--safe-bottom) + 4px); z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,0.04); }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; border: none; background: none; color: var(--text3); font-size: 0.58rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: color 0.2s; text-decoration: none; position: relative; }
.tab-item svg { width: 20px; height: 20px; }
.tab-item.active { color: var(--primary); }
.tab-item.active svg { stroke-width: 2.5; }
.tab-badge { position: absolute; top: 0; right: calc(50% - 14px); min-width: 14px; height: 14px; background: var(--red); color: #fff; font-size: 0.5rem; font-weight: 700; border-radius: 99px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 80vw; background: var(--card); z-index: 160; transform: translateX(-100%); transition: transform 0.3s ease; display: flex; flex-direction: column; overflow-y: auto; }
.drawer.open { transform: translateX(0); }
.drawer-header { background: linear-gradient(135deg, var(--navy) 0%, var(--primary-dark) 100%); padding: calc(var(--safe-top) + 20px) 18px 18px; display: flex; align-items: center; gap: 12px; color: #fff; flex-shrink: 0; }
.drawer-avatar { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700; flex-shrink: 0; }
.drawer-name { font-size: 0.95rem; font-weight: 700; }
.drawer-role { font-size: 0.68rem; opacity: 0.6; margin-top: 2px; }
.drawer-nav { padding: 6px 0; flex: 1; }
.drawer-section-label { padding: 12px 18px 4px; font-size: 0.58rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
.drawer-link { display: flex; align-items: center; gap: 12px; padding: 10px 18px; color: var(--text); text-decoration: none; font-size: 0.82rem; font-weight: 500; transition: background 0.15s; border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.drawer-link:hover, .drawer-link:active { background: rgba(30,64,175,0.05); }
.drawer-link svg { width: 18px; height: 18px; color: var(--text2); flex-shrink: 0; }
.drawer-link.active { color: var(--primary); background: rgba(30,64,175,0.06); }
.drawer-link.active svg { color: var(--primary); }
.drawer-logout { color: var(--red); margin-top: 6px; border-top: 1px solid var(--border); }
.drawer-logout svg { color: var(--red); }

/* Dashboard */
.dash-scroll { padding: 14px; }
.kpi-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--radius-sm); padding: 14px 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.kpi-val { font-family: 'JetBrains Mono', monospace; font-size: 1.4rem; font-weight: 700; }
.kpi-lbl { font-size: 0.6rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.kpi-green { color: var(--green); }
.kpi-red { color: var(--red); }
.kpi-blue { color: var(--primary); }
.kpi-amber { color: var(--amber); }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.78rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.card-body { padding: 0; }
.card-empty { padding: 28px 14px; text-align: center; color: var(--text3); font-size: 0.78rem; }

/* List items */
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.list-item:last-child { border-bottom: none; }
.list-title { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.list-sub { font-size: 0.68rem; color: var(--text2); margin-top: 1px; }
.list-right { text-align: right; margin-left: auto; flex-shrink: 0; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 99px; font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-green { background: rgba(5,150,105,0.1); color: var(--green); }
.badge-red { background: rgba(220,38,38,0.1); color: var(--red); }
.badge-amber { background: rgba(217,119,6,0.1); color: var(--amber); }
.badge-blue { background: rgba(59,130,246,0.1); color: var(--blue); }
.badge-gray { background: rgba(100,116,139,0.1); color: var(--text2); }

/* Section */
.section-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* Progress */
.progress { width: 100%; height: 5px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width 0.5s; }
.bg-green { background: var(--green); }
.bg-amber { background: var(--amber); }
.bg-red { background: var(--red); }
.bg-blue { background: var(--primary); }

/* Accordion */
.accordion-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 14px; border: none; background: none; cursor: pointer; font-family: inherit; text-align: left; gap: 10px; transition: background 0.15s; }
.accordion-trigger:active { background: rgba(30,64,175,0.04); }
.accordion-card-head { border-bottom: 1px solid var(--border); }
.accordion-trigger-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.accordion-chevron { width: 16px; height: 16px; color: var(--text3); transition: transform 0.3s ease; flex-shrink: 0; display: flex; }
.accordion-chevron svg { width: 16px; height: 16px; }
.accordion-open .accordion-chevron { transform: rotate(180deg); }
.accordion-panel { overflow: hidden; max-height: 0; transition: max-height 0.35s ease; }
.accordion-panel-open { max-height: 3000px; }

/* Attendance */
.att-grid { display: flex; flex-direction: column; gap: 0; }
.att-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.att-row:last-child { border-bottom: none; }
.att-avatar { width: 32px; height: 32px; border-radius: 8px; background: rgba(59,130,246,0.08); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
.att-name { flex: 1; min-width: 0; }
.att-name-text { font-size: 0.78rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name-sub { font-size: 0.62rem; color: var(--text3); }
.att-status-group { display: flex; gap: 3px; }
.att-btn { width: 30px; height: 30px; border-radius: 6px; border: 1.5px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; cursor: pointer; transition: all 0.15s; font-family: 'JetBrains Mono', monospace; }
.att-btn.selected { color: #fff; border-color: transparent; }
.att-btn.s-present { background: var(--green); }
.att-btn.s-absent { background: var(--red); }
.att-btn.s-late { background: var(--amber); }
.att-btn.s-sick { background: var(--blue); }
.att-btn.s-excused { background: var(--text3); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); border-radius: 16px 16px 0 0; padding: 20px; width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto; }

/* Toggle */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 22px; transition: 0.3s; }
.toggle-slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* File Upload */
.file-upload-area { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; cursor: pointer; transition: all 0.2s; margin-top: 6px; }
.file-upload-area:active { border-color: var(--primary); background: rgba(30,64,175,0.03); }
.file-upload-area input { display: none; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--border) 25%, rgba(226,232,240,0.4) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-kpi { height: 68px; }
.skeleton-card { height: 160px; margin-bottom: 12px; }

/* Dark Mode */
.dark-mode {
    --bg: #0f172a; --card: #1e293b; --border: #334155;
    --text: #f1f5f9; --text2: #94a3b8; --text3: #64748b;
}
.dark-mode .att-btn { background: #1e293b; border-color: #475569; }

/* Utilities */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-blue { color: var(--primary); }
.text-gray { color: var(--text3); }
.mono { font-family: 'JetBrains Mono', monospace; }
.bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-xs { font-size: 0.68rem; }
.text-sm { font-size: 0.78rem; }
