:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --line: #cfd6df;
    --line-dark: #aeb8c4;
    --text: #1f2933;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #15803d;
    --header: #f8fafc;
    --shadow: 0 12px 30px rgba(31, 41, 51, 0.12);
    --control-panel-height: 230px;
    font-family: "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-header {
    height: 58px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 18px;
    background: #263241;
    color: #fff;
    border-bottom: 1px solid #17202b;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 210px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: #3b82f6;
    font-weight: 700;
}

.brand-block small {
    display: block;
    color: #cbd5e1;
    margin-top: 2px;
    font-size: 12px;
}

.top-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
}

.top-tabs a,
.ghost-link {
    padding: 9px 12px;
    border-radius: 5px;
    color: #e5e7eb;
    white-space: nowrap;
}

.header-button {
    border: 0;
    background: transparent;
}

.top-tabs a.active,
.top-tabs a:hover,
.ghost-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.workspace-shell {
    height: 100vh;
    display: grid;
    grid-template-rows: 44px 68px minmax(0, 1fr) 8px var(--control-panel-height);
    overflow: hidden;
}

.module-tabs,
.command-bar,
.control-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.module-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 0;
    background: #ffffff;
}

.app-header {
    display: none;
}

.module-user {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
    padding: 0 8px 6px 0;
    color: #334155;
    white-space: nowrap;
}

.module-user-name {
    font-weight: 700;
}

.module-user-role {
    color: var(--muted);
    font-size: 12px;
}

.module-tabs-spacer {
    flex: 1;
    min-width: 12px;
}

.module-utility-link {
    height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    margin-bottom: 4px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: #334155;
    white-space: nowrap;
}

.module-utility-link:hover {
    border-color: #60a5fa;
    background: #eff6ff;
    color: #1d4ed8;
}

.module-tabs button {
    height: 36px;
    border: 0;
    background: transparent;
    padding: 0 14px;
    border-radius: 7px 7px 0 0;
    color: #334155;
}

.module-tabs button:hover {
    background: #e8edf3;
}

.module-tabs button.active {
    background: #eef4ff;
    color: #1d4ed8;
    font-weight: 700;
    box-shadow: inset 0 -2px 0 #2563eb;
}

.command-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    background: #f8fafc;
}

.command-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100%;
}

.command-panel[hidden] {
    display: none;
}

.command-field {
    min-width: 150px;
    display: grid;
    align-content: center;
    gap: 4px;
    font-size: 12px;
}

.tool-button,
.primary-button,
.danger-button,
.command-bar select,
.command-bar input,
.inline-form input,
.inline-form select,
.stack-form input,
.form-grid input,
.form-grid select {
    height: 34px;
    border: 1px solid var(--line-dark);
    border-radius: 5px;
    background: #fff;
    padding: 0 10px;
    color: var(--text);
}

.tool-button,
.primary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tool-button.primary,
.primary-button {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.command-button {
    min-height: 38px;
    border: 1px solid #c4d0df;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
}

.command-button:hover {
    background: #eef4ff;
    border-color: #8fb4ff;
}

.command-button.primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
}

.command-button.danger-lite {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.command-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    border-radius: 4px;
    background: #93c5fd;
}

