/* SIS: gold and ink on paper. Spectral for headings, Public Sans for the interface. */
:root {
  --ink: #1F1D1A; --ink-2: #3A3631; --muted: #6B655B; --rule: #E6E1D6; --rule-2: #D6CFBF;
  --paper: #FBFAF7; --card: #FFFFFF; --gold: #B48A2C; --gold-deep: #7A5B12; --gold-wash: #F6EDD6; --gold-line: #E2CD94;
  --ok: #1F7A4D; --ok-wash: #E3F2EA; --bad: #B3261E; --bad-wash: #FBE9E7; --warn: #8A5A00; --warn-wash: #FFF2D6;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: 2rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; margin-top: 1.4em; }
p { margin: 0 0 .8em; max-width: 72ch; }
a { color: var(--gold-deep); text-underline-offset: 2px; }
code { background: var(--gold-wash); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .nowrap { white-space: nowrap; } .break { word-break: break-word; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.loading { padding: 48px 24px; color: var(--muted); }

/* ---------- controls ---------- */
.btn { font: 600 .92rem var(--sans); border-radius: var(--r); padding: 8px 14px; cursor: pointer; border: 1px solid var(--rule-2);
  background: var(--card); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:disabled, .btn-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: var(--ink-2); border-color: var(--gold); box-shadow: inset 0 -3px 0 var(--gold); }
.btn-danger { color: var(--bad); border-color: #E5B4AF; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--gold-wash); border-color: transparent; }
.btn-ghost-dark { background: transparent; color: #E9E3D6; border-color: #4A453E; }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .84rem; }
.btn-on { background: var(--gold-wash); border-color: var(--gold); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--gold-deep); text-decoration: underline; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--rule-2); border-radius: var(--r); padding: 8px 10px; min-height: 38px; max-width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-wash); }
input[readonly] { background: var(--paper); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-weight: 600; font-size: .88rem; }
.field-hint { font-size: .8rem; color: var(--muted); } .field-error { font-size: .8rem; color: var(--bad); }
.field-wide { grid-column: 1 / -1; }
.form { display: flex; flex-direction: column; gap: 14px; } .form.narrow { max-width: 420px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.inline select { min-width: 200px; }
.search { width: 100%; max-width: 420px; margin: 0 0 14px; }

.notice { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); margin: 0 0 14px; border-left: 4px solid; }
.notice > div { min-width: 0; } .notice .secret { margin: 8px 0 4px; }
.notice .pill-rule { margin-right: 6px; vertical-align: 1px; }
.notice-info { background: var(--gold-wash); border-color: var(--gold); }
.notice-success { background: var(--ok-wash); border-color: var(--ok); }
.notice-error { background: var(--bad-wash); border-color: var(--bad); }
.notice-x { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); }
.pill { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--rule); color: var(--ink-2); white-space: nowrap; }
.pill-ok { background: var(--ok-wash); color: var(--ok); } .pill-bad { background: var(--bad-wash); color: var(--bad); }
.pill-warn { background: var(--warn-wash); color: var(--warn); } .pill-gold { background: var(--gold-wash); color: var(--gold-deep); }
.pill-rule { background: var(--ink); color: #fff; font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--rule-2); border-radius: 4px; padding: 0 6px; margin: 2px 4px 2px 0; font-size: .84rem; }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 0 2px; }
.empty { border: 1px dashed var(--rule-2); border-radius: var(--r); padding: 28px 24px; color: var(--muted); }
.empty-title { font-weight: 600; color: var(--ink); margin: 0 0 4px; }
.secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secret code { font-size: 1.05rem; padding: 4px 10px; background: #fff; border: 1px solid var(--gold-line); letter-spacing: .04em; }
.secret-label { font-weight: 600; font-size: .86rem; }

.panel { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; margin: 0 0 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.table { width: 100%; border-collapse: collapse; background: var(--card); margin: 0 0 18px; }
.table th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--ink); padding: 8px 10px; }
.table td { border-bottom: 1px solid var(--rule); padding: 9px 10px; vertical-align: top; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table .clickable { cursor: pointer; } .table .clickable:hover td { background: #FDF8EA; }
.table td.bad, .over { color: var(--bad); font-weight: 600; } .full { color: var(--warn); font-weight: 600; }
.plain { list-style: none; margin: 8px 0; padding: 0; } .plain li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0 auto 0 0; }

/* ---------- wordmark and sign-in ---------- */
.wordmark { font: 700 2.6rem/1 var(--serif); color: #fff; letter-spacing: .02em; text-decoration: none; display: inline-block; padding-bottom: 6px; border-bottom: 4px solid var(--gold); }
.wordmark.small { font-size: 1.5rem; padding-bottom: 3px; border-bottom-width: 3px; }
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 40%) 1fr; }
.login-side { background: var(--ink); color: #E9E3D6; padding: 56px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-staff .login-side { background: linear-gradient(180deg, var(--ink) 0, var(--ink) 70%, #2A251C 100%); }
.login-tag { font: 500 1.6rem/1.25 var(--serif); color: #fff; margin: 28px 0 0; max-width: 16ch; }
.login-small { font-size: .84rem; color: #B9B1A2; margin: 0; }
.login-form { align-self: center; justify-self: center; width: min(380px, 100% - 32px); display: flex; flex-direction: column; gap: 16px; padding: 40px 0; }
.login-form h1 { font-size: 1.8rem; margin: 0 0 4px; }
.login-switch { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }

/* ---------- student ---------- */
.topbar { background: var(--ink); color: #E9E3D6; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin-right: auto; scrollbar-width: none; }
.tab { background: none; border: 0; color: #CFC7B7; font: 600 .92rem var(--sans); padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: #fff; } .tab-on { color: #fff; border-bottom-color: var(--gold); }
.who { display: flex; align-items: center; gap: 10px; font-size: .86rem; }
.who-name { color: #fff; font-weight: 600; } .who-id { color: #B9B1A2; font-variant-numeric: tabular-nums; }
.topbar .btn-ghost { color: #E9E3D6; } .topbar .btn-ghost:hover { background: #2E2B26; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 48px; }
.narrow-page { max-width: 560px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 24px 32px; }

.register { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.term-head h1 { margin-bottom: 4px; }
.window { margin: 0 0 16px; padding-left: 12px; border-left: 4px solid; }
.window.open { border-color: var(--ok); } .window.closed { border-color: var(--gold); color: var(--ink-2); }
.filters { display: flex; gap: 10px; margin-bottom: 6px; } .filters input { flex: 1; }
.courses { list-style: none; padding: 0; margin: 16px 0 0; }
.course { border-top: 2px solid var(--ink); padding: 14px 0 6px; }
.course-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.course-head h3 { margin: 0; font-size: 1.15rem; }
.code { font: 700 .95rem var(--sans); color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.sections { list-style: none; padding: 0; margin: 8px 0 0; }
.section { display: grid; grid-template-columns: 90px minmax(0, 1fr) 210px 120px 150px; gap: 6px 16px; align-items: center; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 8px; background: var(--card); }
.section-on { border-color: var(--ok); background: #F7FBF8; }
.section-id { font-weight: 600; }
.times-text { display: flex; flex-wrap: wrap; gap: 0 10px; } .times-text span { white-space: nowrap; } .section-act { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.section-note { grid-column: 2 / -1; margin: 0; font-size: .85rem; }
.clash-note { color: var(--bad); }

/* week strip: one row per teaching day, 08:00–18:00 */
.strip { display: grid; grid-template-rows: repeat(6, 7px); gap: 2px; font-size: 9px; }
.strip-day { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 4px; }
.strip-label { color: var(--muted); line-height: 7px; font-size: 8px; }
.strip-track { position: relative; height: 7px; background: #F1EEE6; border-radius: 2px; }
.strip-track i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.strip-slot { background: var(--gold); z-index: 1; }
.strip-busy { background: #BDB6A8; }
.strip-clash .strip-slot { background: var(--bad); }
.legend { font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 10px; }
.lg { display: inline-block; width: 14px; height: 7px; border-radius: 2px; } .lg-slot { background: var(--gold); } .lg-busy { background: #BDB6A8; } .lg-clash { background: var(--bad); }

.register-side .side-sticky { position: sticky; top: 76px; background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; }
.register-side h2 { font-size: 1.1rem; }

/* timetable grid */
.tt { display: grid; grid-template-columns: 48px repeat(6, minmax(0, 1fr)); grid-template-rows: auto calc(var(--rows) * var(--h)); border: 1px solid var(--rule); border-radius: var(--r); background: var(--card); overflow: hidden; margin-bottom: 14px; }
.tt-compact { grid-template-columns: 34px repeat(6, minmax(0, 1fr)); }
.tt-dayhead { font-size: .8rem; font-weight: 600; padding: 6px 4px; text-align: center; border-bottom: 2px solid var(--ink); }
.tt-corner { border-bottom: 2px solid var(--ink); }
.tt-hours { display: grid; grid-template-rows: repeat(var(--rows), var(--h)); font-size: .7rem; color: var(--muted); text-align: right; padding-right: 4px; font-variant-numeric: tabular-nums; }
.tt-hours span { padding-top: 2px; }
.tt-col { position: relative; border-left: 1px solid var(--rule); display: grid; grid-template-rows: repeat(var(--rows), var(--h)); }
.tt-cell { border-top: 1px solid #F1EEE6; }
.tt-block { position: absolute; left: 2px; right: 2px; background: var(--gold-wash); border-left: 3px solid var(--gold); border-radius: 3px; padding: 2px 5px; font-size: .74rem; line-height: 1.25; overflow: hidden; display: flex; flex-direction: column; }
.tt-block b { font-size: .78rem; } .tt-compact .tt-block { padding: 1px 2px; left: 1px; right: 1px; border-left-width: 2px; } .tt-compact .tt-block b { font-size: .6rem; letter-spacing: -.02em; }
.tt-new { animation: settle .6s ease-out; border-left-color: var(--ok); }
@keyframes settle { from { background: #FFF; transform: scale(.94); } to { background: var(--gold-wash); transform: none; } }
.tt-scroll { overflow-x: auto; } .tt-scroll .tt { min-width: 560px; }

.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 18px; }
.grade { display: inline-block; min-width: 2.2em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.grade-f { color: var(--bad); } .grade-x { color: var(--muted); }

/* ---------- staff ---------- */
.app-staff { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #E9E3D6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px; }
.side-top { display: flex; align-items: baseline; gap: 10px; padding: 0 8px 20px; }
.side-sub { color: #B9B1A2; font-size: .86rem; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid #4A453E; color: #E9E3D6; border-radius: var(--r); padding: 4px 10px; font: inherit; font-size: .84rem; }
.side nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav { color: #CFC7B7; text-decoration: none; padding: 8px 10px; border-radius: var(--r); font-weight: 500; font-size: .93rem; border-left: 3px solid transparent; }
.nav:hover { background: #2E2B26; color: #fff; }
.nav-on { color: #fff; background: #2E2B26; border-left-color: var(--gold); }
.side-who { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid #3A3631; font-size: .86rem; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.staff-main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 8px 0 22px; border-top: 2px solid var(--ink); }
.stats div { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--rule); }
.stats dt { font-size: .84rem; color: var(--muted); } .stats dd { margin: 2px 0 0; font: 600 1.8rem var(--serif); font-variant-numeric: tabular-nums; }
.stats dd small { font: 400 .9rem var(--sans); color: var(--muted); }
.perm-list { columns: 2; margin: 0; padding-left: 18px; }

.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.picklist { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.pick { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 10px 8px; display: grid; gap: 2px; cursor: pointer; font: inherit; border-left: 3px solid transparent; }
.pick:hover { background: #FDF8EA; } .pick-on { background: var(--gold-wash); border-left-color: var(--gold); }
.roster-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.roster-head h2 { margin: 0 0 2px; }

.drawer-wrap { position: fixed; inset: 0; background: rgba(31, 29, 26, .42); z-index: 50; display: flex; justify-content: flex-end; }
.drawer-wrap.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(720px, 100%); height: 100%; background: var(--paper); display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(31, 29, 26, .18); animation: slidein .18s ease-out; }
.drawer:focus { outline: none; }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--rule); background: var(--card); }
.drawer-head h2 { margin: 0; }
.drawer-x { background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; }
.drawer-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 22px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; background: var(--card); }
.dialog { background: var(--card); border-radius: 10px; padding: 22px; width: min(440px, 100%); box-shadow: 0 16px 48px rgba(31, 29, 26, .25); }
.times { border: 1px solid var(--rule); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.times legend { font-weight: 600; font-size: .88rem; padding: 0 4px; }
.time-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr auto; gap: 6px; }

.perms { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 14px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.perm-group { border: 0; padding: 0; margin: 0; }
.perm-group legend { font: 600 .95rem var(--serif); padding: 0; margin-bottom: 6px; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--card); margin-bottom: 6px; cursor: pointer; }
.perm input { margin-top: 3px; min-height: 0; accent-color: var(--gold-deep); width: 16px; height: 16px; }
.perm span { display: flex; flex-direction: column; } .perm-on { border-color: var(--gold); background: #FFFBF0; }
.import-result { margin-top: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 1000px) {
  .register { grid-template-columns: 1fr; }
  .register-side { order: -1; } .register-side .side-sticky { position: static; }
  .section { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .section .strip { grid-column: 2 / 3; max-width: 260px; }
  .section-seats { grid-column: 3; grid-row: 1; text-align: right; }
  .section-act { grid-column: 3; grid-row: 2; }
}
@media (max-width: 820px) {
  .app-staff { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; padding: 10px 16px; z-index: 20; }
  .side-top { padding: 0; } .nav-toggle { display: block; }
  .side nav, .side-who { display: none; }
  .side-open nav, .side-open .side-who { display: flex; } .side-open nav { padding-top: 10px; max-height: 70vh; }
  .staff-main { padding: 20px 16px 48px; }
  .split { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 28px 24px; } .login-tag { margin-top: 16px; font-size: 1.3rem; }
  .table { display: block; overflow-x: auto; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; } h1 { font-size: 1.6rem; }
  .topbar-inner { flex-wrap: wrap; gap: 6px 12px; padding: 8px 16px; }
  .tabs { order: 3; width: 100%; } .who-id { display: none; }
  .page { padding: 20px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .section { grid-template-columns: 1fr auto; padding: 10px; }
  .section-id { grid-column: 1; } .section-info, .section .strip { grid-column: 1 / -1; max-width: none; }
  .section-seats { grid-column: 2; grid-row: 1; } .section-act { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; }
  .section-note { grid-column: 1 / -1; }
  .time-row { grid-template-columns: 1fr 1fr; }
  .perm-list { columns: 1; }
  .filters { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
