:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1d2129;
    --muted: #5f6673;
    --border: #d9dce1;
    --accent: #2f5bea;
    --accent-hover: #2449c4;
    --error-bg: #fdecec;
    --error-text: #a32020;
    --success-bg: #e8f6ee;
    --success-text: #1e6b3d;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111317;
        --card: #1b1e24;
        --text: #e6e8eb;
        --muted: #9aa1ad;
        --border: #2f343c;
        --accent: #6b8cff;
        --accent-hover: #87a1ff;
        --error-bg: #3a1c1c;
        --error-text: #ffb4b4;
        --success-bg: #17301f;
        --success-text: #9fe0b5;
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 16px;
}

.card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}

h1 { font-size: 1.5rem; margin: 0 0 16px; }

label { display: block; font-weight: 500; margin: 16px 0 6px; }

input[type="email"], input[type="password"], input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

button {
    width: 100%;
    margin-top: 24px;
    padding: 11px 16px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

button:hover { background: var(--accent-hover); }

button.secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }
button.secondary:hover { background: var(--bg); }

a { color: var(--accent); }

.muted { color: var(--muted); font-size: 0.9rem; margin-top: 20px; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 0.95rem; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* Symfony form errors */
form ul { list-style: none; padding: 0; margin: 6px 0 0; color: var(--error-text); font-size: 0.9rem; }

.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 8px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

/* Two-factor authentication */
h2 { font-size: 1.1rem; margin: 28px 0 4px; }

a.button {
    display: block;
    margin-top: 24px;
    padding: 11px 16px;
    text-align: center;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border-radius: 8px;
    text-decoration: none;
}
a.button:hover { background: var(--accent-hover); }

label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }

.steps { padding-left: 20px; }
.qr { display: block; margin: 16px auto; background: #fff; padding: 12px; border-radius: 8px; }
.secret { margin-bottom: 8px; font-size: 0.9rem; }
.secret code { display: block; margin-top: 8px; overflow-wrap: anywhere; }

.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.codes code { font-size: 1rem; }

/* ---- Admin (Phase 6) ---------------------------------------------------- */

.admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
    padding: 12px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.admin-header .brand { margin: 0; color: var(--text); text-decoration: none; }
.admin-nav { display: flex; gap: 16px; flex: 1; }
.admin-nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.admin-nav a.active, .admin-nav a:hover { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.admin-account { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.admin-main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.admin-main h2 { font-size: 1.15rem; margin: 0; }
.admin-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 16px; }
.admin-title h1 { margin: 0; }

.admin-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.admin-panel.narrow { max-width: 480px; }

.admin-main button, .admin-main .button { width: auto; margin-top: 0; }
.admin-panel form button[type="submit"]:last-child { margin-top: 24px; }
.admin-panel .actions form button[type="submit"] { margin-top: 0; }
.button {
    display: inline-block;
    padding: 9px 16px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border-radius: 8px;
    text-decoration: none;
}
.button:hover { background: var(--accent-hover); }
.button.secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }
button.danger { background: var(--error-text); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.filters input, .filters select {
    width: auto;
    padding: 8px 10px;
    font: inherit;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.filters label.inline { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .context { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: var(--muted); max-width: 360px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; margin: 0 4px 2px 0; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--error-bg); color: var(--error-text); }
.badge-info { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-muted { background: var(--bg); color: var(--muted); }

.pagination { display: flex; align-items: center; gap: 16px; margin-top: 16px; color: var(--muted); font-size: 0.9rem; }

/* Checkbox rows rendered by Symfony forms */
.admin-panel input[type="checkbox"] { margin: 20px 8px 0 0; }
.admin-panel input[type="checkbox"] + label { display: inline; font-weight: 500; }
.admin-panel .help-text, .admin-panel small { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* Admin: OIDC clients */
.uri { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.secret-value { display: block; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow-wrap: anywhere; user-select: all; }
.admin-panel textarea { width: 100%; padding: 10px 12px; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; }

/* ---- Sessions (Phase 5) ------------------------------------------------- */

.sessions { list-style: none; padding: 0; margin: 16px 0; }
.session { padding: 12px 0; border-bottom: 1px solid var(--border); }
.session:last-child { border-bottom: 0; }
.session-title { font-weight: 600; }
.session-meta { margin-top: 2px; font-size: 0.85rem; }
.session form button { width: auto; margin-top: 8px; padding: 6px 12px; }
