:root {
    font-family: Inter, Arial, sans-serif;
    --sticky-header-height: 140px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7fb;
    color: #111;
    overflow-y: scroll;
}

.container {
    max-width: 1760px;
    margin: 0 auto;
    padding: 24px 24px 24px;
}

.card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

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

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

button {
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    border-radius: 8px;
}

input, select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
}

.muted {
    color: #666;
}

pre {
    white-space: pre-wrap;
    background: #f0f2f7;
    padding: 8px;
    border-radius: 8px;
}

hr {
    border: none;
    border-top: 1px solid #ececec;
    margin: 16px 0;
}

@media (max-width: 860px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 16px 12px 16px;
    }

    .header-title-row {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .header-user-inline {
        width: 100%;
        justify-content: flex-end;
    }

    .page-nav {
        padding-bottom: 2px;
        gap: 8px;
    }
}


.mode-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    background: #e0e7ff;
    color: #1e3a8a;
}

.mode-badge.legacy {
    background: #ffe4e6;
    color: #9f1239;
}


.tabs {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: #eef2ff;
}

.tab-btn.active {
    background: #1d4ed8;
    color: white;
    border-color: #1d4ed8;
}

.tab-panel.hidden {
    display: none;
}

.app-shell-header {
    position: sticky;
    top: 8px;
    z-index: 120;
    border: 1px solid #dbe5f1;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-title-row h1 {
    margin: 0;
}

.header-user-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    text-decoration: none;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    font-size: 18px;
}

.home-link:hover {
    background: #dbeafe;
}

.header-user-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
}

.header-user-badge:hover {
    background: #dbeafe;
}

.page-nav {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 4px;
    margin: 12px 0 0;
}

.page-nav::-webkit-scrollbar {
    height: 6px;
}

.page-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.nav-link {
    display: inline-block;
    white-space: nowrap;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    text-decoration: none;
    color: #1f2937;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.nav-link:hover {
    transform: translateY(-1px);
    border-color: #93c5fd;
    background: #dbeafe;
}

.nav-link.active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}

.sheet-wrap {
    overflow: auto;
    border: 1px solid #d6dae3;
    border-radius: 8px;
}

.sheet-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    background: #fff;
}

.sheet-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
}

.sheet-table th,
.sheet-table td {
    border: 1px solid #e5e7eb;
    padding: 7px 10px;
    text-align: left;
    vertical-align: middle;
}

.class-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.class-chip {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
}

.parallel-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 8px;
}

.parallel-tab {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    cursor: pointer;
}

.parallel-tab.active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

.plan-block h2 {
    margin-top: 0;
}

#building-load-table input {
    width: 100%;
    min-width: 160px;
}

#building-load-table select {
    width: 100%;
    min-width: 180px;
}


#building-load-table input[list] {
    width: 100%;
    min-width: 220px;
}

.teacher-hours {
    margin-top: 4px;
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
}

.summary-part-row td {
    background: #f8fafc;
    font-weight: 600;
}

.password-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 16px;
}

.password-modal {
    width: min(480px, 100%);
    display: grid;
    gap: 10px;
}

.password-modal h3 {
    margin: 0;
}

.password-modal label {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

.password-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.profile-modal-card {
    max-height: min(88vh, 760px);
    overflow: auto;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    font-size: 14px;
}

.profile-subtitle {
    margin: 0;
}

.summary-sum-row td {
    background: #f1f5f9;
    font-weight: 600;
}

.summary-area-row td {
    background: #f8fafc;
    font-weight: 600;
}

.subject-name-cell {
    text-align: center !important;
}

.hours-cell-wrap {
    padding: 0;
}

.hours-cell {
    width: 100%;
    min-height: 34px;
    background: #ffffff;
    border: 0;
    border-radius: 0;
    position: relative;
}

.hours-cell:hover {
    background: #eef2ff;
}

.hours-cell.empty-hours-cell {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #94a3b8;
}

.hours-cell.empty-hours-cell:hover {
    background: #eef2ff;
    border-color: #94a3b8;
}

.hours-cell.advanced-cell {
    background: #ffd8b5;
}

.hours-index {
    color: #7c3aed;
    font-weight: 700;
    font-size: 11px;
    margin-left: 2px;
}

.subgroup-mark {
    position: absolute;
    right: 4px;
    bottom: 2px;
    font-size: 11px;
    text-transform: lowercase;
    color: #7c2d12;
}

#summary-table th,
#summary-table td {
    text-align: center;
}

