/* ═══════════════════════════════════════════════════════════════════════════
   Imagine — design system
   Mobile-first and full-width: the content column fills the viewport (minus
   the desktop sidebar) with fluid clamp() padding — no fixed max-width.
   Two themes driven by <html data-theme="dark|light">:
     • dark  – near-black surfaces, red accent (product default)
     • light – white surfaces, blue accent
   The toggle persists to localStorage (mirrored to a cookie for SSR).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Theme tokens ──────────────────────────────────────────────────────── */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #09090e;
    --bg-soft: #0e0e15;
    --surface: #13131c;
    --surface-2: #191925;
    --surface-3: #20202e;
    --border: #262634;
    --border-strong: #333347;

    --text: #f4f4f8;
    --text-2: #b9b9c8;
    --text-3: #808095;

    --accent: #ef4444;
    --accent-strong: #dc2626;
    --accent-contrast: #ffffff;
    --accent-soft: rgba(239, 68, 68, 0.14);
    --accent-ring: rgba(239, 68, 68, 0.45);
    --accent-grad: linear-gradient(135deg, #ef4444 0%, #f97316 100%);

    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.14);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.65);
    --scrim: rgba(2, 2, 6, 0.6);
}

:root[data-theme="light"] {
    color-scheme: light;

    --bg: #f5f6fa;
    --bg-soft: #eef0f6;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eef1f8;
    --border: #e3e6f0;
    --border-strong: #c9cede;

    --text: #161922;
    --text-2: #4c5265;
    --text-3: #878da0;

    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-contrast: #ffffff;
    --accent-soft: rgba(37, 99, 235, 0.11);
    --accent-ring: rgba(37, 99, 235, 0.35);
    --accent-grad: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);

    --ok: #059669;
    --ok-soft: rgba(5, 150, 105, 0.12);
    --warn: #b45309;
    --warn-soft: rgba(180, 83, 9, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, 0.10);

    --shadow-1: 0 1px 2px rgba(23, 25, 35, 0.06);
    --shadow-2: 0 12px 32px -16px rgba(23, 25, 35, 0.22);
    --scrim: rgba(23, 25, 35, 0.42);
}

/* ── 2. Reset & base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4 {
    font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 0.5rem;
    color: var(--text);
}

h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0 0 0.9rem; }

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

a:hover { text-decoration: underline; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.1rem 0;
}

img { max-width: 100%; display: block; }

::selection {
    background: var(--accent-soft);
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--accent-ring);
    outline-offset: 2px;
    border-radius: 6px;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }

/* Thin, theme-aware scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

/* ── 3. App shell ─────────────────────────────────────────────────────────── */
.app-shell {
    min-height: 100dvh;
}

.content {
    padding: 4.6rem clamp(0.85rem, 3vw, 3rem) 2.5rem; /* clears the mobile topbar */
    width: 100%;
}

/* Mobile topbar */
.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 3.4rem;
    padding-inline: 0.75rem;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    font-size: 1.05rem;
    margin-right: auto;
}

.topbar-brand:hover { text-decoration: none; }

/* Sidebar (off-canvas on mobile) */
.sidebar {
    position: fixed;
    inset-block: 0;
    left: 0;
    z-index: 60;
    width: min(84vw, 288px);
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    transform: translateX(-104%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
}

body.nav-open .sidebar { transform: none; }

.nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

body.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.05rem 1.1rem 0.9rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1.12rem;
    letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-grad);
    color: #fff;
    box-shadow: var(--shadow-1);
}

.brand-mark .icon { width: 19px; height: 19px; }

/* Nav groups */
.nav-groups {
    flex: 1;
    padding: 0.4rem 0.7rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.nav-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--text-3);
    padding: 0 0.45rem 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.52rem 0.65rem;
    margin-bottom: 2px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link .icon { color: var(--text-3); transition: color 0.15s ease; }

.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav-link:hover .icon { color: var(--text-2); }

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    position: relative;
}

.nav-link.active .icon { color: var(--accent); }

.nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.7rem;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.75rem 0.7rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-footer form { margin: 0; }

.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.65rem 0;
    color: var(--text-3);
    font-size: 0.82rem;
}

/* Theme toggle icons: dark shows the sun (→ light), light shows the moon */
.theme-toggle .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-moon { display: block; }

/* Desktop: fixed sidebar, no topbar; content fills the remaining width */
@media (min-width: 920px) {
    .topbar, .nav-scrim { display: none; }

    .sidebar {
        transform: none;
        width: 264px;
    }

    .content {
        margin-left: 264px;
        width: auto; /* auto, not 100%: 100% + the sidebar margin overflows the viewport */
        padding: 2.2rem clamp(1.4rem, 2.5vw, 3rem) 3rem;
    }
}

