/* Administration */
:root {
  --bg: #f5f3ef; --panel: #fff; --ink: #24201c; --soft: #6b635a; --line: #e4ded4;
  --accent: #8c3b2e; --ok: #2f6b3a; --danger: #a12a2a; --warn: #8a5a00;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
body.admin { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
body.admin-guest { display: flex; align-items: center; justify-content: center; }
a { color: var(--accent); }
h1 { font-family: var(--serif); font-size: 1.9rem; margin: 0 0 .4rem; font-weight: 600; }
h2 { font-family: var(--serif); font-size: 1.3rem; margin: 2rem 0 .8rem; font-weight: 600; }
.box h2:first-child { margin-top: 0; }
code { background: rgba(0,0,0,.06); padding: .1em .35em; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: .5rem 0; width: 100%; }
.muted { color: var(--soft); }
.small { font-size: .85rem; }

/* Barre latérale */
.side { background: #231e1a; color: #e8e0d5; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.side-brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; padding: 0 .6rem; }
.side-brand strong { font-family: var(--serif); font-size: 1.2rem; }
.side-brand span { font-size: .72rem; text-transform: uppercase; letter-spacing: .15em; opacity: .6; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #e8e0d5; text-decoration: none; padding: .55rem .7rem; border-radius: 6px; display: flex; align-items: center; justify-content: space-between; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.pill { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .5rem; font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding: 0 .7rem; font-size: .9rem; }
.side-foot a, .linkish { color: #cfc5b8; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.side-foot a:hover, .linkish:hover { color: #fff; }

.main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1200px; width: 100%; }
.page-title { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }

@media (max-width: 860px) {
  body.admin { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; gap: .8rem; padding: 1rem; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { flex-direction: row; gap: 1.2rem; margin-top: 0; }
}

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #c9bfb1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(.92); border-color: var(--accent); }
.btn-small { padding: .35rem .7rem; font-size: .88rem; }
.btn-block { width: 100%; margin-top: .6rem; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--accent); text-decoration: underline; }
.btn-link.danger, .danger { color: var(--danger); }
form.inline { display: inline; }

/* Messages */
.notice { padding: .8rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.notice-success { background: #edf6ee; border-color: #bcd9c0; color: var(--ok); }
.notice-error { background: #fbeeee; border-color: #e8bcbc; color: var(--danger); }
.notice-warning { background: #fdf5e3; border-color: #ecd59f; color: var(--warn); }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 1rem; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); background: #faf8f5; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr.unread td { font-weight: 600; background: #fffaf2; }
.table.narrow { max-width: 680px; }
.actions { white-space: nowrap; text-align: right; }
.actions > * { margin-left: .8rem; }
.thumb { width: 44px; height: 66px; object-fit: cover; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.25); display: block; }
.thumb-empty { background: linear-gradient(160deg, #c9a79f, var(--accent)); }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: #ece7df; color: var(--soft); }
.tag-ok { background: #e3f1e5; color: var(--ok); }
.tag-accent { background: #f6e6e2; color: var(--accent); }
.empty-state { background: var(--panel); border: 1px dashed var(--line); padding: 2rem; text-align: center; border-radius: 8px; color: var(--soft); }

/* Tableau de bord */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: .3rem; transition: .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px -8px rgba(0,0,0,.2); }
.card strong { color: var(--accent); font-size: 1.05rem; }
.card span { color: var(--soft); font-size: .9rem; }

/* Formulaires */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.box.narrow, .narrow { max-width: 560px; }
fieldset.box legend { font-weight: 700; padding: 0 .4rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.label { font-weight: 600; font-size: .9rem; }
.help { font-size: .82rem; color: var(--soft); margin: .2rem 0 0; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid #d7cfc3; border-radius: 6px; background: #fff; width: 100%; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.input-lg { font-size: 1.3rem !important; font-family: var(--serif); padding: .7rem .8rem !important; }
.check { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.color-field input[type=color] { width: 80px; height: 42px; padding: 2px; border: 1px solid #d7cfc3; border-radius: 6px; background: #fff; }

.edit-form { display: grid; grid-template-columns: 1fr 310px; gap: 1.5rem; align-items: start; margin-top: 1rem; }
.edit-side { position: sticky; top: 1rem; }
@media (max-width: 1000px) { .edit-form { grid-template-columns: 1fr; } .edit-side { position: static; } }

.link-row { display: grid; grid-template-columns: 180px 1fr; gap: .5rem; margin-bottom: .5rem; }
@media (max-width: 640px) { .link-row { grid-template-columns: 1fr; } }

.image-field { display: flex; gap: 1rem; align-items: flex-start; }
.image-field > div { min-width: 0; flex: 1; }
.image-preview { width: 90px; height: 120px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex-shrink: 0; }
.image-empty { display: flex; align-items: center; justify-content: center; text-align: center; font-size: .75rem; color: var(--soft); background: #f3efe9; }
.image-field input[type=file] { font-size: .85rem; max-width: 100%; }

.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 1.5rem 0 1rem; }
.settings-form { max-width: 860px; }

/* Éditeur */
.ed { border: 1px solid #d7cfc3; border-radius: 6px; background: #fff; overflow: hidden; }
.ed:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px; background: #faf8f5; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.ed-bar button { font: inherit; font-size: .82rem; padding: .3rem .55rem; border: 1px solid transparent; background: none; border-radius: 4px; cursor: pointer; color: var(--ink); }
.ed-bar button:hover { background: #fff; border-color: var(--line); }
.ed-bar button.active { background: var(--ink); color: #fff; }
.ed-sep { width: 1px; background: var(--line); margin: 3px 4px; }
.ed-area { padding: 1rem 1.2rem; font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; outline: none; overflow-y: auto; max-height: 70vh; }
.ed-area h2 { font-size: 1.5rem; margin: 1.2em 0 .4em; }
.ed-area h3 { font-size: 1.2rem; margin: 1em 0 .4em; }
.ed-area p { margin: 0 0 .9em; }
.ed-area blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding-left: 1em; font-style: italic; }
.ed-area img { max-width: 100%; height: auto; }
.ed-area hr { border: 0; text-align: center; }
.ed-area hr::after { content: "❧"; color: var(--accent); }
.ed textarea.ed-source { display: none; border: 0; border-radius: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; min-height: 300px; }
.ed.ed-is-source .ed-area { display: none; }
.ed.ed-is-source textarea.ed-source { display: block; }

/* Message */
.message-view { max-width: 760px; }
.message-body { background: #faf8f5; border-radius: 6px; padding: 1rem 1.2rem; margin: 1rem 0 1.5rem; white-space: normal; }
.row-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }

/* Connexion */
.login-box { width: min(400px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; box-shadow: 0 20px 50px -20px rgba(0,0,0,.25); }
.admin-guest .main { padding: 0; width: auto; }

textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.box-alert { border-color: #d4a24c; box-shadow: 0 0 0 3px rgba(212,162,76,.25); }
.store-rows { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.store-row { display: grid; grid-template-columns: 130px 1fr 1.2fr auto auto; gap: .7rem; align-items: center; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fcfbf9; }
.store-row input[type=file] { font-size: .82rem; max-width: 100%; }
.store-logo-preview { height: 44px; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: center; padding: 4px 8px; }
.store-logo-preview img { max-height: 34px; max-width: 100%; object-fit: contain; }
.store-logo-preview span { font-size: .72rem; color: var(--soft); }
.check.small { font-size: .82rem; margin: 0; white-space: nowrap; }
@media (max-width: 760px) { .store-row { grid-template-columns: 1fr 1fr; } }
