/* Situnio — feuille de style unique */

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --border: #e3e6ef;
    --border-strong: #cfd4e2;
    --text: #141a2e;
    --text-2: #4a5270;
    --muted: #7a819c;
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef0ff;
    --brand-text: #3730a3;
    --success: #15803d;
    --success-soft: #e9f8ef;
    --warning: #a35c00;
    --warning-soft: #fff5e0;
    --danger: #c0262d;
    --danger-soft: #fdeceb;
    --info: #1d5fd1;
    --info-soft: #e9f1ff;
    --shadow: 0 1px 2px rgba(20, 26, 46, .05), 0 1px 3px rgba(20, 26, 46, .04);
    --shadow-lg: 0 10px 30px rgba(20, 26, 46, .08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1220;
        --surface: #161b2c;
        --surface-2: #1d2337;
        --border: #272e45;
        --border-strong: #353d58;
        --text: #e8eaf3;
        --text-2: #b3b9d0;
        --muted: #838aa6;
        --brand: #7c74ff;
        --brand-hover: #948dff;
        --brand-soft: #23264a;
        --brand-text: #c4c0ff;
        --success: #4ade80;
        --success-soft: #132a1e;
        --warning: #fbbf4a;
        --warning-soft: #2d2412;
        --danger: #f87171;
        --danger-soft: #331a1d;
        --info: #79a8ff;
        --info-soft: #162442;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1rem; color: var(--text-2); }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }

/* ── Marque ───────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; font-size: 1rem;
}

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2; cursor: pointer;
    text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .icon-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.btn-dark { background: #141a2e; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-block { width: 100%; padding: 11px 16px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: transparent; border: 0; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Formulaires ──────────────────────────────────────────── */
.field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: var(--text); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.optional { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[aria-invalid=true] { border-color: var(--danger); }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon {
    padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--surface-2); color: var(--text-2); font: inherit; font-size: .82rem; cursor: pointer; white-space: nowrap;
}
.hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.field-error { margin: 6px 0 0; font-size: .84rem; color: var(--danger); font-weight: 500; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); flex-shrink: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.captcha { display: flex; justify-content: center; }

/* ── Alertes / badges ─────────────────────────────────────── */
.alert {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
    padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; border: 1px solid transparent;
}
.alert a { font-weight: 600; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.alert-error   { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600;
    line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-text); }
.badge-muted   { background: var(--surface-2);    color: var(--text-2); }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand-text); font-size: .85rem; font-weight: 500;
}
.chip a { color: inherit; font-weight: 700; }

