/* ---------- Thèmes ---------- */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --text: #1f2328;
  --muted: #687078;
  --border: #e3e0d9;
  --accent: #2f6b5b;
  --accent-hover: #255649;
  --accent-soft: #e5efeb;
  --accent-text: #ffffff;
  --error: #b3261e;
  --error-soft: #fbeceb;
  --success: #2e7d4f;
  --shadow: 0 1px 2px rgb(31 35 40 / .04), 0 8px 24px rgb(31 35 40 / .06);
  --backdrop: rgb(31 35 40 / .35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121417;
  --surface: #1b1e22;
  --surface-2: #22262b;
  --text: #e8e6e1;
  --muted: #9aa0a6;
  --border: #30353b;
  --accent: #7cc4ad;
  --accent-hover: #95d2bf;
  --accent-soft: #1f3530;
  --accent-text: #0f1f1a;
  --error: #f2938b;
  --error-soft: #3a2220;
  --success: #7fd19f;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  --backdrop: rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color .2s, color .2s;
}
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.2rem; }
h2 { font-size: 1.35rem; }
small { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-bar { display: flex; align-items: center; gap: 4px; min-width: 0; }
.user-email {
  color: var(--muted); font-size: .875rem; margin-right: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Boutons ---------- */
button {
  font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: 9px 18px; transition: background-color .15s, border-color .15s, color .15s;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .6; cursor: wait; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:hover { background: var(--accent-hover); }
.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.secondary:hover { background: var(--surface-2); }
.ghost { background: transparent; color: var(--muted); padding: 6px 10px; font-size: .875rem; }
.ghost:hover { background: var(--surface-2); color: var(--text); }
.block { width: 100%; margin-top: 4px; padding: 11px 18px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: none;
  background: transparent; color: var(--muted); border-color: var(--border);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Contenu ---------- */
main { max-width: 760px; margin: 32px auto; padding: 0 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 24px;
}
.card.narrow { max-width: 480px; margin: 0 auto; }
.card > h1 { margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.count { color: var(--muted); font-size: .875rem; }

/* Liste des quittances */
.list { list-style: none; margin: 0 -8px; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list a {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px; border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.list a:hover { background: var(--surface-2); }
.list a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.file-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.file-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-title { font-weight: 550; }
.file-name { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-dl {
  flex: none; display: flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: .85rem; font-weight: 600;
}
.empty { text-align: center; color: var(--muted); padding: 32px 0 16px; }
.empty p { margin: 8px 0 0; }

/* ---------- Formulaires ---------- */
label { display: block; margin-bottom: 16px; font-size: .9rem; font-weight: 550; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.notice {
  margin: 0 0 18px; padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text); font-size: .9rem;
}
.hint { margin: 4px 0 20px; color: var(--muted); }
.hint.small { font-size: .82rem; margin: -6px 0 8px; }
.error { color: var(--error); margin: 0 0 8px; font-size: .9rem; }
.error:empty { display: none; }
.error:not(:empty) { background: var(--error-soft); padding: 10px 12px; border-radius: 9px; }
.success { color: var(--success); margin: 0 0 8px; font-size: .9rem; }
.success:empty { display: none; }

/* ---------- Popup de login ---------- */
dialog {
  width: min(400px, calc(100% - 32px)); padding: 28px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
dialog form { position: relative; }
.dialog-theme { position: absolute; top: -8px; right: -8px; }
dialog[open] { animation: pop .18s ease-out; }
.dialog-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px;
  background: var(--accent-soft); color: var(--accent);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .user-email { display: none; }
  .brand-name { display: none; }
  main { margin-top: 20px; }
  .card { padding: 18px; }
  .file-dl span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
