:root {
  --bg: #f4f6fa; --surface: #fff; --text: #14213d; --muted: #5b6678; --line: #e1e6ee;
  --brand: #f28c28; --brand-dark: #e17d17; --on-brand: #14213d; --brand-text: #b45309; --danger: #b42318; --radius: 16px;
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1522; --surface: #172033; --text: #eef2f8; --muted: #9aa6ba; --line: #26324a; --brand: #f28c28; --brand-dark: #ffa24d; --on-brand: #14213d; --brand-text: #f6a752; --danger: #ff8a80; --shadow: 0 8px 24px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; margin: .75rem 0 .25rem; }
.muted { color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: .75rem 0 0; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }
.logo-sm { height: 40px; width: auto; border-radius: 6px; }
.logo { height: 72px; width: auto; border-radius: 8px; display: block; margin: 0 auto 1rem; }

.btn { font: inherit; border: 1px solid transparent; border-radius: 12px; padding: .65rem 1.1rem; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; text-decoration: none; transition: background .15s, transform .15s; }
.btn.primary { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; }
.profile { position: relative; }
.panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 1rem; min-width: 240px; display: grid; gap: .25rem; animation: pop .15s ease-out; }
.badge { justify-self: start; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; }

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: .25rem; animation: rise .35s ease-out both; transition: transform .2s, box-shadow .2s, border-color .2s; }
.card:hover, .card:focus-visible { transform: translateY(-4px); border-color: var(--brand); }
.card:active { transform: translateY(-1px) scale(.99); }
.card .btn { margin-top: auto; align-self: flex-start; }
.card p { flex: 1; margin-bottom: 1.25rem; }
.card-icon { width: 56px; height: 56px; border-radius: 14px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-text); display: grid; place-items: center; }
.card-icon svg { width: 30px; height: 30px; }
.card.disabled { opacity: .55; }
.card.disabled:hover { transform: none; border-color: var(--line); }
.card.disabled .btn { background: var(--muted); }

.auth-page { display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem 1.5rem; animation: rise .35s ease-out both; }
.login-card h1, .login-card .muted { text-align: center; }
form { display: grid; gap: .5rem; margin-top: 1.25rem; }
label { font-weight: 600; font-size: .9rem; }
input { font: inherit; padding: .7rem .85rem; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
input:focus { border-color: var(--brand); }
form .btn { margin-top: .75rem; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) { .label-profile { display: none; } .topbar { padding: .6rem .75rem; } .container { padding-top: 1.25rem; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Page Paramètres */
.group { margin-top: 2rem; }
.group h2 { margin: 0 0 .25rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin-top: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: .25rem; min-height: 92px; transition: transform .15s, border-color .15s; }
.tile:hover, .tile:focus-visible { transform: translateY(-2px); border-color: var(--brand); }
.tile.disabled { opacity: .6; }
.tile.disabled:hover { transform: none; border-color: var(--line); }
.tile .badge { align-self: flex-start; margin-top: auto; }

/* Paramètres : menu des sections + écran réel de l'application dans un cadre */
.settings-page { display: flex; flex-direction: column; height: 100dvh; }
.topbar-title { margin-left: .5rem; }
.settings-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px 1fr; }
.settings-menu { overflow-y: auto; padding: 1rem; border-right: 1px solid var(--line); background: var(--surface); }
.menu-group + .menu-group { margin-top: 1.25rem; }
.menu-group h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .4rem; }
.menu-item { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 10px; padding: .6rem .75rem; min-height: 44px; cursor: pointer; }
.menu-item:hover { background: var(--bg); }
.menu-item[aria-current="page"] { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-text); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.menu-item.disabled { opacity: .55; cursor: default; }
.settings-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-hint { padding: 1.5rem; }
.settings-pane .error { padding: 1rem 1.5rem; }
.settings-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
@media (max-width: 800px) {
  .settings-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-menu { display: flex; gap: .25rem; overflow-x: auto; overflow-y: hidden; padding: .5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .menu-group { display: contents; }
  .menu-group h2, .menu-group .small { display: none; }
  .menu-item { width: auto; white-space: nowrap; flex: none; }
}