#summary-table td:first-child,
#summary-table th:first-child {
    text-align: left;
}

.workspace-panel iframe {
    width: 100%;
    min-height: 760px;
    border: 1px solid #dbe1ea;
    border-radius: 8px;
    background: #fff;
}

.controls-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.controls-row button,
.controls-row select {
    padding: 6px 8px;
}

.subject-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.inline-plus {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    padding: 0;
    line-height: 1;
    font-size: 18px;
    font-weight: 600;
}

.hour-pill {
    min-width: 70px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.load-page {
    --load-pill-blue-bg: #dbeafe;
    --load-pill-blue-border: #60a5fa;
    --load-pill-blue-text: #1d4ed8;
    --load-pill-purple-bright-bg: #c4b5fd;
    --load-pill-purple-bright-border: #8b5cf6;
    --load-pill-purple-bright-text: #4c1d95;
    --load-pill-purple-soft-bg: #ede9fe;
    --load-pill-purple-soft-border: #c4b5fd;
    --load-pill-purple-soft-text: #6d28d9;
    --load-pill-continuity-ok-bg: #dcfce7;
    --load-pill-continuity-ok-border: #86efac;
    --load-pill-continuity-ok-text: #166534;
    --load-pill-continuity-broken-bg: #fef9c3;
    --load-pill-continuity-broken-border: #fde047;
    --load-pill-continuity-broken-text: #854d0e;
}

.teacher-input {
    min-width: 220px;
}

.level-cell {
    width: 100%;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 4px 6px;
}

.level-cell:hover {
    background: #dbeafe;
}


.hour-pill.muted {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

.dismissal-row {
    background: #fee2e2;
}

.dismissal-note {
    margin-top: 4px;
    color: #b91c1c;
    font-size: 12px;
}

.period-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    min-width: 230px;
}

.period-input {
    width: 100%;
    min-width: 110px;
}

.danger-btn {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.hour-pill.unassigned {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.hour-pill.planned,
.hour-pill.planned.active,
.hour-pill.planned.continuity-ok,
.hour-pill.planned.continuity-broken {
    background: var(--load-pill-purple-bright-bg);
    border-color: var(--load-pill-purple-bright-border);
    color: var(--load-pill-purple-bright-text);
    font-weight: 600;
}

.hour-pill.transfer-out,
.hour-pill.transfer-out.active,
.hour-pill.transfer-out.continuity-ok,
.hour-pill.transfer-out.continuity-broken {
    background: var(--load-pill-purple-soft-bg);
    border-color: var(--load-pill-purple-soft-border);
    color: var(--load-pill-purple-soft-text);
    font-weight: 600;
}

.hour-pill.continuity-ok:not(.planned):not(.transfer-out) {
    background: var(--load-pill-continuity-ok-bg);
    border-color: var(--load-pill-continuity-ok-border);
    color: var(--load-pill-continuity-ok-text);
    font-weight: 600;
}

.hour-pill.continuity-broken:not(.planned):not(.transfer-out) {
    background: var(--load-pill-continuity-broken-bg);
    border-color: var(--load-pill-continuity-broken-border);
    color: var(--load-pill-continuity-broken-text);
    font-weight: 600;
}

.hour-pill.active:not(.planned):not(.transfer-out):not(.continuity-ok):not(.continuity-broken) {
    background: var(--load-pill-blue-bg);
    border-color: var(--load-pill-blue-border);
    color: var(--load-pill-blue-text);
    font-weight: 600;
}

dialog {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px;
    max-width: 760px;
    width: calc(100% - 24px);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.subgroup-config.hidden {
    display: none;
}

#save-building-btn {
    position: static;
    top: auto;
    z-index: auto;
}

#save-building-btn.clean-save {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #374151;
}

#save-building-btn.dirty-save {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #78350f;
}

#building-load-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 8;
    box-shadow: inset 0 -1px 0 #d6dae3;
}

