:root {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #0f172a;
    background: #f4f6fb;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e6eaf2;
    --border-soft: #eef1f7;
    --ink: #0f172a;
    --ink-soft: #475569;
    --muted: #94a3b8;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-soft-2: #dbeafe;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --purple: #9333ea;
    --purple-soft: #f3e8ff;
    --pink: #db2777;
    --pink-soft: #fce7f3;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px rgba(15, 23, 42, .06);
    --shadow-pop: 0 18px 44px rgba(15, 23, 42, .16);
    --gold: var(--primary);
    --accent: var(--primary);
    --event: var(--primary);
    --event-2: var(--primary-strong);
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }

/* Hidden by default - Blazor's runtime only reveals this on a genuine unhandled exception.
   Without an explicit "display: none" here it renders as a normal block element and flashes
   on every page load before the WASM runtime finishes booting. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    padding: .85rem 3rem .85rem 1.25rem;
    background: var(--danger-soft);
    color: #7f1d1d;
    border-top: 1px solid color-mix(in srgb, var(--danger), transparent 55%);
    font-size: .88rem;
}
#blazor-error-ui .reload { color: var(--danger); font-weight: 700; text-decoration: underline; margin-left: .4rem; }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; top: .75rem; cursor: pointer; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.navigation-toggle {
    position: fixed;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Shell: full-height sidebar on the left, topbar + content column on the right. */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    background: var(--bg);
}

.sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    color: var(--ink);
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: width .2s ease, padding .2s ease, opacity .18s ease, transform .2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 14px;
}
.brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 6px 14px rgba(37, 99, 235, .28);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink); white-space: nowrap; }

.menu-toggle {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-soft);
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    box-shadow: none;
}
.menu-toggle:hover { background: var(--surface-muted); }
.menu-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.nav-menu {
    display: grid;
    align-content: start;
    gap: 2px;
    width: 100%;
    padding: 6px 12px;
    overflow-y: auto;
}
.nav-menu a,
.nav-module-link {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    pointer-events: auto;
    border-radius: 10px;
    transition: background .14s ease, color .14s ease;
}
.nav-menu a:hover { color: var(--ink); background: var(--surface-muted); }
.nav-menu a > * { pointer-events: none; }
.nav-menu a { touch-action: manipulation; user-select: none; }
.nav-menu a.active {
    color: var(--primary-strong);
    background: var(--primary-soft);
}
.nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.nav-icon svg {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px;
    max-height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-label { display: block; width: 100%; font-size: .89rem; line-height: 1.2; text-align: left; }
.nav-separator { height: 1px; margin: 10px 12px; background: var(--border); }

.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}
.sidebar-user:hover { background: var(--surface-muted); }
.sidebar-user-name { font-size: .88rem; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text { min-width: 0; flex: 1; text-align: left; }
.sidebar-user-caret { flex: 0 0 auto; color: var(--muted); }
.sidebar-user-caret svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.main-column { grid-column: 2; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

.topbar {
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 74px;
    padding: 0 24px;
    background: var(--bg);
    border-bottom: 1px solid transparent;
}
.topbar-spacer { flex: 1; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.header-icon {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: none;
}
.header-icon:hover { background: var(--surface-muted); }
.header-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .66rem;
    font-weight: 800;
    border: 2px solid var(--bg);
}

.profile-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    border: 0;
    color: #fff;
    font-weight: 700;
    font-size: .88rem;
    box-shadow: 0 4px 10px rgba(37, 99, 235, .28);
}
.avatar-menu { position: relative; }
.avatar-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.avatar-menu > summary::-webkit-details-marker { display: none; }
.avatar-menu-caret { color: var(--muted); }
.avatar-menu-caret svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.avatar-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 50;
    width: 200px;
    padding: 8px;
    display: grid;
    gap: 2px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
}
.avatar-menu-panel a, .avatar-menu-panel button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: .55rem .7rem;
    border-radius: 8px;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .86rem;
    text-align: left;
    background: transparent;
    border: 0;
    box-shadow: none;
    cursor: pointer;
}
.avatar-menu-panel a:hover, .avatar-menu-panel button:hover { background: var(--surface-muted); color: var(--ink); }

