:root {
    --bg: #0e0c17;
    --bg-2: #141123;
    --panel: #1a1630;
    --panel-2: #221d40;
    --border: #322b58;
    --border-soft: #272148;

    --text: #ece8f8;
    --muted: #9d94c0;

    --gold: #d4a53d;
    --gold-light: #f3d27a;
    --accent: #8b6cf7;
    --accent-strong: #7250f0;
    --accent-soft: rgba(139, 108, 247, 0.16);

    --danger: #e5566c;
    --danger-soft: rgba(229, 86, 108, 0.14);
    --success: #45cf8f;
    --success-soft: rgba(69, 207, 143, 0.14);

    --solarius: #e25563;
    --aeris: #f2c94c;
    --tellurik: #58b368;
    --hydralis: #5b9dff;

    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 264px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-brand: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
}

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

h1, h2, h3 { margin: 0; font-weight: 650; }
p { margin: 0.4em 0; }

.mono { font-family: Consolas, "Courier New", monospace; font-size: 0.92em; letter-spacing: 0.03em; }
.muted { color: var(--muted); font-weight: 400; }

.icon { vertical-align: -0.18em; flex-shrink: 0; }

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #171233 0%, #100d1f 100%);
    border-right: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.brand {
    padding: 26px 16px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(139, 108, 247, 0.12), transparent);
}

.brand-logo { width: 96px; height: auto; filter: drop-shadow(0 4px 14px rgba(212, 165, 61, 0.35)); }

.brand-title {
    margin-top: 10px;
    font-family: var(--font-brand);
    font-size: 1.12rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-light);
    line-height: 1.35;
}

.nav { flex: 1; padding: 14px 10px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--accent-soft); color: var(--text); }

.nav-link.active {
    background: linear-gradient(90deg, var(--accent-soft), transparent);
    color: var(--gold-light);
    box-shadow: inset 3px 0 0 var(--gold);
}

.nav-group { margin-top: 10px; }
.nav-group summary::-webkit-details-marker { display: none; }

.nav-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 4px;
    cursor: pointer;
    list-style: none;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    user-select: none;
}

.nav-group-title:hover { color: var(--gold-light); }
.nav-group-title .icon { transition: transform 0.2s; }
.nav-group:not([open]) .nav-group-title .icon { transform: rotate(-90deg); }
.nav-group-items { padding-left: 4px; }

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip { display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #1a1230;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--muted); font-size: 0.78rem; }

.btn-logout { width: 100%; justify-content: center; color: var(--muted); }
.btn-logout:hover { color: var(--danger); background: var(--danger-soft); }

.main {
    flex: 1;
    min-width: 0;
    padding: 32px 38px 64px;
    background:
        radial-gradient(ellipse 60% 40% at 80% 0%, rgba(139, 108, 247, 0.07), transparent),
        var(--bg);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gold-light);
    font-family: var(--font-brand);
    letter-spacing: 0.02em;
}