/* ── Pages publiques ──────────────────────────────────────── */
body.auth {
    background:
        radial-gradient(1000px 500px at 10% -10%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%),
        radial-gradient(800px 400px at 100% 110%, color-mix(in srgb, #8b5cf6 10%, transparent), transparent 60%),
        var(--bg);
}
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-brand { margin-bottom: 24px; }
.auth-card {
    width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.35rem; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); margin-bottom: 22px; }
.auth-footer { margin-top: 20px; color: var(--muted); font-size: .9rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: .88rem; }
.error-card { text-align: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; margin-bottom: 10px; }
.error-detail {
    text-align: left; white-space: pre-wrap; font: .8rem/1.5 var(--mono); background: var(--surface-2);
    padding: 12px; border-radius: var(--radius-sm); margin: 0 0 18px; overflow: auto;
}

/* ── Application : structure ──────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; width: 256px; flex-shrink: 0; display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; overflow-y: auto;
}
.sidebar-head { padding: 2px 8px 16px; }
.org-switch {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.org-avatar {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
    background: var(--brand-soft); color: var(--brand-text); font-size: .72rem; font-weight: 700;
}
.org-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 20px 10px 6px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-link {
    display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500; font-size: .92rem;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-badge {
    margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warning);
    color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 20px;
}
.sidebar-foot {
    margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-weight: 600; font-size: .88rem; }
.me-email { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; font-size: .78rem; font-weight: 700;
}
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.2rem; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.content { max-width: 1180px; margin: 0 auto; padding: 28px 32px 60px; }
.nav-backdrop { display: none; }

.impersonation-bar {
    position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    gap: 10px 16px; padding: 8px 16px; background: #fbbf24; color: #3b2600; font-size: .9rem;
}
.impersonation-bar form { margin: 0; }

/* ── Contenu ──────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; }
.breadcrumb { margin-bottom: 14px; font-size: .88rem; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 30px; }
.card-head form { margin: 0; }
.card-head-pad { padding: 16px 20px 0; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.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)); }
.link-card { color: inherit; transition: border-color .15s, transform .15s; }
.link-card:hover { text-decoration: none; border-color: var(--brand); }
.stat-icon { color: var(--brand); margin-bottom: 10px; }
.stat-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--text-2); font-weight: 600; font-size: .9rem; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: .8rem; margin-top: 6px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.card:not(.card-flush) .table th, .card:not(.card-flush) .table td { padding-left: 0; }
.card:not(.card-flush) .table th { background: none; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px !important; }
.list-main { display: inline-flex; align-items: center; gap: 10px; color: inherit; }
.list-main:hover { text-decoration: none; }
.list-main:hover strong { color: var(--brand); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li.empty { justify-content: center; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; flex: 0 0 auto; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 4px; font-size: .9rem; }
.pagination .disabled { color: var(--muted); opacity: .6; }
.pagination .current { color: var(--text-2); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-id { flex: 1; min-width: 200px; }
.profile-id h1 { font-size: 1.35rem; }
.profile-id p { margin: 2px 0 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.actions-row form { margin: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone h2 { color: var(--danger); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 240px; width: auto; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--text-2); }
.checklist li.done { color: var(--muted); text-decoration: line-through; }
.check-dot {
    display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
    border: 2px solid var(--border-strong); font-size: .78rem; font-weight: 700; text-decoration: none; color: var(--text-2);
}
.checklist li.done .check-dot { background: var(--success); border-color: var(--success); color: #fff; }

/* Facturation */
.section-title { font-size: 1.05rem; margin: 8px 0 14px; }
.stat-value-sm { font-size: 1.3rem; margin-top: 6px; }
.badge-info { background: var(--info-soft); color: var(--info); }
.module-card { display: flex; flex-direction: column; }
.module-card h3 { font-size: 1rem; }
.module-card.is-active { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.module-desc { flex: 1; }
.price { font-size: 1.35rem; font-weight: 700; margin: 4px 0 14px; }
.module-actions form { margin: 0 0 6px; }
.module-actions .center { text-align: center; margin: -2px 0 8px; }
.module-card.is-featured { border: 2px solid var(--brand); background: linear-gradient(180deg, var(--brand-soft), var(--surface) 60%); }
.grid-1 { grid-template-columns: minmax(0, 1fr); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 20px; }
.checks li { position: relative; padding-left: 24px; font-size: .92rem; }
.checks li::before { content: '✓'; position: absolute; left: 0; color: var(--success); font-weight: 700; }
.module-actions p { margin-bottom: 6px; }
.upsell { max-width: 520px; margin: 40px auto; text-align: center; padding: 36px 28px; }
.upsell-icon { color: var(--brand); margin-bottom: 12px; }
.upsell-icon .icon { width: 36px; height: 36px; }
.upsell h1 { margin-bottom: 8px; }
.money-up { color: var(--success); font-weight: 600; }
.form-grid { margin-bottom: 0; gap: 0 20px; }
.check-pad { padding-top: 26px; }
input[type=date] {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit;
}
.actions-row .btn-sm { white-space: nowrap; }
.row-muted td { opacity: .6; }

/* Sites */
.steps { margin: 0 0 16px; padding-left: 20px; }
.steps li { margin-bottom: 12px; line-height: 1.6; }
.key-box {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; margin-bottom: 8px;
    background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.key-box code { flex: 1; min-width: 0; word-break: break-all; border: 0; background: none; font-size: .85rem; }
.empty-state { text-align: center; padding: 40px 24px; }
.empty-state h2 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { max-width: 520px; margin: 0 auto 18px; }
.details-card summary { cursor: pointer; list-style: none; }
.details-card summary::-webkit-details-marker { display: none; }
.details-card summary h2::before { content: '▸ '; color: var(--muted); }
.details-card[open] summary h2::before { content: '▾ '; }
.details-card[open] summary { margin-bottom: 12px; }
.chip-sm { padding: 3px 9px; font-size: .78rem; margin: 2px 4px 2px 0; }
.chip-sm:hover { text-decoration: none; filter: brightness(.95); }

/* Journaux */
.log-message { min-width: 320px; word-break: break-word; }
.log-message summary { cursor: pointer; margin-top: 4px; }
.log-detail {
    white-space: pre-wrap; word-break: break-word; font: .76rem/1.5 var(--mono); background: var(--surface-2);
    padding: 8px 10px; border-radius: var(--radius-sm); margin: 6px 0 0; max-height: 260px; overflow: auto;
}
.card-head-pad .filters { margin-bottom: 0; }
.card-head-pad + p.card-head-pad { padding-top: 10px; margin: 0; }
.alert-list { margin-bottom: 20px; }
.alert-list .alert { margin-bottom: 8px; }

/* Histogramme */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 6px; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 4px; background: var(--surface-2); }
.bar span { display: block; width: 100%; border-radius: 4px; background: var(--brand); min-height: 0; }
.bar:hover span { background: var(--brand-hover); }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: 8px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 100; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(10, 14, 30, .45); }
    .topbar {
        display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
        padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .impersonation-bar + .shell .topbar { top: 0; }
    .content { padding: 20px 16px 48px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .auth-card { padding: 24px 20px; }
    .bars { gap: 2px; }
}