.content { grid-column: 2; min-width: 0; min-height: 0; flex: 1; }
.page { max-width: 1580px; margin: 0 auto; padding: 4px 24px 40px; }
h1, h2, h3 { color: var(--ink); font-weight: 800; letter-spacing: -.01em; }
h1 { margin: .1rem 0 .75rem; font-size: clamp(1.5rem, 2.6vw, 2rem); }
h2 { font-size: 1.05rem; }
.page-kicker { display: block; margin-bottom: 3px; color: var(--primary); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); }

button, .button-link {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: .68rem .95rem;
    cursor: pointer;
    font-weight: 700;
    font-size: .88rem;
    color: #fff;
    background: linear-gradient(180deg, var(--primary), var(--primary-strong));
    box-shadow: 0 6px 16px rgba(37, 99, 235, .22);
}
button:hover, .button-link:hover { filter: brightness(1.04); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--border); box-shadow: none; }
button.ghost:hover { background: var(--surface-muted); }
button:disabled { opacity: .6; cursor: not-allowed; filter: none; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .68rem .78rem;
    color: var(--ink);
    background: var(--surface);
}
textarea { min-height: 64px; resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; }

/* General pages */
.hero, .card, .form-card, .list-row, .table-wrap, .loading-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
}
.hero { border-radius: var(--radius-lg); padding: 2.25rem; }
.hero h1 { max-width: 800px; font-size: clamp(1.8rem, 4vw, 2.75rem); }
.eyebrow { color: var(--primary); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .78rem; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.card, .form-card, .list-row { border-radius: var(--radius-md); padding: 1.1rem; }
.card { transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.form-card { max-width: 650px; display: grid; gap: 1rem; }
.form-card label { display: grid; gap: .4rem; color: var(--ink-soft); font-weight: 700; font-size: .88rem; }
.form-actions { display: flex; align-items: center; gap: .8rem; }
.page-actions { display: flex; align-items: center; gap: .8rem; margin: 1rem 0; }
.form-row { display: flex; gap: .7rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.form-row input:not([type="color"]) { flex: 1 1 190px; }
.form-row input[type="color"] { width: 52px; height: 43px; padding: 4px; }
.stack { display: grid; gap: .55rem; }
.list-row { display: flex; align-items: center; gap: .75rem; }
.list-row-editable { flex-wrap: wrap; }
.list-row-editable input:not([type="color"]) { flex: 1 1 160px; width: auto; }
.list-row-editable input[type="color"] { width: 44px; height: 38px; padding: 3px; flex: 0 0 44px; }
.list-row-editable .row-actions { display: flex; gap: .5rem; margin-left: auto; }
.inline-toggle { display: flex; align-items: center; gap: .4rem; color: var(--ink-soft); font-weight: 600; font-size: .85rem; flex: 0 0 auto; }
.inline-toggle input { width: auto; }
button.danger { background: var(--danger); border-color: transparent; box-shadow: none; }
button.danger:hover { filter: brightness(1.08); }
.dot, .subject-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--subject-color, var(--primary)); flex: 0 0 10px; }
.success { color: var(--success); margin-left: .8rem; font-weight: 700; }
.error { color: var(--danger); }
.compact { font-size: .78rem; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 18px; }

.table-wrap { overflow: auto; border-radius: var(--radius-md); margin-bottom: 1rem; }
.timetable { border-collapse: collapse; width: 100%; min-width: 1000px; color: var(--ink); }
.timetable th, .timetable td { border: 1px solid var(--border); padding: .55rem; vertical-align: top; }
.timetable th { background: var(--surface-muted); font-weight: 700; }
.timetable td { min-width: 180px; background: var(--surface); }
.timetable td select, .timetable td input { margin-bottom: .35rem; }

.section-heading { margin: 1.6rem 0 .3rem; font-size: 1.1rem; }

.timing-cell { min-width: 110px !important; }
.timing-cell input[type="time"] { margin-bottom: .35rem; }
.timing-cell input[type="time"]:last-child { margin-bottom: 0; }

.timetable tr.break-row td.break-row-cell { background: var(--surface-muted); padding: .35rem .55rem; text-align: center; }
.break-chip { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
.break-chip input[type="number"] { width: 60px; margin-bottom: 0; text-align: center; }
.break-chip .icon-link-button { color: var(--danger); font-size: 1rem; line-height: 1; padding: 0 .3rem; }
.add-break-button {
    background: none; border: 1px dashed var(--border); border-radius: var(--radius-sm, 6px);
    color: var(--muted); font-size: .74rem; font-weight: 600; padding: .3rem .8rem; cursor: pointer;
}
.add-break-button:hover { color: var(--accent, var(--ink)); border-color: var(--accent, var(--border)); }

.week-break-row, .schedule-break-row { min-height: 34px; border-bottom: 1px solid var(--border-soft); background: var(--surface-muted); }
.schedule-break-label {
    grid-column: 1 / -1;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}
.break-period-label { background: var(--surface-muted); }
.break-period-label strong { color: var(--muted); font-size: .82rem; }
.break-period-label span { color: var(--muted); }
.break-cell { background: var(--surface-muted); }
.break-cell .lesson-input.break-note { min-height: 44px; }
.break-cell .attribute-picker { margin-top: .3rem; }
.break-attribute-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }

.dashboard-break-row td.dashboard-break-cell {
    text-align: center; background: var(--surface-muted); color: var(--muted);
    font-size: .74rem; font-weight: 700; letter-spacing: .02em; padding: .4rem;
}

/* Header sync button */
.header-actions > button.ghost { color: var(--ink-soft); border-color: var(--border); padding: .5rem .72rem; font-size: .78rem; }

/* Calendar heading */
.calendar-page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 14px; }
.calendar-title-group h1 { margin: 0; color: var(--ink); font-size: clamp(1.5rem, 2.6vw, 2rem); }
.calendar-title-nav { display: flex; align-items: center; gap: 9px; }
.round-nav-button {
    width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
    border-radius: 50%; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--border); box-shadow: none;
    font-size: 1.3rem; line-height: 1;
}
.round-nav-button:hover { background: var(--surface-muted); }
.calendar-toolbar { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.segmented button { min-width: 64px; padding: .5rem .8rem; background: transparent; border: 0; border-radius: 999px; color: var(--ink-soft); box-shadow: none; font-weight: 600; }
.segmented button.active { color: #fff; background: linear-gradient(180deg, var(--primary), var(--primary-strong)); }
.date-picker { position: relative; width: 44px; height: 40px; display: grid; place-items: center; color: var(--ink-soft); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); overflow: hidden; }
.date-picker svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; pointer-events: none; }
.date-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.calendar-selector { min-width: 160px; color: var(--ink-soft); background: var(--surface); border-color: var(--border); border-radius: 999px; box-shadow: none; }
.calendar-selector span { margin-left: 12px; }

