:root {
    --bg: #eef2ee;
    --bg-deep: #071018;
    --ink: #12202b;
    --muted: #5d6b74;
    --line: #d7dfd8;
    --card: #ffffff;
    --teal: #128f82;
    --teal-deep: #0b5f57;
    --mint: #1ec8b2;
    --gold: #e0a84a;
    --ok: #1a7a4c;
    --warn: #9a6a12;
    --err: #b42318;
    --shadow: 0 18px 50px rgba(7, 16, 24, 0.08);
    --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Sora, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% -10%, rgba(30, 200, 178, 0.16), transparent 34%),
        radial-gradient(circle at 90% 0%, rgba(224, 168, 74, 0.12), transparent 28%),
        var(--bg);
    line-height: 1.5;
}
h1, h2, .brand { font-family: Fraunces, Georgia, serif; font-weight: 650; letter-spacing: -0.03em; }
a { color: var(--teal-deep); }
.muted { color: var(--muted); }
.eyebrow {
    display: inline-flex;
    margin: 0 0 12px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(18, 143, 130, 0.1);
    color: var(--teal-deep);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-size: 22px;
}
.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(160deg, var(--mint), var(--teal-deep));
    box-shadow: 0 8px 18px rgba(18, 143, 130, 0.28);
}
.brand-mark svg { display: block; }

.page-guest { min-height: 100vh; }
.guest-shell { max-width: 1180px; margin: 0 auto; padding: 22px 20px 72px; }
.topbar, .public-head, .cabinet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.topbar-nav { display: flex; gap: 18px; align-items: center; }
.topbar-nav a:not(.btn) { color: var(--ink); text-decoration: none; font-weight: 500; }
.guest-main { padding-top: 28px; }

.hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 36px;
    align-items: center;
    padding: 36px 40px;
    border-radius: 32px;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.08), transparent 40%),
        var(--bg-deep);
    color: #eef6f3;
    overflow: hidden;
    position: relative;
}
.hero::after {
    content: "";
    position: absolute;
    right: -80px;
    bottom: -80px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(30, 200, 178, 0.28), transparent 68%);
}
.hero h1 { font-size: clamp(36px, 6vw, 62px); line-height: 0.98; margin: 0 0 16px; color: #fff; }
.lead { font-size: 18px; max-width: 540px; color: #b7c4c0; }
.hero-copy { position: relative; z-index: 1; }
.hero-preview {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 16px;
    backdrop-filter: blur(16px);
}
.mini-grid { display: grid; grid-template-columns: 54px repeat(3, 1fr); gap: 8px; }
.mini-grid span {
    min-height: 46px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    font-size: 11px;
    padding: 8px;
    color: #d5e6e1;
}
.mini-grid .h { background: transparent; color: #8aa39b; }
.mini-grid .fill { background: linear-gradient(180deg, rgba(30,200,178,0.28), rgba(30,200,178,0.08)); }

.hero-actions, .form-links { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.feature-grid, .stat-grid, .form-grid, .split { display: grid; gap: 16px; }
.feature-grid { grid-template-columns: repeat(4, 1fr); margin-top: 28px; }
.feature-grid article, .stat-grid article, .stat-card, .panel, .auth-card, .year-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.feature-grid h2 { margin: 8px 0 8px; font-size: 22px; }
.feature-grid p { margin: 0; color: var(--muted); }
.feature-num { font-size: 13px; font-weight: 600; color: var(--teal); }
.stat-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; }
.stat-grid article, .stat-card {
    background:
        linear-gradient(180deg, #fff, #f6fbf9);
}
.stat-card { color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(7, 16, 24, 0.12); border-color: var(--teal); }
.stat-grid strong { display: block; font-size: 36px; font-family: Fraunces, serif; }
.split { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
.stack { display: grid; align-content: start; gap: 0; min-width: 0; max-width: 100%; }
.stack > * { min-width: 0; max-width: 100%; }
.form-grid { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: 1 / -1; }

.btn, .btn-ghost, .btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: linear-gradient(180deg, #17a898, var(--teal-deep));
    color: #f4fffc;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    box-shadow: 0 10px 22px rgba(11, 95, 87, 0.22);
}
.btn:hover { filter: brightness(1.05); }
.btn-ghost {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    box-shadow: none;
    opacity: 0.9;
}
.page-guest .hero .btn-ghost { color: #eef6f3; border-color: rgba(255,255,255,0.24); }
.btn-small { padding: 8px 13px; font-size: 14px; box-shadow: none; }
.btn-danger, .btn.btn-danger {
    background: linear-gradient(180deg, #d4544a, #9d2b24);
    box-shadow: none;
    color: #fff;
}
.link-btn {
    background: none;
    border: 0;
    color: #9a4d1c;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.form { display: grid; gap: 12px; }
.form label, .filters label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.form textarea,
.form input, .form select, .filters select, .copy-row input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 13px;
    font: inherit;
    background: #fbfdfb;
}
.form textarea { min-height: 160px; resize: vertical; font-family: inherit; }
.panel-import { margin-top: 28px; padding: 16px 18px; }
.panel-import h2 { margin: 0; font-size: 20px; }
.import-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.import-hint { margin: 6px 0 10px; font-size: 13px; overflow-wrap: anywhere; }
.import-form { gap: 8px; }
.import-form textarea { min-height: 88px; max-width: 100%; padding: 8px 10px; }
.panel-import textarea[rows="8"] { min-height: 160px; }
.import-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.roster-clear { margin-top: 12px; }
.import-file { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; flex: 1; }
.import-file input { width: 100%; max-width: 100%; padding: 6px 8px; }
.form textarea:focus, .form input:focus, .form select:focus, .filters select:focus {
    outline: 3px solid rgba(18, 143, 130, 0.18);
    border-color: var(--teal);
}
.form input[type="color"] { height: 44px; padding: 4px; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { width: auto; }
.field-error { color: var(--err); font-size: 13px; }
.flash { padding: 12px 14px; border-radius: 14px; margin: 12px 0; }
.flash-success { background: #e5f6ec; color: var(--ok); }
.flash-error { background: #fdecec; color: var(--err); }
.flash-warning { background: #fff4dc; color: var(--warn); }

.auth-card { max-width: 460px; margin: 24px auto; }
.auth-wide { max-width: 760px; }

.page-cabinet { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; background: var(--bg); }
.sidebar {
    background: var(--bg-deep);
    color: #d7e6e1;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sidebar .brand { color: #fff; }
.sidebar-org { margin: 4px 8px 14px; color: #8ea39c; font-size: 13px; }
.side-nav { display: grid; gap: 4px; }
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c9d8d3;
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 12px;
}
.side-nav a svg { opacity: 0.7; flex: 0 0 auto; }
.side-nav a.is-active, .side-nav a:hover {
    background: rgba(30, 200, 178, 0.12);
    color: #fff;
}
.side-nav a.is-active svg { opacity: 1; color: var(--mint); }
.nav-label {
    margin: 14px 10px 4px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6f827c;
}
.sidebar-exit { margin-top: auto; padding-top: 16px; }
.sidebar-exit .btn-ghost { color: #d7e6e1; border-color: rgba(255,255,255,0.14); width: 100%; }
.cabinet-wrap { padding: 28px 32px 48px; }
.cabinet-head h1 { margin: 0; font-size: 34px; }
.cabinet-main { margin-top: 18px; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.list-head h2 { margin: 0; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.table-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin: 0 0 14px;
    padding: 12px;
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: 16px;
}
.table-filters label {
    display: grid;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}
.table-filters input,
.table-filters select {
    min-width: 140px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 10px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}
.table-filters input:focus,
.table-filters select:focus {
    outline: 3px solid rgba(18, 143, 130, 0.18);
    border-color: var(--teal);
}
.filter-search { flex: 1 1 220px; min-width: 180px; }
.filter-search input { width: 100%; min-width: 0; }
.num-col { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.check-col { width: 36px; text-align: center; }
.check-col input { width: auto; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }
.pager a, .pager span {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    background: #fff;
}
.pager a:hover { border-color: var(--teal); color: var(--teal-deep); }
.pager .is-current { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }
.table-wrap { overflow: auto; border-radius: 16px; }
.table, .timetable { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; }
.table th, .table td, .timetable th, .timetable td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}
.table th { background: #f3f7f5; }
.nowrap { white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }
.row-actions form { margin: 0; }
.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.icon-btn:hover { border-color: var(--teal); color: var(--teal-deep); }
.icon-btn-danger { color: var(--err); }
.icon-btn-danger:hover { border-color: var(--err); background: #fdecec; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.year-card { margin-bottom: 12px; }
.badge { background: #e5f6f2; color: var(--teal-deep); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.toolbar, .copy-row, .filters, .pills { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.schedule-tools { margin: 0 0 16px; }
.filters {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.pills a {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
}
.pills a.is-active { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }
.schedule-views { margin: 0 0 16px; }
.steps { padding-left: 20px; }
.compact { margin-top: 10px; }
.inline-edit { position: relative; }
.inline-edit summary { list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit .form.compact {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 4;
    min-width: 240px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.timetable { min-width: 720px; table-layout: fixed; overflow: hidden; border-radius: 18px; }
.timetable thead th { background: var(--bg-deep); color: #e8f4f0; font-weight: 500; border-color: #1a2a32; }
.timetable tbody th { background: #f4f8f6; color: var(--ink); width: 96px; }
.timetable tbody th small, .timetable tbody th span { display: block; }
.cell { cursor: pointer; min-height: 78px; height: 88px; position: relative; background: #fcfffd; }
.cell:hover { background: #eef8f5; }
.cell .plus { color: #b7c4be; font-size: 22px; display: block; text-align: center; padding-top: 22px; }
.cell em, .public-table em {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    border-radius: 0 4px 4px 0;
}
.cell b, .public-table b { display: block; }
.cell span, .public-table span, .public-table small { color: var(--muted); font-size: 13px; }
.table-wrap-all { max-height: calc(100vh - 220px); }
.timetable-all {
    min-width: 0;
    width: max-content;
    table-layout: auto;
    font-size: 12px;
    overflow: visible;
    border-radius: 0;
}
.timetable-all thead th {
    text-align: center;
    padding: 6px 4px;
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.timetable-all .day-head { letter-spacing: 0.02em; }
.timetable-all .slot-num {
    width: 46px;
    min-width: 46px;
    font-weight: 500;
    font-size: 11px;
    color: #d5e6e1;
}
.timetable-all .sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 88px;
    width: 88px;
    background: #f4f8f6;
    vertical-align: middle;
}
.timetable-all thead .sticky-col {
    z-index: 4;
    background: var(--bg-deep);
    color: #e8f4f0;
}
.timetable-all .sticky-col a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}
.timetable-all .sticky-col a:hover { color: var(--teal-deep); }
.timetable-all .day-start { border-left: 2px solid #1a2a32; }
.cell-compact {
    min-height: 40px;
    height: 46px;
    width: 46px;
    max-width: 56px;
    padding: 3px 4px 3px 8px !important;
    overflow: hidden;
}
.cell-compact .plus { font-size: 13px; padding-top: 8px; }
.cell-compact b {
    font-size: 11px;
    line-height: 1.15;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-compact i {
    display: block;
    font-style: normal;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.public-table td, .public-table th { position: relative; }
.public-meta { color: var(--muted); }

.modal { border: 0; border-radius: 22px; padding: 0; width: min(460px, 92vw); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(7, 16, 24, 0.55); }
.modal .form { padding: 22px; }
.modal-wide { width: min(680px, 94vw); }
.modal-wide .form { padding: 0; }
.modal-body { padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h2 { margin: 0 0 4px; }
.modal-head .muted { margin: 0; }
.badge.is-empty { background: #eef1ef; color: var(--muted); font-weight: 500; }
.load-hint { margin: 10px 0 0; font-size: 13px; }
.load-add {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 92px auto;
    align-items: end;
    margin: 16px 0 12px;
}
.load-add .btn { height: 44px; }
.load-group { margin-top: 14px; }
.load-group h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-family: Sora, "Segoe UI", sans-serif;
    font-weight: 600;
    letter-spacing: 0;
}
.load-group h3 small { color: var(--muted); font-weight: 500; }
.load-group ul { list-style: none; margin: 0; padding: 0; }
.load-group li {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 78px 18px 32px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.load-hours {
    width: 78px;
    text-align: right;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 8px;
    font: inherit;
    background: #fbfdfb;
}
.load-hours:focus {
    outline: 3px solid rgba(18, 143, 130, 0.18);
    border-color: var(--teal);
}
.load-total-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.load-total {
    margin: 0;
    font-weight: 600;
}
.load-empty { margin: 8px 0 0; }
.load-import {
    margin: 4px 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f7faf8;
}
.load-import h3 {
    margin: 0;
    font-size: 16px;
    font-family: Sora, "Segoe UI", sans-serif;
    font-weight: 600;
    letter-spacing: 0;
}
.load-import .import-hint { margin: 6px 0 10px; }
.load-import .import-form { gap: 8px; }
.load-import-result { margin: 8px 0 0; font-size: 13px; }
.load-import-result.is-ok { color: var(--ok); }
.load-import-result.is-error { color: var(--err); }

.page-public { max-width: 1100px; margin: 0 auto; padding: 28px 20px 48px; }
.public-foot { margin-top: 28px; color: var(--muted); font-size: 13px; }

@media (max-width: 980px) {
    .hero, .feature-grid, .stat-grid, .split, .form-grid { grid-template-columns: 1fr; }
    .page-cabinet { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 5; }
    .side-nav { grid-template-columns: repeat(2, 1fr); }
    .cabinet-wrap { padding: 18px; }
}

@media (max-width: 720px) {
    .load-add { grid-template-columns: 1fr; }
}

@media print {
    .public-head button, .filters, .public-foot { display: none !important; }
    body { background: #fff; }
    .timetable thead th { background: #eee !important; color: #000 !important; }
}
