:root { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #172033; background: #f4f6f9; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
.topbar { background: #173b6d; color: white; padding: 18px max(24px, calc((100vw - 1180px)/2)); display:flex; align-items:center; justify-content:space-between; gap:20px; box-shadow:0 2px 8px #0002; }
h1,h2,h3,p { margin-top:0; }
h1 { margin-bottom:0; font-size:1.55rem; }
h2 { margin-bottom:6px; font-size:1.65rem; }
h3 { margin-bottom:4px; }
.eyebrow { font-size:.72rem; font-weight:800; letter-spacing:.11em; opacity:.76; }
.school-chip { background:#ffffff18; border:1px solid #ffffff30; padding:9px 13px; border-radius:999px; font-weight:650; }
.shell { max-width:1180px; margin:24px auto 60px; padding:0 20px; }
.hero-card, .controls-card, .panel { background:white; border:1px solid #dfe5ed; border-radius:14px; box-shadow:0 2px 8px #1b365d0d; }
.hero-card { padding:24px; display:flex; align-items:center; justify-content:space-between; gap:20px; border-top:5px solid #173b6d; }
.muted { color:#657185; }
.primary { border:0; border-radius:9px; background:#173b6d; color:white; padding:10px 15px; font-weight:700; cursor:pointer; }
.primary:hover { background:#102f59; }
.controls-card { margin-top:16px; padding:16px; display:flex; gap:14px; flex-wrap:wrap; }
.control-group { min-width:150px; }
.control-group.grow { flex:1; min-width:230px; }
label { display:block; font-size:.76rem; font-weight:800; color:#566276; margin-bottom:6px; text-transform:uppercase; letter-spacing:.04em; }
input, select { width:100%; min-height:42px; border:1px solid #cbd4df; border-radius:8px; background:white; padding:8px 10px; color:#172033; }
.stats { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:16px 0; }
.stat { background:white; border:1px solid #dfe5ed; border-radius:12px; padding:15px 17px; }
.stat-value { font-size:1.55rem; font-weight:800; }
.stat-label { font-size:.8rem; color:#687488; margin-top:2px; }
.panel { margin-top:16px; overflow:hidden; }
.panel-heading { padding:18px 20px; display:flex; align-items:center; justify-content:space-between; gap:14px; border-bottom:1px solid #e6eaf0; }
.panel-heading p { margin-bottom:0; }
.segmented { display:flex; background:#eef2f6; padding:3px; border-radius:9px; }
.segment { border:0; background:transparent; padding:7px 10px; border-radius:7px; cursor:pointer; color:#526074; font-size:.84rem; font-weight:650; }
.segment.active { background:white; color:#173b6d; box-shadow:0 1px 4px #0001; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; }
th { text-align:left; padding:11px 18px; background:#f7f9fb; color:#667286; font-size:.75rem; text-transform:uppercase; letter-spacing:.04em; }
td { padding:13px 18px; border-top:1px solid #edf0f4; }
tbody tr { cursor:pointer; }
tbody tr:hover { background:#f7faff; }
.teacher-name { font-weight:750; }
.location { font-weight:750; white-space:nowrap; }
.badge { display:inline-block; padding:4px 8px; border-radius:999px; font-size:.75rem; font-weight:750; background:#eef2f6; color:#536074; }
.badge.class { background:#e8f1ff; color:#174d8e; }
.badge.prep { background:#f2edf9; color:#69458e; }
.badge.flex { background:#edf7ef; color:#3e7148; }
.badge.ambiguous { background:#fff0e5; color:#9b4e15; }
.empty { padding:28px; text-align:center; color:#657185; }
.hidden { display:none !important; }
.lookup-panel { padding-bottom:18px; }
.lookup-row { display:flex; gap:10px; padding:18px 20px 8px; }
.lookup-row select { flex:1; }
.lookup-result { margin:8px 20px 0; padding:15px; background:#f7f9fb; border-radius:10px; }
.lookup-result strong { color:#172033; }
dialog { width:min(1120px, calc(100vw - 30px)); max-height:92vh; overflow:auto; border:0; border-radius:15px; padding:0; box-shadow:0 20px 70px #0005; }
dialog::backdrop { background:#0a193a80; }
.dialog-header { padding:20px 22px; border-bottom:1px solid #e4e8ee; display:flex; justify-content:space-between; }
.dialog-header h2 { margin-bottom:3px; }
.icon-btn { width:38px; height:38px; border-radius:50%; border:1px solid #d5dce5; background:white; cursor:pointer; font-size:1.5rem; line-height:1; }
.day-schedule { padding:10px 22px 22px; }
.day-row { display:grid; grid-template-columns:105px 85px 1fr; gap:12px; padding:12px 0; border-bottom:1px solid #edf0f4; align-items:start; }
.day-row:last-child { border-bottom:0; }
.day-time { color:#657185; font-size:.86rem; }
.day-period { font-weight:800; color:#173b6d; }
.day-assignment { font-weight:700; }
.day-location { color:#657185; margin-top:2px; font-size:.88rem; }
@media (max-width:760px) {
  .topbar { align-items:flex-start; }
  .school-chip { display:none; }
  .hero-card, .panel-heading { align-items:flex-start; flex-direction:column; }
  .hero-card .primary { width:100%; }
  .stats { grid-template-columns:repeat(2,1fr); }
  .segmented { width:100%; overflow:auto; }
  .segment { flex:1; }
  th:nth-child(4), td:nth-child(4) { display:none; }
  td, th { padding-left:12px; padding-right:12px; }
  .lookup-row { flex-direction:column; }
  .day-row { grid-template-columns:90px 60px 1fr; }
}

.department-control { min-width: 190px; }
.time-block-control { min-width: 260px; }
.badge.duty { background:#fff4df; color:#8a5b13; }
.badge.collaborative { background:#eef0ff; color:#4d55a5; }
.badge.unit_lunch { background:#f4f4f4; color:#5a6472; }

@media (max-width:760px) {
  .department-control, .time-block-control { min-width:100%; }
}

/* Checkpoint 6: authoritative WHS snapshot + 4-day cycle view */
.secondary { border:1px solid #cbd4df; border-radius:8px; background:white; color:#173b6d; padding:8px 12px; font-weight:700; cursor:pointer; }
.secondary:hover { background:#f2f6fb; }
.lookup-result { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.lookup-result-main { line-height:1.55; }
.lookup-actions { display:flex; gap:8px; flex-wrap:wrap; }
.dialog-toolbar { padding:12px 22px 0; display:flex; justify-content:flex-end; }
.day-period span { display:block; margin-top:2px; font-size:.72rem; font-weight:650; color:#657185; }
.badge.split { background:#fff4df; color:#8a5b13; }
.badge.office_hours { background:#e8f6f7; color:#20676c; }
.badge.lunch { background:#f4f4f4; color:#5a6472; }
.badge.untracked { background:#f4f4f4; color:#7b8491; }
.cycle-wrap { overflow:auto; border:1px solid #e5e9ef; border-radius:10px; }
.cycle-table { min-width:1050px; table-layout:fixed; }
.cycle-table th, .cycle-table td { border-right:1px solid #edf0f4; vertical-align:top; }
.cycle-table thead th { position:sticky; top:0; z-index:1; background:#f3f6fa; }
.cycle-table tbody th { width:90px; background:#f7f9fb; color:#173b6d; font-size:.8rem; text-transform:none; letter-spacing:0; }
.cycle-table td { width:240px; padding:12px; }
.cycle-period { font-size:.72rem; font-weight:800; color:#657185; text-transform:uppercase; margin-bottom:4px; }
.cycle-assignment { font-weight:750; line-height:1.25; }
.cycle-location { color:#657185; margin-top:5px; font-size:.84rem; }
.cycle-empty { color:#a1a9b5; text-align:center; padding-top:8px; }
@media (max-width:760px) {
  .lookup-result { align-items:flex-start; flex-direction:column; }
  .lookup-actions { width:100%; }
  .lookup-actions .secondary { flex:1; }
  .dialog-toolbar { justify-content:stretch; }
  .dialog-toolbar .segmented { width:100%; }
}

/* Checkpoint 8: authentication */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.signed-in-user {
  margin-top: 4px;
  text-align: right;
  font-size: 0.78rem;
  color: rgba(255,255,255,.78);
}
.sign-out-btn {
  display: none;
  white-space: nowrap;
}
.auth-gate {
  min-height: calc(100vh - 92px);
  display: grid;
  place-items: center;
  padding: 28px;
}
.auth-card {
  width: min(480px, 100%);
  background: white;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(22, 54, 93, .18);
  padding: 34px;
  text-align: center;
}
.auth-card h2 { margin: 8px 0 12px; }
.auth-card p { color: var(--muted, #667085); line-height: 1.5; }
.auth-button { margin-top: 12px; }
.auth-message { margin-top: 14px; min-height: 1.2em; }
.auth-error { color: #b42318 !important; }
body.auth-required #appShell { display: none; }
body.auth-required .sign-out-btn { display: none; }
body.authorized #authGate { display: none; }
body.authorized #appShell { display: block; }
body.authorized .sign-out-btn { display: inline-flex; }

@media (max-width: 640px) {
  .topbar-actions { gap: 6px; }
  .signed-in-user { display: none; }
  .auth-card { padding: 26px 20px; }
}

.connection-status {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

.connection-status.online {
  opacity: 0.75;
}

.connection-status.offline {
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
}
