/* Mozaiq — back-office */
:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #fafbff; --text: #17152e; --muted: #6b6f86; --faint: #9a9db2;
  --border: #e7e8f2; --border-strong: #d6d8e6;
  --primary: #5b4cf0; --primary-600: #4a3bdc; --primary-50: #f1efff; --primary-100: #e4e0ff;
  --sidebar: #15122c; --sidebar-2: #1e1a3d; --sidebar-text: #b9b6d6; --sidebar-active: #ffffff;
  --green: #0f9f6e; --green-bg: #e3f7ef; --amber: #b7791f; --amber-bg: #fdf3dd; --red: #d93a4a; --red-bg: #fde8ea;
  --blue: #2b6cd8; --blue-bg: #e5efff; --violet: #7a4bd8; --violet-bg: #f0e9ff; --cyan: #0e8aa6; --cyan-bg: #e0f6fa; --gray: #5f6478; --gray-bg: #eef0f5;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(23,21,46,.04), 0 6px 24px rgba(23,21,46,.05); --shadow-lg: 0 20px 60px rgba(23,21,46,.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0e1a; --surface: #181629; --surface-2: #1d1b31; --text: #ecebf7; --muted: #a09fb8; --faint: #6f6d88;
    --border: #2a2842; --border-strong: #37345a; --primary: #7d70ff; --primary-600: #9086ff; --primary-50: #221f45; --primary-100: #2d2960;
    --sidebar: #0b0a14; --sidebar-2: #16142a; --green-bg: #0f2e24; --amber-bg: #33280f; --red-bg: #3a1419; --blue-bg: #13243f; --violet-bg: #271a45; --cyan-bg: #0f2c33; --gray-bg: #25243a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0e1a; --surface: #181629; --surface-2: #1d1b31; --text: #ecebf7; --muted: #a09fb8; --faint: #6f6d88;
  --border: #2a2842; --border-strong: #37345a; --primary: #7d70ff; --primary-600: #9086ff; --primary-50: #221f45; --primary-100: #2d2960;
  --sidebar: #0b0a14; --sidebar-2: #16142a; --green-bg: #0f2e24; --amber-bg: #33280f; --red-bg: #3a1419; --blue-bg: #13243f; --violet-bg: #271a45; --cyan-bg: #0f2c33; --gray-bg: #25243a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 1em; }