.page-sub { color: var(--muted); margin-top: 4px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

.card {
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 24px 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.02rem;
    color: var(--gold-light);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.welcome-card h2 { font-size: 1.1rem; color: var(--gold-light); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; min-width: 0; }

.card-form .field { margin-bottom: 28px; }
.card-form .form-grid > .field { margin-bottom: 0; }
.card-form .card-title { margin-bottom: 22px; }
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field-hint { color: var(--muted); font-size: 0.78rem; }
.field-grow { flex: 1; }

input[type="text"], input[type="password"], input[type="search"],
input[type="url"], input[type="email"], select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: #6f679a; }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 90px; }

.color-input {
    width: 100%;
    height: 42px;
    padding: 4px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.form-grid { display: grid; gap: 18px 20px; align-items: start; }
.form-grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid-5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.form-grid-lois { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.form-grid > .field { margin-bottom: 0; }

.form-actions { display: flex; gap: 12px; margin-top: 22px; align-items: center; }
.inline-fields { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { margin-bottom: 0; }
.inline-form { display: inline-flex; margin: 0; vertical-align: middle; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 4px 14px rgba(114, 80, 240, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, #9b7ffa, var(--accent)); color: #fff; }

.btn-secondary {
    background: var(--panel-2);
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--gold-light); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--text); }

.btn-block { width: 100%; }

.btn-icon {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    background: var(--panel-2);
    border-color: var(--border);
    color: var(--muted);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.btn-icon:hover { color: var(--gold-light); border-color: var(--accent); }
.btn-icon.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.btn-danger-outline {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); color: var(--danger); }

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.filter-bar select { width: auto; min-width: 160px; }

.search-input {
    position: relative;
    flex: 1;
    min-width: 240px;
    display: flex;
    align-items: center;
}

.search-input .icon {
    position: absolute;
    left: 12px;
    color: var(--muted);
    pointer-events: none;
}

.search-input input { padding-left: 38px; }

.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: rgba(139, 108, 247, 0.06); }
.table tbody tr:last-child td { border-bottom: none; }

.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions { width: 1%; }
.td-actions .btn-icon { vertical-align: middle; }
.td-actions > * + * { margin-left: 6px; }
.empty-row { text-align: center; color: var(--muted); padding: 28px !important; font-style: italic; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid transparent;
    vertical-align: middle;
}

.chip-house-solarius { background: rgba(226, 85, 99, 0.13);  color: var(--solarius); border-color: rgba(226, 85, 99, 0.42); }
.chip-house-aeris    { background: rgba(242, 201, 76, 0.12); color: var(--aeris); border-color: rgba(242, 201, 76, 0.42); }
.chip-house-tellurik { background: rgba(88, 179, 104, 0.13);  color: var(--tellurik); border-color: rgba(88, 179, 104, 0.42); }
.chip-house-hydralis { background: rgba(91, 157, 255, 0.12);  color: var(--hydralis); border-color: rgba(91, 157, 255, 0.42); }

.chip-statut-adulte { background: var(--accent-soft); color: var(--accent); border-color: rgba(139, 108, 247, 0.4); }
.chip-statut-eleve  { background: rgba(63, 193, 201, 0.12); color: #3fc1c9; border-color: rgba(63, 193, 201, 0.4); }

.chip-admin { background: rgba(212, 165, 61, 0.15); color: var(--gold-light); border-color: rgba(212, 165, 61, 0.5); }
.chip-role  { background: var(--accent-soft); color: var(--accent); border-color: rgba(139, 108, 247, 0.35); }
.chip-me    { background: var(--success-soft); color: var(--success); font-size: 0.68rem; margin-left: 6px; }
.chip-rang  { background: rgba(212, 165, 61, 0.12); color: var(--gold-light); border-color: rgba(212, 165, 61, 0.35); }

.chip-badge {
    --badge-color: var(--accent);
    background: color-mix(in srgb, var(--badge-color) 16%, transparent);
    color: var(--badge-color);
    border-color: color-mix(in srgb, var(--badge-color) 45%, transparent);
}

.chip-remove {
    display: inline-grid;
    place-items: center;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 1px;
    border-radius: 50%;
    opacity: 0.7;
}
.chip-remove:hover { opacity: 1; background: rgba(0, 0, 0, 0.25); }

.badge-list { margin-top: 22px; }
.badge-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.92rem;
}

.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: var(--danger-soft); color: #f398a8; border: 1px solid rgba(229, 86, 108, 0.4); }
.alert-error .icon { color: var(--danger); margin-top: 2px; }

.toasts {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    animation: toast-in 0.25s ease-out;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success .icon { color: var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-error .icon { color: var(--danger); }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 2px;
}
.toast-close:hover { color: var(--text); }

.toast.hiding { opacity: 0; transform: translateX(20px); transition: opacity 0.3s, transform 0.3s; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 50% 40% at 20% 20%, rgba(139, 108, 247, 0.14), transparent),
        radial-gradient(ellipse 40% 35% at 80% 75%, rgba(212, 165, 61, 0.08), transparent),
        var(--bg);
}

.auth-wrap { width: 100%; max-width: 420px; padding: 24px; }

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    padding: 38px 34px 30px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.auth-logo { width: 110px; height: auto; filter: drop-shadow(0 6px 20px rgba(212, 165, 61, 0.4)); }

.auth-title {
    font-family: var(--font-brand);
    font-size: 1.35rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin: 16px 0 26px;
}
.auth-form { text-align: left; }

.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap input { padding-right: 44px; }

.toggle-password {
    position: absolute;
    right: 6px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: 50%;
}
.toggle-password:hover { color: var(--gold-light); background: var(--accent-soft); }
.toggle-password .ico-eye-off { display: none; }
.toggle-password.revealed .ico-eye { display: none; }
.toggle-password.revealed .ico-eye-off { display: block; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s;
}

.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.stat-card strong { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat-card span { color: var(--muted); font-size: 0.83rem; }

.stat-gold .icon { color: var(--gold-light); }
.stat-red .icon { color: var(--danger); }
.stat-blue .icon { color: #6fb7ff; }
.stat-violet .icon { color: var(--accent); }
.stat-green .icon { color: var(--success); }

.role-card { padding: 0; overflow: hidden; }
.role-card summary::-webkit-details-marker { display: none; }

.role-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.role-summary:hover { background: rgba(139, 108, 247, 0.05); }
.role-name { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.role-meta { display: flex; align-items: center; gap: 14px; }
.role-card[open] .role-meta .icon:last-child { transform: rotate(180deg); }

.role-body { padding: 10px 22px 22px; border-top: 1px solid var(--border-soft); }
.role-body > .inline-form { margin-top: 16px; }

.perm-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.perm-group {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 14px 12px;
    margin: 0;
}

.perm-group legend {
    padding: 0 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-light);
}

.perm-check {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 2px;
    cursor: pointer;
    border-radius: 6px;
}

.perm-check:hover { color: var(--gold-light); }
.perm-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.search-select { position: relative; min-width: 0; }

.ss-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    min-height: 42px;
    padding: 6px 34px 6px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-select.open .ss-control { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ss-placeholder { color: #6f679a; }
.ss-value { font-weight: 500; }

.ss-caret {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    transition: transform 0.2s;
}
.search-select.open .ss-caret { transform: translateY(-50%) rotate(180deg); }

.ss-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    background: var(--accent-soft);
    border: 1px solid rgba(139, 108, 247, 0.4);
    color: var(--text);
    border-radius: 999px;
    font-size: 0.82rem;
}

.ss-chip button {
    display: grid;
    place-items: center;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 1px;
    border-radius: 50%;
}
.ss-chip button:hover { color: var(--danger); }

.ss-panel {
    position: absolute;
    z-index: 60;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: none;
    overflow: hidden;
}

.search-select.open .ss-panel { display: block; }

.ss-search { padding: 8px; border-bottom: 1px solid var(--border-soft); }
.ss-search input { padding: 8px 10px; }

.ss-list { max-height: 240px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; }

.ss-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.ss-option:hover, .ss-option.focused { background: var(--accent-soft); }
.ss-option.selected { color: var(--gold-light); }
.ss-option .ss-meta { font-size: 0.76rem; color: var(--muted); }
.ss-empty { padding: 12px; text-align: center; color: var(--muted); font-style: italic; }

.photo-add { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.photo-add input { flex: 1; }
.photo-add .btn { flex-shrink: 0; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.photo-thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: zoom-in;
    transition: border-color 0.15s, transform 0.15s;
}

.photo-thumb:hover { border-color: var(--accent); transform: scale(1.02); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-thumb.broken img { display: none; }
.photo-thumb.broken::after {
    content: "Lien invalide";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--danger);
    font-size: 0.78rem;
}

.photo-zoom-hint {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    opacity: 0;
    transition: opacity 0.15s;
}
.photo-thumb:hover .photo-zoom-hint { opacity: 1; }

.photo-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 2;
}
.photo-remove:hover { background: var(--danger); }

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(8, 6, 16, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lightbox.open { display: flex; }

.lightbox img {
    max-width: 88vw;
    max-height: 86vh;
    transform-origin: center;
    user-select: none;
    cursor: grab;
    border-radius: 4px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
}

.lightbox img.dragging { cursor: grabbing; }

.lightbox-controls {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    box-shadow: var(--shadow);
}

.lightbox-controls button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.05rem;
    font-weight: 700;
}

.lightbox-controls button:hover { background: var(--accent-soft); color: var(--gold-light); }

.lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
}
.lightbox-close:hover { color: var(--danger); border-color: var(--danger); }

.lightbox-zoom-label {
    align-self: center;
    color: var(--muted);
    font-size: 0.8rem;
    min-width: 46px;
    text-align: center;
}

.peine-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.peine-row { display: flex; gap: 8px; align-items: center; }
.peine-row input { flex: 1; }

.peine-list { margin: 0; padding: 0; list-style: none; }
.peine-list li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; flex-wrap: wrap; }
.peine-min { color: var(--success); }
.peine-max { color: var(--danger); }
.peine-arrow { color: var(--muted); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.detail-grid .card { margin-bottom: 16px; }
.detail-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.05rem; }
.witness-list { margin: 0; padding: 0; list-style: none; }
.witness-list li { padding: 5px 0; display: flex; align-items: center; gap: 8px; border-bottom: 1px dashed var(--border-soft); }
.witness-list li:last-child { border-bottom: none; }
.prose { white-space: normal; line-height: 1.7; }

.error-page {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
}

.error-icon { color: var(--gold); opacity: 0.8; }
.error-page h1 { font-family: var(--font-brand); color: var(--gold-light); }
.error-page p { color: var(--muted); }

@media (max-width: 900px) {
    .app { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    .main { padding: 20px 16px 50px; }
    .form-grid-lois { grid-template-columns: 1fr; }
    .filter-bar select { width: 100%; }
    .td-actions { text-align: left; }
}