.command-icon.undo,
.command-icon.redo { border-radius: 50%; background: #cbd5e1; }
.command-icon.auto { background: #f59e0b; }
.command-icon.verify { background: #22c55e; }
.command-icon.reset { background: #ef4444; }
.command-icon.school { background: #64748b; }
.command-icon.lesson,
.command-icon.subject { background: #60a5fa; }
.command-icon.teacher { background: #111827; }
.command-icon.class,
.command-icon.users { background: #fb7185; }
.command-icon.room { background: #a78bfa; }
.command-icon.clock { background: #14b8a6; }
.command-icon.export,
.command-icon.backup,
.command-icon.save { background: #3b82f6; }
.command-icon.chart { background: #84cc16; }
.command-icon.help,
.command-icon.map { background: #f97316; }
.command-icon.calendar { background: #0f766e; }
.command-icon.relation {
    background:
        radial-gradient(circle at 20% 20%, #4aa3ff 0 2px, transparent 3px),
        radial-gradient(circle at 72% 20%, #f47d7d 0 2px, transparent 3px),
        radial-gradient(circle at 48% 48%, #55c776 0 2px, transparent 3px),
        radial-gradient(circle at 22% 76%, #8b7cf6 0 2px, transparent 3px),
        radial-gradient(circle at 78% 76%, #f6c453 0 2px, transparent 3px),
        #eef2f7;
}

.tool-button.primary:hover,
.primary-button:hover {
    background: var(--primary-dark);
}

.danger-button {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.compact {
    height: 30px;
    padding: 0 10px;
}

.toggle-filter,
.check-line {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.view-checkboxes {
    display: grid;
    gap: 2px;
    align-content: center;
    font-size: 12px;
    line-height: 16px;
}

.toggle-filter input,
.check-line input {
    width: 16px;
    height: 16px;
}

.grid-stage {
    min-height: 0;
    overflow: auto;
    background: #e4e9ef;
    display: flex;
}

.schedule-grid {
    display: grid;
    min-width: 1000px;
    width: max-content;
    --row-label-width: 176px;
    --period-width: 49px;
    --row-height: 44px;
    grid-auto-rows: var(--row-height);
}

.view-rail {
    position: sticky;
    left: 0;
    z-index: 16;
    flex: 0 0 18px;
    background: #d9e2ec;
    border-right: 1px solid #b8c4d2;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

.view-rail button {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    height: 76px;
    width: 18px;
    border: 0;
    border-bottom: 1px solid #1f2937;
    background: #eef2f7;
    color: #111;
    padding: 3px 0;
    font-size: 12px;
}

.view-rail button.active {
    background: #ffffff;
    color: #1d4ed8;
    font-weight: 700;
}

.grid-corner,
.day-header,
.period-header,
.row-header,
.grid-cell {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.grid-corner,
.day-header,
.period-header {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--header);
}

.grid-corner {
    left: 0;
    z-index: 9;
    display: grid;
    place-items: center;
    min-width: var(--row-label-width);
    font-weight: 700;
    border-left: 1px solid var(--line);
    cursor: pointer;
}

.day-header {
    height: 30px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    border-top: 1px solid var(--line);
    cursor: pointer;
}

.period-header {
    top: 30px;
    height: 28px;
    display: grid;
    place-items: center;
    text-align: center;
    font-size: 12px;
    color: #475569;
}

.row-header {
    position: sticky;
    left: 0;
    z-index: 4;
    min-width: var(--row-label-width);
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 8px;
    font-weight: 700;
}

.row-name {
    min-width: 0;
    flex: 0 1 auto;
    max-width: calc(100% - 30px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unplaced-card-count {
    flex: 0 0 auto;
    color: #dc2626;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.row-header.highlight,
.grid-cell.highlight {
    background: #fff7ed;
}

.row-header.unplaced-filter-active {
    background: linear-gradient(90deg, #dbeafe, #eff6ff);
    box-shadow: inset 5px 0 0 #2563eb, 0 2px 8px rgba(37, 99, 235, 0.18);
}

.row-header.selected-resource-row,
.preview-row-header {
    background: #86efac;
    color: #14532d;
    box-shadow: inset 5px 0 0 #16a34a;
}

.preview-row-header {
    font-size: 12px;
}

.row-color,
.swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    flex: 0 0 auto;
}

.swatch {
    display: inline-block;
    margin-right: 7px;
    vertical-align: -2px;
}

.grid-cell {
    width: var(--period-width);
    min-height: var(--row-height);
    background: #fff;
    padding: 2px;
    position: relative;
}

.schedule-grid[data-day-dividers="enabled"][data-day-divider-thickness="small"] {
    --day-divider-width: 2px;
}

.schedule-grid[data-day-dividers="enabled"][data-day-divider-thickness="medium"] {
    --day-divider-width: 4px;
}

.schedule-grid[data-day-dividers="enabled"][data-day-divider-thickness="large"] {
    --day-divider-width: 6px;
}

.schedule-grid[data-day-dividers="enabled"] .day-divider {
    border-right: var(--day-divider-width, 4px) solid var(--day-divider-color, #2563eb);
}

.grid-cell.timeoff-blocked-cell {
    display: grid;
    place-items: center;
    padding: 0;
    background: #c7c7ca;
    color: #73737a;
}

.grid-cell.timeoff-blocked-cell::after {
    content: '×';
    font-size: 17px;
    font-weight: 500;
    line-height: 1;
}

.grid-cell.drop-target {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background: #eff6ff;
}

.grid-cell.preview-target {
    box-shadow: inset 0 0 0 2px #2563eb;
    background: #eff6ff;
}

.grid-cell.placement-preview-cell {
    padding: 2px;
}

.grid-cell.placement-preview-cell.timeoff-blocked-cell {
    padding: 0;
}

.period-header.placement-preview-period.is-available {
    background: #bbf7d0;
}

.period-header.placement-preview-period.is-conflict {
    background: #fecaca;
}

.period-header.placement-preview-period.is-unavailable {
    background: #e5e7eb;
}

.preview-grid-divider {
    min-height: 9px;
    background: #e4e9ef;
    border-bottom: 1px solid #b8c4d2;
}

.lesson-card {
    position: relative;
    width: 100%;
    min-height: 28px;
    display: grid;
    align-content: center;
    gap: 1px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #17202b;
    padding: 3px 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
    user-select: none;
}

.lesson-card.lesson-block-card {
    border-color: rgba(15, 23, 42, 0.42);
    box-shadow: inset 3px 0 0 rgba(15, 23, 42, 0.24), 0 1px 2px rgba(15, 23, 42, 0.18);
}

.lesson-card.lesson-block-card.block-middle,
.lesson-card.lesson-block-card.block-end {
    cursor: default;
    opacity: 0.94;
}

.lesson-block-badge {
    position: absolute;
    top: 2px;
    right: 3px;
    border-radius: 999px;
    color: #fff;
    background: rgba(15, 23, 42, 0.72);
    padding: 1px 4px;
    font-size: 8px;
    font-weight: 800;
    line-height: 1.3;
    pointer-events: none;
}

.lesson-card + .lesson-card {
    margin-top: 4px;
}

.lesson-card strong,
.lesson-card span,
.lesson-card em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lesson-card strong {
    font-size: 11px;
    line-height: 1;
}

.lesson-teacher-code {
    font-style: normal;
}

.lesson-card span {
    font-size: 9px;
    line-height: 1;
}

.lesson-card.locked {
    border-style: dashed;
    cursor: not-allowed;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.45);
}


.schedule-grid[data-grid-size="small"] .grid-cell {
    padding: 1px;
}

.schedule-grid[data-grid-size="fit"] {
    min-width: 0;
    width: 100%;
}

.schedule-grid[data-grid-size="fit"] .day-header {
    font-size: 12px;
}

.schedule-grid[data-grid-size="fit"] .period-header {
    font-size: 10px;
}

.schedule-grid[data-grid-size="fit"] .row-header {
    gap: 5px;
    padding: 0 5px;
}

.schedule-grid[data-grid-size="fit"] .row-color {
    width: 11px;
    height: 11px;
}

.schedule-grid[data-grid-size="small"] .lesson-card {
    min-height: 20px;
    padding: 2px;
    border-radius: 2px;
}

.schedule-grid[data-grid-size="fit"] .grid-cell {
    padding: 1px;
}

.schedule-grid[data-grid-size="fit"] .lesson-card {
    min-height: 18px;
    padding: 1px;
    border-radius: 2px;
}

.schedule-grid[data-grid-size="small"] .lesson-card strong {
    font-size: 9px;
    text-overflow: clip;
}

.schedule-grid[data-grid-size="fit"] .lesson-card strong {
    font-size: 8px;
    text-overflow: clip;
}

.schedule-grid[data-grid-size="small"] .lesson-teacher-code {
    display: none;
}

.schedule-grid[data-grid-size="fit"] .lesson-teacher-code {
    display: none;
}

.schedule-grid[data-grid-size="small"] .lesson-card span {
    display: none;
}

.schedule-grid[data-grid-size="fit"] .lesson-card span {
    display: none;
}

.command-button.grid-size-active {
    border-color: #2563eb;
    background: #e8f1ff;
    color: #1d4ed8;
}

.lesson-card.conflict {
    border: 2px solid var(--danger);
}

.lesson-card.half {
    width: calc(50% - 2px);
    display: inline-grid;
}

.panel-resizer {
    height: 8px;
    cursor: row-resize;
    background: linear-gradient(#d7dde5, #c5ced9);
    border-top: 1px solid #b8c4d2;
    border-bottom: 1px solid #aeb8c4;
    position: relative;
}

.panel-resizer::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 2px;
    width: 54px;
    height: 3px;
    border-top: 1px solid #7b8794;
    border-bottom: 1px solid #7b8794;
    transform: translateX(-50%);
}

.control-panel {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 270px;
    gap: 0;
    min-height: 0;
    background: #fff;
    border-top: 1px solid var(--line-dark);
}

.detail-pane,
.unplaced-pane,
.preview-pane {
    min-width: 0;
    padding: 12px;
    border-right: 1px solid var(--line);
    overflow: auto;
}

.detail-pane h2,
.unplaced-pane h2,
.preview-pane h2,
.data-section h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 5px;
    overflow: hidden;
}

.segmented button {
    height: 28px;
    border: 0;
    background: #fff;
    padding: 0 9px;
}

.segmented button.active {
    background: #e8edf3;
    font-weight: 600;
}

.unplaced-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 58px));
    grid-auto-flow: dense;
    gap: 3px;
}

.unplaced-list .lesson-block-card {
    min-width: 0;
    min-height: 34px;
}

.unplaced-pane.drop-target {
    outline: 2px solid #1d4ed8;
    outline-offset: -3px;
    background: #e8eef8;
}

.mini-grid {
    display: grid;
    gap: 4px;
    font-size: 12px;
}

.mini-slot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid #e5e7eb;
    padding: 4px 0;
}

.mini-candidate {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 2px;
    border-bottom: 1px solid #e5e7eb;
}

.mini-candidate-color {
    width: 12px;
    height: 24px;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: 3px;
}

.mini-candidate strong,
.mini-candidate small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-candidate strong {
    font-size: 12px;
}

.mini-candidate small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.context-menu {
    position: fixed;
    z-index: 30;
    min-width: 170px;
    padding: 5px;
    border: 1px solid var(--line-dark);
    background: #fff;
    box-shadow: var(--shadow);
    border-radius: 6px;
}

.context-menu button {
    width: 100%;
    height: 30px;
    text-align: left;
    border: 0;
    border-radius: 4px;
    background: transparent;
    padding: 0 9px;
}

.context-menu button:hover {
    background: #eef2f7;
}

.cell-preview-popup {
    position: fixed;
    z-index: 35;
    width: min(270px, calc(100vw - 16px));
    max-height: min(340px, calc(100vh - 16px));
    overflow: hidden;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background: #fff;
    box-shadow: var(--shadow);
}

.cell-preview-popup-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #d8e0ea;
    background: #f8fafc;
    font-size: 12px;
}

.cell-preview-popup-head span {
    color: var(--muted);
    white-space: nowrap;
}

.cell-preview-popup-list {
    max-height: 285px;
    overflow: auto;
}

.cell-preview-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    padding: 7px 9px;
    color: var(--text);
    text-align: left;
}

.cell-preview-option:hover {
    background: #eff6ff;
}

.cell-preview-option > span:last-child {
    min-width: 0;
}

.cell-preview-option strong,
.cell-preview-option small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-preview-option strong {
    font-size: 12px;
}

.cell-preview-option small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.cell-preview-empty {
    padding: 14px 10px;
    color: var(--muted);
    font-size: 12px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    padding: 11px 14px;
    border-radius: 6px;
    color: #fff;
    background: #1f2937;
    box-shadow: var(--shadow);
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--success);
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.24);
    display: grid;
    place-items: center;
}

.app-modal[hidden] {
    display: none;
}

.generation-modal {
    z-index: 60;
}

.generation-window {
    width: min(500px, calc(100vw - 36px));
}

.generation-choice {
    padding: 22px;
}

.generation-choice > p {
    margin: 6px 0 18px;
    color: var(--muted);
    line-height: 1.45;
}

.generation-shuffle-options {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid #bfd0d6;
    border-radius: 6px;
    background: #f8fbfc;
}

.generation-shuffle-options > strong {
    display: block;
    margin-bottom: 9px;
}

.generation-duration-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.generation-duration-options button {
    min-height: 86px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 10px 8px;
    border: 1px solid #9bb2bb;
    border-radius: 5px;
    background: #f3f8fa;
    color: #214c5a;
}

.generation-duration-options button:hover,
.generation-duration-options button:focus-visible,
.generation-duration-options button.active {
    border-color: #24718a;
    background: #e3f1f5;
}

.generation-duration-options button.active {
    box-shadow: inset 0 0 0 1px #24718a;
}

.generation-duration-options span {
    color: var(--muted);
    font-size: 11px;
}

.generation-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 22px 18px;
}

.generation-actions button {
    min-height: 34px;
}

.placement-conflict-window {
    width: min(480px, calc(100vw - 36px));
}

.placement-conflict-body {
    padding: 18px 20px 12px;
}

.placement-conflict-body p {
    margin: 0 0 10px;
}

.placement-conflict-list {
    max-height: 150px;
    margin: 0;
    padding-left: 20px;
    overflow: auto;
    color: #991b1b;
    font-size: 13px;
    line-height: 1.45;
}

.placement-conflict-body .muted {
    margin: 12px 0 0;
}

.placement-conflict-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px 18px;
}

.placement-conflict-actions button {
    min-height: 34px;
}

.generation-body {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 14px;
    padding: 22px;
    align-items: center;
}

.generation-body p {
    margin: 5px 0 0;
}

.generation-spinner {
    width: 28px;
    height: 28px;
    border: 4px solid #d8e2e6;
    border-top-color: #24718a;
    border-radius: 50%;
    animation: generation-spin .8s linear infinite;
}

.generation-progress {
    grid-column: 1 / -1;
    height: 7px;
    overflow: hidden;
    border-radius: 99px;
    background: #e3eaed;
}

.generation-progress span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: #24718a;
    animation: generation-progress 1.35s ease-in-out infinite;
}

.generation-body .muted {
    grid-column: 1 / -1;
}

@media (max-width: 520px) {
    .generation-duration-options {
        grid-template-columns: 1fr;
    }

    .generation-duration-options button {
        min-height: 60px;
    }
}

@keyframes generation-spin {
    to { transform: rotate(360deg); }
}

@keyframes generation-progress {
    from { transform: translateX(-110%); }
    to { transform: translateX(265%); }
}

@media (prefers-reduced-motion: reduce) {
    .generation-spinner,
    .generation-progress span {
        animation: none;
    }
}

.modal-window {
    background: #fff;
    border: 1px solid #8a8f99;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.day-dividers-window {
    width: min(440px, calc(100vw - 36px));
}

.day-dividers-body {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.day-dividers-body > p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.day-divider-fieldset {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin: 0;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
}

.day-divider-fieldset legend {
    padding: 0 5px;
    color: #334155;
    font-weight: 700;
}

.day-divider-fieldset label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.day-divider-fieldset input {
    accent-color: var(--primary);
}

.day-divider-color {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-weight: 700;
}

.day-divider-color input {
    width: 64px;
    height: 34px;
    padding: 2px;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    background: #fff;
}

.day-divider-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 22px 20px;
}

.day-divider-actions button {
    min-height: 34px;
}

.relation-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    display: grid;
    grid-template-rows: 28px auto minmax(0, 1fr);
}

.modal-titlebar {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #475f66;
    color: #fff;
    padding: 0 9px;
    font-size: 13px;
}

.modal-titlebar button {
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
}

.schedules-window {
    width: min(860px, calc(100vw - 36px));
    height: min(820px, calc(100vh - 36px));
    min-height: min(430px, calc(100vh - 36px));
    display: grid;
    grid-template-rows: 28px minmax(0, 1fr);
}

.schedules-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    min-height: 0;
}

.schedules-list-pane {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #f8fafc;
    border-right: 1px solid var(--line);
    min-width: 0;
    min-height: 0;
}

.schedules-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid #dbe3ec;
}

.schedules-head h2 {
    margin: 0;
    font-size: 22px;
}

.schedules-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.schedule-list {
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
}

.schedule-row {
    width: 100%;
    min-height: 58px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid #d8e0ea;
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: left;
    color: var(--text);
    margin-bottom: 8px;
}

.schedule-row:hover,
.schedule-row.active {
    border-color: #60a5fa;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.12);
}

.schedule-row.active {
    background: #eff6ff;
}

.schedule-row strong,
.schedule-row span {
    display: block;
}

.schedule-row span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.schedule-row .schedule-pill {
    display: inline-block;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    padding: 4px 8px;
    font-size: 12px;
    margin-top: 0;
    white-space: nowrap;
}

.schedule-create-pane {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 18px;
    background: #fff;
}

.schedule-form {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.schedule-delete-button {
    margin-top: 14px;
}

.schedule-delete-window {
    width: min(430px, calc(100vw - 36px));
}

.schedule-delete-content {
    padding: 20px;
}

.schedule-delete-content p {
    margin: 0;
    line-height: 1.45;
}

.schedule-delete-content .muted {
    margin-top: 8px;
}

.schedule-form label {
    display: grid;
    gap: 6px;
    color: #334155;
}

.schedule-form input[type="text"] {
    height: 36px;
    border: 1px solid #b8c4d3;
    border-radius: 6px;
    padding: 0 10px;
}

.schedule-choice-group {
    display: grid;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #dbe3ec;
    border-radius: 8px;
    padding: 10px;
}

.schedule-choice-group label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.relation-global-rules {
    display: grid;
    grid-template-columns: auto minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 14px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #c4c9d0;
    background: #f8fafc;
}

.relation-global-rules > strong {
    white-space: nowrap;
    font-size: 13px;
}

.relation-global-rules label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.relation-global-rules label span {
    display: grid;
    gap: 2px;
}

.relation-global-rules label b {
    font-size: 12px;
    font-weight: 650;
}

.relation-global-rules label small {
    color: var(--muted);
    line-height: 1.3;
}

.relation-global-rules input[type="checkbox"] {
    margin-top: 2px;
}

.relations-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
}

.relations-list-pane {
    border-right: 1px solid #c4c9d0;
    background: #f7f7f7;
    display: grid;
    grid-template-rows: 82px 42px minmax(0, 1fr);
    min-width: 0;
}

.relation-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #d6d8dc;
}

.relation-head h2 {
    margin: 0;
    font-size: 22px;
}

.relation-actions {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 4px 14px;
    border-bottom: 1px solid #d6d8dc;
}

.circle-action {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    line-height: 1;
}

.circle-action.add { background: #4bc45f; }
.circle-action.edit { background: #f3cf62; color: #334155; }
.circle-action.delete { background: #f08080; }

.relations-table {
    font-size: 12px;
}

.relations-table tr {
    cursor: pointer;
}

.relations-table tr.selected-row,
.relations-table tr:hover {
    background: #e7f6c2;
}

.relation-warning {
    color: #dc2626;
    font-weight: 700;
    padding-right: 7px;
}

.relation-editor {
    min-height: 0;
    display: grid;
    grid-template-columns: 260px 260px minmax(360px, 1fr);
    grid-template-rows: minmax(0, 1fr) 46px;
    gap: 10px;
    padding: 16px 14px 0;
    overflow: visible;
}

.relation-step {
    display: grid;
    align-content: start;
    gap: 10px;
    border-right: 1px dashed #d6d8dc;
    padding-right: 10px;
}

.relation-step.wide {
    border-right: 0;
}

.relation-step h3 {
    margin: 0;
    font-size: 28px;
    font-weight: 400;
}

.relation-step label {
    display: grid;
    gap: 6px;
}

.relation-step select,
.relation-step input:not([type="checkbox"]) {
    min-height: 28px;
    border: 1px solid #c4c9d0;
    padding: 3px 6px;
}

.flat-button {
    min-height: 30px;
    border: 1px solid #d2d6dc;
    background: #f6f7f9;
    padding: 4px 10px;
}

.relation-options {
    display: grid;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px dashed #d6d8dc;
    border-bottom: 1px dashed #d6d8dc;
}

.relation-options label {
    display: block;
}

.number-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.relation-time-map {
    display: grid;
    gap: 3px;
    padding: 6px;
    background: #d4ffff;
    max-width: 360px;
}

.time-map-row {
    display: grid;
    grid-template-columns: 72px repeat(12, 18px);
    gap: 2px;
    align-items: center;
}

.time-map-row strong {
    font-size: 10px;
}

.time-map-cell {
    width: 18px;
    height: 13px;
    border: 1px solid #aeb2b8;
    background: #fff;
    display: block;
}

.time-map-cell input {
    position: absolute;
    opacity: 0;
}

.time-map-cell span {
    display: block;
    width: 100%;
    height: 100%;
}

.time-map-cell input:checked + span {
    background: #0b36ff;
}

.modal-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #d6d8dc;
    padding: 8px 0;
}

.confirm-button {
    min-height: 30px;
    border: 1px solid #40a34c;
    background: #47b54f;
    color: #fff;
    padding: 4px 14px;
}

.entity-window {
    width: min(1040px, calc(100vw - 56px));
    height: min(680px, calc(100vh - 56px));
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr);
    border-radius: 8px;
    overflow: hidden;
}

.entity-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    background: #f8fafc;
}

.entity-nav {
    padding: 12px;
    border-right: 1px solid #d8e0ea;
    background: #eef3f8;
    display: grid;
    align-content: start;
    gap: 8px;
}

.entity-nav button {
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    text-align: left;
}

.entity-nav button.active,
.entity-nav button:hover {
    border-color: #60a5fa;
    background: #eff6ff;
    color: #1d4ed8;
}

.entity-main {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: 54px minmax(0, 1fr) 48px;
    background: #fff;
}

.entity-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #d8e0ea;
}

.entity-toolbar input {
    width: min(320px, 35vw);
    height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 0 10px;
}

.entity-table-wrap {
    min-height: 0;
    overflow: auto;
}

.entity-table {
    font-size: 13px;
}

.entity-table-subjects,
.entity-table-classes {
    table-layout: fixed;
}

.entity-table-subjects th,
.entity-table-subjects td,
.entity-table-classes th,
.entity-table-classes td {
    padding-left: 6px;
    padding-right: 6px;
}

.entity-table-subjects th:nth-child(1) { width: 5%; }
.entity-table-subjects th:nth-child(2) { width: 15%; }
.entity-table-subjects th:nth-child(3) { width: 34%; }
.entity-table-subjects th:nth-child(4) { width: 17%; }
.entity-table-subjects th:nth-child(5) { width: 14%; }
.entity-table-subjects th:nth-child(6) { width: 15%; }

.entity-table-classes th:nth-child(1) { width: 4%; }
.entity-table-classes th:nth-child(2) { width: 17%; }
.entity-table-classes th:nth-child(3) { width: 9%; }
.entity-table-classes th:nth-child(4) { width: 9%; }
.entity-table-classes th:nth-child(5) { width: 18%; }
.entity-table-classes th:nth-child(6) { width: 10%; }
.entity-table-classes th:nth-child(7) { width: 18%; }
.entity-table-classes th:nth-child(8) { width: 15%; }

.entity-sort-button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-align: left;
    padding: 0;
}

.entity-sort-button:hover,
.entity-sort-button.active {
    color: #1d4ed8;
}

.entity-table tr {
    cursor: pointer;
}

.entity-table tbody tr:hover,
.entity-table tbody tr.selected-row {
    background: #e7f0ff;
}

.entity-table.sortable tbody tr {
    cursor: grab;
}

.entity-table.sortable tbody tr.dragging {
    opacity: 0.55;
}

.entity-table.sortable tbody tr.drag-over {
    box-shadow: inset 0 2px 0 #2563eb;
}

.drag-handle {
    display: inline-block;
    margin-left: 7px;
    color: #64748b;
    font-weight: 700;
    vertical-align: -1px;
}

.timeoff-preview {
    width: max-content;
    min-width: 64px;
    min-height: 32px;
    display: inline-grid;
    gap: 1px;
    border: 1px solid #0f172a;
    border-radius: 2px;
    background: #111827;
    padding: 2px;
    vertical-align: middle;
}

.timeoff-preview:hover {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.timeoff-preview-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 5px;
    gap: 1px;
}

.timeoff-preview span span {
    width: 5px;
    height: 5px;
    border: 1px solid rgba(0, 0, 0, 0.24);
}

.timeoff-preview .available {
    background: #39ff14;
}

.timeoff-preview .blocked {
    background: #ff1f1f;
}

.timeoff-preview .empty {
    background: #4b5563;
}

.entity-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 8px 12px;
}

.related-lessons-window {
    width: min(900px, calc(100vw - 48px));
    height: min(620px, calc(100vh - 48px));
    display: grid;
    grid-template-rows: 28px auto minmax(0, 1fr) 52px;
    border-radius: 6px;
    overflow: hidden;
}

.related-lessons-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 22px 14px;
    border-bottom: 1px solid #9aa8b8;
    background: #fff;
}

.related-lessons-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid #5f89bf;
    background: #8cb9ee;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
}

.related-lessons-head h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.15;
}

.related-lessons-head p {
    margin: 4px 0 0;
    color: #1f2937;
    font-size: 14px;
}

.related-lessons-table-wrap {
    min-height: 0;
    overflow: auto;
    padding: 14px 22px 0;
    background: #fff;
}

.related-lessons-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
}

.related-lessons-table th {
    height: 30px;
    border-bottom: 1px solid #94a3b8;
    color: #111827;
    text-align: left;
    font-weight: 600;
}

.related-lessons-table th:nth-child(1) { width: 24%; }
.related-lessons-table th:nth-child(2) { width: 23%; }
.related-lessons-table th:nth-child(3) { width: 18%; }
.related-lessons-table th:nth-child(4) { width: 16%; }
.related-lessons-table th:nth-child(5) { width: 19%; }

.related-lessons-table td {
    min-height: 34px;
    border-bottom: 1px solid #e2e8f0;
    padding: 7px 8px 7px 0;
    vertical-align: top;
    word-break: break-word;
}

.related-lessons-table tbody tr {
    cursor: pointer;
}

.related-lessons-table tbody tr:hover {
    background: #eef6ff;
}

.related-lessons-table tbody tr.selected-row {
    background: #dbeafe;
}

.lesson-code {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    min-height: 20px;
    margin-right: 8px;
    border-left: 3px solid rgba(0, 0, 0, 0.25);
    color: #111827;
    font-weight: 700;
    font-size: 11px;
}

.empty-related-lessons {
    color: var(--muted);
    text-align: center;
    padding: 22px;
}

.related-lessons-footer {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 10px 14px;
    background: #fff;
}

.related-lessons-actions {
    display: flex;
    gap: 8px;
}

.related-lessons-actions .danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.entity-edit-window {
    width: min(560px, calc(100vw - 56px));
    display: grid;
    grid-template-rows: 34px auto 48px;
    border-radius: 8px;
    overflow: hidden;
}

.lesson-reduction-window {
    width: min(720px, calc(100vw - 36px));
    max-height: min(760px, calc(100vh - 36px));
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr) 54px;
    border-radius: 8px;
    overflow: hidden;
}

.lesson-teacher-change-window {
    width: min(500px, calc(100vw - 36px));
    display: grid;
    grid-template-rows: 34px auto 54px;
    border-radius: 8px;
    overflow: hidden;
}

.lesson-teacher-change-body {
    padding: 22px 18px;
}

.lesson-teacher-change-body p {
    margin: 0;
    border: 1px solid #f0b44c;
    border-left-width: 5px;
    border-radius: 6px;
    background: #fff8e8;
    color: #6b4d16;
    line-height: 1.5;
    padding: 13px 14px;
}

.lesson-teacher-change-actions {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 9px 12px;
}

.lesson-reduction-body {
    min-height: 0;
    overflow: auto;
    padding: 18px;
}

.lesson-reduction-warning {
    border: 1px solid #f0b44c;
    border-left-width: 5px;
    border-radius: 6px;
    background: #fff8e8;
    padding: 12px 14px;
}

.lesson-reduction-warning p {
    margin: 5px 0 0;
    color: #6b4d16;
    line-height: 1.45;
}

.lesson-reduction-requirements {
    display: grid;
    gap: 7px;
    margin: 14px 0;
}

.lesson-reduction-requirement {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-radius: 5px;
    background: #eef3f8;
    padding: 9px 11px;
    color: #334155;
}

.lesson-reduction-requirement strong {
    color: #9f1d20;
    white-space: nowrap;
}

.lesson-reduction-requirement small {
    display: block;
    margin-top: 2px;
    color: #64748b;
}

.lesson-reduction-schedule {
    margin-top: 14px;
    border: 1px solid #d8e0ea;
    border-radius: 7px;
    overflow: hidden;
}

.lesson-reduction-schedule h3 {
    margin: 0;
    border-bottom: 1px solid #d8e0ea;
    background: #f8fafc;
    padding: 9px 12px;
    font-size: 13px;
}

.lesson-reduction-option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #edf0f4;
    padding: 10px 12px;
    cursor: pointer;
}