code, pre, .code { font-family: var(--mono); font-size: 12.5px; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.app { display: grid; grid-template-columns: 252px 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; scrollbar-width: thin; scrollbar-color: #332f5c transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { color: #fff; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #7c6cff, #ff6b9d); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(124,108,255,.4); }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--sidebar-text); letter-spacing: 0; }
.site-link { margin: 0 14px 12px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--sidebar-2); color: #d9d6f3; font-size: 13px; }
.site-link:hover { color: #fff; background: #25214a; }
.nav { list-style: none; margin: 0; padding: 6px 10px 20px; flex: 1; }
.nav > li > a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--sidebar-text); font-weight: 500; transition: background .15s, color .15s; }
.nav > li > a:hover { background: var(--sidebar-2); color: #fff; }
.nav > li.open > a, .nav > li.active > a { color: var(--sidebar-active); background: var(--sidebar-2); }
.nav > li.active > a { background: linear-gradient(90deg, rgba(124,108,255,.28), rgba(124,108,255,.08)); }
.nav .chev { margin-left: auto; opacity: .5; transition: transform .2s; }
.nav li.open .chev { transform: rotate(180deg); }
.nav ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 34px; display: none; }
.nav li.open ul { display: block; }
.nav ul a { display: block; padding: 6px 12px; border-radius: 8px; color: var(--sidebar-text); font-size: 13px; }
.nav ul a:hover { color: #fff; }
.nav ul a.active { color: #fff; background: rgba(255,255,255,.06); }
.nav .count { margin-left: auto; background: var(--primary); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 600; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-foot a { color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar .menu-toggle { display: none; }
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input[type=search] { padding-left: 38px; background: var(--surface); }
.topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-menu { position: relative; }
.user-menu > button { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; color: var(--text); font: inherit; padding: 4px 6px; border-radius: 10px; }
.user-menu > button:hover { background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #ff6b9d); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; object-fit: cover; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); }
.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 2px; font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin: -4px 0 16px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; margin-bottom: 12px; }
.grid { display: grid; gap: 20px; }
.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)); }
.stats-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 20px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.split-left { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.sticky { position: sticky; top: 80px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .label .icon { color: var(--primary); }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .trend { font-size: 12px; font-weight: 600; }
.trend.up { color: var(--green); } .trend.down { color: var(--red); }
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin: 0 auto 14px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-icon { width: 34px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-danger { color: var(--red); }

/* Forms */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.req { color: var(--red); }
input:not([type]), input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=month], input[type=tel], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 14px var(--font); transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9db2' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.help { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.field-inline { display: flex; gap: 8px; align-items: center; }
.field-toggle { display: flex; gap: 12px; align-items: flex-start; }
.toggle-label { font-weight: 600; font-size: 13.5px; cursor: pointer; display: block; }
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; margin-top: 1px; }
.switch input[type=checkbox] { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; cursor: pointer; transition: background .2s; }
.switch span::before { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(17px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); }
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 8px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.color-input { display: flex; gap: 8px; }
.color-input input[type=color] { width: 44px; height: 40px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; flex-shrink: 0; }
.image-input { display: flex; gap: 8px; align-items: center; }
.image-input__preview { width: 44px; height: 40px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; color: var(--faint); }
.image-input__preview img { width: 100%; height: 100%; object-fit: cover; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 700; margin-bottom: 12px; font-size: 15px; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--bg); border: 1px solid var(--border-strong); border-right: 0; border-radius: 10px 0 0 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-group input { border-radius: 0 10px 10px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; color: var(--muted); font: 600 13.5px var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; } .tab-panel.active { display: block; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .pill { padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 12.5px; }
.filters .pill.active { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); }
.filters form { margin-left: auto; display: flex; gap: 6px; }
.filters input[type=search] { height: 34px; width: 220px; }
.filters select { height: 34px; width: auto; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 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 { background: var(--surface-2); }
.table .title { font-weight: 600; color: var(--text); }
.table .title:hover { color: var(--primary); }
.row-actions { display: flex; gap: 10px; font-size: 12.5px; margin-top: 3px; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
.row-actions a, .row-actions button { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.row-actions a:hover, .row-actions button:hover { color: var(--primary); }
.row-actions .danger:hover { color: var(--red); }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; color: var(--faint); }
.cell-flex { display: flex; align-items: center; gap: 12px; }
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); padding: 0 8px; }
.pagination a:hover { background: var(--surface); }
.pagination .current { background: var(--primary); color: #fff; }
.bulk { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bulk select { width: auto; height: 32px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: var(--green); } .badge-amber { background: var(--amber-bg); color: var(--amber); } .badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); } .badge-violet { background: var(--violet-bg); color: var(--violet); } .badge-cyan { background: var(--cyan-bg); color: var(--cyan); } .badge-gray { background: var(--gray-bg); color: var(--gray); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); font-size: 12px; color: var(--muted); margin: 0 4px 4px 0; }
.score { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; border: 3px solid; }
.score.good { color: var(--green); border-color: var(--green); } .score.ok { color: var(--amber); border-color: var(--amber); } .score.bad { color: var(--red); border-color: var(--red); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.good { background: var(--green); } .dot.ok { background: var(--amber); } .dot.bad { background: var(--red); }

/* Notices */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.notice-success { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.notice-error { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.notice-warning { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.notice-info { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 30%, transparent); color: var(--blue); }
.notice .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: grid; gap: 8px; }
.toast { background: #17152e; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; font-weight: 500; animation: toast-in .25s ease-out; max-width: 380px; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* Lists & misc */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.checklist li { gap: 10px; }
.check-circle { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; }
.check-circle.done { background: var(--green); border-color: var(--green); color: #fff; }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #ff6b9d); border-radius: 99px; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.log { background: #0f0e1a; color: #d6d4ee; padding: 16px; border-radius: 12px; font: 12px/1.6 var(--mono); max-height: 420px; overflow: auto; white-space: pre-wrap; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* Chart */
.chart { position: relative; height: 200px; display: flex; align-items: flex-end; gap: 2px; padding-top: 10px; }
.chart .bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; cursor: default; opacity: .85; transition: opacity .15s; }
.chart .bar:hover { opacity: 1; }
.chart .bar::after { content: ""; position: absolute; inset: -40px -1px 0; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.chart-grid { position: absolute; inset: 10px 0 0; pointer-events: none; }
.chart-grid span { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); font-size: 10.5px; color: var(--faint); }
.chart-tip { position: fixed; pointer-events: none; background: #17152e; color: #fff; padding: 7px 10px; border-radius: 8px; font-size: 12px; z-index: 100; white-space: nowrap; display: none; box-shadow: var(--shadow-lg); }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { position: relative; border-radius: 12px; overflow: hidden; background: var(--bg); border: 2px solid transparent; aspect-ratio: 1; cursor: pointer; transition: border-color .15s, transform .15s; }
.media-item:hover { border-color: var(--primary-100); }
.media-item.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .file { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 10px; font-size: 12px; word-break: break-all; }
.media-item .alt-warn { position: absolute; top: 6px; right: 6px; background: var(--amber); color: #fff; border-radius: 6px; font-size: 10px; font-weight: 700; padding: 2px 6px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.drag { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,14,26,.55); backdrop-filter: blur(3px); z-index: 900; display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: min(1000px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal.small { width: min(520px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 20px; overflow: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
@keyframes fade { from { opacity: 0; } }

/* Rich text */
.richtext { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rt-toolbar button, .rt-toolbar select { height: 28px; min-width: 28px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); display: grid; place-items: center; font: 600 12px var(--font); padding: 0 6px; width: auto; }
.rt-toolbar select { padding-right: 22px; background-position: right 4px center; }
.rt-toolbar button:hover { background: var(--bg); color: var(--text); }
.rt-editor { min-height: 140px; max-height: 480px; overflow: auto; padding: 12px 14px; outline: none; line-height: 1.6; }
.rt-editor:focus { box-shadow: inset 0 0 0 2px var(--primary-100); }
.rt-editor h2 { font-size: 1.3em; } .rt-editor h3 { font-size: 1.12em; } .rt-editor p { margin: 0 0 .8em; }
.rt-editor blockquote { border-left: 3px solid var(--primary); margin: 0 0 1em; padding-left: 12px; color: var(--muted); }

/* SERP preview */
.serp { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--surface); font-family: arial, sans-serif; }
.serp .serp-site { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.serp .serp-fav { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--primary); }
.serp .serp-title { color: #1a0dab; font-size: 19px; line-height: 1.3; margin-bottom: 3px; }
.serp .serp-desc { color: #4d5156; font-size: 13.5px; line-height: 1.55; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .serp .serp-title { color: #99c3ff; } :root:not([data-theme="light"]) .serp .serp-desc { color: #bdc1c6; } }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; font-size: 13px; }
.checks .dot { margin-top: 6px; }
.meter { font-size: 12px; margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.meter .progress { flex: 1; height: 5px; }

/* Repeater rows */
.rows { display: grid; gap: 8px; }
.row-item { display: grid; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.row-item .handle { cursor: grab; color: var(--faint); }

/* Plugin & theme cards */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.pkg { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.pkg:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(23,21,46,.1); }
.pkg-top { display: flex; gap: 12px; align-items: flex-start; }
.pkg-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), #ff6b9d); flex-shrink: 0; }
.pkg h3 { margin: 0 0 2px; font-size: 15.5px; }
.pkg .meta { font-size: 12px; color: var(--muted); }
.pkg p { color: var(--muted); font-size: 13px; margin: 0; flex: 1; }
.pkg .pkg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.pkg .price { font-weight: 700; margin-right: auto; }
.pkg.inactive .pkg-icon { background: var(--gray-bg); color: var(--gray); }
.theme-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.theme-card .shot { aspect-ratio: 16/10; background: linear-gradient(135deg, var(--primary-50), var(--bg)); display: grid; place-items: center; color: var(--primary); overflow: hidden; }
.theme-card .shot img { width: 100%; height: 100%; object-fit: cover; }
.theme-card .body { padding: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.theme-card.active { outline: 3px solid var(--primary); }
.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Login / install */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-side { background: radial-gradient(circle at 20% 20%, #7c6cff 0, transparent 45%), radial-gradient(circle at 80% 70%, #ff6b9d 0, transparent 40%), #15122c; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.03em; max-width: 440px; margin: 0 0 14px; }
.auth-side p { color: #d0cdf0; max-width: 420px; font-size: 15px; }
.auth-side .tiles { position: absolute; right: -60px; top: 50%; transform: translateY(-50%) rotate(-12deg); display: grid; grid-template-columns: repeat(3, 90px); gap: 14px; opacity: .22; }
.auth-side .tiles span { height: 90px; border-radius: 22px; background: #fff; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-box { width: min(400px, 100%); }
.auth-box h1 { font-size: 26px; margin-bottom: 6px; }
.auth-box .btn { width: 100%; }

/* Responsive */
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } .sticky { position: static; } }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 100; transform: translateX(-100%); transition: transform .25s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
  .topbar { padding: 0 16px; } .topbar .menu-toggle { display: inline-flex; }
  .content { padding: 20px 16px 60px; }
  .grid-2, .grid-3, .split-left, .type-cards { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; }
  .row-actions { opacity: 1; }
  .filters form { margin-left: 0; width: 100%; } .filters input[type=search] { flex: 1; width: auto; }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } .topbar-search { display: none; } .page-head h1 { font-size: 20px; } }
@media print { .sidebar, .topbar, .page-head .actions { display: none !important; } .app { display: block; } }

/* Médiathèque : dossiers, sélection, retouche */
.media-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.media-folders { padding: 14px; position: sticky; top: 76px; }
.media-folders a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.media-folders a:hover { background: var(--bg); }
.media-folders a.active { background: var(--primary-50, var(--bg)); color: var(--primary); font-weight: 600; }
.media-folders .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-newfolder { display: flex; gap: 6px; margin: 12px 0 8px; }
.media-newfolder input { height: 32px; font-size: 13px; }
.media-cell { position: relative; }
.media-check { position: absolute; top: 8px; left: 8px; z-index: 2; background: rgba(255,255,255,.9); border-radius: 6px; padding: 3px 5px; line-height: 0; opacity: 0; transition: opacity .15s; }
.media-cell:hover .media-check, .media-check:has(input:checked), [data-media-bulk].has-selection .media-check { opacity: 1; }
.media-cell:has(input:checked) .media-item { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.media-bulk { position: sticky; top: 64px; z-index: 5; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.media-bulk select { width: auto; height: 32px; }
.img-editor { position: relative; user-select: none; line-height: 0; background: repeating-conic-gradient(var(--bg) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; border-radius: 12px; overflow: hidden; }
.img-editor img { width: 100%; display: block; }
.img-editor.cropping { cursor: crosshair; }
.img-editor.focal-mode { cursor: pointer; }
.img-crop { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }
.img-focal { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(0,0,0,.4); pointer-events: none; }
.img-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 860px) { .media-layout { grid-template-columns: 1fr; } .media-folders { position: static; } }
