:root { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #172033; background: #f4f7fb; }
* { box-sizing: border-box; }
body { display: flex; flex-direction: column; margin: 0; min-height: 100vh; }
.topbar { background: linear-gradient(115deg, #123564, #1d4f8d); color: white; min-height: 72px; padding: .75rem 5vw; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.brand { color: white; font-weight: 800; text-decoration: none; font-size: 1.1rem; letter-spacing: -.01em; }
.main-nav { display: flex; align-items: center; flex: 1; flex-wrap: wrap; gap: .25rem; }
.main-nav a, .account-menu > a { border-radius: 6px; color: white; padding: .4rem .55rem; text-decoration: none; }
.main-nav a:hover, .account-menu > a:hover { background: #ffffff20; }
.nav-dropdown { position: relative; }
.nav-dropdown summary { border-radius: 6px; cursor: pointer; list-style: none; padding: .4rem .55rem; }
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: '⌄'; font-size: .9rem; margin-left: .35rem; }
.nav-dropdown[open] summary, .nav-dropdown summary:hover { background: #ffffff20; }
.nav-dropdown[open] summary::after { content: '⌃'; }
.nav-dropdown-menu { background: #fff; border-radius: 8px; box-shadow: 0 10px 26px #091d3938; left: 0; min-width: 185px; padding: .35rem; position: absolute; top: calc(100% + .45rem); z-index: 10; }
.main-nav .nav-dropdown-menu a { color: #173f73; display: block; padding: .55rem .7rem; }
.main-nav .nav-dropdown-menu a:hover { background: #eef5ff; }
.account-menu { align-items: center; display: flex; gap: .5rem; }
.account-name { font-weight: 700; white-space: nowrap; }
.role-badge { border-radius: 999px; display: inline-block; font-size: .78rem; font-weight: 800; padding: .22rem .55rem; white-space: nowrap; }
.role-user { background: #e8f1ff; color: #1e5293; }
.role-admin { background: #fff0c9; color: #785000; }
.container { flex: 1; width: min(100% - 2rem, 980px); margin: 2rem auto; }
.site-footer { border-top: 1px solid #dbe6f3; color: #5a6d87; font-size: .88rem; padding: 1.25rem 1rem; text-align: center; }
.site-footer p { margin: 0; }
.auth-card, .card { background: white; border-radius: 12px; box-shadow: 0 6px 20px #17203318; padding: 2rem; }
.auth-card { width: min(100%, 420px); margin: 4rem auto; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .4rem; font-weight: 600; }
input, select { border: 1px solid #b7c3d5; border-radius: 6px; padding: .7rem; font: inherit; }
button { background: linear-gradient(135deg, #173f73, #245a9d); color: white; border: 0; border-radius: 7px; padding: .75rem 1rem; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 2px 5px #173f7326; }
.error { background: #fee8e8; color: #9e1c1c; border-radius: 6px; padding: .75rem; }
.notice { background: #e6f5ea; color: #155d2b; border-radius: 6px; padding: .75rem; }
.password-reset-link { margin: 1.25rem 0 0; text-align: center; }
.password-reset-link a { color: #173f73; font-weight: 600; }
.action-link { display: inline-block; color: #173f73; font-weight: 700; }
.dashboard-hero { margin-bottom: 2rem; }
.dashboard-hero h1 { margin-bottom: .4rem; }
.action-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1.5rem; }
.action-card { align-items: center; background: #fff; border: 1px solid #dbe6f3; border-radius: 12px; color: #172033; display: flex; gap: .9rem; min-height: 92px; padding: 1rem; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.action-card:hover { border-color: #7ea7d4; box-shadow: 0 8px 20px #173f731c; transform: translateY(-2px); }
.action-card strong, .action-card small { display: block; }
.action-card small { color: #5a6d87; margin-top: .2rem; }
.action-icon { align-items: center; background: #e8f1ff; border-radius: 10px; color: #173f73; display: inline-flex; font-size: 1.5rem; font-weight: 800; height: 42px; justify-content: center; width: 42px; }
.admin-tools-title { font-size: 1.15rem; margin: 2rem 0 0; }
.admin-grid .action-card { background: #fffcf3; }
.exam-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; align-items: center; gap: .75rem; grid-column: 1 / -1; }
.button-secondary { border: 1px solid #173f73; border-radius: 6px; color: #173f73; font-weight: 700; padding: .65rem 1rem; text-decoration: none; }
.exam-list-card { margin-top: 1.5rem; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.row-actions form { display: inline; }
.teacher-actions { display: grid; grid-template-columns: repeat(2, max-content); min-width: 250px; white-space: normal; }
.teacher-actions .action-button { text-align: center; }
.action-button { border: 1px solid; border-radius: 6px; display: inline-block; font: inherit; font-weight: 700; padding: .45rem .7rem; text-decoration: none; }
.action-edit { background: #fff; border-color: #173f73; color: #173f73; }
button.action-delete { background: #fff; border-color: #b42318; color: #b42318; }
.mapping-grade-form { grid-template-columns: minmax(180px, 260px); margin-bottom: 1.5rem; }
.mapping-form { display: grid; justify-items: start; }
.mapping-table-wrap { max-width: 100%; overflow-x: auto; }
.mapping-table th:not(:first-child), .mapping-table td { text-align: center; }
.mapping-table input[type="checkbox"] { accent-color: #173f73; height: 1.2rem; width: 1.2rem; }
.free-dates-form { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.date-search-form { grid-template-columns: minmax(180px, 260px) max-content; align-items: end; }
.history-filter { grid-template-columns: minmax(220px, 420px); }
.history-table td:last-child { min-width: 360px; white-space: normal; }
.teacher-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.role-picker { border: 1px solid #dbe6f3; border-radius: 8px; display: grid; gap: .7rem; grid-column: 1 / -1; margin: 0; padding: 1rem; }
.role-picker legend { font-weight: 800; padding: 0 .35rem; }
.role-choice { align-items: flex-start; border: 1px solid #dbe6f3; border-radius: 8px; cursor: pointer; display: flex; gap: .65rem; padding: .75rem; }
.role-choice:has(input:checked) { background: #eef5ff; border-color: #4e85c0; }
.role-choice input { accent-color: #173f73; margin-top: .18rem; padding: 0; }
.role-choice strong, .role-choice small { display: block; }
.role-choice small { color: #5a6d87; font-weight: 400; margin-top: .15rem; }
.section-form { grid-template-columns: minmax(220px, 420px); }
.maintenance-card { max-width: 760px; }
.warning-text { background: #fff3cd; border-left: 4px solid #d79a00; color: #654800; padding: .85rem 1rem; }
.maintenance-counts { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 1.5rem; }
.maintenance-counts span { background: #eef5ff; border-radius: 999px; color: #28496f; padding: .4rem .75rem; }
.maintenance-options { border: 1px solid #dbe6f3; border-radius: 8px; display: grid; gap: .7rem; margin: 0; padding: 1rem; }
.maintenance-options legend { font-weight: 800; padding: 0 .35rem; }
.form-help { color: #5a6d87; font-size: .92rem; margin: .1rem 0; }
.teacher-checklist { display: grid; gap: .5rem; max-height: 260px; overflow: auto; padding-right: .4rem; }
.teacher-checklist small { color: #5a6d87; font-weight: 400; }
.danger-button { background: linear-gradient(135deg, #a81d1d, #d0392d); }
.checkbox-label { align-self: center; display: flex; font-weight: 600; gap: .55rem; }
.checkbox-label input { height: 1.1rem; width: 1.1rem; }
.results-card { margin-top: 1.5rem; }
.page-heading { margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem; border-bottom: 1px solid #e2e8f0; text-align: left; }
th { color: #40526e; }
.calendar-card { overflow-x: auto; }
.calendar-filters { grid-template-columns: repeat(2, minmax(180px, 260px)); align-items: end; margin-bottom: 1.5rem; }
.calendar-navigation { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.calendar-navigation h2 { margin: 0; font-size: 1.25rem; text-transform: capitalize; }
.calendar-navigation a { color: #173f73; font-weight: 700; text-decoration: none; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr)); border: 1px solid #dbe4f0; border-radius: 8px; overflow: hidden; }
.calendar-weekday { background: #edf3fa; color: #40526e; font-weight: 700; padding: .6rem; text-align: center; }
.calendar-day { min-height: 108px; border-top: 1px solid #dbe4f0; border-left: 1px solid #dbe4f0; padding: .45rem; background: white; }
.calendar-day:nth-child(7n + 1) { border-left: 0; }
.calendar-day.is-empty { background: #f8fafc; }
.calendar-day.is-selected { outline: 3px solid #173f73; outline-offset: -3px; }
.calendar-date { display: inline-flex; width: 1.8rem; height: 1.8rem; align-items: center; justify-content: center; color: #40526e; text-decoration: none; font-weight: 700; border-radius: 50%; }
.has-events .calendar-date { color: white; background: #173f73; }
.calendar-markers { display: grid; gap: .25rem; margin-top: .35rem; }
.event-marker { border-left: 4px solid var(--event-color); background: color-mix(in srgb, var(--event-color) 12%, white); color: #172033; font-size: .76rem; font-weight: 700; overflow: hidden; padding: .2rem .3rem; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.more-events { color: #173f73; font-size: .78rem; font-weight: 700; padding: .15rem .3rem; text-decoration: none; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin-top: 1.25rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.calendar-legend i { background: var(--event-color); border-radius: 50%; display: inline-block; height: .85rem; width: .85rem; }
.calendar-details { margin-top: 1.5rem; }
.details-list { display: grid; gap: 1rem; }
.event-details { border-left: 5px solid var(--event-color); background: #f8fafc; padding: 1rem; }
.event-details h3 { margin: 0 0 .75rem; }
.event-details dl { display: grid; gap: .5rem; margin: 0; }
.event-details dl div { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 1rem; }
.event-details dt { color: #40526e; font-weight: 700; }
.event-details dd { margin: 0; }
@media (max-width: 800px) { .topbar { padding: .75rem 1rem; } .main-nav { order: 3; flex-basis: 100%; } .account-menu { margin-left: auto; } .nav-dropdown-menu { position: static; margin-top: .2rem; } }
@media (max-width: 640px) { .container { width: min(100% - 1rem, 980px); } .auth-card, .card { padding: 1.25rem; } .exam-form, .free-dates-form, .date-search-form, .teacher-form, .section-form, .action-grid { grid-template-columns: 1fr; } .account-name { display: none; } }