/* Planner surfaces (week / month grids) */
.planner-surface {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    color: var(--ink);
}
.week-surface { overflow-x: auto; overflow-y: visible; }
.week-board { --day-columns: 5; min-width: 860px; }
.week-board.day-mode { min-width: 420px; }
.week-grid { display: grid; grid-template-columns: 64px repeat(var(--day-columns), minmax(0, 1fr)); }
.week-grid > * { border-right: 1px solid var(--border-soft); }
.week-grid > *:last-child { border-right: 0; }
.week-grid-header { min-height: 43px; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.period-heading { display: grid; place-items: center; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.day-heading { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 8px 10px; font-weight: 700; font-size: .95rem; }
.day-heading span { color: var(--muted); font-size: .76rem; font-weight: 500; }
.day-heading.today { background: var(--primary-soft); color: var(--primary-strong); }

.week-grid-summary { min-height: 92px; border-bottom: 1px solid var(--border); }
.summary-spacer { background: var(--surface-muted); }
.day-summary { position: relative; min-width: 0; padding: 6px 7px 25px; background: var(--surface); }
.day-banners { display: flex; flex-wrap: wrap; gap: 4px; min-height: 25px; }
.holiday-banner, .holiday {
    display: inline-flex; align-items: center; width: fit-content; max-width: 100%;
    padding: .28rem .48rem; border-radius: 6px; background: var(--success-soft); color: #15803d; font-size: .72rem; font-weight: 700;
}
.attribute-chip, .month-attribute {
    display: inline-flex; align-items: center; width: fit-content; max-width: 100%;
    padding: .25rem .45rem; border: 1px solid color-mix(in srgb, var(--chip), transparent 45%);
    border-left: 5px solid var(--chip); border-radius: 6px;
    background: color-mix(in srgb, var(--chip), white 88%); color: color-mix(in srgb, var(--chip), black 55%); font-size: .7rem; font-weight: 700;
}
.day-note { min-height: 38px; height: 38px; margin-top: 4px; padding: 7px 8px; border: 1px solid transparent; border-radius: 6px; background: var(--surface-muted); font-size: .76rem; resize: none; box-shadow: none; }
.day-note:focus { background: var(--surface); border-color: var(--border); }
.attribute-picker { position: absolute; right: 6px; bottom: 5px; z-index: 15; font-size: .69rem; }
.attribute-picker summary { list-style: none; cursor: pointer; color: var(--muted); }
.attribute-picker summary::-webkit-details-marker { display: none; }
.attribute-picker-panel { position: absolute; top: calc(100% + 5px); right: 0; width: 190px; display: grid; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-pop); }
.attribute-option { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-left: 4px solid var(--chip); border-radius: 5px; background: color-mix(in srgb, var(--chip), white 90%); color: var(--ink); }
.attribute-option input { width: auto; margin: 0; }
.appointment-chip {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0; width: fit-content; max-width: 100%;
    padding: .22rem .48rem; border-radius: 6px; cursor: pointer;
    background: color-mix(in srgb, var(--chip), white 85%); color: color-mix(in srgb, var(--chip), black 60%);
    font-size: .68rem; line-height: 1.25;
}
.appointment-chip strong { font-size: .66rem; font-weight: 800; }
.appointment-chip span { font-weight: 600; }
.appointment-chip:hover { filter: brightness(0.97); }

.week-grid-row { min-height: 89px; border-bottom: 1px solid var(--border-soft); }
.week-grid-row:last-child { border-bottom: 0; }
.period-label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--ink-soft); background: var(--surface-muted); }
.period-label strong { font-size: 1rem; font-weight: 800; }
.period-label span { color: var(--muted); font-size: .68rem; }
.week-cell { position: relative; min-width: 0; padding: 6px; background: var(--surface); }
.week-cell::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dotted var(--border); pointer-events: none; }
.base-lesson {
    position: relative; z-index: 2; height: 20px; display: flex; align-items: center; gap: 5px; min-width: 0;
    padding: 1px 3px; color: var(--muted); font-size: .68rem; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.base-lesson strong { color: var(--ink-soft); }
.base-lesson .subject-dot { background: var(--subject-color); }
.lesson-input {
    position: relative; z-index: 3; height: 54px; min-height: 54px; padding: 7px 8px;
    border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); resize: none;
    font-size: .78rem; line-height: 1.25; transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.lesson-input::placeholder { opacity: 0; }
.week-cell:hover .lesson-input::placeholder, .lesson-input:focus::placeholder { opacity: .7; }
.lesson-input:hover, .lesson-input:focus { border-color: var(--border); background: var(--surface-muted); }
.lesson-input.has-entry {
    color: var(--primary-strong);
    background: var(--primary-soft);
    border-color: var(--primary-soft-2);
    box-shadow: none;
}

/* Month */
.month-surface { padding: 0; overflow: auto; }
.month-weekdays, .month-grid { min-width: 760px; display: grid; grid-template-columns: repeat(7, 1fr); }
.month-weekdays { background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.month-weekdays div { padding: 10px; text-align: center; border-right: 1px solid var(--border-soft); font-weight: 700; color: var(--ink-soft); }
.month-weekdays div:last-child { border-right: 0; }
.month-grid { gap: 0; }
.month-day {
    min-height: 125px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
    padding: 8px; color: var(--ink); background: var(--surface); border: 0; border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); border-radius: 0; box-shadow: none; text-align: left;
}
.month-day:nth-child(7n) { border-right: 0; }
.month-day.outside { opacity: .45; }
.month-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.month-day > strong { font-size: .98rem; }
.note-preview { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .72rem; }
.month-attribute { font-size: .64rem; }
.month-lessons { display: flex; flex-wrap: wrap; gap: 3px; width: 100%; }
.month-lesson {
    display: inline-flex; align-items: center; gap: 4px; width: fit-content; max-width: 100%;
    padding: .15rem .4rem; border-radius: 5px; background: var(--surface-muted); color: var(--ink-soft);
    font-size: .64rem; font-weight: 700;
}
.month-lesson::before { content: ""; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: var(--chip); }
.month-appointments { display: flex; flex-wrap: wrap; gap: 3px; width: 100%; }
.month-appointment {
    display: inline-flex; align-items: center; width: fit-content; max-width: 100%; cursor: pointer;
    padding: .15rem .4rem; border-left: 3px solid var(--chip); border-radius: 4px;
    background: color-mix(in srgb, var(--chip), white 85%); color: color-mix(in srgb, var(--chip), black 60%);
    font-size: .64rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.month-appointment:hover { filter: brightness(0.97); }

.appointment-form-overlay {
    position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
    background: rgba(15, 23, 42, .45); padding: 20px;
}
.appointment-form-card {
    width: min(440px, 100%); max-height: 90vh; overflow-y: auto; padding: 1.5rem;
    border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-pop);
    display: grid; gap: 1rem;
}
.appointment-form-card h2 { margin: 0; }
.appointment-form-card label { display: grid; gap: .4rem; color: var(--ink-soft); font-weight: 700; font-size: .88rem; }
.appointment-form-card .inline-toggle { display: flex; flex-direction: row; align-items: center; gap: .5rem; }

/* Read-only schedule */
.schedule-surface { overflow-x: auto; }
.schedule-board { min-width: 820px; }
.schedule-grid { display: grid; grid-template-columns: 66px repeat(5, minmax(0, 1fr)); }
.schedule-grid > * { border-right: 1px solid var(--border-soft); }
.schedule-grid > *:last-child { border-right: 0; }
.schedule-header { border-bottom: 1px solid var(--border); }
.schedule-header > div { padding: 11px 8px; text-align: center; font-weight: 700; color: var(--ink-soft); background: var(--surface-muted); }
.schedule-row { min-height: 67px; border-bottom: 1px solid var(--border-soft); }
.schedule-row:last-child { border-bottom: 0; }
.schedule-cell { display: flex; align-items: center; gap: 6px; padding: 9px; }
.schedule-cell small { color: var(--muted); margin-left: auto; }
.schedule-free { color: var(--muted); font-size: .76rem; }

.loading-card { width: fit-content; padding: .9rem 1.1rem; border-radius: var(--radius-sm); color: var(--ink-soft); }

/* Shimmer loading skeletons */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
    background-image: linear-gradient(90deg, var(--surface-muted) 25%, var(--border-soft) 37%, var(--surface-muted) 63%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line { height: 14px; border-radius: 7px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.full { width: 100%; }
.skeleton-block { width: 100%; border-radius: var(--radius-md); }
.skeleton-lines { padding: 1.4rem; }
.skeleton-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.skeleton-panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.2rem; }
.skeleton-dashboard, .skeleton-grid-page { padding: 4px 0 1rem; }
.auth-loading-shell { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.auth-loading-card { width: min(420px, 100%); padding: 1.6rem; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); }

@media (max-width: 900px) {
    .skeleton-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .skeleton-panel-grid { grid-template-columns: 1fr; }
}

.page-error-card {
    max-width: 720px;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--danger-soft);
    border-radius: var(--radius-md);
    color: #7f1d1d;
    background: var(--danger-soft);
    box-shadow: var(--shadow-card);
}
.page-error-card h1 { color: #991b1b; font-size: clamp(1.4rem, 3vw, 1.8rem); }
.page-error-card p { margin-bottom: 0; line-height: 1.55; }

/* Holiday overview */
.holiday-list { display: grid; gap: 10px; max-width: 850px; }
.holiday-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-card); }
.holiday-card h2 { margin: 0 0 3px; }
.holiday-card p { margin: 0; }
.holiday-date { width: 58px; height: 58px; flex: 0 0 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--primary-strong); background: var(--primary-soft); }
.holiday-date strong { font-size: 1.25rem; line-height: 1; }
.holiday-date span { margin-top: 3px; font-size: .66rem; text-transform: uppercase; font-weight: 700; }
.mobile-sync { display: none; }

