/* Portail local — même charte que l'Atelier Marque Blanche en ligne. */
:root {
    --bg: #eef1ee;
    --panel: #ffffff;
    --panel-2: #f5f7f5;
    --ink: #1c2420;
    --muted: #5b6861;
    --line: #d5dcd7;
    --accent: #1f5a86;
    --accent-ink: #ffffff;
    --accent-soft: #e2edf6;
    --ok: #2e7d4f;
    --ok-soft: #e1f2e7;
    --warn: #9a5b12;
    --font-ui: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --radius: 10px;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #121614;
      --panel: #1a201d;
      --panel-2: #202724;
      --ink: #e4ebe6;
      --muted: #9aa8a0;
      --line: #2e3833;
      --accent: #86b4dc;
      --accent-ink: #0d1a24;
      --accent-soft: #1d2d3a;
      --ok: #7cc79a;
      --ok-soft: #1b3024;
      --warn: #e0a55a;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121614;
    --panel: #1a201d;
    --panel-2: #202724;
    --ink: #e4ebe6;
    --muted: #9aa8a0;
    --line: #2e3833;
    --accent: #86b4dc;
    --accent-ink: #0d1a24;
    --accent-soft: #1d2d3a;
    --ok: #7cc79a;
    --ok-soft: #1b3024;
    --warn: #e0a55a;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    padding: 0 16px;
  }
  button, input, select, textarea { font: inherit; color: inherit; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .app { max-width: 1480px; margin: 0 auto; padding-block: 18px 32px; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }

  .topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
  .brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
  .brand h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
  .brand p { margin: 0; color: var(--muted); font-size: 0.9rem; }
  .tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
  .tabs button {
    border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; cursor: pointer;
    font-weight: 600; color: var(--muted);
  }
  .tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
  .count-pill { font-family: var(--font-mono); font-size: 0.75rem; margin-left: 6px; opacity: 0.8; }

  .view[hidden] { display: none !important; }

  /* ── Visionneuse ─────────────────────────────────────────── */
  .viewer { display: flex; flex-direction: column; gap: 10px; flex: 1; }
  .toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
  }
  .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .seg button { border: 0; background: var(--panel); padding: 6px 12px; cursor: pointer; font-weight: 500; }
  .seg button + button { border-left: 1px solid var(--line); }
  .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .iconbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
  .iconbtn:disabled { opacity: 0.4; cursor: default; }
  .address {
    flex: 1 1 220px; min-width: 0; font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .address b { color: var(--ink); font-weight: 500; }
  .stage {
    position: relative; flex: 1; min-height: 520px; background: var(--panel-2);
    border: 1px solid var(--line); border-radius: var(--radius); display: flex; justify-content: center; overflow: hidden;
  }
  .stage iframe { border: 0; width: 100%; height: 100%; min-height: 520px; background: #fff; display: block; transition: width 0.25s ease; }
  .stage.mobile iframe { width: 390px; max-width: 100%; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .stage-note { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
  .toast {
    position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
    background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 0.88rem;
    max-width: calc(100% - 32px); box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  }
  .hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

  /* ── Configurateur ───────────────────────────────────────── */
  .builder { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 16px; flex: 1; align-items: start; }
  @media (max-width: 1000px) { .builder { grid-template-columns: 1fr; } }
  .form-col { display: flex; flex-direction: column; gap: 12px; }
  .preview-col { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 40px); min-height: 560px; }
  @media (max-width: 1000px) { .preview-col { position: static; height: 80dvh; } }
  .preview-col .stage { min-height: 0; }
  .preview-col .stage iframe { min-height: 0; }

  details.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
  details.box > summary {
    list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px;
  }
  details.box > summary::-webkit-details-marker { display: none; }
  details.box > summary::after { content: "+"; color: var(--muted); font-weight: 400; }
  details.box[open] > summary::after { content: "–"; }
  details.box > summary small { color: var(--muted); font-weight: 400; margin-left: auto; }
  .box-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }

  .presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .presets span { color: var(--muted); font-size: 0.85rem; margin-right: 4px; }
  .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 0.88rem; }
  .chip:hover { border-color: var(--accent); }

  label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); font-weight: 500; }
  label.field input, label.field textarea, label.field select, .row input, .row select {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; color: var(--ink); font-size: 0.92rem; width: 100%; min-width: 0;
  }
  label.field textarea { resize: vertical; min-height: 64px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .colors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .colors input[type="color"] { padding: 2px; height: 36px; cursor: pointer; }
  .slug { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
  .slug b { color: var(--ink); font-weight: 500; }

  .rows { display: flex; flex-direction: column; gap: 6px; }
  .row { display: grid; grid-template-columns: 1fr 120px; gap: 6px; }
  .product { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; grid-template-columns: 1fr 90px; gap: 6px; background: var(--panel-2); }
  .product .full { grid-column: 1 / -1; }
  .product input, .product select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; font-size: 0.9rem; }
  .product .num { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); grid-column: 1 / -1; }

  .logo-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .logo-thumb { width: 120px; height: 44px; border: 1px dashed var(--line); border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); overflow: hidden; color: var(--muted); font-size: 0.75rem; }
  .logo-thumb img { max-width: 100%; max-height: 100%; }
  .btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
  .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .btn:disabled { opacity: 0.5; cursor: default; }

  .send { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
  .send h2 { margin: 0; font-size: 1rem; }
  .send p { margin: 0; }
  .send-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .status { font-size: 0.88rem; }
  .status[data-kind="ok"] { color: var(--ok); }
  .status[data-kind="error"] { color: var(--warn); }

  pre.code {
    margin: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
    font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.45; max-height: 280px; overflow: auto; white-space: pre;
  }
  .code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .code-head b { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 500; }

  /* ── Demandes ───────────────────────────────────────────── */
  .requests { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .req { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 14px; border-top: 1px solid var(--line); }
  .req:first-child { border-top: 0; }
  .req h3 { margin: 0; font-size: 0.98rem; }
  .req .meta { color: var(--muted); font-size: 0.82rem; font-family: var(--font-mono); }
  .pill { font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; align-self: start; }
  .pill.sent { background: var(--accent-soft); color: var(--accent); }
  .pill.done { background: var(--ok-soft); color: var(--ok); }
  .empty { padding: 18px 14px; color: var(--muted); }

  @media (max-width: 560px) {
    .two, .colors { grid-template-columns: 1fr; }
    .row { grid-template-columns: 1fr; }
  }
  @media (prefers-reduced-motion: reduce) { .stage iframe { transition: none; } }

  .layout { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; flex: 1; align-items: start; }
  @media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
  .side { display: flex; flex-direction: column; gap: 12px; }
  .shop-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .shop { display: grid; grid-template-columns: 34px 1fr; gap: 4px 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
  .shop:first-child { border-top: 0; }
  .shop.is-active { background: var(--accent-soft); }
  .swatch { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); grid-row: span 2; }
  .shop h3 { margin: 0; font-size: 0.98rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .shop .meta { color: var(--muted); font-size: 0.8rem; font-family: var(--font-mono); }
  .shop .actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
  .shop .actions form { display: contents; }
  .btn.small { padding: 4px 10px; font-size: 0.82rem; }
  .flash { margin: 0; padding: 10px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 500; }
  .flash[data-kind="error"] { background: var(--accent-soft); color: var(--warn); }
  .main-stage { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 110px); min-height: 560px; position: sticky; top: 12px; }
  @media (max-width: 900px) { .main-stage { position: static; height: 80dvh; } }
  .main-stage .stage { min-height: 0; }
  .main-stage .stage iframe { min-height: 0; }
  a.btn { text-decoration: none; display: inline-block; }
  .toolbar a.btn { color: inherit; }
  .confirm { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--warn); border-radius: 8px; grid-column: 2; font-size: 0.85rem; }
  a.btn:not(.btn-primary) { color: var(--ink); }
  .password-field { position: relative; display: block; }
  label.field .password-field input { padding-right: 84px; }
  .password-toggle {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    background: none; border: 0; padding: 4px 8px; cursor: pointer;
    color: var(--accent); font-size: 0.8rem; font-weight: 600;
  }
  .confirm.access input { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
  .shop .look { grid-column: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .look-colors { display: inline-flex; height: 14px; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
  .look-colors span { width: 16px; }
  .shop > :not(.swatch) { grid-column: 2; }
  .shop .swatch { grid-column: 1; grid-row: 1 / span 3; }
  .btn.danger { color: var(--warn); border-color: var(--warn); }
  a.btn.danger:not(.btn-primary) { color: var(--warn); }
  .btn.danger-solid { background: var(--warn); color: #fff; border-color: var(--warn); }
  .confirm.danger-zone input { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; box-sizing: border-box; }
