*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface2: #f2f2ef;
  --border: rgba(0,0,0,0.09);
  --border-mid: rgba(0,0,0,0.16);
  --text: #1a1a18;
  --text2: #6b6b67;
  --text3: #9e9e9a;
  --green: #1B6B4A;
  --green-light: #E8F5EE;
  --green-mid: #1D9E75;
  --amber: #854F0B;
  --amber-light: #FAEEDA;
  --amber-mid: #EF9F27;
  --red: #A32D2D;
  --red-light: #FCEBEB;
  --red-mid: #E24B4A;
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 220px;
  --panel-w: 300px;
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ---- AUTH ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 40px 36px; width: 360px; }
.auth-logo { font-size: 26px; font-weight: 600; color: var(--green); letter-spacing: -0.5px; margin-bottom: 4px; }
.auth-sub { font-size: 12px; color: var(--text3); margin-bottom: 28px; }
.auth-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.auth-input { width: 100%; padding: 9px 12px; border: 0.5px solid var(--border-mid); border-radius: var(--radius); font-size: 14px; color: var(--text); background: var(--surface); margin-bottom: 14px; outline: none; }
.auth-input:focus { border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(29,158,117,0.1); }
.auth-btn { width: 100%; padding: 10px; background: var(--green); color: white; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 4px; }
.auth-btn:hover { background: #155a3c; }
.auth-error { background: var(--red-light); color: var(--red); font-size: 12px; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; display: none; }
.auth-error.show { display: block; }

/* ---- APP SHELL ---- */
.app { display: flex; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }

/* ---- SIDEBAR ---- */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 22px 18px 16px; border-bottom: 0.5px solid var(--border); }
.logo-name { font-size: 20px; font-weight: 600; color: var(--green); letter-spacing: -0.3px; }
.logo-sub { font-size: 10px; color: var(--text3); margin-top: 2px; letter-spacing: 0.3px; }
.nav { padding: 12px 8px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); padding: 0 10px; margin: 12px 0 5px; }
.nav-section:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--text2); transition: background 0.1s, color 0.1s; margin-bottom: 1px; user-select: none; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--green-light); color: var(--green); font-weight: 500; }
.nav-item i { font-size: 16px; }
.nav-item.active i { color: var(--green); }
.sidebar-user { padding: 12px 16px; border-top: 0.5px solid var(--border); }
.user-name { font-size: 12px; font-weight: 500; color: var(--text); }
.user-role { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.logout-btn { font-size: 11px; color: var(--text3); cursor: pointer; background: none; border: none; padding: 0; display: flex; align-items: center; gap: 4px; }
.logout-btn:hover { color: var(--red); }

/* ---- MAIN ---- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar { padding: 12px 20px; background: var(--surface); border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; min-height: 52px; flex-shrink: 0; }
.page-title { font-size: 15px; font-weight: 500; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.date-nav { display: flex; align-items: center; gap: 5px; }
.date-btn { background: none; border: 0.5px solid var(--border-mid); border-radius: var(--radius); padding: 5px 8px; cursor: pointer; color: var(--text2); font-size: 13px; display: flex; align-items: center; }
.date-btn:hover { background: var(--surface2); }
.date-label { font-size: 12px; font-weight: 500; color: var(--text); min-width: 160px; text-align: center; background: var(--surface2); padding: 5px 10px; border-radius: var(--radius); }
.content-area { flex: 1; overflow-y: auto; padding: 18px 20px; }

/* ---- PAGE VIEWS ---- */
.page-view { display: none; }
.page-view.active { display: block; }

/* ---- STAT CARDS ---- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.stat-value { font-size: 26px; font-weight: 500; color: var(--text); line-height: 1; }

/* ---- CLASS CARDS ---- */
.classes-grid { display: flex; flex-direction: column; gap: 10px; }
.class-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.class-header { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 0.5px solid var(--border); }
.class-left { display: flex; flex-direction: column; gap: 5px; }
.class-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.badge-physical { background: var(--green-light); color: var(--green); }
.badge-online { background: var(--blue-light); color: var(--blue); }
.badge-room { background: var(--surface2); color: var(--text2); }
.badge-session-a { background: #EEF0FB; color: #3A3AB5; }
.badge-session-b { background: #F5EEFB; color: #7A3AB5; }
.class-meta { display: flex; align-items: center; gap: 14px; }
.class-meta-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); }
.class-meta-item i { font-size: 13px; color: var(--text3); }
.class-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.teacher-pill { display: flex; align-items: center; gap: 6px; background: var(--surface2); border-radius: 20px; padding: 4px 10px 4px 5px; font-size: 12px; color: var(--text2); }
.student-list { padding: 10px 16px 12px; display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; }
.student-chip { display: flex; align-items: center; gap: 6px; border-radius: 20px; padding: 4px 10px 4px 6px; font-size: 12px; cursor: pointer; transition: opacity 0.1s; border: 0.5px solid var(--border); background: var(--surface2); color: var(--text); }
.student-chip:hover { opacity: 0.8; }
.student-chip.makeup { background: var(--amber-light); border-color: rgba(239,159,39,0.3); }
.makeup-tag { font-size: 10px; background: var(--amber-light); color: var(--amber); padding: 1px 5px; border-radius: 3px; font-weight: 500; }
.session-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--green-mid); }
.dot-low { background: var(--amber-mid); }
.dot-none { background: var(--red-mid); }
.capacity-pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.cap-ok { background: var(--green-light); color: var(--green); }
.cap-warn { background: var(--amber-light); color: var(--amber); }
.cap-full { background: var(--red-light); color: var(--red); }
.empty-day { text-align: center; padding: 60px 20px; color: var(--text3); }
.empty-day i { font-size: 32px; display: block; margin-bottom: 10px; opacity: 0.5; }

