:root {
    --bg: #0b1650;
    --surface: #16257a;
    --surface-2: #2238b0;
    --text: #f2f3f8;
    --muted: #a9b6e8;
    --accent: #2b4bff;
    --accent-soft: #9fb4ff;
    --ok: #2ecc71;
    --warn: #f5a623;
    --err: #ff5c6c;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-soft); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Barre du haut ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; }
.brand img { height: 44px; width: auto; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--text); }
.link-quiet { color: var(--muted) !important; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff !important;
    border: 0;
    border-radius: 999px;
    padding: 10px 22px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn-small { padding: 6px 16px; font-size: 14px; }
.btn-ghost { background: transparent; border: 1px solid var(--surface-2); color: var(--text) !important; }
.btn-danger { background: transparent; border: 1px solid var(--err); color: var(--err) !important; }
.btn-danger:hover { background: var(--err); color: #fff !important; }

/* ---------- Messages ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 16px; }
.alert-ok { background: rgba(46, 204, 113, .15); border: 1px solid var(--ok); }
.alert-err { background: rgba(255, 92, 108, .15); border: 1px solid var(--err); }

/* ---------- Formulaires ---------- */
label { display: block; margin: 0 0 14px; color: var(--muted); font-size: 14px; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=url] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 18px; color: var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > label { flex: 1; margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Connexion ---------- */
.auth-card {
    max-width: 400px;
    margin: 8vh auto 0;
    background: var(--surface);
    padding: 28px;
    border-radius: 16px;
    border-top: 3px solid var(--accent);
}
.auth-logo { display: block; height: 110px; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; margin: 0 0 12px; font-size: 22px; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.muted { color: var(--muted); }
.auth-card .muted { text-align: center; margin-top: 0; }

/* ---------- Liste des clients ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar h1 { margin: 0; font-size: 24px; flex: 1; }
.toolbar input[type=search] { max-width: 300px; margin: 0; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px 18px; min-width: 120px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 1000px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
th { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.td-actions { white-space: nowrap; }
.cell-link { max-width: 380px; overflow-wrap: anywhere; font-size: 13px; color: var(--muted); }
.td-actions form { display: inline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: rgba(46, 204, 113, .18); color: var(--ok); }
.badge-warn { background: rgba(245, 166, 35, .18); color: var(--warn); }
.badge-err { background: rgba(255, 92, 108, .18); color: var(--err); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- Bandeau à gauche ---------- */
body.with-sidebar { --side-w: 250px; }
body.with-sidebar.side-collapsed { --side-w: 76px; }

.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--side-w);
    background: #101e66;
    border-right: 1px solid var(--surface-2);
    display: flex; flex-direction: column;
    overflow-x: hidden; overflow-y: auto;
    z-index: 50;
    transition: width .2s ease, transform .2s ease;
}
.side-brand { display: block; padding: 18px 16px 14px; text-align: center; border-bottom: 1px solid var(--surface-2); }
.side-brand img { max-width: 100%; max-height: 96px; width: auto; height: auto; }
.side-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }

.side-link, .side-sub {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: var(--text); text-decoration: none;
    font-weight: 600; font-size: 15px;
    cursor: pointer; list-style: none;
}
.side-link:hover, .side-sub:hover { background: var(--surface-2); }
.side-link.active, .side-sub.active { background: var(--accent); color: #fff; }
.side-group > summary { list-style: none; }
.side-group > summary::-webkit-details-marker { display: none; }
.side-group .chev { margin-left: auto; font-size: 18px; transition: transform .2s ease; }
.side-group[open] .chev { transform: rotate(90deg); }
.side-sub { margin-left: 34px; padding: 8px 12px; font-weight: 500; font-size: 14px; color: var(--muted); }
.side-sub.active { color: #fff; }
.ico { width: 20px; height: 20px; flex: 0 0 20px; }
.side-label { white-space: nowrap; }

.collapse-btn {
    margin: 10px auto 18px; width: 38px; height: 38px; flex: 0 0 38px;
    border-radius: 50%; border: 0; cursor: pointer;
    background: var(--surface-2); color: var(--text); font-size: 22px; line-height: 1;
}
.collapse-btn:hover { background: var(--accent); }
.content { margin-left: var(--side-w, 0); transition: margin-left .2s ease; }
.menu-toggle {
    display: none; position: fixed; top: 8px; left: 8px; z-index: 60;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--surface-2);
    background: var(--surface); color: var(--text); font-size: 20px; cursor: pointer;
}

body.side-collapsed .side-label,
body.side-collapsed .chev,
body.side-collapsed .side-sub { display: none; }
body.side-collapsed .side-link { justify-content: center; padding: 12px 0; }
body.side-collapsed .side-brand { padding: 12px 6px; }
body.side-collapsed .side-brand img { max-height: 48px; }
body.side-collapsed .collapse-btn { transform: rotate(180deg); }

@media (max-width: 900px) {
    .sidebar { width: 250px; transform: translateX(-100%); }
    body.side-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .7); }
    .content { margin-left: 0; padding-top: 52px; }
    .menu-toggle { display: block; }
    .collapse-btn { display: none; }
    body.side-collapsed .side-label { display: inline; }
    body.side-collapsed .chev { display: inline; }
    body.side-collapsed .side-sub { display: flex; }
    body.side-collapsed .side-link { justify-content: flex-start; padding: 11px 12px; }
}

/* ---------- Pages d'apparence : images, annonce, thèmes, profil ---------- */
.muted { color: var(--muted); }
input[type=file] {
    display: block; width: 100%; margin-top: 6px; padding: 10px;
    background: var(--bg); color: var(--text);
    border: 1px dashed var(--surface-2); border-radius: 10px; font: inherit;
}
textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 14px; min-height: 90px; resize: vertical;
    background: var(--bg); color: var(--text); border: 1px solid var(--surface-2); border-radius: 10px; font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.preview {
    display: flex; align-items: center; justify-content: center;
    min-height: 160px; margin: 8px 0 18px; padding: 14px; text-align: center;
    border-radius: var(--radius); color: var(--muted);
    background:
        repeating-conic-gradient(#1a2a85 0% 25%, #132070 0% 50%) 50% / 24px 24px;
}
.preview img { max-width: 100%; max-height: 320px; border-radius: 8px; }
.form-narrow { max-width: 520px; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.theme-card { background: var(--surface); border: 2px solid var(--surface-2); border-radius: 14px; padding: 14px; }
.theme-card.current { border-color: var(--accent); }
.theme-card h3 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.theme-preview { border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.tp-logo { width: 46px; height: 8px; border-radius: 4px; margin: 0 auto 10px; }
.tp-tiles { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
.tp-tiles span { display: block; height: 38px; border-radius: 6px; }
.tp-tiles span:first-child { grid-row: span 2; height: 82px; }
.tp-bar { height: 8px; border-radius: 4px; margin-top: 10px; opacity: .85; }
.swatches { display: flex; gap: 6px; margin-bottom: 12px; }
.swatches i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .15); }
.announce-preview { margin-top: 14px; padding: 12px 16px; border-radius: 10px; background: var(--bg); border-left: 4px solid var(--accent); }

/* Boutons d'action empilés : toujours visibles, même sur écran moyen */
.td-actions { white-space: normal; min-width: 130px; }
.td-actions form, .td-actions > a { display: block; margin: 0 0 6px; }
.td-actions .btn { width: 100%; text-align: center; }
