/* ==========================================================================
   CMS Institutionnel — Administration
   ========================================================================== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --text: #1d2939;
  --muted: #667085;
  --primary: #2954d6;
  --primary-600: #1f43b3;
  --primary-50: #eef2ff;
  --success: #12805c;
  --success-50: #e7f6ef;
  --warning: #b54708;
  --warning-50: #fff4e5;
  --danger: #c4320a;
  --danger-50: #fdeceb;
  --sidebar: #101828;
  --sidebar-text: #c0c6d4;
  --sidebar-active: #ffffff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0 } .mt-2 { margin-top: 8px } .mt-4 { margin-top: 16px } .mb-0 { margin-bottom: 0 } .mb-4 { margin-bottom: 16px }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
i[data-lucide], svg.lucide { width: 18px; height: 18px; stroke-width: 1.8; flex-shrink: 0; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; justify-content: center; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-img { display: block; width: 120px; height: auto; border-radius: 10px; background: #fff; padding: 8px 14px; box-shadow: 0 2px 8px rgba(0,0,0,.35); transition: opacity .15s; }
.brand-img:hover { opacity: .9; }
.nav { padding: 12px 10px 24px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7a8399; padding: 6px 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(79,124,255,.18); color: var(--sidebar-active); }
.nav .sub { margin: 2px 0 6px 28px; border-left: 1px solid rgba(255,255,255,.1); }
.nav .sub a { padding: 6px 12px; font-size: 13px; font-weight: 400; }
.sidebar-footer { padding: 12px 20px; font-size: 12px; color: #7a8399; border-top: 1px solid rgba(255,255,255,.07); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .burger { display: none; }
.user-menu { position: relative; margin-left: auto; }
.user-menu > button { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 8px; font: inherit; color: inherit; }
.user-menu > button:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 210px; padding: 6px; display: none; z-index: 50; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.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)); }
.layout-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.layout-form > aside { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.layout-form > aside .card + .card { margin-top: 0; }

.stat { display: flex; align-items: center; gap: 14px; padding: 18px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; }
a.stat:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .input:focus-visible { outline: 3px solid rgba(41, 84, 214, .25); outline-offset: 1px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); border-color: #f5c2b8; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; padding: 0; height: 32px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.actions form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 550; margin-bottom: 6px; }
.req { color: var(--danger); }
.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select.input[multiple] { height: auto; padding: 6px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(41, 84, 214, .15); outline: none; }
.has-error .input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }
.help { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.input-group { display: flex; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; border-left: 0; height: 38px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; min-width: 160px; height: 36px; }
[dir="rtl"].input, .rtl .input, .rtl textarea { direction: rtl; text-align: right; }

/* « .field > label.switch » : doit l'emporter sur « .field > label { display: block } », sinon le switch chevauche le libellé. */
.switch, .field > label.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; margin-bottom: 0; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.switch-ui { display: inline-block; width: 36px; height: 20px; border-radius: 20px; background: #d0d5dd; position: relative; transition: background .15s; flex-shrink: 0; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid rgba(41,84,214,.25); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table .title-cell { font-weight: 550; }
.table .thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.tree-indent { display: inline-block; color: #c0c6d4; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty i[data-lucide] { width: 40px; height: 40px; color: #c0c6d4; margin-bottom: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-success { background: var(--success-50); color: var(--success); border-color: #b5e3cf; }
.badge-warning { background: var(--warning-50); color: var(--warning); border-color: #f8d6a8; }
.badge-danger { background: var(--danger-50); color: var(--danger); border-color: #f5c2b8; }
.badge-primary { background: var(--primary-50); color: var(--primary); border-color: #c7d4ff; }
.badge-muted { opacity: .8; }
.locale-badges { display: inline-flex; gap: 3px; }
.locale-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; background: var(--success-50); color: var(--success); }
.locale-badge.missing { background: var(--surface-2); color: #b0b7c3; text-decoration: line-through; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; white-space: pre-line; }
.alert-success { background: var(--success-50); color: var(--success); border-color: #b5e3cf; }
.alert-error { background: var(--danger-50); color: var(--danger); border-color: #f5c2b8; }
.alert-info { background: var(--primary-50); color: var(--primary); border-color: #c7d4ff; }
.alert-warning { background: var(--warning-50); color: var(--warning); border-color: #f8d6a8; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tab { padding: 11px 14px; border: 0; background: none; cursor: pointer; font: inherit; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: #d0d5dd; }
.tab .dot.ok { background: var(--success); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.rtl { direction: rtl; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Media ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.media-tile:hover { box-shadow: var(--shadow-lg); }
.media-tile.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(41,84,214,.3); }
.media-thumb { aspect-ratio: 4 / 3; background: repeating-conic-gradient(#f2f4f7 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: grid; place-items: center; overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .file-icon { color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; text-transform: uppercase; font-size: 12px; }
.media-thumb .file-icon i[data-lucide] { width: 34px; height: 34px; }
.media-meta { padding: 8px 10px; font-size: 12px; }
.media-meta .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.dropzone { border: 2px dashed #c7cdd8; border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); background: var(--surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.upload-progress { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.upload-progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

.media-field { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; gap: 12px; align-items: center; background: var(--surface-2); }
.media-field-preview { width: 96px; height: 72px; border-radius: 6px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; font-size: 11px; text-align: center; }
.media-field-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-field-actions { display: flex; flex-direction: column; gap: 6px; }
.media-gallery { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface-2); }
.media-gallery-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 8px; }
.media-gallery-items:empty { display: none; }
.media-gallery-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; font-size: 11px; text-align: center; cursor: grab; }
.media-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.media-gallery-item button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(16,24,40,.75); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; }
.media-gallery-item button svg { width: 13px; height: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .55); z-index: 1000; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(1100px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal-sm { width: min(520px, 100%); }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header h2 { margin: 0; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------- Permissions matrix ---------- */
.perm-group { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.perm-group-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; padding: 12px 14px; }
.perm-list code { font-size: 11px; }

/* ---------- Menu tree ---------- */
.tree-list { list-style: none; margin: 0; padding: 0; min-height: 10px; }
.tree-list .tree-list { margin-left: 28px; padding-top: 6px; }
.tree-item { margin-bottom: 6px; }
.tree-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.tree-row .handle { cursor: grab; color: var(--muted); }
.sortable-ghost > .tree-row { background: var(--primary-50); border-style: dashed; }

/* ---------- Form builder ---------- */
.fb { display: grid; grid-template-columns: 220px minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.fb-palette { position: sticky; top: 76px; }
.fb-palette button { display: flex; width: 100%; align-items: center; gap: 8px; margin-bottom: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font: inherit; text-align: left; }
.fb-palette button:hover { border-color: var(--primary); color: var(--primary); }
.fb-step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.fb-step.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(41,84,214,.12); }
.fb-step-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.fb-step-header .num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.fb-fields { padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; min-height: 60px; }
.fb-field { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.fb-field.half { flex-basis: calc(50% - 4px); }
.fb-field.third { flex-basis: calc(33.33% - 6px); }
.fb-field:hover { border-color: #b3c3f5; }
.fb-field.selected { border-color: var(--primary); background: var(--primary-50); }
.fb-field .handle { cursor: grab; color: var(--muted); }
.fb-field .meta { flex: 1; min-width: 0; }
.fb-field .meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-field .meta span { font-size: 12px; color: var(--muted); }
.fb-props { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
.fb-option { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 6px; margin-bottom: 6px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(rgba(10,18,38,.52), rgba(10,18,38,.52)), url('images/bg/bg-6.jpg') center/cover no-repeat; }
.auth-card { width: min(420px, 100%); }
.auth-card .card-body { padding: 32px; }
.auth-brand { display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
.auth-brand img { display: block; max-width: 220px; height: auto; filter: drop-shadow(0 4px 16px rgba(41,84,214,.18)); }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.module-card { display: flex; gap: 14px; padding: 18px; }
.module-card .icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 2000; background: var(--sidebar); color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); animation: slideup .2s ease-out; }
.toast.error { background: var(--danger); }
@keyframes slideup { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .fb { grid-template-columns: 180px minmax(0, 1fr); }
  .fb-props { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 1024px) {
  .layout-form { grid-template-columns: 1fr; }
  .layout-form > aside { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 100; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar .burger { display: inline-flex; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .fb { grid-template-columns: 1fr; }
  .fb-palette { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .fb-palette button { width: auto; margin: 0; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- Assistant IA ---------- */
.ai-hint { display: flex; align-items: center; gap: 6px; padding: 8px 18px; background: linear-gradient(90deg, #f3efff, #eef2ff); border-bottom: 1px solid var(--border); }
.ai-hint i[data-lucide], .ai-hint svg { width: 15px; height: 15px; color: #7c3aed; }
.ai-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.btn-ai { border-color: #d9ccff; color: #6d28d9; background: #faf7ff; }
.btn-ai:hover { background: #f3edff; border-color: #b9a2ff; }
.btn.is-loading { cursor: progress; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-filled { animation: aiFill 2.2s ease-out; }
@keyframes aiFill { 0% { box-shadow: 0 0 0 3px rgba(124, 58, 237, .45); border-color: #7c3aed; background: #faf7ff; } 100% { box-shadow: none; } }
.audit-head { display: flex; gap: 20px; align-items: center; }
.audit-head p { margin: 0; }
.audit-score { --pct: calc(var(--score) * 1%); flex-shrink: 0; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(closest-side, #fff 78%, transparent 80%), conic-gradient(var(--color) var(--pct), var(--border) 0); font-weight: 800; }
.audit-score span { font-size: 28px; line-height: 1; color: var(--color); }
.audit-score small { color: var(--muted); font-weight: 500; }
.audit-checks { list-style: none; padding: 0; margin: 0; }
.audit-checks li { display: flex; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.audit-checks .badge svg { width: 13px; height: 13px; }
.cms-faq-preview details { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; }
.cms-faq-preview summary { cursor: pointer; font-weight: 600; }
.cms-faq-preview p { margin: 8px 0 0; }
