/* Charte : ardoise, turquoise et or du logo « Au Chat l’Heureux ». Cartes par étape, récapitulatif sur fond or pâle. */
:root {
  --teal: #1a7b7b; --teal-dark: #145f5f; --heading: #203038; --on-teal: #ffffff;
  --gold: #f2b850; --gold-soft: #fdf4de;
  --ink: #203038; --muted: #55646b; --line: #dce2e4; --line-strong: #b4c0c4;
  --bg: #f4f7f7; --card: #ffffff;
  --danger: #b3261e; --danger-bg: #fdecea; --err-text: #5f1410;
  --ok: #1e6b3a; --warn: #8a5a00; --focus: rgba(26, 123, 123, 0.35);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal: #46b5b2; --teal-dark: #7fd0cd; --heading: #e7edef; --on-teal: #0b1a1d;
    --gold: #d9a23f; --gold-soft: #2b2516;
    --ink: #e7edef; --muted: #9fb0b6; --line: #2c3d44; --line-strong: #47595f;
    --bg: #0f191d; --card: #17242a;
    --danger: #ff8a80; --danger-bg: #3a1f1d; --err-text: #ffd9d5;
    --ok: #7bd49a; --warn: #e8b85a; --focus: rgba(127, 208, 205, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --teal: #46b5b2; --teal-dark: #7fd0cd; --heading: #e7edef; --on-teal: #0b1a1d;
  --gold: #d9a23f; --gold-soft: #2b2516;
  --ink: #e7edef; --muted: #9fb0b6; --line: #2c3d44; --line-strong: #47595f;
  --bg: #0f191d; --card: #17242a;
  --danger: #ff8a80; --danger-bg: #3a1f1d; --err-text: #ffd9d5;
  --ok: #7bd49a; --warn: #e8b85a; --focus: rgba(127, 208, 205, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.top {
  text-align: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 16px;
  background: var(--card);
  border-bottom: 6px solid var(--gold);
}
.logo { width: 190px; height: auto; max-width: 70%; background: #fff; border-radius: 14px; padding: 6px 10px; }
.top h1 { margin: 8px 0 2px; font-size: 1.35rem; color: var(--heading); text-wrap: balance; }
.sub { margin: 0; color: var(--muted); font-size: 0.95rem; }

main { max-width: 640px; margin: 0 auto; padding: 14px 16px 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.card h3 { margin: 18px 0 8px; font-size: 0.95rem; color: var(--teal-dark); text-transform: uppercase; letter-spacing: 0.03em; }
.n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--teal); color: var(--on-teal); font-size: 0.9rem; flex: none;
}

.field { margin: 0 0 12px; min-width: 0; }
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
abbr { color: var(--danger); text-decoration: none; }

input, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  font: inherit;
  font-size: 16px; /* évite le zoom automatique sur iPhone */
  background: var(--card);
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  border-color: var(--teal);
}
input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.cp-ville { grid-template-columns: 0.8fr 1.2fr; }
@media (max-width: 380px) {
  .grid2, .cp-ville { grid-template-columns: 1fr; }
}

.inline { display: flex; gap: 8px; align-items: stretch; }
.inline input { flex: 1; }