#building-load-table {
    --load-subject-col-width: 220px;
    --load-teacher-col-width: 260px;
}

#building-load-table tbody td:first-child,
#building-load-table thead tr.load-main-head th:first-child {
    position: sticky;
    left: 0;
    z-index: 9;
    background: #fff;
    width: var(--load-subject-col-width);
    min-width: var(--load-subject-col-width);
    max-width: var(--load-subject-col-width);
}

#building-load-table tbody td:nth-child(2),
#building-load-table thead tr.load-main-head th:nth-child(2) {
    position: sticky;
    left: var(--load-subject-col-width);
    z-index: 9;
    background: #fff;
    width: var(--load-teacher-col-width);
    min-width: var(--load-teacher-col-width);
    max-width: var(--load-teacher-col-width);
}

#building-load-table thead tr.load-main-head th:first-child,
#building-load-table thead tr.load-main-head th:nth-child(2) {
    z-index: 11;
}

.mini-level {
    margin-left: 4px;
    font-size: 10px;
    vertical-align: super;
    color: #1f2937;
}

.load-status-card { position: sticky; top: calc(var(--sticky-header-height, 140px) + 12px); z-index: 20; display:flex; gap:20px; align-items:center; }
.error-row-highlight { outline: 2px solid #d32f2f; background: #fff2f2; }
.load-change-row td { background: #f3e8ff; }
.load-change-row .subject-cell { color: #6b21a8; font-weight: 700; }

.labeled-grid .field-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    align-items: center;
    gap: 10px;
}

.labeled-grid .field-row > span {
    color: #334155;
    font-weight: 600;
}

.labeled-grid .field-row input,
.labeled-grid .field-row select {
    width: 100%;
}

@media (max-width: 860px) {
    .labeled-grid .field-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}


.table-scroll-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

.table-scroll-controls input[type="range"] {
    flex: 1;
}

.table-scroll-controls.disabled {
    opacity: 0.5;
}

.table-scroll-controls.disabled button,
.table-scroll-controls.disabled input {
    pointer-events: none;
}

#building-load-table {
    min-width: 1500px;
    --load-subject-col-width: 220px;
    --load-teacher-col-width: 260px;
}

.load-page .container {
    max-width: 1760px;
}

.class-sort-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 0;
    font-weight: 600;
}

.class-sort-btn.active {
    color: #1d4ed8;
    text-decoration: underline;
}

.conflict-row td {
    background: #fee2e2;
}

.summary-value.conflict-row {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 700;
}


.load-page .load-toolbar {
    position: static !important;
    top: auto;
    z-index: 0;
}

.load-page .load-toolbar .load-status-card {
    position: static;
    top: auto;
    z-index: auto;
    margin-top: 8px;
}

.load-page .sheet-wrap {
    max-height: calc(100vh - 230px);
}

.load-page .sheet-table thead th {
    top: 0;
    z-index: 5;
}

#building-load-table thead tr.load-main-head th {
    top: 0;
    z-index: 7;
    background: #f8fafc;
}

#building-load-table thead tr.load-class-head th {
    position: sticky;
    top: 38px;
    z-index: 7;
    background: #f1f5f9;
}

.load-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.head-action-btn {
    padding: 6px 10px;
    border-radius: 8px;
}

.load-page .compact-note {
    margin: 6px 0 0;
}

.inline-load-stats {
    margin-left: auto;
    display: flex;
    gap: 14px;
    align-items: center;
}

.load-color-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 8px 0 0;
    font-size: 13px;
}

.legend-title {
    font-weight: 600;
    color: #334155;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #334155;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
}

.legend-swatch-ok {
    background: var(--load-pill-continuity-ok-bg);
    border-color: var(--load-pill-continuity-ok-border);
}

.legend-swatch-broken {
    background: var(--load-pill-continuity-broken-bg);
    border-color: var(--load-pill-continuity-broken-border);
}

.legend-swatch-blue {
    background: var(--load-pill-blue-bg);
    border-color: var(--load-pill-blue-border);
}

.legend-swatch-transfer-in {
    background: var(--load-pill-purple-bright-bg);
    border-color: var(--load-pill-purple-bright-border);
}

