:root {
  --bg: #0f1923;
  --sidebar: #141f2e;
  --surface: #1a2840;
  --surface2: #1f3050;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --accent: #1a7de0;
  --accent2: #2d8ff0;
  --green: #27ae60;
  --green2: #2ecc71;
  --red: #e8344a;
  --gold: #f5a623;
  --text: #e8edf5;
  --text2: #8a9bb5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }

/* ── AUTH ── */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(ellipse at 30% 40%, #1a3560 0%, #0f1923 60%); }
.auth-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 20px; padding: 40px; width: 340px; box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 160px; height: auto; display: block; margin: 0 auto 20px; }
.auth-title { font-family: 'Nunito', sans-serif; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { font-size: 12px; color: var(--text2); margin-bottom: 28px; }
.auth-label { font-size: 11px; color: var(--text2); text-align: left; margin-bottom: 5px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }
.auth-input { width: 100%; padding: 11px 14px; background: var(--surface2); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'Poppins', sans-serif; font-size: 14px; margin-bottom: 14px; outline: none; transition: border-color 0.15s; }
.auth-input:focus { border-color: var(--accent); }
.auth-btn { width: 100%; padding: 13px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 800; cursor: pointer; transition: background 0.2s; margin-top: 4px; }
.auth-btn:hover { background: var(--accent2); }
.auth-error { color: var(--red); font-size: 12px; margin-top: 10px; display: none; }
.role-hint { font-size: 11px; color: var(--text2); margin-top: 14px; }

/* ── APP ── */
#app { display: none; min-height: 100vh; }
.app-header { background: var(--sidebar); border-bottom: 1px solid var(--border); padding: 13px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.header-left { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.header-logo { height: 38px; width: auto; }
.header-title { font-family: 'Nunito', sans-serif; font-size: 17px; font-weight: 900; color: var(--text); }
.header-sub { font-size: 11px; color: var(--text2); margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.school-select { background: var(--surface2); border: 1px solid var(--border2); color: var(--accent); font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700; border-radius: 20px; padding: 3px 10px; outline: none; cursor: pointer; margin-top: 4px; }
.role-badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; background: var(--surface2); color: var(--text2); border: 1px solid var(--border2); }
.role-badge.admin { color: var(--gold); border-color: rgba(245,166,35,0.3); }
.sync-btn { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--surface2); border: 1px solid var(--border2); color: var(--text); border-radius: var(--radius-sm); font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.sync-btn:hover { border-color: var(--accent); color: var(--accent); }
.sync-btn.syncing { opacity: 0.6; pointer-events: none; }
.sync-btn svg { transition: transform 0.6s; }
.sync-btn.syncing svg { animation: spin 1s linear infinite; }
.logout-btn { background: none; border: 1px solid var(--border2); color: var(--text2); padding: 7px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; cursor: pointer; font-family: 'Poppins', sans-serif; transition: all 0.15s; }
.logout-btn:hover { border-color: var(--red); color: var(--red); }
.last-sync { font-size: 11px; color: var(--text2); }

/* ── TABS ── */
.tab-bar { background: var(--sidebar); border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; }
.tab { padding: 13px 18px; font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; border: none; background: none; font-family: 'Poppins', sans-serif; border-bottom: 2px solid transparent; transition: all 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── STAT CARDS ── */
.stats-row { display: flex; gap: 14px; padding: 20px 24px 0; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 130px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 11px; color: var(--text2); font-weight: 500; letter-spacing: 0.3px; margin-bottom: 6px; }
.stat-value { font-family: 'Nunito', sans-serif; font-size: 26px; font-weight: 900; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-card.blue .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green2); }
.stat-card.gold .stat-value { color: var(--gold); }
.stat-card.red .stat-value { color: var(--red); }

/* ── CONTENT ── */
.tab-content { display: none; padding: 20px 24px; }
.tab-content.active { display: block; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.section-title { font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 800; }
.search-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input { padding: 8px 12px; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'Poppins', sans-serif; font-size: 13px; outline: none; width: 220px; transition: border-color 0.15s; }
.search-input:focus { border-color: var(--accent); }
.filter-select { padding: 8px 10px; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'Poppins', sans-serif; font-size: 12px; outline: none; cursor: pointer; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text2); border-bottom: 1px solid var(--border); letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap; background: var(--sidebar); }
td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.badge-paid { background: rgba(39,174,96,0.15); color: #2ecc71; border: 1px solid rgba(39,174,96,0.2); }
.badge-pending { background: rgba(245,166,35,0.12); color: var(--gold); border: 1px solid rgba(245,166,35,0.2); }
.badge-cancelled { background: rgba(232,52,74,0.12); color: var(--red); border: 1px solid rgba(232,52,74,0.2); }
.badge-inactive { background: rgba(138,155,181,0.15); color: var(--text2); border: 1px solid rgba(138,155,181,0.25); }

/* ── DELIVERED TOGGLE ── */
.deliver-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; border: none; font-family: 'Poppins', sans-serif; transition: all 0.15s; white-space: nowrap; }
.deliver-btn.not-delivered { background: var(--surface2); color: var(--text2); border: 1px solid var(--border2); }
.deliver-btn.not-delivered:hover { border-color: var(--green); color: var(--green); }
.deliver-btn.delivered { background: rgba(39,174,96,0.15); color: var(--green2); border: 1px solid rgba(39,174,96,0.25); }
.deliver-time { font-size: 10px; color: var(--text2); margin-top: 3px; display: block; }
.undo-btn { font-size: 10px; color: var(--red); background: none; border: none; cursor: pointer; font-family: 'Poppins', sans-serif; padding: 0; display: none; }
.admin-mode .undo-btn { display: inline; }

/* ── STUDENT TABLE ── */
.student-name-main { font-weight: 600; }
.student-name-class { font-size: 11px; color: var(--text2); margin-top: 1px; }

/* ── EMPTY STATE ── */
.empty-state { padding: 48px 24px; text-align: center; color: var(--text2); }
.empty-state .icon { font-size: 32px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── TOAST ── */
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--surface2); border: 1px solid var(--border2); color: var(--text); padding: 10px 20px; border-radius: 50px; font-size: 13px; opacity: 0; transition: all 0.25s; z-index: 999; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: rgba(39,174,96,0.9); border-color: var(--green); color: white; }
#toast.err { background: rgba(232,52,74,0.9); border-color: var(--red); color: white; }

/* ── NOTE BUTTON ── */
.note-btn { background: none; border: 1px solid var(--border2); color: var(--text2); border-radius: var(--radius-sm); padding: 5px 8px; cursor: pointer; display: flex; align-items: center; transition: all 0.15s; }
.note-btn:hover { border-color: var(--accent); color: var(--accent); }
.note-btn.has-note { border-color: rgba(245,166,35,0.4); color: var(--gold); background: rgba(245,166,35,0.08); }
.note-preview { font-size: 10px; color: var(--text2); margin-top: 3px; max-width: 160px; line-height: 1.3; }

/* ── SPINNER ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ── AUTO SYNC INDICATOR ── */
.sync-indicator { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text2); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green2); flex-shrink: 0; }
.sync-dot.error { background: var(--red); }
.sync-dot.syncing { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.3 } }

