/* ============================================================
   BoardGameDeals Admin — Design system (light SaaS)
   Palette neutre froide + accent indigo. Grille 4/8px.
   ============================================================ */

:root {
    color-scheme: light;

    /* Surfaces */
    --bg: #f6f7f9;
    --bg-subtle: #eef0f3;
    --surface: #ffffff;
    --surface-raised: #ffffff;

    /* Lines */
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --border-subtle: #eef0f3;

    /* Text */
    --text: #111827;
    --text-soft: #374151;
    --muted: #6b7280;
    --muted-strong: #4b5563;
    --text-on-accent: #ffffff;

    /* Accent */
    --accent: #5b5bd6;
    --accent-hover: #4d4dc7;
    --accent-soft: #eef0fc;
    --accent-border: #c9caf4;

    /* Status */
    --success: #16a34a;
    --success-soft: #ecfdf5;
    --success-border: #bbf7d0;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --warning-border: #fde68a;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --info: #2563eb;
    --info-soft: #eff6ff;
    --info-border: #bfdbfe;

    /* Radii */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

    /* Layout */
    --sidebar-width: 248px;
    --topbar-height: 60px;

    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "tnum";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

body { font-family: "Inter", system-ui, -apple-system, sans-serif; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

::selection { background: var(--accent-soft); }

/* Spin (loading) */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* Scrollbars discrets */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ============================================================
   App shell
   ============================================================ */

.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

/* Sidebar */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 30;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-subtle);
    min-height: var(--topbar-height);
}

.sidebar__logo {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    flex: none;
}

.sidebar__title { display: grid; gap: 1px; min-width: 0; }
.sidebar__title strong { font-size: 0.92rem; font-weight: 700; line-height: 1.2; }
.sidebar__title small { font-size: 0.74rem; color: var(--muted); }

.sidebar__nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 18px; }

.nav-group { display: grid; gap: 2px; }
.nav-group__label {
    padding: 4px 12px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--r-md);
    color: var(--text-soft);
    font-weight: 500;
    font-size: 0.88rem;
    transition: background-color 120ms ease, color 120ms ease;
}
.nav-link:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; flex: none; stroke-width: 1.9; }

.sidebar__footer { padding: 12px; border-top: 1px solid var(--border-subtle); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); }
.user-chip:hover { background: var(--bg-subtle); }

.avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.78rem;
    flex: none;
}
.avatar--lg { width: 40px; height: 40px; font-size: 0.92rem; }

.user-chip__body { min-width: 0; }
.user-chip__name { font-size: 0.84rem; font-weight: 600; line-height: 1.2; }
.user-chip__sub { font-size: 0.74rem; color: var(--muted); }

.logout-btn {
    width: 100%;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 600;
    font-size: 0.84rem;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.logout-btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--topbar-height);
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar__left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__menu-btn { display: none; }
.topbar__crumbs { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--muted); min-width: 0; }
.topbar__crumbs strong { color: var(--text); font-weight: 600; }
.topbar__crumbs .sep { color: var(--border-strong); }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar__search {
    position: relative;
    width: 280px;
    max-width: 32vw;
}
.topbar__search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--text);
    font-size: 0.84rem;
    transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
.topbar__search input::placeholder { color: var(--muted); }
.topbar__search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.topbar__search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }

.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    transition: background-color 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.9; }

.content {
    flex: 1;
    padding: 24px;
    display: grid;
    gap: 20px;
    align-content: start;
}

/* Mobile drawer */
.scrim { display: none; }

/* ============================================================
   Page header
   ============================================================ */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-header__title { display: grid; gap: 4px; min-width: 0; }
.page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.page-header p { margin: 0; color: var(--muted); font-size: 0.88rem; max-width: 72ch; }
.page-header__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.86rem;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn svg { width: 16px; height: 16px; stroke-width: 1.9; }

