/*
  Schedly — design theme
  Clean, light, academic look. Palette and component language follow the
  CPP201 teaching site (blue #1b4f9c + green #5cae3c on a soft grey canvas).
*/
:root {
  --blue-900: #0e2f5c; --blue-700: #1b4f9c; --blue-600: #2461c0; --blue-100: #e8f0fc; --blue-50: #f3f7fe;
  --green-700: #3f8f2f; --green-600: #5cae3c; --green-100: #eaf6e4;
  --bg: #f7f9fc; --surface: #fff; --surface-alt: #f1f4f9;
  --text: #16202e; --muted: #55606f; --border: #dbe2ec;
  --success: #2e8b47; --success-bg: #e9f7ee; --error: #c0392b; --error-bg: #fdecea;
  --warning: #9a6200; --warning-bg: #fdf3e2; --info: #1b4f9c; --info-bg: #e8f0fc;
  --font-ui: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(16,32,64,.08); --shadow-md: 0 6px 20px rgba(16,32,64,.10);
  --header-h: 68px; --max-w: 1240px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--blue-900); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
code { background: var(--surface-alt); padding: 1px 6px; border-radius: 4px; }
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img { height: 40px; width: 40px; }
.brand-title { font-weight: 800; font-size: 1.15rem; color: var(--blue-900); display: block; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: var(--muted); display: block; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--text); font-weight: 600; font-size: .94rem; padding: 8px 12px; border-radius: var(--r-sm); }
.nav a:hover { background: var(--surface-alt); text-decoration: none; }
.nav a.active { background: var(--blue-100); color: var(--blue-700); }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.user-menu .who { text-align: right; line-height: 1.2; }
.user-menu .who strong { display: block; }
.site-header .nav-toggle { display: none; }

/* Layout */
main { padding: 28px 0 56px; min-height: calc(100vh - var(--header-h) - 64px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green-700); margin-bottom: 6px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; padding: 18px 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); padding: 20px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.7rem; font-weight: 800; color: var(--blue-900); line-height: 1.2; }
.stat .value.good { color: var(--success); } .stat .value.bad { color: var(--error); } .stat .value.warn { color: var(--warning); }

