:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --line: #d8dce3;
    --txt: #1c2530;
    --muted: #607086;
    --accent: #0f6f8f;
    --danger: #bf1e2e;
    --warn: #c58d10;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Trebuchet MS", "Segoe UI", sans-serif; color: var(--txt); background: radial-gradient(circle at 10% 10%, #e8f6f9, var(--bg)); }
a { color: var(--accent); text-decoration: none; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { border: 1px solid var(--line); padding: 0.45rem; vertical-align: top; }
th { background: #eef2f6; }
.app-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: #0f2337; color: #f1f5fa; padding: 1rem; }
.sidebar h1 { font-size: 1.05rem; margin: 0 0 1rem; }
.sidebar nav { display: grid; gap: 0.4rem; }
.sidebar a { color: #d8e8ff; font-size: 0.92rem; }
.content { padding: 1rem 1.1rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem; margin-bottom: 0.9rem; }
.editor-tabs { display: flex; gap: 0.4rem; margin: 0.45rem 0 0.2rem; }
.tab-btn { background: #dce7f1; color: #17374d; border: 1px solid #b8cad9; }
.tab-btn.active { background: #17374d; color: #fff; border-color: #17374d; }
.timetable-panel { display: none; }
.timetable-panel.active { display: block; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 0.8rem; }
.kpis .card h3 { margin: 0; color: var(--muted); font-size: 0.88rem; }
.kpis .card p { font-size: 1.4rem; margin: 0.4rem 0 0; }
label { display: grid; gap: 0.22rem; font-size: 0.86rem; margin-bottom: 0.55rem; }
input, select, button { border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem; font-size: 0.9rem; }
button, .btn { background: #17374d; color: #fff; border: none; cursor: pointer; padding: 0.5rem 0.8rem; border-radius: 6px; }
button:hover, .btn:hover { filter: brightness(1.05); }
.inline { display: inline-block; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 0.5rem; }
.flash { padding: 0.7rem; border-radius: 6px; margin-bottom: 0.8rem; }
.flash-success { background: #ddf5e4; color: #1c6d36; }
.flash-error { background: #fde3e7; color: #882332; }
.hard { color: var(--danger); }
.ok { color: #1b6d35; }
.warning { color: var(--warn); }
.slot { min-height: 60px; background: #fefefe; }
.drop-slot.drag-over { outline: 2px dashed var(--accent); background: #edf8fb; }
.drop-slot.class-drag-highlight { background: #e3f2fb; box-shadow: inset 0 0 0 2px #7fb0cc; }
.lesson-card {
    border: 1px solid hsl(var(--subject-hue, 200) 35% 70%);
    border-left: 5px solid hsl(var(--subject-hue, 200) 60% 45%);
    border-radius: 6px;
    padding: 0.3rem;
    margin: 0.2rem 0;
    background: hsl(var(--subject-hue, 200) 80% 97%);
    display: grid;
    gap: 0.16rem;
    container-type: inline-size;
}
.lesson-card.locked { border-left-color: #7f7f7f; }
.lesson-card.hard-conflict { background: #ffe4e9; border-color: #d04f64; }
.lesson-card.soft-warning { background: #fff5da; border-color: #cea64a; }
.lock-toggle { background: transparent; }
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(145deg, #0f2f44, #133f5b); }
.auth-card { width: min(96vw, 360px); background: #fff; border-radius: 10px; border: 1px solid #d9e1ea; padding: 1rem; }
.muted { color: var(--muted); font-size: 0.86rem; }

.planner-table { table-layout: fixed; }
.planner-table .class-col { min-width: 110px; width: 110px; background: #e8edf4; position: sticky; left: 0; z-index: 2; }
.planner-table .period-col { width: 44px; text-align: center; }
.planner-table .slot { min-height: 78px; }
.planner-table td[colspan=\"2\"] .lesson-card { min-height: 72px; }

.unplaced-pool { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: stretch; }
.pool-dropzone { min-height: 88px; border: 2px dashed #c7d5e1; border-radius: 8px; padding: 0.6rem; background: #fbfdff; }
.pool-dropzone.drag-over { border-color: var(--accent); background: #edf8fb; }
.pool-card {
    --period-span: 1;
    width: clamp(120px, calc(120px * var(--period-span)), 380px);
    cursor: grab;
}
.pool-card:active { cursor: grabbing; }
.mini-link { font-size: 0.78rem; color: #315f79; text-decoration: underline; }
.card-actions { display: flex; gap: 0.25rem; align-items: center; }
.icon-btn {
    width: 1.55rem;
    height: 1.55rem;
    border: 1px solid #9fb8ca;
    border-radius: 6px;
    background: #fff;
    color: #28495f;
    display: inline-grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
}
.icon-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.adaptive-card .card-summary,
.adaptive-card .card-full { display: grid; gap: 0.12rem; }
.adaptive-card .card-summary { display: none; }
.adaptive-card.duration-1 { font-size: 0.82rem; }
.adaptive-card.duration-2 { font-size: 0.9rem; }
.adaptive-card .card-summary strong,
.adaptive-card .card-summary span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-card { cursor: pointer; }

@container (max-width: 180px) {
    .adaptive-card .card-full { display: none; }
    .adaptive-card .card-summary { display: grid; }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 21, 31, 0.55);
    display: grid;
    place-items: center;
    z-index: 40;
    padding: 1rem;
}
.modal-backdrop[hidden] {
    display: none !important;
}
.modal-card {
    width: min(92vw, 560px);
    background: #fff;
    border: 1px solid #c8d3df;
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #e0e6ed;
}
.modal-head h3 { margin: 0; font-size: 1rem; }
.modal-body { padding: 0.8rem; }
.modal-body p { margin: 0.2rem 0; }
.modal-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    padding: 0.7rem 0.8rem;
    border-top: 1px solid #e0e6ed;
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 3; }
    .kpis { grid-template-columns: 1fr; }
    .grid-form { grid-template-columns: 1fr; }
    .planner-table { font-size: 0.8rem; }
    .planner-table .class-col { min-width: 84px; width: 84px; }
    .planner-table .period-col { width: 34px; }
    .pool-card { width: min(100%, 280px); }
}
