:root {
    --ink: #211a4a;
    --midnight: #171333;
    --blue: #6574ff;
    --lavender: #b7bfff;
    --muted: #6d6c82;
    --paper: #fafafe;
    --line: #e4e3ed;
    --surface: #ffffff;
    --font: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.6;
}
a { color: inherit; }
button, a.button-primary { font: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.skip-link {
    position: absolute;
    left: 12px;
    top: -40px;
    background: #fff;
    padding: 8px 12px;
    z-index: 20;
}
.skip-link:focus { top: 8px; }

.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 12px 20px;
    background: linear-gradient(125deg, #171333, #211a4a 70%);
    color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 0 4px #6574ff33;
}
.brand-title { display: block; font-weight: 700; letter-spacing: -0.3px; }
.brand-subtitle { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
.header-status { margin: 0 auto 0 12px; font-size: 12px; color: #d6d3e9; }
.header-actions { display: flex; gap: 8px; }
.header-button, .nav-toggle {
    background: transparent;
    color: #fff;
    border: 1px solid #ffffff40;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    text-decoration: none;
}
.logout-form { display: inline; margin: 0; }
.guest-shell .app-header { position: sticky; top: 0; }
.guest-main { max-width: 720px; margin: 0 auto; }
.auth-panel { max-width: 460px; }
.auth-form { margin: 0; }
.auth-field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.auth-field input {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}
.auth-error { margin: 0; color: #8b1e3f; font-size: 14px; }
button.button-primary {
    border: 0;
    cursor: pointer;
}
.nav-toggle { display: none; }

.app-body { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 72px); }
.app-nav { background: #fff; border-right: 1px solid var(--line); padding: 20px 12px; }
.nav-label {
    margin: 0 12px 10px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}
.app-nav ul { list-style: none; margin: 0; padding: 0; }
.app-nav a {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
}
.app-nav a.is-active, .app-nav a:hover { background: #eeeefa; }
.nav-status { font-size: 11px; color: var(--muted); }

.app-main-wrap { padding: 24px 28px 48px; }
.breadcrumb { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.page-header h1 { margin: 8px 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -1px; line-height: 1.15; }
.eyebrow {
    margin: 0;
    color: #5759b1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.lede, .meta { color: var(--muted); }
.status-text { font-weight: 650; }
.panel, .module-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px 22px;
    margin: 16px 0;
}
.plain-list { margin: 0; padding-left: 20px; }
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.module-card { margin: 0; }
.module-card h3 { margin: 0 0 8px; }
.button-primary {
    display: inline-flex;
    align-items: center;
    min-height: 46px;
    padding: 10px 18px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font-weight: 650;
}
.nav-backdrop { display: none; }

.drawer {
    position: fixed;
    inset: 0;
    background: #17133366;
    z-index: 30;
}
.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 100%);
    height: 100%;
    background: #fff;
    overflow: auto;
    padding: 20px;
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.drawer-header button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}
.help-content h2, .help-content h3 { margin-top: 1.4em; }
.helper-boundary { background: #eeeefa; border-radius: 12px; padding: 12px; }
.helper-prompts { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.helper-prompts button {
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
}
.helper-answer { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.helper-note { color: var(--muted); font-size: 13px; }
.banner { border-color: #c8c4e6; background: #f4f3fb; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table caption {
    caption-side: top;
    text-align: left;
    font-weight: 650;
    margin-bottom: 8px;
}
.data-table th, .data-table td {
    text-align: left;
    vertical-align: top;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
}
.data-table th { font-size: 13px; color: var(--muted); }
.auth-field select {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    width: 100%;
}
.admin-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.admin-actions form { margin: 0; }
.role-list { list-style: none; margin: 0; padding: 0; }
.role-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }

@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .header-status { display: none; }
    .app-body { grid-template-columns: 1fr; }
    .app-nav {
        position: fixed;
        inset: 72px auto 0 0;
        width: min(280px, 88vw);
        z-index: 25;
        transform: translateX(-110%);
        transition: transform 0.2s ease;
    }
    .app-nav.is-open { transform: translateX(0); }
    .nav-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 72px 0 0;
        background: #17133355;
        z-index: 24;
    }
    .app-main-wrap { padding: 18px 16px 40px; }
}
