@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Sora:wght@400;600;700;800&display=swap');

:root {
  --primary: #1a56db;
  --primary-dark: #1241a0;
  --primary-light: #e8f0fe;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --gold: #d97706;
  --bg: #f0f4ff;
  --sidebar-bg: #0f1b4c;
  --sidebar-text: #a8b8d8;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(26,86,219,0.08);
  --shadow-lg: 0 8px 40px rgba(26,86,219,0.14);
  --radius: 16px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: 260px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; position: fixed;
  left: 0; top: 0; bottom: 0; z-index: 100;
}
.sidebar-logo { padding: 24px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-logo h1 { font-family: 'Sora', sans-serif; font-size: 18px; color: #fff; font-weight: 800; }
.sidebar-logo h1 span { color: var(--accent); }
.sidebar-logo p { font-size: 11px; color: var(--sidebar-text); margin-top: 3px; }
.role-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 10.5px; font-weight: 700; margin-top: 8px; }
.role-badge.owner { background: rgba(245,158,11,0.2); color: #fbbf24; }
.role-badge.superadmin { background: rgba(217,119,6,0.25); color: #fcd34d; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-section-title { font-size: 10px; font-weight: 700; color: #3d5080; text-transform: uppercase; letter-spacing: 1.2px; padding: 8px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 10px; cursor: pointer; transition: all 0.2s; color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; margin-bottom: 2px; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(26,86,219,0.4); }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.07); }
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: #fff; flex-shrink: 0; }
.user-info p { font-size: 13px; color: #fff; font-weight: 600; }
.user-info span { font-size: 11px; color: var(--sidebar-text); }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; margin-top: 10px; background: rgba(239,68,68,0.15); border: none; border-radius: 9px; color: #f87171; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; text-decoration: none; }
.logout-btn:hover { background: rgba(239,68,68,0.25); }

/* MAIN */
.main { margin-left: 260px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: var(--card); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar h2 { font-family: 'Sora', sans-serif; font-size: 19px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.date-badge { background: var(--primary-light); color: var(--primary); padding: 5px 13px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.fb-status { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.fb-status.connected { background: var(--success-light); color: #065f46; }
.fb-status.offline { background: var(--warning-light); color: #92400e; }
.fb-dot { width: 7px; height: 7px; border-radius: 50%; }
.content { padding: 26px; flex: 1; }

/* CARDS */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14.5px; font-weight: 700; }
.card-body { padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }

/* STATS */
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0; }
.stat-info p { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-info h3 { font-size: 26px; font-weight: 800; margin-top: 1px; }
.stat-info small { font-size: 11.5px; color: var(--success); font-weight: 600; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 17px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; font-family: inherit; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26,86,219,0.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-gold { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-gold { background: #fef3c7; color: #92400e; }

/* FORMS */
.form-group { margin-bottom: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; }
label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { width: 100%; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); transition: all 0.2s; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
textarea { resize: vertical; min-height: 75px; }
.section-divider { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 1.5px solid var(--border); }

/* TABLE */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
thead tr { background: #f8faff; }
th { padding: 12px 15px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1.5px solid var(--border); }
td { padding: 12px 15px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8faff; }
.avatar-cell { display: flex; align-items: center; gap: 9px; }
.mini-avatar { width: 31px; height: 31px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; color: #fff; flex-shrink: 0; }

/* ATTENDANCE */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 11px; }
.att-card { background: var(--card); border-radius: 12px; padding: 13px; border: 2px solid var(--border); cursor: pointer; transition: all 0.2s; text-align: center; }
.att-card.present { border-color: var(--success); background: var(--success-light); }
.att-card.absent { border-color: var(--danger); background: var(--danger-light); }
.att-card.halfday { border-color: var(--accent); background: var(--accent-light); }
.att-card .att-name { font-size: 12px; font-weight: 700; margin-top: 7px; }
.att-card .att-roll { font-size: 10.5px; color: var(--text-muted); }
.att-status-btn { display: flex; gap: 5px; justify-content: center; margin-top: 9px; }
.att-btn { width: 27px; height: 27px; border-radius: 50%; border: none; cursor: pointer; font-size: 12px; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.att-btn.p { background: var(--success); color: #fff; }
.att-btn.a { background: var(--danger); color: #fff; }
.att-btn.h { background: var(--accent); color: #fff; }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,27,76,0.55); z-index: 999; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border-radius: var(--radius); width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp 0.3s; }
.modal-lg { max-width: 680px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal-header h3 { font-size: 15.5px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; background: var(--bg); border-radius: 8px; border: none; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--card); }

/* TABS */
.tabs { display: flex; gap: 5px; background: var(--bg); padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tab { padding: 7px 16px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; color: var(--text-muted); }
.tab.active { background: var(--card); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* PERMISSION TOGGLE */
.perm-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.perm-row:last-child { border: none; }
.perm-label p { font-size: 13.5px; font-weight: 600; }
.perm-label span { font-size: 11.5px; color: var(--text-muted); }
.toggle { width: 42px; height: 24px; background: #cbd5e1; border-radius: 12px; cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle.on { background: var(--success); }
.toggle::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.toggle.on::after { left: 21px; }

/* QUICK ACTIONS */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 11px; margin-bottom: 22px; }
.quick-btn { background: var(--card); border-radius: 12px; padding: 16px 12px; text-align: center; cursor: pointer; border: 1.5px solid var(--border); transition: all 0.2s; text-decoration: none; display: block; }
.quick-btn:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-btn .q-icon { font-size: 24px; margin-bottom: 7px; }
.quick-btn p { font-size: 12px; font-weight: 700; color: var(--text); }

/* PROGRESS */
.progress-bar { height: 7px; background: var(--border); border-radius: 20px; overflow: hidden; margin-top: 7px; }
.progress-fill { height: 100%; border-radius: 20px; transition: width 0.5s; }

/* HALFDAY */
.halfday-section { background: var(--accent-light); border: 1.5px solid var(--accent); border-radius: 12px; padding: 15px; margin-top: 11px; }
.halfday-section h4 { font-size: 13px; font-weight: 700; color: #92400e; margin-bottom: 11px; }

/* REMARK */
.remark-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.remark-item:last-child { border: none; }
.remark-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ROUTE CARD */
.route-card { background: var(--card); border-radius: var(--radius-sm); padding: 15px; border: 1.5px solid var(--border); margin-bottom: 11px; display: flex; align-items: center; justify-content: space-between; }

/* LOADING */
.loading { display: flex; align-items: center; justify-content: center; padding: 36px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* TOAST */
#toast { position: fixed; bottom: 22px; right: 22px; z-index: 9999; display: none; min-width: 220px; padding: 13px 17px; border-radius: 12px; background: #0f1b4c; color: #fff; font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,0.25); align-items: center; gap: 9px; }

/* SUPER ADMIN */
.sa-header { background: linear-gradient(135deg, #7c2d12, #d97706); border-radius: var(--radius); padding: 24px; color: #fff; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.sa-header h2 { font-family: 'Sora', sans-serif; font-size: 20px; font-weight: 800; }
.sa-stat { background: rgba(255,255,255,0.15); border-radius: 12px; padding: 14px 18px; text-align: center; min-width: 80px; }
.sa-stat h3 { font-size: 28px; font-weight: 800; }
.sa-stat p { font-size: 11.5px; opacity: 0.8; }

/* OWNER WELCOME */
.owner-welcome { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: var(--radius); padding: 24px; color: #fff; margin-bottom: 22px; position: relative; overflow: hidden; }
.owner-welcome::after { content: '🏫'; position: absolute; right: 24px; top: 50%; transform: translateY(-50%); font-size: 60px; opacity: 0.2; }
.owner-welcome h2 { font-family: 'Sora', sans-serif; font-size: 21px; font-weight: 800; }
.owner-welcome p { font-size: 13px; opacity: 0.85; margin-top: 4px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 20px; }

/* ALERT */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.alert-danger { background: var(--danger-light); color: #991b1b; }
.alert-success { background: var(--success-light); color: #065f46; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

@media(max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
