:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface-2: #243044;
    --border: #2d3a4f;
    --text: #e8edf5;
    --muted: #9aa8bc;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 10px;
    --font: "Instrument Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: linear-gradient(160deg, #0b1020 0%, #121a2b 45%, #0f1419 100%);
    color: var(--text);
    min-height: 100vh;
}

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

.shell { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.brand { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-weight: 500; }

.nav { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.nav a {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid transparent;
}
.nav a.active, .nav a:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }

h1, h2, h3 { margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: #3f1d24; border-color: #7f1d1d; color: #fecaca; }

.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.form-row .help { color: var(--muted); font-size: 0.82rem; margin-top: 0.3rem; line-height: 1.4; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], input[type="color"], select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0f1724;
    color: var(--text);
    font: inherit;
}

textarea { min-height: 90px; resize: vertical; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: #132a1d;
    border: 1px solid #166534;
    color: #bbf7d0;
    margin-bottom: 1rem;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Profile editor */
.profile-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .profile-layout { grid-template-columns: 1fr; }
}

.module-nav {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

.module-nav a {
    display: block;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}
.module-nav a:hover { background: var(--surface-2); color: var(--text); }

.module-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: visible;
    position: relative;
}

.module-card:has(.help-hint:hover),
.module-card:has(.help-hint:focus-within),
.module-card:has(.help-hint.is-open) {
    z-index: 10;
}

.module-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    cursor: pointer;
}

.module-card header h3 { margin: 0; font-size: 1rem; }
.module-card .body { padding: 1rem; display: none; }
.module-card.open .body { display: block; }

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.repeater-item {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    background: #111827;
}

.repeater-item .item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: #1e3a5f;
    color: #bfdbfe;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card { width: min(420px, 100%); }

code {
    background: #0f1724;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Help hints (? tooltips) */
.help-hint {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    flex-shrink: 0;
    cursor: help;
    outline: none;
    z-index: 1;
}

.help-hint:hover,
.help-hint:focus-within,
.help-hint.is-open {
    z-index: 1000;
}

.form-row:has(.help-hint:hover),
.form-row:has(.help-hint:focus-within),
.form-row:has(.help-hint.is-open),
.legend-with-help:has(.help-hint:hover),
.legend-with-help:has(.help-hint:focus-within),
.legend-with-help:has(.help-hint.is-open),
.module-title-row:has(.help-hint:hover),
.module-title-row:has(.help-hint:focus-within),
.module-title-row:has(.help-hint.is-open) {
    position: relative;
    z-index: 2;
}

.help-hint__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    color: #bfdbfe;
    background: #1e3a5f;
    border: 1px solid #3b82f6;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.help-hint--md .help-hint__icon {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.8rem;
}

.help-hint__icon--inline {
    width: 1rem;
    height: 1rem;
    font-size: 0.65rem;
    vertical-align: middle;
}

.help-hint:hover .help-hint__icon,
.help-hint:focus-visible .help-hint__icon,
.help-hint.is-open .help-hint__icon {
    background: var(--accent);
    color: #fff;
    transform: scale(1.05);
}

.help-hint__tooltip {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: min(300px, calc(100vw - 1.5rem));
    max-width: 300px;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    background: #0f1724;
    border: 1px solid var(--accent);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text);
    text-align: left;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

.help-hint__title {
    display: block;
    font-weight: 600;
    color: #93c5fd;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}

.help-hint__text {
    display: block;
    color: #cbd5e1;
}

.help-hint.is-positioned .help-hint__tooltip,
.help-hint.is-open .help-hint__tooltip {
    opacity: 1;
    visibility: visible;
}

.label-with-help {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.label-with-help__text {
    line-height: 1.3;
}

.module-title-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.module-title-row h3 {
    margin: 0;
}

.module-intro {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.75rem 0.85rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    background: #132238;
    border: 1px solid #1e3a5f;
}

.module-intro__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    color: #bfdbfe;
    background: #1e3a5f;
    border: 1px solid #3b82f6;
}

.module-intro p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.subsection-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.75rem 0;
}

.subsection-fieldset--dashed {
    border-style: dashed;
}

.legend-with-help,
.subsection-heading {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.subsection-heading {
    margin: 0.75rem 0 0.5rem;
    font-size: 0.95rem;
}

.module-nav__title {
    display: block;
    margin-bottom: 0.35rem;
}

.module-nav__hint {
    margin: 0 0 0.65rem;
    line-height: 1.4;
}

.module-nav__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.module-nav__item a {
    flex: 1;
    min-width: 0;
}

.toggle-with-help {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
