:root {
  color-scheme: light;
  font: 106.25%/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg: #f2f2f7; --surface: #fff; --text: #1c1c1e; --muted: #606066;
  --border: #d1d1d6; --accent: #0066cc; --tint: #e9f2ff; --hover: #e5e5ea;
  --warning: #8d3b10; --warning-bg: #fff4e9; --missing: #b42318;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1e; --surface: #2c2c2e; --text: #f5f5f7; --muted: #b4b4ba;
  --border: #48484a; --accent: #80baff; --tint: #203c60; --hover: #38383a;
  --warning: #ffc399; --warning-bg: #422e25; --missing: #ff9b94;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.75rem; letter-spacing: -.04em; line-height: 1.2; margin-bottom: .5rem; }
h2 { font-size: 1rem; font-weight: 650; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: .7rem; font-weight: 650; letter-spacing: .08em; margin-bottom: .8rem; }
.readonly-badge { display: inline-block; margin-left: .65rem; padding: .18rem .5rem; background: var(--tint); color: var(--accent); border-radius: 1rem; letter-spacing: 0; font-size: .7rem; font-weight: 600; }
.overview { max-width: 1050px; margin: 0 auto; padding: max(2.3rem, env(safe-area-inset-top)) max(1.2rem, env(safe-area-inset-right)) max(1.2rem, env(safe-area-inset-bottom)) max(1.2rem, env(safe-area-inset-left)); }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.overview-brand { display: flex; align-items: flex-start; gap: .75rem; min-width: 0; }
.portal-home { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: .6rem; }
.portal-home img { display: block; width: 34px; height: 34px; object-fit: contain; }
.intro { margin-bottom: 0; font-size: .9rem; }
.header-actions, .toolbar, .toolbar-actions, .filter-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.header-actions { flex-shrink: 0; }
.button, .text-button, .arrow-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem .85rem; border-radius: .65rem; color: var(--accent); text-decoration: none; line-height: 1.3; }
.button { border: 1px solid var(--border); background: var(--surface); }
.text-button, .arrow-button { border: 0; background: transparent; }
.primary { background: #0071e3; color: #fff; border-color: transparent; font-weight: 600; }
.controls { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; padding: .8rem 1rem; }
.week-nav { display: flex; align-items: center; justify-content: center; gap: .6rem; }
.week-nav h2 { font-size: 1.15rem; text-align: center; margin: 0; min-width: 0; flex: 1; font-variant-numeric: tabular-nums; }
.arrow-button { width: 44px; flex-shrink: 0; padding: .5rem; }
.arrow-button svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.toolbar { justify-content: space-between; font-size: .82rem; margin: .35rem -.5rem .4rem; }
.unit-filter { border-top: 1px solid var(--border); padding-top: .3rem; }
summary { cursor: pointer; padding: .65rem .15rem; font-size: .9rem; overflow-wrap: anywhere; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.filter-actions { font-size: .82rem; margin: -.2rem -.5rem .4rem; }
.unit-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem .65rem; padding-bottom: .4rem; }
.unit-option { display: flex; align-items: center; gap: .5rem; min-height: 44px; cursor: pointer; font-size: .85rem; overflow-wrap: anywhere; }
.unit-option input { margin: 0; width: 1.05rem; height: 1.05rem; flex-shrink: 0; accent-color: var(--accent); }
.overview-status { margin: 1rem .2rem .8rem; font-size: .82rem; }
.loading-panel { display: flex; align-items: flex-start; gap: 1rem; margin: 1rem 0; padding: 1.1rem; border: 2px solid var(--accent); border-radius: .85rem; background: var(--tint); color: var(--accent); }
.loading-spinner { display: block; flex: 0 0 auto; width: 2rem; height: 2rem; margin-top: .1rem; border: 4px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: loading-turn .85s linear infinite; }
.loading-content { flex: 1; min-width: 0; }
.loading-panel h2 { font-size: 1.05rem; line-height: 1.4; margin: 0 0 .4rem; }
.loading-panel p { font-size: .85rem; margin: 0; overflow-wrap: anywhere; }
.loading-panel progress { display: block; width: 100%; height: .8rem; margin: .8rem 0 .5rem; accent-color: var(--accent); }
.loading-panel .loading-count { font-size: .8rem; font-variant-numeric: tabular-nums; }
.loading-panel-compact { align-items: center; }
.loading-panel-compact p { font-weight: 650; }
@keyframes loading-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation: none; } }
.action-status { font-size: .82rem; margin: 0 .2rem .8rem; }
.action-status:empty { display: none; }
.load-problems { padding: 1rem 1.1rem; border: 1px solid var(--warning); border-radius: .85rem; color: var(--warning); background: var(--warning-bg); margin-bottom: 1rem; font-size: .85rem; overflow-wrap: anywhere; }
.load-problems h2 { margin-bottom: .35rem; }
.load-problems p { margin-bottom: .5rem; }
.load-problems ul { padding-left: 1.1rem; margin: .4rem 0 .7rem; }
.load-problems li + li { margin-top: .35rem; }
.load-problems .button { color: var(--warning); border-color: currentColor; background: transparent; }
.week-states, .missing-info { border: 1px solid var(--border); border-radius: .85rem; padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--surface); }
.week-states h2, .missing-info h2 { margin-bottom: .55rem; }
.missing-info ul { display: flex; flex-wrap: wrap; gap: .35rem 1rem; list-style: none; padding: 0; margin: 0; }
.missing-info li { color: var(--missing); font-size: .95rem; overflow-wrap: anywhere; min-width: 0; }
.missing-info strong { font-weight: 700; }
.missing-info p { font-size: .82rem; margin: .55rem 0 0; }
.week-states ul { list-style: none; padding: 0; margin: 0; }
.week-states li { font-size: .85rem; margin-top: .35rem; overflow-wrap: anywhere; }
.agenda { display: grid; gap: .7rem; }
.day-card { display: grid; grid-template-columns: 8.8rem minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: .85rem; min-width: 0; overflow: hidden; }
.day-heading { padding: 1rem; }
.day-heading h2 { margin: 0 0 .15rem; }
.day-date { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-card.weekend .day-heading { background: var(--bg); }
.day-content { padding: .3rem 1rem; min-width: 0; }
.event-list { list-style: none; padding: 0; margin: 0; }
.event-row { display: grid; grid-template-columns: minmax(5.5rem, 8.5rem) minmax(0, 1fr); align-items: baseline; gap: .9rem; padding: .75rem 0; overflow-wrap: anywhere; }
.event-row + .event-row { border-top: 1px solid var(--border); }
.unit-name { font-size: .8rem; font-weight: 650; color: var(--accent); }
.event-topic { margin: 0; font-size: .95rem; white-space: pre-wrap; }
.event-note { display: block; font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.empty-day { color: var(--muted); margin: .7rem 0; font-size: .85rem; }
.horizon-notes { font-size: .85rem; line-height: 1.5; margin: .6rem .2rem; }
.empty-selection { padding: 1.5rem; text-align: center; color: var(--muted); }
.source-details { margin-top: 1rem; color: var(--muted); }
.source-details summary { font-size: .8rem; }
.source-details ul { list-style: none; padding: 0 .2rem; margin: 0; }
.source-details li { margin: .4rem 0; font-size: .75rem; overflow-wrap: anywhere; }
.page-footer { color: var(--muted); font-size: .75rem; line-height: 1.5; padding: 1.2rem .2rem; }
.login-gate { max-width: 430px; padding: 12vh 1.2rem 2rem; margin: 0 auto; }
.login-gate .muted { font-size: .88rem; }
.login-gate form { display: grid; gap: .5rem; }
.login-gate label { font-size: .8rem; color: var(--muted); margin-top: .5rem; }
.login-gate input { width: 100%; min-height: 46px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: .6rem; padding: .6rem .75rem; }
.login-gate .primary { margin-top: .8rem; }
#password-message { margin-top: 1rem; min-height: 1.3rem; }
.back-link { display: block; margin-top: 1rem; font-size: .8rem; }
dialog { width: min(430px, calc(100% - 1.4rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; border: 1px solid var(--border); border-radius: 1rem; padding: 1.2rem; color: var(--text); background: var(--surface); }
dialog::backdrop { background: #0007; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.dialog-heading h2 { font-size: 1.2rem; margin: 0; }
#change-password-form, #password-fields { display: grid; gap: .5rem; }
#change-password-form label { font-size: .8rem; color: var(--muted); }
#change-password-form input:not([type="checkbox"]), #change-password-form select { width: 100%; min-height: 46px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: .6rem; padding: .6rem .75rem; }
#password-account-name { margin-bottom: .4rem; overflow-wrap: anywhere; font-size: .88rem; }
.password-visibility { display: flex; align-items: center; gap: .5rem; min-height: 40px; }
.password-visibility input { width: 1rem; height: 1rem; accent-color: var(--accent); }
#change-password-note, #change-password-message { font-size: .8rem; }
#change-password-note { margin-bottom: .3rem; }
#change-password-message { margin-top: .8rem; }
#change-password-message:empty { display: none; }
#logout-all { margin-top: .8rem; }
.noscript { max-width: 400px; margin: 1rem auto; padding: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (hover: hover) { .button:hover, .text-button:hover, .arrow-button:hover { background: var(--hover); } .primary:hover { background: #005bb5; } }
@media (max-width: 720px) {
  .overview { padding-top: max(1.2rem, env(safe-area-inset-top)); }
  .page-header { align-items: flex-start; flex-direction: column; }
  .header-actions { font-size: .82rem; }
  .unit-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day-card { grid-template-columns: 7rem minmax(0, 1fr); }
  .event-row { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
}
@media (max-width: 440px) {
  .overview { padding-left: max(.7rem, env(safe-area-inset-left)); padding-right: max(.7rem, env(safe-area-inset-right)); }
  h1 { font-size: 1.55rem; }
  .controls { padding: .65rem; }
  .loading-panel { gap: .7rem; padding: .85rem; }
  .loading-spinner { width: 1.6rem; height: 1.6rem; border-width: 3px; }
  .toolbar { display: block; }
  .toolbar-actions { justify-content: space-between; gap: 0; }
  .toolbar .text-button { padding-inline: .5rem; }
  .week-nav { gap: .15rem; }
  .week-nav h2 { font-size: 1rem; }
  .unit-options { grid-template-columns: minmax(0, 1fr); }
  .day-card { grid-template-columns: minmax(0, 1fr); }
  .day-heading { display: flex; align-items: baseline; gap: .5rem; padding: .7rem .8rem 0; }
  .day-card.weekend .day-heading { background: transparent; }
  .day-content { padding: .1rem .8rem .3rem; }
}
@media (prefers-contrast: more) { :root { --muted: #444; --border: #777; } :root[data-theme="dark"] { --muted: #ddd; --border: #999; } }
@media (forced-colors: active) {
  :root, :root[data-theme="dark"] { --bg: Canvas; --surface: Canvas; --text: CanvasText; --muted: CanvasText; --border: ButtonText; --accent: LinkText; --tint: Canvas; --hover: ButtonFace; --warning: CanvasText; --warning-bg: Canvas; --missing: CanvasText; }
}
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #ccc; --accent: #111; --tint: #fff; --warning: #000; --warning-bg: #fff; --missing: #b42318; font-size: 10pt; }
  .overview { max-width: none; padding: 0; }
  .header-actions, .toolbar, .arrow-button, .unit-options, .filter-actions, .source-details, .action-status, .load-problems button, .loading-panel, dialog { display: none !important; }
  .page-header { margin-bottom: 1rem; }
  .controls { padding: .5rem; }
  .unit-filter { border: 0; padding: 0; }
  .unit-filter summary { text-align: center; list-style: none; padding: .2rem; }
  .day-card { break-inside: avoid; grid-template-columns: 7rem minmax(0, 1fr); border-radius: 0; }
  .day-heading { display: block; padding: .7rem; }
  .event-row { grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr); padding: .45rem 0; }
  .week-states, .missing-info, .load-problems { break-inside: avoid; }
  .readonly-badge { border: 1px solid #777; }
}
