:root {
  color-scheme: light;
  --bg: #FBF9F3;
  --surface: #FFFFFF;
  --surface-soft: #F5F3EC;
  --ink: #1F2421;
  --muted: #69726A;
  --line: #E4DFD0;
  --maroon: #9E2A2B;
  --maroon-dark: #6E1519;
  --maroon-soft: #F5DEDE;
  --green: #2C5234;
  --green-dark: #1E3A24;
  --green-soft: #CFE7D6;
  --shadow: 0 18px 48px rgba(31, 36, 33, .08);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: -.025em; }
p { margin: 0; line-height: 1.65; }
[hidden] { display: none !important; }
.muted, .field-help { color: var(--muted); }
.eyebrow { color: var(--green); font-size: .72rem; font-weight: 700; letter-spacing: .14em; line-height: 1.4; text-transform: uppercase; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-family: 'Playfair Display', Georgia, serif; font-size: 1.2rem; }
.brand small { color: var(--muted); font-size: .76rem; }
.auth-page { display: grid; place-items: center; padding: 28px 16px; }
.auth-shell { width: min(100%, 490px); display: grid; justify-items: center; gap: 22px; }
.auth-shell > .brand { margin-bottom: 2px; }
.auth-card { width: 100%; display: grid; gap: 12px; padding: clamp(24px, 5vw, 38px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card-wide { width: min(100%, 580px); }
.auth-card h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); }
.auth-card > .muted { margin-bottom: 8px; font-size: .94rem; }
.form-stack { display: grid; gap: 10px; }
.field-label { display: block; margin-top: 5px; color: var(--ink); font-size: .84rem; font-weight: 700; }
.field-input { width: 100%; min-width: 0; min-height: 46px; padding: 11px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fff; transition: border-color .15s, box-shadow .15s; }
.field-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(44, 82, 52, .12); }
.field-input::placeholder { color: #9AA197; }
.field-help { font-size: .78rem; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: .82rem; }
.form-row.end { justify-content: flex-end; }
.form-row.between { justify-content: space-between; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: .86rem; transition: transform .15s, background .15s, border-color .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary { color: #fff; background: var(--maroon); }
.btn-primary:hover { background: var(--maroon-dark); }
.btn-secondary { color: var(--green-dark); border-color: var(--line); background: var(--surface-soft); }
.btn-secondary:hover { border-color: #B9C8B9; background: #EEF2EA; }
.btn-danger { color: #fff; background: #9B2F2F; }
.btn-block { width: 100%; min-height: 48px; margin-top: 6px; }
.form-message { min-height: 1.4em; color: var(--maroon); font-size: .82rem; }
.form-message.success { color: var(--green); }
.auth-footnote { padding-top: 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: .76rem; line-height: 1.6; }
.copyright { color: var(--muted); font-size: .76rem; text-align: center; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; font-size: .86rem; }
.check-row input { width: 17px; height: 17px; accent-color: var(--green); }
.otp-input { max-width: 220px; font-size: 1.25rem; font-weight: 700; letter-spacing: .3em; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 260px; padding: 24px 16px 18px; border-right: 1px solid var(--line); background: #fff; }
.sidebar-brand { padding: 4px 10px 26px; }
.side-nav { display: grid; gap: 6px; }
.side-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 10px 12px; color: #49534B; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; font-size: .88rem; font-weight: 600; }
.side-link > span { display: grid; place-items: center; width: 24px; height: 24px; color: var(--green); font-size: 1rem; }
.side-link:hover { background: var(--surface-soft); }
.side-link.active { color: var(--maroon-dark); background: var(--maroon-soft); }
.side-link.active > span { color: var(--maroon); }
.sidebar-bottom { display: grid; gap: 14px; margin-top: auto; }
.logout-button { min-height: 42px; color: var(--maroon); border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 700; }
.secure-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .72rem; }
.secure-label i { width: 8px; height: 8px; border-radius: 50%; background: #3C9455; }
.main-area { min-height: 100vh; margin-left: 260px; padding: 0 34px 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 96px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin-top: 3px; font-size: 1.55rem; }
.teacher-identity { display: flex; align-items: center; gap: 10px; font-size: .84rem; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; color: var(--green-dark); border-radius: 50%; background: var(--green-soft); font-weight: 700; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.page-content { width: min(100%, 1200px); margin: 28px auto 42px; }
.dashboard-footer { width: min(100%, 1200px); margin: 0 auto; padding-top: 14px; color: var(--muted); border-top: 1px solid var(--line); font-size: .74rem; }
.loading-card, .panel, .panel-card, .stat-card, .welcome-card { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 6px 22px rgba(31, 36, 33, .035); }
.welcome-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 30px; background: linear-gradient(125deg, #fff 0%, #F5F3EC 100%); }
.welcome-card h2 { margin: 7px 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.welcome-card p { max-width: 650px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.stat-card span { display: block; color: var(--muted); font-size: .78rem; }
.stat-card strong { display: block; margin-top: 6px; color: var(--green-dark); font-size: 1.6rem; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 5px 0; font-size: clamp(1.45rem, 3vw, 2rem); }
.section-heading p:not(.eyebrow) { color: var(--muted); font-size: .88rem; }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel-card h3 { margin-bottom: 10px; font-size: 1.1rem; }
.panel-card p { color: var(--muted); font-size: .86rem; }
.panel-card .panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th, .table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
.table td strong { display: block; }
.table td small { display: block; margin-top: 3px; color: var(--muted); }
.status-pill { display: inline-flex; padding: 5px 9px; color: var(--green-dark); border-radius: 100px; background: var(--green-soft); font-size: .72rem; font-weight: 700; }
.status-pill.live { color: #7D2526; background: var(--maroon-soft); }
.empty-state { padding: 36px 18px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-family: 'Playfair Display', Georgia, serif; font-size: 1.2rem; }
.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(20, 25, 21, .56); }
.modal-card { width: min(100%, 620px); max-height: min(90vh, 760px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h2 { margin-top: 5px; font-size: 1.45rem; }
.modal-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.profile-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.profile-item { padding: 12px; border-radius: 9px; background: var(--surface-soft); }
.profile-item span { display: block; color: var(--muted); font-size: .72rem; }
.profile-item strong { display: block; overflow-wrap: anywhere; margin-top: 4px; font-size: .84rem; }
.sidebar-overlay { display: none; }
@media (max-width: 980px) {
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { position: fixed; z-index: 19; inset: 0; display: block; background: rgba(20, 25, 21, .38); }
  .main-area { margin-left: 0; padding: 0 22px 18px; }
  .menu-toggle { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .topbar { justify-content: flex-start; }
  .teacher-identity { margin-left: auto; }
}
@media (max-width: 680px) {
  .auth-page { padding: 18px 12px; }
  .auth-card { padding: 22px 18px; }
  .main-area { padding: 0 14px 16px; }
  .topbar { min-height: 78px; gap: 10px; }
  .topbar h1 { font-size: 1.2rem; }
  .teacher-identity strong { display: none; }
  .page-content { margin-top: 18px; }
  .welcome-card { align-items: flex-start; flex-direction: column; padding: 22px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .content-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .form-grid, .profile-list { grid-template-columns: 1fr; }
  .modal-card { padding: 20px 16px; }
  .table { min-width: 560px; }
  .btn { min-height: 40px; }
}

.btn-sm { min-height: 34px; padding: 7px 10px; font-size: .76rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.portal-toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(90vw, 380px); padding: 13px 16px; color: #fff; border-radius: 9px; background: var(--maroon-dark); box-shadow: var(--shadow); font-size: .84rem; }
.portal-toast.success { background: var(--green-dark); }