.hint { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

/* Boutons */
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 48px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn.big { min-height: 54px; font-size: 1.05rem; }
.btn.small { width: auto; min-height: 46px; padding: 8px 14px; font-size: 0.9rem; }
.btn.primary { background: var(--teal); color: var(--on-teal); }
.btn.primary:hover, .btn.primary:active { filter: brightness(0.92); }
.btn.secondary { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
.btn.ghost { background: transparent; color: var(--teal-dark); border-color: var(--line); font-weight: 600; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.actions { display: grid; gap: 10px; margin: 6px 0 14px; }

/* Récapitulatif */
.recap { background: var(--gold-soft); border-color: var(--gold); }
.recap dl { margin: 0; }
.recap dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line-strong); }
.recap dt { color: var(--ink); }
.recap dd { margin: 0; font-weight: 700; white-space: nowrap; }
.recap .total { border-bottom: 0; padding-top: 10px; font-size: 1.05rem; }
.recap .total small { font-weight: 400; color: var(--muted); }
.recap .total dd { color: var(--teal-dark); font-size: 1.15rem; }

/* Erreurs et messages */
.errors {
  background: var(--danger-bg);
  border: 1.5px solid var(--danger);
  color: var(--err-text);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
}
.errors strong { display: block; margin-bottom: 4px; }
.errors ul { margin: 4px 0 0; padding-left: 20px; }
.errors a { color: inherit; font-weight: 600; }
.status { margin: 8px 0 0; font-size: 0.9rem; color: var(--ok); min-height: 1.2em; }
.status.warn { color: var(--warn); }

.result { border-color: var(--teal); border-width: 2px; }
.filename { margin: 0 0 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; word-break: break-all; color: var(--muted); }

details.card > summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
details.card[open] > summary { margin-bottom: 8px; }
.help ul { padding-left: 20px; margin: 6px 0 10px; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 6px 16px 28px; }

/* ===== Connexion ===== */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-box .logo { margin: 0 auto 8px; display: block; max-width: 70%; height: auto; }
.login-box h1 { font-size: 1.3rem; margin: 6px 0 12px; }
.login-box .card { text-align: left; }
.form-error { background: var(--danger-bg); border: 1.5px solid var(--danger); color: var(--err-text); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: 0.92rem; }
.center { text-align: center; }

/* ===== Structure de l'application ===== */
main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.page-title { font-size: 1.3rem; margin: 6px 0 12px; }
.conn { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); text-align: center; }
.conn.ok { color: var(--ok); }
.conn.offline, .conn.auth { color: var(--warn); }
h3 { font-size: 1rem; margin: 16px 0 8px; color: var(--teal-dark); }

.notice { background: var(--gold-soft); border: 1.5px solid var(--gold); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; font-size: 0.92rem; }
.notice p { margin: 0 0 8px; }
.notice .btn { margin-top: 2px; }
.notice-inline { background: var(--gold-soft); border-left: 4px solid var(--gold); padding: 8px 12px; border-radius: 6px; font-size: 0.88rem; margin: 8px 0; }
.save-status { margin: 0 0 10px; font-size: 0.92rem; color: var(--ok); }
.save-status.warn { color: var(--warn); font-weight: 600; }

/* ===== Barre d'onglets (en bas) ===== */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; appearance: none; background: transparent; border: 0; border-top: 3px solid transparent; color: var(--muted); font: inherit; font-size: 0.75rem; font-weight: 600; min-height: 58px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--teal-dark); border-top-color: var(--gold); }
.tab:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; }

/* ===== Historique ===== */
.hist { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.hist-item { width: 100%; text-align: left; appearance: none; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font: inherit; cursor: pointer; display: grid; gap: 2px; min-height: 64px; }
.hist-item:active { border-color: var(--teal); }
.hist-item .muted { color: var(--muted); font-size: 0.85rem; }
.back { margin-bottom: 10px; }
.detail { margin: 0 0 10px; }
.detail > div { padding: 6px 0; border-bottom: 1px dashed var(--line-strong); }
.detail dt { font-size: 0.8rem; color: var(--muted); }
.detail dd { margin: 0; font-weight: 600; word-break: break-word; }
.btn.danger { background: transparent; color: var(--err-text); border-color: var(--danger); }
.confirm-row { background: var(--danger-bg); border: 1.5px solid var(--danger); border-radius: var(--radius); padding: 10px 14px; margin: 6px 0; color: var(--err-text); }
.confirm-row p { margin: 0 0 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }

@media (min-width: 768px) {
  main { max-width: 760px; }
  .actions:not(.two) { grid-template-columns: 1fr 1fr; }
  .actions .big { grid-column: 1 / -1; }
}

[hidden] { display: none !important; }

@media print { .actions, details, .foot { display: none; } }