.btn-primary { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: var(--text-on-accent); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-sm { height: 32px; padding: 0 10px; font-size: 0.82rem; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.btn:disabled, button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none !important;
}

/* ============================================================
   Cards & panels
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.card__pad { padding: 18px; }
.card__pad--lg { padding: 22px; }

.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-subtle);
}
.card__header--tight { padding: 14px 18px; }
.card__title { display: grid; gap: 2px; min-width: 0; }
.card__title h2, .card__title h3 { margin: 0; font-size: 0.98rem; font-weight: 700; color: var(--text); letter-spacing: -0.005em; }
.card__title p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.card__header__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: none; }

.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

.stack { display: grid; gap: 14px; }
.stack--sm { gap: 10px; }
.stack--xs { gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

.eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.muted-copy { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }

/* ============================================================
   Stat cards
   ============================================================ */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stat {
    display: grid;
    gap: 6px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.stat__label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.stat__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat__hint { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.stat__delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600; }
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }

.stat--accent { border-color: var(--accent-border); background: linear-gradient(180deg, var(--accent-soft), var(--surface)); }
.stat--accent .stat__value { color: var(--accent); }

/* ============================================================
   Status rows
   ============================================================ */

.status-list { display: grid; gap: 1px; background: var(--border-subtle); border: 1px solid var(--border-subtle); border-radius: var(--r-md); overflow: hidden; }
.status-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 4px 16px;
    align-items: baseline;
    padding: 12px 14px;
    background: var(--surface);
}
.status-row__label { font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.status-row__value { font-size: 0.9rem; font-weight: 600; color: var(--text); text-align: right; }
.status-row__detail { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); }

/* ============================================================
   Badges
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--muted-strong);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge--bare::before { display: none; }

.badge--success { background: var(--success-soft); border-color: var(--success-border); color: #15803d; }
.badge--warning { background: var(--warning-soft); border-color: var(--warning-border); color: #b45309; }
.badge--danger { background: var(--danger-soft); border-color: var(--danger-border); color: #b91c1c; }
.badge--info { background: var(--info-soft); border-color: var(--info-border); color: #1d4ed8; }
.badge--accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* ============================================================
   Forms
   ============================================================ */

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--text-soft); }

.field input,
.field select,
.field textarea,
.input {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field textarea { height: auto; padding: 9px 12px; line-height: 1.5; resize: vertical; }

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); }

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 34px;
}

.field-hint { font-size: 0.78rem; color: var(--muted); line-height: 1.45; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; }

/* Switch / toggle */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: var(--r-pill);
    background: var(--border-strong);
    transition: background-color 150ms ease;
    flex: none;
}
.toggle__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 150ms ease;
}
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle__track { box-shadow: 0 0 0 3px var(--accent-soft); }
.toggle__label { font-size: 0.86rem; font-weight: 500; color: var(--text-soft); }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
}
.switch-row__text { min-width: 0; }
.switch-row__text strong { display: block; font-size: 0.88rem; font-weight: 600; }
.switch-row__text p { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

/* Checkbox */
.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.checkbox:hover { background: var(--bg-subtle); }
.checkbox--active { border-color: var(--accent-border); background: var(--accent-soft); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.checkbox__body { min-width: 0; display: grid; gap: 1px; }
.checkbox__body strong { font-size: 0.84rem; font-weight: 600; }
.checkbox__body small { font-size: 0.78rem; color: var(--muted); }

/* ============================================================
   Alerts
   ============================================================ */

.alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.86rem;
    line-height: 1.5;
}
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; stroke-width: 1.9; }
.alert--error { background: var(--danger-soft); border-color: var(--danger-border); color: #991b1b; }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); color: #92400e; }
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: #166534; }
.alert__body { min-width: 0; }
.alert__body strong { display: block; font-weight: 700; margin-bottom: 2px; }
.alert__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ============================================================
   Empty states
   ============================================================ */

.empty {
    display: grid;
    gap: 6px;
    justify-items: start;
    padding: 28px 20px;
    border-radius: var(--r-md);
    border: 1px dashed var(--border-strong);
    background: var(--bg-subtle);
    text-align: left;
}
.empty--compact { padding: 18px; }
.empty--error { border-style: solid; border-color: var(--danger-border); background: var(--danger-soft); }
.empty__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.empty--error .empty__icon { color: var(--danger); border-color: var(--danger-border); background: var(--surface); }
.empty__icon svg { width: 18px; height: 18px; stroke-width: 1.9; }
.empty strong { font-size: 0.92rem; font-weight: 700; }
.empty p { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.5; max-width: 52ch; }
.empty__actions { display: flex; gap: 8px; margin-top: 6px; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    overflow: hidden;
}
.table-wrap--scroll { max-height: 560px; overflow: auto; }
.table-scroll { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    min-width: 640px;
}
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: top; }
.table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-subtle);
    color: var(--muted-strong);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--border-subtle); color: var(--text-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-subtle); }
.table td strong { font-weight: 600; color: var(--text); }
.table td.muted, .table th.muted { color: var(--muted); }
.table .actions-col { width: 1%; text-align: right; white-space: nowrap; }
.table .num { font-variant-numeric: tabular-nums; }

