:root {
    --primary: #5145f5;
    --primary-dark: #3f35d8;
    --navy: #172554;
    --muted: #718096;
    --border: #e2e8f0;
    --surface: #ffffff;
    --light: #f5f7ff;
    --danger: #c63737;
    --success: #0f8a61;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    background: #f8faff;
    color: var(--navy);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(81, 69, 245, .22);
    outline-offset: 2px;
}

.topbar {
    min-height: 68px;
    padding: 12px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--surface);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--navy);
    font-size: 18px;
    font-weight: 900;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 25px; }

.nav { display: flex; align-items: center; gap: 19px; }
.nav a { color: var(--muted); font-size: 13px; font-weight: 700; }
.nav a.active { color: var(--primary); }
.nav form { margin: 0; }

.page { width: min(1220px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 55px; }
.page-narrow { width: min(1000px, calc(100% - 36px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 5px; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: 1.2px; }
.muted { color: var(--muted); }
.page-heading .muted, .card-heading .muted, .card > .muted { margin: 4px 0 0; font-size: 13px; }

.card {
    margin-bottom: 24px;
    padding: 23px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
    box-shadow: 0 7px 24px rgba(23, 37, 84, .035);
}
.card h2 { margin: 0 0 8px; font-size: 19px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.card-heading h2 { margin-bottom: 0; }

.stack { display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1.25fr .8fr; gap: 17px; }
.course-form { display: grid; gap: 20px; }
.inline-form { display: flex; align-items: flex-end; gap: 15px; margin-top: 20px; }
.grow { flex: 1; }

label { display: block; }
label > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
label small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; font-weight: 400; }
label > span small { display: inline; margin: 0; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--navy);
    transition: border-color .15s, box-shadow .15s;
}
input, select { height: 46px; padding: 0 12px; }
textarea { min-height: 300px; padding: 13px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(81, 69, 245, .08); outline: none; }
input::placeholder, textarea::placeholder { color: #a0abc0; }
.json-field textarea { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }

.button {
    min-height: 43px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
}
.button:hover { text-decoration: none; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--primary); }
.course-form > .button { justify-self: start; min-width: 140px; }

.link-button, .danger-link {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}
.danger-link { color: var(--danger); }
.link-button:hover, .danger-link:hover { text-decoration: underline; }

.alert { margin-bottom: 20px; padding: 13px 15px; border-radius: 11px; font-size: 13px; }
.alert-error { border: 1px solid #f2c6c6; background: #fff1f1; color: #a82d2d; }
.alert-success { border: 1px solid #bce7d7; background: #eefbf5; color: var(--success); }

.json-help { margin-top: -7px; }
.json-help summary { color: var(--primary); cursor: pointer; font-size: 12px; font-weight: 700; }
.json-help pre { padding: 15px; border-radius: 10px; overflow-x: auto; background: #111a3a; color: #e8ebff; font-size: 11px; }
.json-help .muted { font-size: 11px; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 10px; letter-spacing: .6px; text-align: left; text-transform: uppercase; }
td { padding: 14px 12px; border-bottom: 1px solid #edf1f7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.actions { display: flex; align-items: center; gap: 13px; white-space: nowrap; }
.actions form { display: inline-flex; }
.badge { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 99px; background: var(--light); color: var(--primary); font-size: 9px; font-weight: 800; }
code { padding: 2px 5px; border-radius: 5px; background: var(--light); color: var(--primary); }
.empty-state { padding: 30px 15px; color: var(--muted); text-align: center; }

.login-page { min-height: 100vh; padding: 25px; display: grid; place-items: center; background: linear-gradient(145deg, #f5f7ff, #fff); }
.login-card { width: min(420px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: 0 18px 50px rgba(23, 37, 84, .08); }
.login-card h1 { margin: 0 0 8px; font-size: 28px; }
.login-card > .muted { margin: 0 0 22px; font-size: 13px; }
.brand-mark { width: 54px; height: 54px; margin-bottom: 18px; border-radius: 15px; display: grid; place-items: center; background: var(--light); font-size: 29px; }

@media (max-width: 850px) {
    .form-grid { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .nav { width: 100%; flex-wrap: wrap; gap: 13px; }
}

@media (max-width: 600px) {
    .page, .page-narrow { width: min(100% - 24px, 1220px); padding-top: 25px; }
    .topbar { padding: 13px 17px; }
    .page-heading, .card-heading { align-items: stretch; flex-direction: column; }
    .page-heading .button { align-self: flex-start; }
    .card { padding: 17px; border-radius: 14px; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .login-card { padding: 24px; }
    .actions { gap: 10px; }
}