/* ── 4. Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.52rem 1.05rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: #fff;
}

.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.84rem; border-radius: 8px; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── 5. Forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }

.field-label,
label.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 0.3rem;
}

.input,
.form-control,
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.25s ease;
}

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

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

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                      linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
    background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.1rem;
}

input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.45rem 0;
    cursor: pointer;
}

.checkbox-row input { margin-top: 0.22rem; }

.checkbox-row .checkbox-text { font-weight: 500; color: var(--text); }
.checkbox-row .checkbox-desc { font-size: 0.8rem; color: var(--text-3); }

/* Validation (Blazor) */
.validation-message,
.text-danger {
    color: var(--danger);
    font-size: 0.82rem;
    margin-top: 0.25rem;
    display: block;
}

.validation-summary,
.validation-errors {
    margin: 0 0 0.9rem;
    padding: 0;
    list-style: none;
    color: var(--danger);
    font-size: 0.87rem;
}

.invalid.modified:not([type="checkbox"]) {
    border-color: var(--danger);
}

.valid.modified:not([type="checkbox"]) {
    border-color: var(--ok);
}

/* ── 6. Cards, panels & page furniture ────────────────────────────────────── */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1.4rem;
}

.page-head .lede {
    color: var(--text-3);
    margin: 0.15rem 0 0;
    max-width: 62ch;
}

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

.card + .card { margin-top: 1rem; }

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.card-title .icon { color: var(--accent); }
.card-title h2, .card-title h3 { margin: 0; }

/* ── 7. Tables ────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 560px;
}

.table th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-3);
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

.table td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: var(--surface-2); }

.row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ── 8. Badges & chips ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.14rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--surface-3);
    color: var(--text-2);
    white-space: nowrap;
}

.badge .icon { width: 12px; height: 12px; }

.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* ── 9. Alerts ────────────────────────────────────────────────────────────── */
.alert {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    margin-bottom: 1rem;
    font-size: 0.92rem;
}

.alert .icon { margin-top: 0.12rem; }

.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert-warning { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* ── 10. Pagination ───────────────────────────────────────────────────────── */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-top: 1.5rem;
}

.pager-status {
    font-size: 0.85rem;
    color: var(--text-3);
    min-width: 7.5rem;
    text-align: center;
}

/* ── 11. Feed ─────────────────────────────────────────────────────────────── */
/* Mobile-first density: 2-up on phones, tiles grow with the viewport. */
.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
    gap: clamp(0.5rem, 1.6vw, 1.1rem);
}

@media (min-width: 640px) {
    .feed-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

@media (min-width: 1400px) {
    .feed-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

.feed-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.feed-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
    border-color: var(--border-strong);
}

.feed-thumb {
    display: block;
    aspect-ratio: 1 / 1;
    background: var(--surface-3);
}

.feed-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-body {
    padding: clamp(0.55rem, 1.6vw, 0.8rem) clamp(0.65rem, 1.8vw, 0.9rem) clamp(0.65rem, 1.8vw, 0.9rem);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.feed-prompt {
    font-size: 0.87rem;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.feed-negative {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-3);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-negative .icon {
    width: 12px;
    height: 12px;
    flex: none;
}

.feed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
}

.feed-byline {
    font-size: 0.76rem;
    color: var(--text-3);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── 12. Studio ───────────────────────────────────────────────────────────── */
.studio-grid {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 1080px) {
    .studio-grid { grid-template-columns: minmax(340px, 460px) 1fr; align-items: start; }
}

/* Very wide screens: give the (now 20k-character) prompt form more room. */
@media (min-width: 1800px) {
    .studio-grid { grid-template-columns: minmax(420px, 560px) 1fr; }
}

.seed-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.seed-row .input { flex: 1; }

.result-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    min-height: clamp(260px, 45vh, 420px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    text-align: center;
}

.result-panel img {
    max-height: 62vh;
    border-radius: 12px;
    box-shadow: var(--shadow-2);
}

.result-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
}

/* Spinner */
.spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);
    animation: spin 0.85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.generating-note {
    color: var(--text-3);
    font-size: 0.9rem;
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.45; } }

/* Quota meter */
.quota {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 0.84rem;
    color: var(--text-2);
}

.quota-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
}