/* ---------------- Dashboard ---------------- */
.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dashboard-header h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 2.8vw, 1.9rem); }
.dashboard-header p { margin: 0; color: var(--muted); font-size: .92rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.stat-icon { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: 12px; }
.stat-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon.stat-blue { background: var(--primary-soft); color: var(--primary-strong); }
.stat-icon.stat-green { background: var(--success-soft); color: #15803d; }
.stat-icon.stat-purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.stat-pink { background: var(--pink-soft); color: var(--pink); }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; line-height: 1.3; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.dashboard-main { display: grid; gap: 18px; min-width: 0; }
.dashboard-side { display: grid; gap: 18px; min-width: 0; }

.panel { border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); padding: 18px 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-header h2 { margin: 0; }
.panel-actions { display: flex; align-items: center; gap: 6px; }
.chip-button { padding: .4rem .75rem; border-radius: 999px; font-size: .78rem; box-shadow: none; background: var(--surface-muted); color: var(--ink-soft); }
.chip-button:hover { background: var(--border-soft); }
.chip-button.active { background: var(--primary); color: #fff; }
.chip-button.active:hover { background: var(--primary-strong); }

.setup-hints { display: grid; gap: .6rem; margin-bottom: 1.4rem; }
.setup-hint { display: flex; align-items: center; gap: .65rem; padding: .85rem 1.1rem; border-radius: var(--radius-md); background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning), transparent 55%); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; transition: transform .15s ease; }
.setup-hint:hover { transform: translateY(-1px); }
.setup-hint-icon { flex: 0 0 auto; color: var(--warning); font-size: 1.05rem; }
.setup-hint-arrow { margin-left: auto; color: var(--warning); font-weight: 800; }
.icon-link-button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-muted); color: var(--ink-soft); box-shadow: none; padding: 0; font-size: 1.1rem; }
.icon-link-button:hover { background: var(--border-soft); }
.link-more { display: inline-block; margin-top: 10px; color: var(--primary-strong); font-weight: 700; font-size: .85rem; }