.lesson-reduction-option:last-child {
    border-bottom: 0;
}

.lesson-reduction-option:hover {
    background: #f7fbff;
}

.lesson-reduction-option.is-selected {
    background: #e8f2ff;
}

.lesson-reduction-option.is-locked {
    cursor: not-allowed;
    opacity: 0.62;
    background: #f8fafc;
}

.lesson-reduction-option input {
    width: 17px;
    height: 17px;
    accent-color: #c53232;
}

.lesson-reduction-option-main strong,
.lesson-reduction-option-main small {
    display: block;
}

.lesson-reduction-option-main small {
    margin-top: 3px;
    color: #64748b;
}

.lesson-reduction-hours {
    border-radius: 999px;
    background: #e2e8f0;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.lesson-reduction-status {
    min-height: 20px;
    margin: 14px 0 0;
    color: #9f1d20;
    font-weight: 700;
}

.lesson-reduction-status.is-complete {
    color: #15803d;
}

.lesson-reduction-actions {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 9px 12px;
}

.lesson-reduction-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.entity-form-fields {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.entity-form-fields label {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.entity-form-fields input,
.entity-form-fields select {
    min-height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 0 8px;
}

.entity-form-fields input[type="color"] {
    width: 62px;
    padding: 2px;
}

.entity-field-hint {
    grid-column: 2;
    color: #64748b;
    font-size: 11px;
    font-weight: 400;
}

.entity-resource-field {
    grid-template-columns: 160px minmax(0, 1fr) !important;
}

.entity-resource-control {
    min-width: 0;
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.entity-resource-control button {
    min-height: 32px;
}

.entity-primary-resource-control {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 6px 10px;
    align-items: center;
}

.entity-primary-resource-control .entity-resource-summary {
    grid-column: 1 / -1;
}

.entity-resource-summary {
    min-width: 0;
    overflow: hidden;
    color: #475569;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nested-modal {
    z-index: 60;
}

.lesson-copy-window {
    width: min(470px, calc(100vw - 32px));
    display: grid;
    grid-template-rows: 34px auto 48px;
    overflow: hidden;
}

.lesson-copy-options {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.lesson-copy-option {
    min-height: 44px;
    border: 1px solid #b9c3cf;
    border-radius: 6px;
    background: #f8fafc;
    color: #1f2933;
    font-weight: 600;
    text-align: left;
    padding: 0 14px;
}

.lesson-copy-option:hover {
    border-color: #2563eb;
    background: #eef4ff;
}

.lesson-copy-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 8px 12px;
}

.lesson-resource-window {
    width: min(900px, calc(100vw - 32px));
    height: min(610px, calc(100vh - 32px));
    display: grid;
    grid-template-rows: 30px minmax(0, 1fr) 48px;
    overflow: hidden;
}

.lesson-resource-columns {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    gap: 8px;
    padding: 16px 10px 10px;
}

.resource-pane {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: 30px minmax(0, 1fr);
    border: 1px solid #94a3b8;
    background: #fff;
}

.resource-table-head,
.resource-row {
    display: grid;
    grid-template-columns: 88px minmax(120px, 1fr) minmax(120px, 1fr);
    align-items: center;
}

.resource-table-head {
    border-bottom: 1px solid #94a3b8;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
}

.resource-table-head span,
.resource-row span {
    min-width: 0;
    padding: 5px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resource-table-body {
    min-height: 0;
    overflow: auto;
}

.resource-row {
    position: relative;
    width: 100%;
    min-height: 28px;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    color: #111827;
    text-align: left;
}

.resource-row:hover,
.resource-row.marked {
    background: #e8f1ff;
}

.resource-row.selected-resource span:first-child::before {
    content: "✓";
    margin-right: 6px;
    color: #34a853;
    font-weight: 700;
}

.resource-row.primary-resource span:last-child {
    padding-right: 48px;
}

.resource-row.primary-resource::after {
    content: "Ana";
    position: absolute;
    right: 7px;
    top: 5px;
    border: 1px solid #86a8d9;
    border-radius: 3px;
    background: #eef4ff;
    color: #1d4ed8;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
}

.resource-transfer {
    display: grid;
    place-items: center;
    color: #1683d8;
    font-size: 28px;
}

.lesson-resource-actions {
    display: grid;
    grid-template-columns: auto auto auto 1fr auto;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #d8e0ea;
    padding: 8px 12px;
}

.lesson-resource-separate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
}

.lesson-resource-separate input {
    width: 15px;
    height: 15px;
    margin: 0;
}

@media (max-width: 700px) {
    .lesson-resource-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
    }

    .lesson-resource-columns {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) 24px minmax(0, 1fr);
    }

    .resource-transfer {
        transform: rotate(90deg);
    }

    .entity-resource-control {
        grid-template-columns: 1fr;
    }

    .entity-primary-resource-control {
        grid-template-columns: 1fr;
    }

    .entity-primary-resource-control .entity-resource-summary {
        grid-column: auto;
    }
}

.entity-check {
    grid-template-columns: 160px auto !important;
}

.entity-form-actions {
    padding: 8px 12px;
}

.timeoff-window {
    width: min(1160px, calc(100vw - 56px));
    display: grid;
    grid-template-rows: 34px auto;
    border-radius: 8px;
    overflow: hidden;
}

.timeoff-editor-body {
    padding: 18px;
    background: #fff;
}

.timeoff-editor-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

#timeOffMatrix {
    min-width: 0;
}

