:root {
    --bg: #f4f5f8;
    --card: #ffffff;
    --text: #1d2130;
    --muted: #6b7185;
    --line: #e3e6ee;
    --primary: #4f46e5;
    --primary-soft: #eef0ff;
    --accent: #e5395b;
    --green: #15803d;
    --green-soft: #e3f6e9;
    --orange: #b45309;
    --orange-soft: #fdf1df;
    --red: #b91c1c;
    --red-soft: #fde8e8;
    --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 8px 0 4px; }
h3 { margin: 0 0 8px; }

/* Menu latéral (AdminMenu.java) */
.side {
    position: fixed; top: 0; left: 0; bottom: 0; width: 232px; z-index: 20;
    background: var(--card); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 14px 12px; overflow-y: auto;
}
.side ~ .page, .side ~ .footer { margin-left: 232px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 14px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 22px; justify-content: center; }
.logo {
    width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 800;
}
.side-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 18px; padding: 2px 10px; cursor: pointer; }
.side-nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.side-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 8px 4px; }
.side-section a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text); font-weight: 600; }
.side-section a:hover { background: var(--bg); text-decoration: none; }
.side-section a.on { background: var(--primary-soft); color: var(--primary); }
.side-ico { width: 20px; text-align: center; }
.side-logout { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 6px 0; border-top: 1px solid var(--line); }
.who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

/* Page */
.page { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.footer { max-width: 1200px; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.upper { text-transform: uppercase; letter-spacing: .04em; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--card); border-radius: var(--radius); border: 1px dashed var(--line); }

/* Cartes et grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 760px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.big-number { font-size: 28px; font-weight: 700; margin: 4px 0; }
.danger-zone { border-color: var(--red-soft); }

/* Formulaires */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; cursor: pointer; }
input[type=text], input[type=number], input[type=password], input[type=datetime-local], select, textarea {
    font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.chip { display: inline-block; margin: 2px 4px 0 0; padding: 1px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 12px; }
.chip.off { display: none; }
.filters { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters label { min-width: 180px; }
.cartes-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cartes-pick label { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.cartes-pick label span { display: flex; flex-direction: column; }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--line); background: #fff; color: var(--text);
}
.btn:hover { text-decoration: none; border-color: #c9cede; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }

/* Alertes et badges */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.err { background: var(--red-soft); color: var(--red); }
.err-text { color: var(--red); max-width: 260px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--muted); }
.badge.green, .badge.envoye { background: var(--green-soft); color: var(--green); }
.badge.grey, .badge.annule { background: var(--line); color: var(--muted); }
.badge.attente, .badge.encours { background: var(--orange-soft); color: var(--orange); }
.badge.erreur { background: var(--red-soft); color: var(--red); }

/* Tableaux */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }

/* Aperçu de la carte */
.phone-card { background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 6px 24px rgba(20, 24, 40, .08); border: 1px solid var(--line); }
.pc-author { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.pc-photo { height: 150px; border-radius: 12px; background: #eceef4; display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; margin-bottom: 10px; word-break: break-all; padding: 0 8px; }
.pc-photo img { width: 100%; height: 100%; object-fit: cover; }
.pc-photo.round { width: 150px; margin-left: auto; margin-right: auto; border-radius: 50%; }
.pc-title { font-weight: 700; font-size: 16px; }
.pc-body { color: var(--muted); font-size: 14px; white-space: pre-wrap; }
.pc-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pc-btn { padding: 6px 12px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; }
.pc-btn.alt { background: var(--primary-soft); color: var(--primary); }
.pc-btn:empty, .pc-more:empty { display: none; }
.pc-more { margin-top: 8px; font-size: 13px; color: var(--primary); font-weight: 600; }

/* Connexion */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.login-box form { text-align: left; margin-top: 12px; }

@media (max-width: 900px) {
    .split { grid-template-columns: 1fr; }
    .grid2, .cartes-pick { grid-template-columns: 1fr; }
    .side { position: sticky; width: auto; bottom: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; }
    .side-top { padding: 0; }
    .side-toggle { display: inline-block; }
    .side-nav { display: none; padding-top: 12px; }
    .side.open .side-nav { display: flex; }
    .side ~ .page, .side ~ .footer { margin-left: 0; }
    .page { padding: 16px; }
    .grid4 { grid-template-columns: 1fr 1fr; }
}

/* Pages larges (éditeur) */
.page.wide { max-width: 1320px; }
.split.editor { grid-template-columns: minmax(0, 1fr) 380px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.steps ol { margin: 4px 0 12px; padding-left: 20px; line-height: 1.7; }
.publish-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.publish-row label { min-width: 280px; flex: 1; }
.file-btn { cursor: pointer; }
.sticky-bottom { position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 6px 24px rgba(20, 24, 40, .1); }

/* Champs de l'éditeur de skin */
.skin-field { display: grid; grid-template-columns: 170px minmax(0, 1fr) 28px; gap: 10px; align-items: center; padding: 4px 0; }
.skin-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.skin-field.is-set .skin-label { color: var(--text); }
.skin-control { display: flex; gap: 8px; align-items: center; }
.skin-control input[type=range] { flex: 1; accent-color: var(--primary); }
.skin-control input[type=number] { width: 84px; }
.skin-control input[type=color] { width: 46px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.skin-control select { width: 100%; }
.skin-field:not(.is-set) input[type=color], .skin-field:not(.is-set) input[type=range] { opacity: .45; }
.check.mini { font-size: 12px; color: var(--muted); font-weight: 500; }
.skin-clear { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; border-radius: 6px; visibility: hidden; }
.skin-field.is-set .skin-clear { visibility: visible; }
.skin-clear:hover { background: var(--red-soft); color: var(--red); }
.skin-quad { border-top: 1px dashed var(--line); padding-top: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 12px; }
.grid4 .skin-field { grid-template-columns: 1fr; gap: 4px; }
.grid4 .skin-field .skin-control input[type=range] { display: none; }
.grid4 .skin-field .skin-control input[type=number] { width: 100%; }
.grid4 .skin-clear { display: none; }

/* Aperçu du fil */
.phone { width: 100%; max-width: 380px; border: 10px solid #1d2130; border-radius: 30px; overflow: hidden; background: #fff; max-height: calc(100vh - 80px); overflow-y: auto; }
.pv-feed { min-height: 560px; }
.pv-alert-title { font-weight: 700; font-size: 13px; padding: 8px 10px 4px; }
.pv-stories { display: flex; gap: 8px; padding: 4px 10px 10px; }
.pv-story { width: 46px; height: 64px; border-radius: 10px; background: linear-gradient(160deg, var(--primary), var(--accent)); opacity: .55; }
.pv-head { display: flex; gap: 8px; align-items: center; padding: 8px 10px; font-size: 13px; }
.pv-head small { color: var(--muted); }
.pv-avatar { width: 34px; height: 34px; border-radius: 50%; background: #dadde5; flex: none; }
.pv-img { height: 180px; background: linear-gradient(135deg, #c7d2fe, #fbcfe8); }
.pv-text { padding: 8px 10px; font-size: 13px; }
.pv-divider { height: 1px; background: #e3e6ee; margin: 0 6px; }
.pv-bar { display: flex; align-items: center; padding: 6px 8px 8px; }
.pv-pill { display: inline-flex; align-items: center; white-space: nowrap; }
.skin-control select.token { width: auto; min-width: 150px; }

/* Icônes de la barre du bas (éditeur de skin) */
.ico-prev { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; flex: none; }
.pv-gbab { position: sticky; bottom: 0; display: flex; justify-content: space-around; align-items: center; padding: 6px 4px 8px; border-top: 1px solid #e3e6ee; }
.pv-gbab-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 60px; }
.pv-gbab-btn small { font-size: 11px; }
.skin-control input[data-icon] { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.skin-control input[data-icon].bad { border-color: #c0392b; background: #fdecea; }
.ico-link { font-size: 12px; white-space: nowrap; }

/* Éditeur de skins : images de l'app à nom fixe */
.app-images { margin-bottom: 20px; }
.img-group + .img-group { margin-top: 18px; }
.img-group h3 { margin: 0 0 8px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.img-slot { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.img-thumb { height: 110px; border-radius: 6px; background: #f1f3f8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* Miniature : même hauteur que son cadre, largeur selon l'image (centrée) ; clic = agrandie */
.img-thumb img { height: 100%; width: auto; max-width: none; flex: none; display: block; cursor: zoom-in; }
/* Image agrandie : 3 fois la hauteur de la miniature (110 px), dans une fenêtre flottante */
.img-pop { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 18, 30, .72); display: flex; flex-direction: column;
           align-items: center; justify-content: center; gap: 10px; padding: 16px; cursor: zoom-out; }
.img-pop img { height: 330px; width: auto; max-width: 95vw; max-height: 85vh; object-fit: contain; border-radius: 8px;
               background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.img-pop span { color: #fff; font-weight: 600; font-size: 14px; }
.img-slot input[type=file] { font-size: 12px; max-width: 100%; }
.img-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