.dashboard-table { width: 100%; border-collapse: collapse; }
.dashboard-table th { padding: 8px 10px; text-align: left; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.dashboard-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); font-size: .88rem; vertical-align: middle; }
.dashboard-table tr:last-child td { border-bottom: 0; }
.dashboard-table .muted-cell { color: var(--muted); }

.subject-badge { display: inline-flex; align-items: center; padding: .28rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: color-mix(in srgb, var(--chip), white 85%); color: color-mix(in srgb, var(--chip), black 45%); }

.empty-row { padding: 18px 4px; color: var(--muted); font-size: .88rem; }

.mini-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mini-week-day { border-radius: var(--radius-sm); border: 1px solid var(--border-soft); padding: 8px; min-height: 150px; background: var(--surface-muted); }
.mini-week-day.today { background: var(--primary-soft); border-color: var(--primary-soft-2); }
.mini-week-day-head { font-size: .76rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; text-align: center; }
.mini-week-day.today .mini-week-day-head { color: var(--primary-strong); }
.mini-week-entry { margin-bottom: 4px; padding: 4px 6px; border-radius: 7px; font-size: .68rem; font-weight: 700; line-height: 1.3; background: color-mix(in srgb, var(--chip), white 85%); color: color-mix(in srgb, var(--chip), black 45%); }
.mini-week-entry span { display: block; font-weight: 500; opacity: .85; }
.mini-week-appointment { margin-bottom: 4px; padding: 4px 6px; border-left: 3px solid var(--chip); border-radius: 6px; font-size: .68rem; font-weight: 700; line-height: 1.3; background: color-mix(in srgb, var(--chip), white 90%); color: color-mix(in srgb, var(--chip), black 45%); }
.mini-week-appointment span { display: block; font-weight: 600; opacity: .85; }
.mini-week-empty { color: var(--muted); font-size: .7rem; text-align: center; padding-top: 12px; }