.quota-bar > span {
    display: block;
    height: 100%;
    background: var(--accent-grad);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── 13. Landing / hero ───────────────────────────────────────────────────── */
/* Full-width hero: copy stays centered at a readable measure, the feature
   grid below it spans the whole content column. */
.hero {
    padding: clamp(1.6rem, 6vw, 4.5rem) 0 2rem;
    text-align: center;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.1rem;
}

.hero-eyebrow .icon { width: 14px; height: 14px; color: var(--accent); }

.hero h1 {
    font-size: clamp(2.1rem, 6vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    margin-bottom: 0.8rem;
}

.grad-text {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero .lede {
    color: var(--text-2);
    font-size: 1.06rem;
    max-width: 54ch;
    margin: 0 auto 1.6rem;
}

.hero-actions {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

.feature-grid {
    display: grid;
    gap: clamp(0.7rem, 1.6vw, 1.2rem);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    margin-top: 2.5rem;
}

.feature {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    text-align: left;
}

.feature .icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.feature h3 { margin-bottom: 0.25rem; }
.feature p { color: var(--text-3); font-size: 0.88rem; margin: 0; }

/* ── 14. Stats & admin dashboard ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    margin-bottom: 1.4rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.1rem;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.stat-label {
    color: var(--text-3);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.admin-nav-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.admin-card {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem;
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-card:hover {
    text-decoration: none;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.admin-card .icon {
    width: 21px;
    height: 21px;
    color: var(--accent);
    margin-top: 0.15rem;
}

.admin-card h3 { margin-bottom: 0.15rem; }
.admin-card p { margin: 0; font-size: 0.85rem; color: var(--text-3); }

/* ── 15. Toolbars, empty states, claims editor ────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar .searchbox { flex: 1 1 220px; max-width: 340px; }

.empty-state {
    text-align: center;
    padding: 3rem 1.25rem;
    color: var(--text-3);
    border: 1px dashed var(--border-strong);
    border-radius: 16px;
    background: var(--surface-2);
}

.empty-state .icon {
    width: 34px;
    height: 34px;
    margin: 0 auto 0.7rem;
    color: var(--text-3);
}

.empty-state h3 { color: var(--text-2); }

.perm-group { margin-bottom: 1.1rem; }

.perm-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-3);
    margin-bottom: 0.4rem;
}

.perm-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.45rem;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.perm-item:hover { border-color: var(--accent); }
.perm-item input { margin-top: 0.25rem; }

.perm-item code {
    font-size: 0.72rem;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 0.05rem 0.4rem;
    border-radius: 6px;
}

/* Replicate parameter editor (admin models page) */
.param-editor {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem;
    margin-bottom: 0.55rem;
    background: var(--surface-2);
}

.param-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    align-items: center;
}

@media (min-width: 720px) {
    .param-row { grid-template-columns: 1.4fr 0.9fr 1.1fr auto; }
}

/* Declared after the media block so the two-column variant wins at any width. */
.param-row-2 {
    grid-template-columns: 1fr 1fr;
    margin-top: 0.45rem;
}

.param-row .icon-btn {
    width: 2rem;
    height: 2rem;
}

/* ── 16. Bootstrap shims (Identity account pages only) ────────────────────── */
.row { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.row > * { flex: 1 1 320px; min-width: 0; max-width: 480px; }

.form-floating {
    display: flex;
    flex-direction: column;
}

.form-floating > label {
    order: -1;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.35rem;
}

.mb-3 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.w-100 { width: 100%; }
.mx-auto { margin-inline: auto; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.text-secondary { color: var(--text-3); }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0.3rem 0.5rem;
}

.btn-link:hover { text-decoration: underline; }

.btn.btn-lg { padding: 0.65rem 1.3rem; }

.nav-pills {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    margin: 0 0 1.2rem;
    list-style: none;
}

.nav-pills .nav-item { list-style: none; }

.nav-pills .nav-link { color: var(--text-2); }

.nav-pills .nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.checkbox label { display: flex; gap: 0.5rem; align-items: center; color: var(--text-2); }

/* ── 17. Blazor chrome ────────────────────────────────────────────────────── */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--warn-soft);
    color: var(--text);
    border-top: 1px solid var(--warn);
    padding: 0.7rem 1.2rem 0.7rem 1rem;
    backdrop-filter: blur(10px);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.85rem;
    top: 0.6rem;
}

.blazor-error-boundary {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--danger);
}

.blazor-error-boundary::after { content: "An error has occurred."; }

/* Status message (Identity) */
.status-message-success { color: var(--ok); }
.status-message-error { color: var(--danger); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