/* ── CONFIG BANNER ── */
.config-banner { background: rgba(245,166,35,0.1); border: 1px solid rgba(245,166,35,0.25); border-radius: var(--radius); padding: 14px 18px; margin: 20px 24px 0; font-size: 13px; display: flex; align-items: flex-start; gap: 12px; }
.config-banner-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.config-banner-text { flex: 1; color: var(--gold); line-height: 1.5; }
.config-banner-text strong { display: block; margin-bottom: 3px; }
.config-banner-text code { background: rgba(0,0,0,0.3); padding: 1px 6px; border-radius: 4px; font-size: 11px; color: #fff; }

/* ── CONFIG MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; padding: 28px; width: 480px; max-width: 95vw; }
.modal-title { font-family: 'Nunito', sans-serif; font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { font-size: 12px; color: var(--text2); margin-bottom: 20px; line-height: 1.5; }
.modal-label { font-size: 11px; color: var(--text2); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 5px; }
.modal-input { width: 100%; padding: 10px 12px; background: var(--surface2); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: 'Poppins', sans-serif; font-size: 13px; margin-bottom: 14px; outline: none; transition: border-color 0.15s; }
.modal-input:focus { border-color: var(--accent); }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.btn-primary { padding: 9px 20px; background: var(--accent); color: white; border: none; border-radius: var(--radius-sm); font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent2); }
.btn-cancel { padding: 9px 16px; background: none; border: 1px solid var(--border2); color: var(--text2); border-radius: var(--radius-sm); font-family: 'Poppins', sans-serif; font-size: 13px; cursor: pointer; }