.note-card { display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-muted); border-left: 4px solid var(--chip, var(--primary)); margin-bottom: 10px; }
.note-card:last-child { margin-bottom: 0; }
.note-card-icon { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--chip, var(--primary)), white 82%); color: color-mix(in srgb, var(--chip, var(--primary)), black 40%); }
.note-card-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.note-card-body { min-width: 0; flex: 1; }
.note-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.note-card-title { font-weight: 700; font-size: .88rem; }
.note-card-time { color: var(--muted); font-size: .74rem; flex: 0 0 auto; }
.note-card-text { margin: 3px 0 6px; color: var(--ink-soft); font-size: .8rem; line-height: 1.4; }
.note-card-tag { display: inline-flex; padding: .18rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 700; background: color-mix(in srgb, var(--chip, var(--primary)), white 85%); color: color-mix(in srgb, var(--chip, var(--primary)), black 45%); }

.appointment-list { display: grid; gap: 12px; }
.appointment-row { display: flex; align-items: center; gap: 10px; }
.appointment-icon { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary-strong); }
.appointment-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.appointment-text { min-width: 0; flex: 1; }
.appointment-title { font-weight: 700; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appointment-time { color: var(--muted); font-size: .76rem; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill { display: inline-flex; align-items: center; padding: .38rem .75rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: color-mix(in srgb, var(--chip), white 85%); color: color-mix(in srgb, var(--chip), black 45%); }

.birthday-list { display: grid; gap: 12px; }
.birthday-row { display: flex; align-items: center; gap: 10px; }
.birthday-icon { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); font-size: 1rem; }
.birthday-text { min-width: 0; flex: 1; }
.birthday-name { font-weight: 700; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.birthday-meta { color: var(--muted); font-size: .76rem; }

/* Class management */
.class-name-link {
    background: none; border: none; box-shadow: none; padding: 0; margin: 0;
    color: var(--ink); font-weight: 700; font-size: .95rem; text-align: left; cursor: pointer; flex: 1;
}
.class-name-link:hover { color: var(--primary-strong, var(--ink)); text-decoration: underline; }
.scan-upload-label { position: relative; overflow: hidden; display: inline-flex; align-items: center; cursor: pointer; }
.scan-upload-label input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-preview { margin: 1rem 0; }

.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px 26px; color: var(--muted); font-size: .8rem; flex-wrap: wrap; }
.app-footer a { color: var(--ink-soft); font-weight: 600; }
.app-footer a:hover { color: var(--primary-strong); }
.app-footer-links { display: flex; gap: 18px; }

/* Sidebar collapse on desktop. CSS-only so it does not depend on Blazor event dispatch. */
@media (min-width: 901px) {
    .app-shell { transition: grid-template-columns .2s ease; }
    .navigation-toggle:checked + .app-shell { grid-template-columns: 0 minmax(0, 1fr); }
    .navigation-toggle:checked + .app-shell .sidebar {
        width: 0;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transform: translateX(-100%);
        border-right: 0;
    }
}

/* Dark theme */
.theme-dark {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-muted: #16203380;
    --border: #223049;
    --border-soft: #1b2740;
    --ink: #e8edf7;
    --ink-soft: #b6c2d9;
    --muted: #7c8aa8;
    --primary-soft: #17264a;
    --primary-soft-2: #1d2f5c;
    --success-soft: #123322;
    --warning-soft: #3a2a0c;
    --danger-soft: #3a1620;
    --purple-soft: #241536;
    --pink-soft: #33132a;
    color-scheme: dark;
}
.theme-dark body { background: var(--bg); }

@media (prefers-color-scheme: dark) {
    .theme-system {
        --bg: #0b1220;
        --surface: #121a2b;
        --surface-muted: #16203380;
        --border: #223049;
        --border-soft: #1b2740;
        --ink: #e8edf7;
        --ink-soft: #b6c2d9;
        --muted: #7c8aa8;
        --primary-soft: #17264a;
        --primary-soft-2: #1d2f5c;
        --success-soft: #123322;
        --warning-soft: #3a2a0c;
        --danger-soft: #3a1620;
        --purple-soft: #241536;
        --pink-soft: #33132a;
        color-scheme: dark;
    }
}

@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .calendar-page-heading { align-items: flex-start; flex-direction: column; }
    .calendar-toolbar { justify-content: flex-start; }
    .header-actions > button.ghost { display: none; }
}