/* Flow (from CPP201 teaching flow) */
.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.flow-step { flex: 1 1 130px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; color: var(--text); box-shadow: var(--shadow-sm); }
a.flow-step:hover { text-decoration: none; border-color: var(--blue-600); }
.flow-step .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700); font-weight: 800; font-size: .85rem; margin-bottom: 6px; }
.flow-step.done .n { background: var(--green-600); color: #fff; }
.flow-step strong { display: block; color: var(--blue-900); }
.flow-step span.d { font-size: .82rem; color: var(--muted); }
.flow-arrow { align-self: center; color: var(--muted); font-weight: 700; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font: 600 .94rem var(--font-ui); padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer; transition: background .15s, box-shadow .15s; text-decoration: none; line-height: 1.3; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue-700); color: #fff; } .btn-primary:hover { background: var(--blue-600); }
.btn-accent { background: var(--green-600); color: #fff; } .btn-accent:hover { background: var(--green-700); }
.btn-ghost { background: var(--surface); color: var(--blue-700); border-color: var(--border); } .btn-ghost:hover { background: var(--surface-alt); }
.btn-danger { background: var(--surface); color: var(--error); border-color: #efc2bc; } .btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-link { background: none; border: 0; color: var(--blue-600); padding: 0; font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
form.inline { display: inline; }

/* Badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--blue-100); color: var(--blue-700); }
.badge-muted { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); }

/* Alerts */
.flashes { margin-bottom: 18px; }
.alert { border-radius: var(--r-sm); padding: 11px 14px; margin-bottom: 8px; border: 1px solid; font-size: .94rem; }
.alert-success { background: var(--success-bg); border-color: #bfe3cb; color: #1d5e30; }
.alert-error { background: var(--error-bg); border-color: #f2c4be; color: #8e2a1f; }
.alert-warning { background: var(--warning-bg); border-color: #f1d9ad; color: #6f4700; }
.alert-info { background: var(--info-bg); border-color: #c9daf6; color: var(--blue-900); }
.callout { border-left: 4px solid var(--warning); background: var(--warning-bg); padding: 14px 16px; border-radius: var(--r-sm); }
.callout.ok { border-color: var(--success); background: var(--success-bg); }
.callout.bad { border-color: var(--error); background: var(--error-bg); }
.callout h3 { margin-bottom: 6px; }
.callout ul { margin: 6px 0 0; padding-left: 20px; }
.callout li + li { margin-top: 4px; }

/* Forms */
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: .95rem; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(36,97,192,.25); outline-offset: 1px; border-color: var(--blue-600); }
input[type=number] { max-width: 110px; }
input[type=file] { font-size: .9rem; max-width: 100%; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; }
.check input { margin-top: 4px; }
.check strong { display: block; font-weight: 600; }
.check span.d { display: block; color: var(--muted); font-size: .84rem; }
fieldset { border: 0; padding: 0; margin: 0; }
.option-list { display: grid; gap: 10px; }
.weights { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.weights .d { font-size: .84rem; color: var(--muted); }
.slot-picker { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px; background: var(--surface-alt); }
.slot-picker label { font-weight: 400; font-size: .84rem; display: flex; gap: 6px; align-items: center; margin: 0; }
.upload-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.upload-row:last-child { border-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-alt); color: var(--blue-900); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--blue-50); }
tr.flag td { background: #fff7f6; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Details / disclosure */
details.panel { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
details.panel + details.panel { margin-top: 10px; }
details.panel > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; align-items: center; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "▸"; color: var(--muted); transition: transform .15s; }
details.panel[open] > summary::after { transform: rotate(90deg); }
details.panel .body { padding: 0 16px 14px; }
details.panel ul { margin: 0; padding-left: 18px; font-size: .88rem; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--blue-700); border-color: var(--blue-700); }
.tabs a:hover { text-decoration: none; color: var(--blue-700); }

/* Timetable grid */
.tt-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tt-toolbar select { width: auto; min-width: 200px; }
.tt-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.tt { border-collapse: separate; border-spacing: 0; min-width: 760px; table-layout: fixed; }
.tt th, .tt td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; }
.tt th:first-child, .tt td:first-child { width: 96px; position: sticky; left: 0; background: var(--surface-alt); z-index: 1; }
.tt td.time { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); white-space: nowrap; }
.tt td { height: 52px; }
.tt td.off { background: repeating-linear-gradient(45deg, #fafbfd, #fafbfd 6px, #f2f4f8 6px, #f2f4f8 12px); }
.chip { display: block; border-radius: 6px; padding: 4px 7px; margin-bottom: 4px; font-size: .78rem; line-height: 1.3; background: var(--blue-100); border-left: 3px solid var(--blue-700); color: var(--blue-900); cursor: default; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0; font-family: inherit; }
button.chip { cursor: pointer; }
button.chip:hover { background: #d9e6fa; }
.chip strong { display: block; font-size: .8rem; }
.chip .sub { color: var(--muted); font-size: .72rem; }
.chip.c1 { background: var(--green-100); border-color: var(--green-600); }
.chip.c2 { background: #fff1e0; border-color: #e08a1e; }
.chip.c3 { background: #f1e9fb; border-color: #8a5cc6; }
.chip.c4 { background: #e5f6f6; border-color: #2a9d9d; }
.chip.c5 { background: #fde8ef; border-color: #c4507a; }
.chip.flagged { box-shadow: inset 0 0 0 2px var(--error); }
.chip.locked strong::after { content: " 🔒"; font-size: .7rem; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }

/* Dialog */
dialog { border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 0; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(14,47,92,.35); }
dialog .dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-head h3 { margin: 0; }
dialog .dlg-body { padding: 18px 20px; }
dialog .dlg-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--surface-alt); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Auth */
.auth-wrap { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; margin-bottom: 18px; }
.credential { font-family: var(--font-mono); background: var(--surface); border: 1px dashed var(--blue-600); padding: 10px 12px; border-radius: var(--r-sm); margin-top: 8px; user-select: all; }

.loading-overlay { position: fixed; inset: 0; background: rgba(247,249,252,.88); display: grid; place-items: center; z-index: 100; }
.loading-overlay .box { text-align: center; }
.spinner { width: 46px; height: 46px; border: 4px solid var(--blue-100); border-top-color: var(--blue-700); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-menu .who { display: none; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .site-header { height: auto; min-height: var(--header-h); flex-wrap: wrap; padding: 10px 16px; }
  .site-header .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .nav.open { display: flex; }
  .upload-row { grid-template-columns: 1fr; }
  .flow-arrow { display: none; }
  .container { padding: 0 16px; }
}
@media print {
  .site-header, .site-footer, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card, .tt-wrap { box-shadow: none; }
}
.grid-3 > [data-span] { grid-column: span 2; } @media (max-width: 760px) { .grid-3 > [data-span] { grid-column: auto; } } hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
