:root {
    color-scheme: light;
    --bg: #eef3f1;
    --surface: #ffffff;
    --surface-soft: #f7faf9;
    --ink: #14221f;
    --muted: #63716d;
    --line: #d8e1dd;
    --line-strong: #c7d3ce;
    --accent: #0f6f61;
    --accent-dark: #0a3b35;
    --accent-soft: #e5f2ef;
    --warn: #8a5a00;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(20, 34, 31, 0.08);
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Segoe UI, system-ui, Arial, sans-serif;
    background:
        linear-gradient(180deg, #e8f0ed 0, #f5f7f6 260px),
        var(--bg);
    color: var(--ink);
}

a { color: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    min-height: 118px;
    padding: 28px max(32px, calc((100vw - 1220px) / 2));
    background:
        linear-gradient(135deg, rgba(73, 197, 173, 0.16) 0 36%, transparent 36%),
        #082d28;
    color: #fff;
    border-bottom: 5px solid #49c5ad;
    box-shadow: 0 18px 46px rgba(10, 59, 53, 0.22);
}

.brand {
    display: grid;
    align-items: center;
    gap: 12px;
    min-width: 310px;
    padding-left: 24px;
    border-left: 10px solid #49c5ad;
    font-weight: 800;
    text-decoration: none;
    line-height: 1;
    letter-spacing: 0;
}

.brand-title {
    font-size: 42px;
}

.brand-subtitle {
    margin-top: 7px;
    color: #bdebe1;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

nav {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
}

nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 15px;
    border-radius: 8px;
    color: #edf8f5;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.17);
}

.layout {
    width: min(1220px, calc(100% - 36px));
    margin: 24px auto 60px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metrics div {
    min-height: 86px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(20, 34, 31, 0.05);
}

.metrics strong {
    display: block;
    font-size: 30px;
    line-height: 1.1;
    color: var(--accent-dark);
}

.metrics span, .hint, small {
    color: var(--muted);
}

.warnings {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.warning, .success, .warning-group {
    margin: 0;
    padding: 11px 13px;
    border-radius: var(--radius);
    background: #fff8e8;
    color: var(--warn);
    border: 1px solid #efd38f;
}

.warning.danger {
    background: #fff0ee;
    color: var(--danger);
    border-color: #f1b8b1;
}

.warning-group {
    padding: 0;
    overflow: hidden;
}

.warning-group summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    font-weight: 800;
}

.warning-group ul {
    margin: 0;
    padding: 0 13px 13px 30px;
}

.warning-group li {
    margin: 5px 0;
}

.warning-group.danger {
    background: #fff0ee;
    color: var(--danger);
    border-color: #f1b8b1;
}

.warning-group.info {
    background: #edf7fb;
    color: #23566f;
    border-color: #b8d6e6;
}

.success {
    background: #eaf7ef;
    color: #146c2e;
    border-color: #b8dfc3;
    margin-bottom: 18px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

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

h1, h2, p { margin-top: 0; }
h1 {
    margin-bottom: 12px;
    font-size: 31px;
    line-height: 1.15;
}
h2 {
    margin-bottom: 14px;
    font-size: 21px;
    line-height: 1.2;
}
p { line-height: 1.5; }

.panel, .side-panel, .course-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.panel, .side-panel {
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.side-panel {
    box-shadow: 0 10px 28px rgba(20, 34, 31, 0.06);
}

.narrow { max-width: 780px; }

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.course-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.course-area-list {
    display: grid;
    gap: 14px;
}

.course-area-row {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--area-accent, var(--accent));
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--area-soft, var(--surface-soft)), #fff 58%);
}

.course-area-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.course-area-head h3 {
    margin: 0;
    font-size: 18px;
}

.course-area-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.course-row-scroll {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 220px);
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
}

.course-row-scroll .course-card {
    min-height: 134px;
    scroll-snap-align: start;
}

.course-card.themed {
    border-color: color-mix(in srgb, var(--area-accent, var(--accent)) 26%, var(--line));
    box-shadow: none;
}

.course-card.themed:hover {
    border-color: var(--area-accent, var(--accent));
}

.course-card.themed .area {
    background: var(--area-soft, var(--accent-soft));
    color: var(--area-accent, var(--accent));
}

.card-title {
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.manage-card .row-actions {
    margin-top: 4px;
}

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

.preview-stat {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--accent-dark);
    font-weight: 800;
}

.compact-warnings { margin-bottom: 18px; }

.filter-bar {
    display: grid;
    grid-template-columns: minmax(210px, 1.4fr) repeat(4, minmax(130px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin: 18px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.filter-bar label {
    color: var(--muted);
    font-size: 13px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.result-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-weight: 700;
}

.course-card {
    display: grid;
    gap: 9px;
    padding: 15px;
    text-decoration: none;
    transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.course-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(20, 34, 31, 0.08);
}

.course-note {
    display: inline-flex;
    max-width: 720px;
    margin: 8px 0 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--muted);
    font-weight: 700;
}

.area {
    width: fit-content;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

meter {
    width: 100%;
    height: 10px;
}

.bad { color: var(--danger); font-weight: 800; }

.compact-list {
    display: grid;
    gap: 8px;
}

.compact-list > span, .assign-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.empty {
    color: var(--muted);
    padding: 12px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
    gap: 10px;
    align-items: end;
}

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

.quick-add {
    display: grid;
    gap: 10px;
    margin-bottom: 24px;
}

.decision-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #efd38f;
    border-radius: var(--radius);
    background: #fff8e8;
    color: var(--warn);
}

.decision-box p { margin: 4px 0 0; }

.assignment-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.assignment-list {
    display: grid;
    gap: 10px;
}

.assignment-area {
    display: grid;
    gap: 6px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.assignment-area strong {
    color: var(--accent-dark);
}

.assignment-area a {
    display: block;
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.assignment-area span {
    color: var(--muted);
}

.assignment-area.missing {
    background: #fff9ec;
    border-color: #efd38f;
}

.assignment-area.conflict {
    background: #fff1ef;
    border-color: #f1b8b1;
}

.bulk-assign {
    display: grid;
    gap: 8px;
}

.check-row {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    align-items: start;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.check-row:hover {
    border-color: var(--accent);
    background: var(--surface-soft);
}

.check-row input {
    min-height: auto;
    margin-top: 3px;
    padding: 0;
}

.check-row small {
    display: block;
    margin-top: 2px;
    font-weight: 600;
}

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

.side-panel .two-col {
    grid-template-columns: 1fr;
}

.inline-form {
    grid-template-columns: minmax(220px, 1fr) auto;
}

label {
    display: grid;
    gap: 7px;
    color: var(--accent-dark);
    font-weight: 800;
}

input, select, textarea, button, .button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    padding: 9px 11px;
    font: inherit;
}

input, select, textarea {
    background: #fff;
    color: var(--ink);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(15, 111, 97, 0.22);
    border-color: var(--accent);
}

textarea { resize: vertical; }

button, .button {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

button:hover, .button:hover {
    background: #0b5f53;
}

.ghost {
    background: #fff;
    color: var(--accent);
}

.ghost:hover {
    background: var(--accent-soft);
}

.ghost.danger {
    color: var(--danger);
    border-color: #efc0bb;
}

.link {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    font-size: 13px;
    color: var(--muted);
    background: var(--surface-soft);
    font-weight: 800;
}

tbody tr:hover td {
    background: #fbfdfc;
}

.overview-wrap {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.overview-table { min-width: 980px; }

.overview-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    min-width: 210px;
}

th.sticky-col { background: var(--surface-soft); }

.matrix-cell {
    min-width: 130px;
    max-width: 180px;
    font-size: 14px;
}

.matrix-cell a {
    display: inline-block;
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.matrix-cell.missing {
    background: #fff9ec;
    color: var(--warn);
}

.matrix-cell.missing span { color: var(--warn); }

.matrix-cell.conflict {
    background: #fff1ef;
    color: var(--danger);
}

.matrix-cell.conflict a {
    display: block;
    color: var(--danger);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.ok {
    background: #eaf7ef;
    color: #146c2e;
}

.status-pill.warn {
    background: #fff7e0;
    color: var(--warn);
}

.status-pill.danger {
    background: #fff0ee;
    color: var(--danger);
}

.destructive-footer {
    width: min(1220px, calc(100% - 36px));
    margin: 0 auto 42px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.destructive-footer form {
    display: flex;
    justify-content: flex-end;
}

.delete-all-names {
    width: auto;
    min-width: 230px;
    background: #e00000;
    border-color: #e00000;
    color: #fff;
    box-shadow: 0 12px 28px rgba(224, 0, 0, 0.18);
}

.delete-all-names:hover {
    background: #b80000;
    border-color: #b80000;
}

@media (max-width: 860px) {
    .topbar, .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        min-height: auto;
        padding: 20px 22px;
    }

    .brand { font-size: 28px; }

    nav { justify-content: flex-start; }

    .metrics, .split, .form-grid, .inline-form, .two-col, .filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .destructive-footer form {
        justify-content: stretch;
    }

    .delete-all-names {
        width: 100%;
    }
}
