:root {
    --bg: #f4f1ea;
    --surface: #fffdf8;
    --surface-strong: #f7f0e2;
    --line: #d9cdb6;
    --text: #2f2419;
    --muted: #6f6251;
    --brand: #9d3d1f;
    --brand-dark: #6f2813;
    --accent: #d7a84b;
    --success: #2e6b45;
    --danger: #9d2f2f;
    --shadow: 0 20px 45px rgba(70, 48, 26, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(215, 168, 75, 0.18), transparent 30%),
        linear-gradient(180deg, #fbf8f1 0%, var(--bg) 100%);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-dark);
}

.shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.brand {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

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

.nav a,
.nav button {
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.9);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}

.nav a:hover,
.nav button:hover {
    background: var(--surface-strong);
}

.card {
    background: var(--surface);
    border: 1px solid rgba(217, 205, 182, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.stack {
    display: grid;
    gap: 18px;
}

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

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

.hero {
    margin-bottom: 20px;
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.panel-title {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.muted {
    color: var(--muted);
}

.flash,
.errors {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid;
}

.flash {
    color: var(--success);
    background: #eef8f0;
    border-color: #b8d8c0;
}

.errors {
    color: var(--danger);
    background: #fdf1f1;
    border-color: #e1b8b8;
}

.errors .list-clean {
    gap: 6px;
}

form {
    display: grid;
    gap: 16px;
}

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

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

fieldset {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    background: rgba(247, 240, 226, 0.35);
}

legend {
    padding: 0 8px;
    font-weight: 700;
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.96rem;
}

.field-note {
    color: var(--muted);
    font-size: 0.88rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    background: var(--brand);
    color: #fff;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
    color: #fff;
}

.button.secondary,
button.secondary {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--line);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.student-list {
    display: grid;
    gap: 16px;
}

.student-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(247, 240, 226, 0.35);
    padding: 18px;
}

.student-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.student-card-title {
    margin: 0;
    font-size: 1.05rem;
}

.button.ghost,
button.ghost {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--line);
}

.button.ghost:hover,
button.ghost:hover {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid #efe6d7;
    vertical-align: top;
}

th {
    background: #f6efe3;
    color: var(--muted);
    font-size: 0.92rem;
}

tr:last-child td {
    border-bottom: none;
}

.list-clean {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    background: linear-gradient(180deg, #fffdf8 0%, #f7efe2 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
}

.stat strong {
    display: block;
    margin-top: 6px;
    font-size: 1.35rem;
}

.empty {
    padding: 16px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    color: var(--muted);
    background: rgba(255,255,255,0.5);
}

@media (max-width: 900px) {
    .grid-2,
    .grid-3,
    .stat-row,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
}
