:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --text: #17212f;
    --muted: #6e7a8a;
    --line: #d8e1ef;
    --primary: #0c7b6f;
    --primary-2: #11a592;
    --danger: #d63952;
    --shadow: 0 10px 30px rgba(12, 29, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 0% 0%, #d2f4ef 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, #d6e8ff 0%, transparent 45%),
        var(--bg);
}

.app-shell {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.hero {
    background: linear-gradient(135deg, #0f5c9d, #169b8e);
    color: #fff;
    border-radius: 8px;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.hero h1 {
    margin: 0 0 6px;
    font-size: 30px;
}

.hero p {
    margin: 0;
    opacity: 0.95;
}

.layout {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-forms {
    padding: 14px;
    max-height: none;
    overflow: visible;
}

.panel-forms h2 {
    margin: 4px 0 10px;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.tab {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
    padding: 8px 6px;
    cursor: pointer;
    font-weight: 600;
}

.tab.is-active {
    background: #d5f6f2;
    border-color: #96ddd5;
}

.tab-content {
    display: none;
}

.tab-content.is-active {
    display: grid;
    grid-template-columns: minmax(320px, 520px) 1fr;
    gap: 12px;
    align-items: start;
}

.form-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 0;
}

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

input[type="text"], input[type="number"], input[type="time"], select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
}

label {
    color: #2f4155;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.btn {
    border: 1px solid #2d7f75;
    background: #d6f4f0;
    color: #0f534b;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn:hover {
    filter: brightness(0.96);
}

.btn-primary {
    background: #fff;
    color: #0b5e54;
    border-color: #b7fff5;
}

.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.btn-danger {
    background: #ffe5ea;
    border-color: #ffb7c5;
    color: #911d34;
}

.btn-sm {
    padding: 5px 8px;
    font-size: 12px;
}

.list {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 8px;
    display: grid;
    gap: 6px;
    background: #fcfdff;
}

.manager-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
}

.manager-block h3,
.manager-block h4 {
    margin: 4px 0;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
}

.availability-grid {
    overflow-x: auto;
}

.availability-table {
    display: grid;
    grid-template-columns: 70px repeat(5, minmax(55px, 1fr));
    gap: 6px;
}

.av-head,
.av-slot {
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f7faff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    font-size: 13px;
    font-weight: 700;
}

.av-cell {
    border-radius: 8px;
    border: 1px solid #bcd0e8;
    min-height: 32px;
    cursor: pointer;
    font-weight: 700;
}

.av-cell.is-on {
    background: #f3fbf8;
}

.av-cell.is-off {
    background: #ffe6ea;
    color: #99223d;
    border-color: #f3b8c4;
}

.room-checkboxes {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #fbfdff;
}

.checkbox-grid {
    display: grid;
    gap: 6px;
}

.checkbox-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 8px;
    background: #fff;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 13px;
}

.subject-item {
    gap: 8px;
}

.subject-delete-btn {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.18);
    color: #0f172a;
}

.panel-timetable {
    padding: 12px;
    overflow: auto;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.toolbar label {
    gap: 6px;
}

.planner-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px 10px;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fcff;
}

.planner-settings label {
    display: grid;
    gap: 4px;
    align-items: start;
}

.planner-settings .btn {
    align-self: end;
    height: 38px;
}

.timetable-grid {
    display: grid;
    grid-template-columns: 90px repeat(5, minmax(170px, 1fr));
    gap: 7px;
}

.head-cell {
    text-align: center;
    padding: 8px 5px;
    border-radius: 8px;
    background: #e9f2ff;
    border: 1px solid #caddfb;
    font-weight: 700;
}

.slot-label {
    border-radius: 8px;
    border: 1px dashed #bdd0e8;
    color: #36516f;
    background: #f8fbff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    white-space: pre-line;
    text-align: center;
    line-height: 1.2;
}

.cell {
    border: 1px dashed var(--line);
    background: #fbfdff;
    min-height: 90px;
    border-radius: 8px;
    padding: 5px;
    transition: border-color 0.15s ease;
    display: grid;
    gap: 5px;
    align-content: start;
}

.cell.drag-over {
    border-color: var(--primary-2);
    background: #e9fffc;
}

.lesson {
    border-radius: 8px;
    border: 2px solid rgba(23, 33, 47, 0.16);
    padding: 8px;
    display: grid;
    gap: 5px;
    cursor: grab;
    color: #102030;
}

.lesson.is-overflow {
    border-color: #e79029;
    box-shadow: inset 0 0 0 1px rgba(231, 144, 41, 0.3);
}

.lesson-overflow-badge {
    display: inline-flex;
    width: fit-content;
    padding: 2px 7px;
    border-radius: 999px;
    background: #fff2df;
    color: #8c4e08;
    border: 1px solid #e6b982;
    font-size: 11px;
    font-weight: 700;
}

.lesson:active {
    cursor: grabbing;
}

.lesson-subject {
    font-weight: 700;
}

.lesson-meta {
    font-size: 12px;
}

.lesson-controls {
    display: flex;
    justify-content: flex-end;
}

.empty-note {
    padding: 40px 10px;
    color: var(--muted);
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(9, 19, 32, 0.55);
}

.modal.is-open {
    display: grid;
}

.modal-card {
    width: min(460px, calc(100vw - 30px));
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 14px;
}

.modal-card h3 {
    margin: 0 0 8px;
}

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

@media (max-width: 1260px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .panel-forms {
        max-height: none;
    }
    .tab-content.is-active {
        grid-template-columns: 1fr;
    }
}