/* ============================================================
   Scraper specifics
   ============================================================ */

.scope-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.scope-card {
    display: grid;
    gap: 6px;
    text-align: left;
    padding: 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.scope-card:hover { border-color: var(--border-strong); }
.scope-card--active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--accent-soft); }
.scope-card__label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.scope-card__title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.scope-card__desc { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.scope-card__meta { font-size: 0.78rem; color: var(--muted-strong); margin-top: 4px; }

/* ============================================================
   Error feed
   ============================================================ */

.error-list { display: grid; gap: 10px; }
.error-item {
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
}
.error-item__head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.error-item__title { font-size: 0.86rem; font-weight: 600; color: var(--text); word-break: break-word; }
.error-item__msg { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.5; font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

/* ============================================================
   Code block
   ============================================================ */

.code-block {
    margin: 0;
    padding: 14px;
    overflow: auto;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: #0f172a;
    color: #e2e8f0;
    line-height: 1.55;
    font-size: 0.8rem;
    font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 460px;
}

/* ============================================================
   Charts
   ============================================================ */

.chart-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
.chart-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chart-card__title { display: grid; gap: 2px; }
.chart-card__title strong { font-size: 0.92rem; font-weight: 700; }
.chart-card__title p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.chart-card__legend { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.chart-card__legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--muted-strong); }
.chart-card__legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--series-color, var(--accent)); }
.chart-card__surface { min-width: 0; }

.chart-stack { display: grid; gap: 14px; }

.donut-row { display: grid; grid-template-columns: minmax(280px, 1.1fr) minmax(280px, 0.9fr); gap: 14px; align-items: stretch; }
.donut-wrap { position: relative; display: grid; place-items: center; min-height: 280px; }
.donut-center {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    display: grid;
    justify-items: center;
    gap: 2px;
    pointer-events: none;
}
.donut-center strong { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.legend-list { display: grid; gap: 8px; max-height: 320px; overflow: auto; }
.legend-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.legend-item__swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--series-color, var(--accent)); }
.legend-item__body { min-width: 0; display: grid; gap: 1px; }
.legend-item__body strong { font-size: 0.84rem; font-weight: 600; }
.legend-item__body p { margin: 0; font-size: 0.78rem; color: var(--muted); }

/* ============================================================
   Timeline
   ============================================================ */

.timeline { display: grid; gap: 1px; background: var(--border-subtle); border: 1px solid var(--border-subtle); border-radius: var(--r-md); overflow: hidden; }
.timeline__item { display: grid; gap: 3px; padding: 12px 14px; background: var(--surface); }
.timeline__item strong { font-size: 0.82rem; font-weight: 700; }
.timeline__item p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ============================================================
   Auth (login)
   ============================================================ */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 10%, rgba(91, 91, 214, 0.07), transparent 35%),
        radial-gradient(circle at 85% 90%, rgba(91, 91, 214, 0.05), transparent 30%);
    pointer-events: none;
}
.auth-card {
    position: relative;
    width: min(100%, 400px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 28px;
}
.auth-card__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-card__brand .sidebar__logo { width: 36px; height: 36px; }
.auth-card__brand strong { font-size: 0.92rem; font-weight: 700; }
.auth-card__title { display: grid; gap: 4px; margin-bottom: 18px; }
.auth-card__title h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.auth-card__title p { margin: 0; font-size: 0.86rem; color: var(--muted); line-height: 1.5; }
.auth-form { display: grid; gap: 14px; }
.auth-form__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: var(--muted); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
    .grid--sidebar { grid-template-columns: 1fr; }
    .donut-row { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 220ms ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }
    .scrim.is-visible { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, 0.4); z-index: 25; }
    .topbar__menu-btn { display: grid; }
    .topbar__search { width: 200px; }
    .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
    .scope-picker { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content { padding: 16px; gap: 16px; }
    .topbar { padding: 0 16px; }
    .topbar__search { display: none; }
    .stat-grid, .stat-grid--3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header__actions { width: 100%; }
    .page-header__actions .btn { flex: 1; }
    .status-row { grid-template-columns: 1fr; }
    .status-row__value { text-align: left; }
    .auth-card { padding: 22px; }
    .table { font-size: 0.82rem; min-width: 560px; }
}

/* Radzen light overrides pour cohérence */
.rz-chart { font-family: "Inter", system-ui, sans-serif; }
