:root {
  color-scheme: light;
  --navy: #0d416c;
  --navy-2: #123654;
  --teal: #0b817b;
  --teal-soft: #e5f5f2;
  --blue-soft: #eaf2f9;
  --ink: #16334d;
  --muted: #64788b;
  --line: #d9e3eb;
  --surface: #ffffff;
  --bg: #f3f7fa;
  --danger: #b42318;
  --warning: #996a00;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.loading-screen, .auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.loading-screen { color: var(--muted); align-content: center; gap: 10px; }
.spinner { width: 34px; height: 34px; border: 3px solid #cbd9e4; border-top-color: var(--teal); border-radius: 999px; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-card { width: min(100%, 440px); padding: 28px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 20px 60px rgb(16 49 75 / .12); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 48px; height: 48px; border-radius: 15px; }
.brand strong { display: block; font-size: 1.2rem; }
.brand small { color: var(--muted); }
.auth-card h1 { margin: 28px 0 8px; font-size: 1.45rem; }
.auth-card p { color: var(--muted); line-height: 1.55; }
.field { display: grid; gap: 7px; margin-top: 16px; }
.field label { font-size: .88rem; font-weight: 700; }
input, select { width: 100%; height: 44px; border: 1px solid #bccbd7; border-radius: 11px; padding: 0 12px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgb(11 129 123 / .14); border-color: var(--teal); }
.btn { min-height: 42px; border: 0; border-radius: 11px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; background: var(--navy); color: #fff; }
.btn:hover { background: var(--navy-2); }
.btn.secondary { color: var(--navy); background: var(--blue-soft); }
.btn.ghost { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.full { width: 100%; margin-top: 20px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.alert { margin-top: 16px; padding: 12px 14px; border-radius: 11px; border: 1px solid #f1c7c3; background: #fff1ef; color: #8d241a; line-height: 1.45; }
.alert.info { border-color: #b9dbe7; background: #edf8fb; color: #245a6d; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; color: #fff; background: linear-gradient(120deg, #0d416c, #0c5c75); box-shadow: 0 6px 22px rgb(12 54 84 / .18); }
.topbar .brand img { width: 42px; height: 42px; }
.topbar .brand small { color: #c9e4ee; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-menu span { max-width: 220px; text-align: right; }
.user-menu small { display: block; color: #c8e0ea; }
.layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { padding: 20px 14px; border-right: 1px solid var(--line); background: #fff; }
.nav { display: grid; gap: 6px; position: sticky; top: 92px; }
.nav button { width: 100%; border: 0; border-radius: 11px; padding: 12px 13px; display: flex; align-items: center; justify-content: space-between; gap: 9px; text-align: left; color: #466177; background: transparent; font-weight: 700; }
.nav button small { flex: 0 0 auto; border-radius: 999px; padding: 2px 6px; color: #786000; background: #fff0b8; font-size: .68rem; }
.nav button:hover { background: var(--blue-soft); }
.nav button.active { color: #fff; background: var(--navy); box-shadow: 0 5px 16px rgb(13 65 108 / .2); }
.content { min-width: 0; padding: 28px; }
.content-inner { max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 1.9rem); }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.search-wrap { position: relative; width: min(100%, 540px); }
.search-wrap input { height: 48px; padding-left: 42px; box-shadow: 0 6px 20px rgb(25 60 90 / .08); }
.search-icon { position: absolute; left: 14px; top: 13px; color: var(--teal); }
.suggestions { position: absolute; z-index: 30; top: 52px; width: 100%; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 18px 48px rgb(24 50 76 / .18); }
.suggestions button { width: 100%; display: flex; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid #edf1f4; padding: 12px 14px; text-align: left; background: #fff; }
.suggestions button:hover { background: #f0f8f7; }
.suggestions small { color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 7px 24px rgb(31 63 91 / .06); }
.card-head { padding: 18px 20px; border-bottom: 1px solid #e8eef3; }
.card-head h2 { margin: 0; font-size: 1.05rem; }
.card-head p { margin: 5px 0 0; color: var(--muted); font-size: .9rem; }
.card-body { padding: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 18px; }
.toolbar .field { margin: 0; min-width: 150px; flex: 1 1 180px; }
.version-badge, .badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 800; }
.version-badge { color: #075c58; background: var(--teal-soft); }
.badge.tc { color: #185b95; background: #e8f1fb; }
.badge.ph { color: #08736c; background: #e6f6f2; }
.badge.hkst { color: #7c5000; background: #fff0c7; }
.badge.missing { color: #8d4b00; background: #fff0d8; }
.next-card { margin-bottom: 18px; overflow: hidden; border: 0; color: #fff; background: linear-gradient(120deg, #0d416c, #0a7775); }
.next-card .card-body { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.next-card h2 { margin: 0 0 8px; font-size: 1rem; color: #ccebe8; }
.next-main { font-size: 1.3rem; font-weight: 850; }
.next-meta { margin-top: 6px; color: #d7ecf2; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td { padding: 11px 12px; border-bottom: 1px solid #e7edf2; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 2; color: #3d5970; background: #eff4f8; font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
.weekly { min-width: 920px; }
.weekly th:first-child { position: sticky; left: 0; z-index: 5; min-width: 104px; }
.weekly tbody th:first-child { color: #3d5970; background: #f7f9fb; }
.weekly th:not(:first-child), .weekly td:not(:first-child) { min-width: 158px; border-left: 1px solid #e8edf2; }
.weekly thead th small { display: block; margin-top: 3px; color: var(--muted); font-weight: 650; }
.weekly td { height: 92px; }
.weekly .today-column { border-left: 2px solid #35a69b; border-right: 2px solid #35a69b; background: #edfaf7; }
.weekly thead .today-column { color: #075f5a; background: #d9f3ed; box-shadow: inset 0 3px 0 #0b817b; }
.slot-entry + .slot-entry { margin-top: 9px; padding-top: 9px; border-top: 1px dashed #cad8e1; }
.slot-title { font-weight: 850; color: var(--navy); }
.slot-sub { margin-top: 3px; font-size: .88rem; color: #4f6679; }
.slot-room { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed #b9cad6; border-radius: 13px; background: #fafcfd; }
.mobile-list { display: none; }
.day-section { margin-bottom: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.day-title { padding: 10px 13px; font-weight: 800; background: #eef4f8; }
.lesson { display: grid; grid-template-columns: 80px 1fr; gap: 10px; padding: 12px 13px; border-top: 1px solid #edf1f4; }
.lesson-time { color: var(--teal); font-weight: 800; }
.lesson strong { display: block; }
.lesson small { color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.stat { padding: 16px; border-radius: 13px; background: #f0f5f8; }
.stat strong { display: block; font-size: 1.35rem; color: var(--navy); }
.stat span { color: var(--muted); font-size: .82rem; }
.issues { max-height: 280px; overflow: auto; margin: 14px 0; padding: 0; list-style: none; }
.issues li { padding: 9px 11px; border-bottom: 1px solid #eee; }
.issues .error { color: var(--danger); }
.issues .warning { color: var(--warning); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.check-item input { width: 18px; height: 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: #fff; color: var(--muted); font-weight: 700; }
.tabs button.active { border-color: var(--teal); background: var(--teal-soft); color: #075f5a; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; border-radius: 12px; color: #fff; background: #183f5d; box-shadow: 0 12px 36px rgb(13 43 66 / .28); }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; }
.section-gap { margin-top: 18px; }
.account-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.account-section > summary { padding: 18px 20px; list-style: none; cursor: pointer; font-weight: 800; color: var(--navy); }
.account-section > summary::-webkit-details-marker { display: none; }
.account-section > summary::after { content: "+"; float: right; font-size: 1.25rem; color: var(--teal); }
.account-section[open] > summary { border-bottom: 1px solid #e8eef3; }
.account-section[open] > summary::after { content: "−"; }
.account-section tr[hidden] { display: none; }
.form-gap { margin-top: 14px; }
.result-space { margin-top: 16px; }
.roles-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.overview td { text-align: center; vertical-align: middle; }
.overview td > strong { display: block; font-size: 1.3rem; color: var(--navy); }
.overview td > small { display: block; color: var(--muted); }
.slot-link { margin-top: 8px; border: 0; padding: 4px 0; color: var(--teal); background: transparent; font-size: .76rem; font-weight: 800; }
.install-btn { color: #0d416c; background: #fff; }
.install-btn:hover { color: #fff; background: #0a7775; }
.topbar-action { color: #fff !important; border-color: #6d91a8 !important; }
dialog { width: min(92vw, 460px); border: 1px solid var(--line); border-radius: 18px; padding: 24px; color: var(--ink); box-shadow: 0 24px 80px rgb(9 35 55 / .28); }
dialog::backdrop { background: rgb(9 35 55 / .48); }
dialog h2 { margin: 0 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.coming-soon { max-width: 700px; text-align: center; }
.coming-soon .card-body { padding: 46px 28px; }
.coming-soon h2 { margin: 14px 0 8px; }
.coming-soon p { max-width: 560px; margin: 0 auto 22px; color: var(--muted); line-height: 1.6; }
.coming-icon { display: block; margin-bottom: 14px; color: var(--teal); font-size: 3rem; line-height: 1; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 72px; z-index: 15; overflow-x: auto; padding: 9px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; width: max-content; position: static; }
  .nav button { width: auto; white-space: nowrap; padding: 9px 12px; }
  .content { padding: 20px 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 13px; }
  .topbar .brand small, .user-menu span { display: none; }
  .sidebar { top: 64px; }
  .weekly-scroll { margin-inline: -1px; }
  .page-head { display: block; }
  .page-actions { justify-content: flex-start; margin-top: 12px; }
  .page-head .version-badge { margin-top: 10px; }
  .next-card .card-body { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card-body, .card-head { padding: 15px; }
  .weekly { min-width: 860px; }
  .weekly th:not(:first-child), .weekly td:not(:first-child) { min-width: 148px; }
}

.teaching-tabs { margin: 0 0 14px; }
.teaching-toolbar { align-items: end; }
.week-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.week-caption { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; color: var(--muted); }
.week-caption b { color: var(--navy); }
.teaching-log-head, .teaching-log-row {
  display: grid;
  grid-template-columns: minmax(145px, .8fr) minmax(130px, .75fr) minmax(240px, 1.5fr) minmax(150px, .8fr) 34px;
  gap: 12px;
  align-items: center;
}
.teaching-log-head { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .8rem; font-weight: 800; }
.teaching-log-row { min-height: 74px; padding: 11px 12px; border-bottom: 1px solid #edf1f4; }
.teaching-log-row:last-child { border-bottom: 0; }
.teaching-log-row.editable:hover { background: #f7fbfc; }
.teaching-log-row b, .teaching-log-row span { display: block; }
.teaching-log-row span, .teaching-log-row small { color: var(--muted); }
.lesson-content b { color: var(--navy); }
.lesson-state small { margin-top: 5px; }
.lesson-detail { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; color: var(--teal); background: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.status-pill { display: inline-flex !important; width: fit-content; padding: 5px 9px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.status-pill.planned { color: #536371; background: #eef2f5; }
.status-pill.completed { color: #0b655a; background: #e1f5ef; }
.status-pill.cancelled { color: #9b2c2c; background: #fde8e8; }
.status-pill.incomplete { color: #8a5310; background: #fff0d5; }
.status-pill.moved, .status-pill.makeup, .status-pill.substitute, .status-pill.content { color: #164e79; background: #e6f2fb; }
.exception-options { display: grid; gap: 9px; margin: 16px 0; }
.exception-options > label { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.exception-options input { width: 18px; height: 18px; margin-top: 2px; }
.exception-options span, .exception-options small { display: block; }
.exception-options small { margin-top: 3px; color: var(--muted); }
.danger-outline { color: var(--danger); border-color: #eab3b3; background: #fff; }
.grow { flex: 1 1 280px; }

@media (max-width: 760px) {
  .teaching-log-head { display: none; }
  .teaching-log-row { grid-template-columns: 1fr 1fr 32px; gap: 8px 12px; }
  .lesson-date { grid-column: 1; }
  .lesson-class { grid-column: 2; }
  .lesson-content { grid-column: 1 / 3; }
  .lesson-state { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; }
  .lesson-detail { grid-column: 3; grid-row: 1 / 4; align-self: center; }
  .week-caption { flex-direction: column; }
}