/* ---- AVATAR ---- */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; flex-shrink: 0; }
.av-green { background: #9FE1CB; color: #085041; }
.av-blue { background: #B5D4F4; color: #0C447C; }
.av-amber { background: #FAC775; color: #633806; }
.av-pink { background: #F4C0D1; color: #72243E; }
.av-purple { background: #CECBF6; color: #3C3489; }

/* ---- SIDE PANEL ---- */
.side-panel { width: var(--panel-w); background: var(--surface); border-left: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; transition: width 0.2s; }
.side-panel.collapsed { width: 0; }
.panel-header { padding: 13px 16px; border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; min-height: 52px; flex-shrink: 0; }
.panel-title { font-size: 13px; font-weight: 500; color: var(--text); }
.panel-close { background: none; border: none; cursor: pointer; color: var(--text3); font-size: 18px; padding: 2px 4px; border-radius: 4px; }
.panel-close:hover { color: var(--text); background: var(--surface2); }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.panel-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; color: var(--text3); font-size: 13px; text-align: center; gap: 8px; }
.panel-empty i { font-size: 28px; }
.sd-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sd-name { font-size: 15px; font-weight: 500; color: var(--text); }
.sd-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }
.credit-box { background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.credit-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.credit-label { color: var(--text2); }
.credit-val { font-weight: 500; color: var(--text); }
.detail-section { margin-bottom: 14px; }
.detail-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 7px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 0.5px solid var(--border); font-size: 12px; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text2); }
.detail-val { color: var(--text); font-weight: 500; }
.action-btn { width: 100%; padding: 8px 12px; background: none; border: 0.5px solid var(--border-mid); border-radius: var(--radius); font-size: 12px; color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; transition: background 0.1s, color 0.1s; }
.action-btn:hover { background: var(--surface2); color: var(--text); }
.action-btn.primary { background: var(--green-light); color: var(--green); border-color: transparent; }
.action-btn.primary:hover { background: #c5eed8; }
.attendance-item { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 0.5px solid var(--border); font-size: 12px; }
.attendance-item:last-child { border-bottom: none; }
.att-date { color: var(--text2); }
.att-status { font-weight: 500; }
.att-present { color: var(--green); }
.att-absent { color: var(--red); }
.att-makeup { color: var(--amber); font-size: 10px; margin-left: 4px; }

/* ---- TABLES ---- */
.table-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-wrap { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 7px 11px; min-width: 240px; }
.search-wrap i { font-size: 15px; color: var(--text3); flex-shrink: 0; }
.search-wrap input { border: none; outline: none; background: none; font-size: 13px; color: var(--text); width: 100%; }
.search-wrap input::placeholder { color: var(--text3); }
.count-label { font-size: 12px; color: var(--text3); }
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: var(--radius); font-size: 12px; cursor: pointer; border: 0.5px solid var(--border-mid); background: none; color: var(--text2); transition: background 0.1s; }
.btn:hover { background: var(--surface2); color: var(--text); }
.btn.btn-primary { background: var(--green); color: white; border-color: transparent; }
.btn.btn-primary:hover { background: #155a3c; }
.btn i { font-size: 14px; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; border: 0.5px solid var(--border); font-size: 13px; }
.data-table th { text-align: left; padding: 9px 14px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); font-weight: 500; background: var(--surface2); border-bottom: 0.5px solid var(--border); }
.data-table td { padding: 10px 14px; border-bottom: 0.5px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); cursor: pointer; }
.no-data { text-align: center; padding: 40px; color: var(--text3); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.pill-green { background: var(--green-light); color: var(--green); }
.pill-amber { background: var(--amber-light); color: var(--amber); }
.pill-red { background: var(--red-light); color: var(--red); }
.pill-blue { background: var(--blue-light); color: var(--blue); }
.pill-gray { background: var(--surface2); color: var(--text2); }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 480px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,0.15); }
.modal-header { padding: 16px 20px; border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-size: 14px; font-weight: 500; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 0.5px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 10px; border: 0.5px solid var(--border-mid); border-radius: var(--radius); font-size: 13px; color: var(--text); background: var(--surface); outline: none; font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(29,158,117,0.1); }
.form-textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 3px; display: none; }
.form-error.show { display: block; }

/* ---- MANAGEMENT SUMMARY ---- */
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.summary-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.summary-card-title { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.summary-card-value { font-size: 32px; font-weight: 500; color: var(--text); line-height: 1; }
.summary-card-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }
.utilization-bar { height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.utilization-fill { height: 100%; border-radius: 3px; }

/* ---- CHANGE LOG ---- */
.log-entry { padding: 10px 0; border-bottom: 0.5px solid var(--border); font-size: 12px; }
.log-entry:last-child { border-bottom: none; }
.log-meta { display: flex; justify-content: space-between; color: var(--text3); margin-bottom: 3px; font-size: 11px; }
.log-change { color: var(--text); }
.log-reason { color: var(--text2); font-style: italic; margin-top: 2px; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* ---- TOAST ---- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: white; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); animation: slideIn 0.2s ease; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- LOADING ---- */
.loading-overlay { position: fixed; inset: 0; background: var(--surface); display: flex; align-items: center; justify-content: center; z-index: 300; }
.loading-overlay.hidden { display: none; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LEGEND ---- */
.legend { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--text2); }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .side-panel { display: none; }
}