.legend-swatch-transfer-out {
    background: var(--load-pill-purple-soft-bg);
    border-color: var(--load-pill-purple-soft-border);
}


.curriculum-page .container {
    max-width: 1760px;
}

.curriculum-page .curriculum-toolbar {
    position: sticky;
    top: calc(var(--sticky-header-height, 140px) + 12px);
    z-index: 35;
}

.curriculum-page .sheet-wrap {
    max-height: calc(100vh - 240px);
}

#summary-table {
    min-width: 1500px;
}

#summary-table th,
#summary-table td {
    min-width: 120px;
}

#summary-table th:first-child,
#summary-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 6;
    background: #fff;
    min-width: 280px;
}

#summary-table .summary-direction-row th {
    position: sticky;
    top: 0;
    z-index: 7;
    background: #f8fafc;
}

#summary-table .summary-class-row th {
    position: sticky;
    top: 38px;
    z-index: 7;
    background: #f1f5f9;
}

.readonly-block {
    position: relative;
}

.readonly-note {
    margin-top: 12px;
}

.login-page .container {
    max-width: 520px;
}

.home-page {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.home-page .container {
    max-width: 1200px;
}

.home-menu-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.home-menu-card {
    text-decoration: none;
    color: inherit;
    border: 1px solid #dbe5f1;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.home-menu-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(30, 41, 59, 0.12);
    border-color: #93c5fd;
}

.home-menu-sticker {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0e7ff;
    font-size: 22px;
}

.home-menu-card h2 {
    margin: 12px 0 8px;
}

.home-menu-load .home-menu-sticker {
    background: #dbeafe;
}

.home-menu-admin .home-menu-sticker {
    background: #fef3c7;
}

.placeholder-card,
.access-denied-card {
    max-width: 680px;
}

.login-card {
    margin-top: 64px;
}

.admin-card {
    overflow: hidden;
}

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

.section-heading.compact {
    margin-bottom: 12px;
}

.section-heading h2,
.section-heading h3 {
    margin: 0 0 4px;
}

.admin-section-badge {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 7px 12px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
}

.admin-section-badge.soft {
    background: #e2e8f0;
    color: #334155;
}

.admin-user-form {
    align-items: start;
    gap: 14px;
}

.field-stack {
    display: grid;
    gap: 6px;
    font-size: 14px;
    color: #334155;
}

.field-stack span {
    font-weight: 600;
}

.admin-switches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #dbe5f1;
}

.toggle-pill input {
    margin: 0;
}

.full-span {
    grid-column: 1 / -1;
}

.compact-row {
    align-items: center;
    justify-content: space-between;
}

.compact-actions {
    margin-bottom: 0;
}

.admin-panel {
    background: linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
    border: 1px solid #dbe5f1;
    border-radius: 16px;
    padding: 18px;
}

.permission-matrix-wrap {
    overflow-x: auto;
}

.permission-matrix-table {
    width: 100%;
    min-width: 680px;
    table-layout: fixed;
}

.permission-matrix-table th,
.permission-matrix-table td {
    text-align: center;
}

.permission-matrix-table th:first-child,
.permission-matrix-table td:first-child {
    text-align: left;
    width: 58%;
}

.scope-mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.scope-mode-card {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 14px 14px 14px 40px;
    border-radius: 14px;
    border: 1px solid #dbe5f1;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.scope-mode-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.08);
    transform: translateY(-1px);
}

.scope-mode-card:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.12);
}

.scope-mode-card.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.scope-mode-card input {
    position: absolute;
    top: 16px;
    left: 14px;
    margin: 0;
}

.scope-mode-title {
    font-weight: 700;
    color: #0f172a;
}

.scope-mode-text {
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
}

.building-checkbox-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.load-scope-summary {
    color: #1e293b;
}

.building-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.building-checkbox-grid.is-disabled {
    opacity: 0.72;
}

.building-checkbox-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #dbe5f1;
    background: #fff;
}

.building-checkbox-pill input {
    margin: 0;
}

.users-table td {
    vertical-align: top;
}

.table-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 600;
}

.load-scope-badge {
    background: #eff6ff;
    color: #1d4ed8;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-muted {
    background: #e2e8f0;
    color: #475569;
}