/* Mobile bottom nav (hidden on desktop) */
.mobile-bottom-nav { display: none; }

@media (max-width: 900px) {
    .app-shell {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 64px minmax(0, 1fr);
        padding-bottom: 67px;
    }
    .sidebar {
        position: fixed;
        grid-row: auto;
        top: 64px;
        bottom: 67px;
        left: 0;
        width: min(82vw, 300px);
        overflow-y: auto;
        transform: translateX(-102%);
        box-shadow: 16px 0 35px rgba(15, 23, 42, .18);
    }
    .navigation-toggle:checked + .app-shell .sidebar { transform: translateX(0); }
    .main-column { grid-column: 1; }
    .topbar { min-height: 64px; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
    .brand-name { font-size: 1.05rem; }
    .profile-avatar { width: 36px; height: 36px; font-size: .78rem; }

    .nav-menu a { min-height: 50px; }
    .content { grid-column: 1; grid-row: 2; }
    .page { padding: 12px 12px 24px; }
    .mobile-bottom-nav {
        position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; height: 67px;
        display: grid; grid-template-columns: repeat(4, 1fr); align-items: stretch;
        padding-bottom: env(safe-area-inset-bottom);
        color: var(--ink-soft); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -7px 22px rgba(15, 23, 42, .08);
    }
    .mobile-bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; }
    .mobile-bottom-nav a.active { color: var(--primary-strong); background: var(--primary-soft); }
    .mobile-bottom-nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

    .calendar-page-heading { gap: 10px; margin-bottom: 10px; }
    .calendar-title-group h1 { font-size: 1.5rem; }
    .calendar-toolbar { width: 100%; gap: 6px; }
    .segmented { flex: 1 1 auto; }
    .segmented button { flex: 1; min-width: 0; padding: .48rem .55rem; }
    .calendar-selector { min-width: 0; padding-inline: .75rem; }
    .week-board.week-mode { min-width: 800px; }
    .week-board.day-mode { min-width: 100%; }
    .week-board.day-mode .week-grid { grid-template-columns: 56px minmax(0, 1fr); }
    .week-grid { grid-template-columns: 56px repeat(var(--day-columns), minmax(142px, 1fr)); }
    .week-grid-row { min-height: 82px; }
    .lesson-input { height: 49px; min-height: 49px; }
    .month-weekdays, .month-grid { min-width: 610px; }
    .month-day { min-height: 100px; }
    .card-grid { grid-template-columns: 1fr; }
    .page-heading { flex-direction: column; }
    .form-card { max-width: none; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-header { flex-direction: column; }

    .mobile-sync { display: block; padding: 12px 18px 20px; border-top: 1px solid var(--border); }
    .mobile-sync button.ghost { width: 100%; }
}

@media (max-width: 640px) {
    .stat-grid { grid-template-columns: 1fr; }
    .mini-week { grid-template-columns: repeat(7, minmax(90px, 1fr)); overflow-x: auto; }
}

@media (max-width: 520px) {
    .page { padding-inline: 9px; }
    .calendar-selector { display: none; }
    .date-picker { width: 40px; height: 38px; }
    .calendar-title-nav { gap: 5px; }
    .round-nav-button { width: 30px; height: 30px; }
    .calendar-title-group h1 { font-size: 1.3rem; }
    .page-kicker { font-size: .63rem; }
    .planner-surface { border-radius: 10px; }
    .hero { padding: 1.35rem; }
    .hero h1 { font-size: 1.9rem; }
    .month-weekdays, .month-grid { min-width: 560px; }
    .month-day { min-height: 92px; padding: 5px; }
    .note-preview { display: none; }
}