.timeoff-copy-panel {
    width: 174px;
    flex: 0 0 174px;
    display: grid;
    gap: 8px;
    padding-top: 2px;
}

.timeoff-copy-panel[hidden] {
    display: none;
}

.timeoff-copy-button {
    width: 100%;
    min-height: 38px;
    line-height: 1.25;
    white-space: normal;
}

.timeoff-copy-button span {
    color: #1683d8;
    font-size: 18px;
}

.timeoff-copy-panel small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.timeoff-copy-actions {
    grid-template-columns: auto auto auto 1fr auto;
}

.timeoff-copy-window .resource-row.selected-resource span:first-child::before {
    content: "✓";
}

.modal-timeoff-table {
    min-width: min(820px, calc(100vw - 110px));
}

@media (max-width: 1040px) {
    .timeoff-editor-content {
        display: grid;
    }

    .timeoff-copy-panel {
        width: auto;
        grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
        align-items: center;
    }
}

.timeoff-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.login-shell,
.install-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #e8edf3;
}

.login-panel,
.install-panel {
    width: min(760px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-panel {
    width: min(430px, 100%);
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
}

h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.muted {
    color: var(--muted);
}

.alert {
    padding: 11px 12px;
    border-radius: 6px;
    margin: 14px 0;
}

.alert.success {
    color: #166534;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
}

.alert.danger {
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.stack-form,
.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack-form label,
.form-grid label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

.form-grid .check-line,
.form-grid button {
    grid-column: 1 / -1;
}

.content-page {
    padding: 22px;
    max-width: 1280px;
    margin: 0 auto;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.data-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.data-tabs a {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 10px;
}

.data-section {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.original-page {
    max-width: none;
}

.original-list tr.selected-row {
    background: #e4f4bf;
}

.tool-link {
    color: #1d4ed8;
    text-decoration: underline;
}

.availability-bar {
    font-family: Consolas, monospace;
    color: #00b050;
    background: #111;
    font-size: 10px;
    letter-spacing: 0;
    padding: 1px 2px;
}

.timeoff-wrap {
    overflow: auto;
    border: 1px solid #8a8f99;
}

.timeoff-table {
    width: max-content;
    min-width: 720px;
}

.timeoff-table th,
.timeoff-table td {
    border: 1px solid #8a8f99;
    padding: 0;
    height: 24px;
    min-width: 42px;
    text-align: center;
    background: #d0d0d3;
    color: #111;
}

.timeoff-table th {
    background: #c0c0c4;
    font-size: 11px;
    text-transform: none;
}

.timeoff-table .timeoff-bulk-toggle {
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.timeoff-table .timeoff-bulk-toggle:hover,
.timeoff-table .timeoff-bulk-toggle:focus-visible {
    background: #9eabb0;
    outline: 2px solid #24718a;
    outline-offset: -2px;
}

.timeoff-table td.available {
    background: #42f05a;
}

.timeoff-table td.blocked {
    background: #c7c7ca;
}

.timeoff-table td.inherited-blocked {
    background: #ef4444;
    color: #fff;
    cursor: not-allowed;
}

.timeoff-table td.inherited-blocked label {
    cursor: not-allowed;
}

.timeoff-table label {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}

.timeoff-table input {
    position: absolute;
    opacity: 0;
}

.timeoff-table span {
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.inline-check {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line-dark);
    border-radius: 5px;
    background: #fff;
    padding: 0 10px;
}

.inline-check input {
    height: auto;
    border: 0;
    padding: 0;
}

.calendar-form {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.calendar-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.period-time-editor {
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.period-time-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #d8e0ea;
    background: #fff;
}

.period-time-wrap {
    overflow: auto;
}

.period-time-table {
    min-width: 1120px;
    width: max-content;
}

.period-time-table th,
.period-time-table td {
    border: 1px solid #d8e0ea;
    padding: 7px;
    vertical-align: top;
}

.period-time-table thead th {
    text-align: center;
    background: #eef4ff;
    color: #1e3a8a;
}

.period-time-table tbody th {
    min-width: 120px;
    background: #fff;
    color: #0f172a;
    text-transform: none;
    font-size: 13px;
}

.period-time-action-heading,
.period-time-copy-cell {
    min-width: 180px;
}

.period-time-copy-cell {
    vertical-align: middle !important;
}

.period-time-copy-cell .primary-button {
    white-space: nowrap;
}

.period-time-table td {
    min-width: 82px;
    background: #fff;
}

.period-time-table label {
    display: grid;
    gap: 3px;
    font-size: 11px;
    color: var(--muted);
}

.period-time-table label + label {
    margin-top: 6px;
}

.period-time-table input[type="time"] {
    width: 100%;
    min-width: 68px;
    height: 28px;
    border: 1px solid #b8c4d3;
    border-radius: 5px;
    padding: 0 4px;
    color: var(--text);
}

.lesson-form select {
    min-width: 150px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px;
    text-align: left;
}

th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    color: #475569;
}

.report-band {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.report-band div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.report-band strong {
    display: block;
    font-size: 28px;
}

.report-band span {
    color: var(--muted);
}

@media (max-width: 820px) {
    .app-header {
        height: auto;
        min-height: 30px;
        flex-wrap: wrap;
        padding: 10px;
    }

    .workspace-shell {
        height: auto;
        min-height: 100vh;
        grid-template-rows: auto auto 62vh auto;
    }

    .command-bar,
    .module-tabs {
        flex-wrap: wrap;
    }

    .control-panel {
        grid-template-columns: 1fr;
    }

    .schedules-body {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .schedules-list-pane {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .form-grid,
    .report-band {
        grid-template-columns: 1fr;
    }
}

@media print {
    .app-header,
    .module-tabs,
    .command-bar,
    .control-panel,
    .data-tabs,
    button {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .workspace-shell {
        display: block;
        height: auto;
    }

    .grid-stage {
        overflow: visible;
    }
}

/* Merkez idare paneli */
.idare-body {
    min-height: 100vh;
    margin: 0;
    color: #172033;
    background:
        radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 32rem),
        #f4f7fb;
}

.idare-login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.idare-login-card {
    width: min(440px, 100%);
    border: 1px solid #dbe3ef;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 70px rgba(23, 32, 51, 0.13);
    padding: 34px;
}

.idare-login-card h1 {
    font-size: 30px;
}

.idare-login-brand,
.idare-brand-mark {
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8, #0f2f7e);
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(29, 78, 216, 0.24);
}

.idare-login-brand {
    width: 52px;
    height: 52px;
    margin-bottom: 24px;
    border-radius: 14px;
    font-size: 18px;
}

.idare-login-form {
    margin-top: 24px;
}

.idare-login-form input,
.idare-create-panel input,
.idare-subform input {
    min-height: 42px;
    border-color: #cdd7e5;
    border-radius: 7px;
    background: #fff;
    padding: 0 12px;
}

.idare-login-form .primary-button,
.idare-create-panel .primary-button,
.idare-subform .primary-button {
    min-height: 42px;
    border-radius: 7px;
}

.idare-security-note {
    margin: 22px 0 0;
    color: #718096;
    font-size: 12px;
    text-align: center;
}

.idare-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid #dce4ef;
    background: rgba(255, 255, 255, 0.94);
    padding: 10px max(22px, calc((100vw - 1360px) / 2));
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
}

.idare-brand,
.idare-session,
.idare-session > span {
    display: flex;
    align-items: center;
}

.idare-brand {
    gap: 12px;
    color: inherit;
}

.idare-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 11px;
}

.idare-brand > span:last-child,
.idare-session > span {
    align-items: flex-start;
    flex-direction: column;
}

.idare-brand small,
.idare-session small {
    margin-top: 2px;
    color: #718096;
    font-size: 11px;
}

.idare-session {
    gap: 14px;
}

.idare-session > span {
    text-align: right;
}

.idare-logout {
    min-height: 34px;
    border: 1px solid #d5deeb;
    border-radius: 7px;
    color: #344054;
    background: #fff;
    padding: 0 14px;
}

.idare-main {
    width: min(1360px, calc(100% - 44px));
    margin: 0 auto;
    padding: 36px 0 64px;
}

.idare-welcome,
.idare-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.idare-welcome {
    margin-bottom: 22px;
}

.idare-welcome h1 {
    font-size: clamp(26px, 3vw, 36px);
}

.idare-welcome p:last-child {
    max-width: 720px;
    margin: 0;
}

.idare-new-link {
    min-height: 42px;
    flex: 0 0 auto;
    border-radius: 8px;
    padding: 0 18px;
}

.idare-maintenance {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    border: 1px solid #bbd2c4;
    border-radius: 14px;
    background: #f2fbf5;
    padding: 18px 20px;
    scroll-margin-top: 90px;
}

.idare-maintenance.is-active {
    border-color: #f2b8b5;
    background: #fff5f4;
}

.idare-maintenance-status {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: #18864b;
    font-size: 20px;
    font-weight: 900;
}

.idare-maintenance.is-active .idare-maintenance-status {
    background: #c4322b;
}

.idare-maintenance h2 {
    margin: 1px 0 4px;
    font-size: 19px;
}

.idare-maintenance p:last-child {
    margin: 0;
    color: #64748b;
    font-size: 12px;
}

.idare-maintenance-button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    padding: 0 16px;
    font-weight: 800;
}

.idare-maintenance-button.enable {
    background: #c4322b;
}

.idare-maintenance-button.disable {
    background: #18864b;
}

.maintenance-notice {
    display: grid;
    gap: 7px;
    border: 1px solid #f1b6b2;
    border-radius: 10px;
    color: #8f211c;
    background: #fff3f2;
    padding: 20px;
    text-align: center;
}

.maintenance-notice strong {
    font-size: 19px;
}

.maintenance-notice span {
    color: #a44540;
    font-size: 13px;
}

.idare-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.idare-stats article {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #dce4ef;
    border-radius: 12px;
    background: #fff;
    padding: 20px 22px;
}

.idare-stats span {
    color: #62708a;
    font-size: 13px;
    font-weight: 600;
}

.idare-stats strong {
    color: #183b8f;
    font-size: 32px;
}

.idare-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 380px);
    gap: 20px;
    align-items: start;
}

.idare-schools-panel,
.idare-create-panel,
.idare-detail {
    border: 1px solid #dce4ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(44, 62, 92, 0.055);
}

.idare-schools-panel {
    min-width: 0;
    padding: 22px;
}

.idare-section-head h2,
.idare-create-panel h2,
.idare-subform h3,
.idare-admin-grid h3 {
    margin: 0;
}

.idare-section-head p,
.idare-subform > p {
    margin: 5px 0 0;
    color: #718096;
    font-size: 12px;
}

.idare-school-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.idare-school-card {
    min-width: 0;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    border: 1px solid #dfe6f0;
    border-radius: 10px;
    background: #fff;
    padding: 14px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.idare-school-card:hover,
.idare-school-card.selected {
    border-color: #8daff4;
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.09);
}

.idare-school-card.selected {
    background: #f8faff;
}

.idare-school-code {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #1d4ed8;
    background: #eaf0ff;
    font-size: 19px;
    font-weight: 800;
}

.idare-school-info {
    min-width: 0;
}

.idare-school-info h3 {
    margin: 0;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.idare-school-info p {
    margin: 5px 0 7px;
    color: #7a879d;
    font-size: 11px;
}

.idare-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.idare-badges span {
    border-radius: 999px;
    color: #516078;
    background: #eef2f7;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
}

.idare-badges .status-ok {
    color: #14723d;
    background: #dcfce7;
}

.idare-badges .status-error {
    color: #b42318;
    background: #fee4e2;
}

.idare-manage-link,
.idare-school-login {
    border: 1px solid #b8c8e6;
    border-radius: 7px;
    color: #1d4ed8;
    background: #fff;
    padding: 8px 11px;
    font-size: 12px;
    font-weight: 700;
}

.idare-detail {
    margin-top: 22px;
    background: #fbfcff;
    padding: 20px;
    scroll-margin-top: 90px;
}

.idare-detail-code {
    display: block;
    margin-bottom: 4px;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.idare-admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
    gap: 24px;
    margin-top: 22px;
}

.idare-admin-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.idare-admin-list > div {
    min-width: 0;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid #e1e7f0;
    border-radius: 8px;
    background: #fff;
    padding: 9px;
}

.idare-admin-list small {
    color: #8a96a8;
    font-size: 10px;
}

.idare-user-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #4368c7;
    font-size: 11px;
    font-weight: 800;
}

.idare-subform {
    display: grid;
    gap: 11px;
    border-left: 1px solid #dde5f0;
    padding-left: 24px;
}

.idare-subform label {
    display: grid;
    gap: 5px;
    color: #3d4b63;
    font-size: 12px;
    font-weight: 700;
}

.idare-create-panel {
    padding: 24px;
    position: sticky;
    top: 94px;
    scroll-margin-top: 90px;
}

.idare-create-panel > .muted {
    margin: 7px 0 22px;
    font-size: 12px;
    line-height: 1.55;
}

.idare-create-panel label small {
    color: #8a96a8;
    font-size: 10px;
    font-weight: 400;
}

.idare-form-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    color: #61708a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.idare-form-divider::before,
.idare-form-divider::after {
    height: 1px;
    flex: 1;
    background: #e2e8f0;
    content: "";
}

.idare-create-button {
    height: auto !important;
    min-height: 46px !important;
    padding: 8px 14px;
    text-align: center;
}

.idare-empty {
    margin-top: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    color: #718096;
    padding: 28px;
    text-align: center;
}

@media (max-width: 980px) {
    .idare-layout,
    .idare-admin-grid {
        grid-template-columns: 1fr;
    }

    .idare-create-panel {
        position: static;
    }

    .idare-subform {
        border-top: 1px solid #dde5f0;
        border-left: 0;
        padding-top: 22px;
        padding-left: 0;
    }
}

@media (max-width: 640px) {
    .idare-header,
    .idare-welcome,
    .idare-section-head {
        align-items: flex-start;
    }

    .idare-header,
    .idare-welcome {
        flex-direction: column;
    }

    .idare-session {
        width: 100%;
        justify-content: space-between;
    }

    .idare-session > span {
        text-align: left;
    }

    .idare-main {
        width: min(100% - 24px, 1360px);
        padding-top: 24px;
    }

    .idare-stats {
        grid-template-columns: 1fr;
    }

    .idare-maintenance {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .idare-maintenance form {
        grid-column: 1 / -1;
    }

    .idare-maintenance-button {
        width: 100%;
    }

    .idare-stats article {
        min-height: 76px;
    }

    .idare-schools-panel,
    .idare-create-panel,
    .idare-detail,
    .idare-login-card {
        padding: 18px;
    }

    .idare-school-card {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .idare-school-code {
        width: 44px;
        height: 44px;
    }

    .idare-manage-link {
        grid-column: 2;
        justify-self: start;
    }

    .idare-school-login {
        margin-top: 8px;
    }

    .idare-admin-list > div {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .idare-admin-list small {
        grid-column: 2;
    }
}