.admin-edit-dialog {
    max-width: 1440px;
    width: min(1440px, calc(100vw - 32px));
    max-height: calc(100vh - 24px);
    padding: 0;
    overflow: hidden;
}

.admin-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
}

.dialog-hero {
    margin: -24px -24px 0;
    padding: 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border-bottom: 1px solid #dbe5f1;
}

.dialog-hero h3 {
    margin: 0 0 6px;
}

.dialog-actions {
    justify-content: flex-end;
    margin-bottom: 0;
}

.inline-actions {
    justify-content: flex-start;
}

.sticky-dialog-actions {
    position: sticky;
    bottom: -24px;
    margin: 0 -24px -24px;
    padding: 16px 24px 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, #ffffff 40%);
    border-top: 1px solid #dbe5f1;
    box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.06);
}

@media (max-width: 1100px) {
    .section-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-edit-form {
        grid-template-columns: 1fr;
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 18px;
    }

    .admin-edit-dialog {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }

    .dialog-hero {
        margin: -18px -18px 0;
        padding: 18px;
    }

    .sticky-dialog-actions {
        bottom: -18px;
        margin: 0 -18px -18px;
        padding: 14px 18px 18px;
    }
}

.settings-period-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.settings-period-card {
    border: 1px solid #d7deea;
    border-radius: 14px;
    padding: 16px;
    background: #f8fbff;
    display: grid;
    gap: 10px;
}

.settings-period-card h3 {
    margin: 0 0 4px;
}

.summary-class-row .muted {
    font-size: 12px;
    margin-top: 4px;
}


.period-accent-cell {
    background: #8b5cf6 !important;
    color: #fff !important;
    border-color: #7c3aed !important;
}

.period-accent-cell .mini-level {
    color: rgba(255,255,255,0.9) !important;
}

.tab-btn {
    border: 1px solid var(--line);
    background: #fff;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
}

.tab-btn.active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

.file-upload-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.file-upload-inline input[type="file"] {
    max-width: 220px;
}

#pending-body input[type="checkbox"][data-pending-check] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.meta-group-cell {
    background: #dcfce7 !important;
    border-color: #22c55e !important;
    color: #166534;
    font-weight: 700;
}

.nav-home-link {
    font-size: 18px;
    min-width: 42px;
    text-align: center;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 16px;
}

.module-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid #dbe5f1;
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.14);
    border-color: #93c5fd;
}

.module-card h2 {
    margin: 0 0 8px;
}

.module-card p {
    margin: 0;
    color: #475569;
    line-height: 1.45;
}

.module-icon {
    display: inline-flex;
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #dbeafe;
    font-size: 26px;
    margin-bottom: 14px;
}

.module-card-primary {
    border-color: #93c5fd;
    background: linear-gradient(160deg, #ffffff 0%, #eff6ff 100%);
}

.module-card-placeholder .module-icon {
    background: #e2e8f0;
}

.module-placeholder-card h2 {
    margin-top: 0;
}

.module-admin-section {
    margin-top: 16px;
}

.settings-period-table input,
.settings-period-table select {
    width: 100%;
    min-width: 120px;
}

.settings-period-table .period-default-cell {
    text-align: center;
}

.settings-period-table .period-default-cell input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

@media (max-width: 980px) {
    .module-grid {
        grid-template-columns: 1fr;
    }
}

.result-box {
    max-height: 240px;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 10px;
}

.debug-output-hidden .result-box,
.debug-output-hidden [data-debug-output="1"] {
    display: none !important;
}

.contingent-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.contingent-tabs button.nav-link {
    cursor: pointer;
}

#contingent-stats-table th,
#contingent-stats-table td {
    text-align: center;
    white-space: nowrap;
    padding: 4px 6px;
}

#contingent-stats-table thead th {
    background: #f1f5f9;
}

.year-status-ok {
    background: #d8f7dd;
    color: #1f6a2a;
    font-weight: 600;
}

.year-status-broken {
    background: #fff3cd;
    color: #7a5800;
    font-weight: 600;
}

@media print {
    body { background: #fff; }
    .container { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: 1px solid #000; page-break-inside: avoid; }
    #contingent-stats-table { font-size: 11px; }
}
