/* Application patron Ma Quincaillerie : blanc et orange comme le PC, carte du chiffre en bleu nuit.
   Polices du système uniquement (aucune ressource externe). */
:root {
  /* Palette : blanc cassé chaud + bleu nuit + orange de la marque ; vert sapin (argent),
     rouge brique (alertes). Textes secondaires >= 4.5:1 sur blanc. */
  --bg: #f7f6f2; --surface: #ffffff; --fg: #15242e; --muted: #5d6870; --line: #e9e6df;
  --accent: #ee580c; --accent-dark: #c4470b; --accent-soft: #fdf0e7;
  --navy: #1a3340; --navy-2: #0f222b;
  --ok: #2b7a62; --ok-soft: #e8f3ee; --danger: #b8402f; --danger-soft: #fbece8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent }
[hidden] { display: none !important }
html, body { margin: 0 }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(238, 88, 12, .45); outline-offset: 2px }
svg { flex-shrink: 0 }

/* ---------------------------------------------------------------- connexion */
.login { max-width: 420px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 20px 32px; display: flex; flex-direction: column; gap: 22px; }
.login-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 26px rgba(238, 88, 12, .25) }
.login-head h1 { margin: 6px 0 0; font-size: 26px; letter-spacing: -.02em }
.login-head p { margin: 0; color: var(--muted) }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
#loginForm { display: flex; flex-direction: column; gap: 16px; box-shadow: 0 10px 30px rgba(23, 43, 55, .07) }
label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 800; color: var(--muted) }
input { font: inherit; font-size: 17px; color: var(--fg); background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; width: 100%; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(238, 88, 12, .15) }
.btn-primary { border: 0; border-radius: 15px; padding: 16px; font-size: 17px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #f26a1f, var(--accent-dark)); box-shadow: 0 10px 22px rgba(238, 88, 12, .3) }
.btn-primary:disabled { opacity: .6 }
.btn-ghost { border: 1.5px solid var(--line); background: #fff; border-radius: 13px; padding: 12px; font-weight: 800; color: var(--danger); margin-top: 10px }
.err { margin: 0; color: var(--danger); background: var(--danger-soft); font-weight: 700; font-size: 14px; padding: 10px 12px; border-radius: 12px }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px }

/* ---------------------------------------------------------------- application */
.app { max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; gap: 16px }
.install { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid #f4c7ab; color: var(--accent-dark); border-radius: 14px; padding: 10px 12px; font-size: 14px; font-weight: 700; margin-bottom: 14px }
.install span { flex: 1 }
.install button { border: 0; background: var(--accent); color: #fff; font-weight: 800; border-radius: 10px; padding: 9px 12px; min-height: 40px }
.install #installClose { background: transparent; color: var(--accent-dark); padding: 6px 8px }

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 4px 2px 2px }
.greet { display: flex; flex-direction: column; gap: 6px; min-width: 0 }
.today { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-dark) }
.hello { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.025em; font-weight: 800; color: var(--fg) }
.shop-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px;
  font-size: 14px; font-weight: 700; color: var(--fg); box-shadow: 0 2px 8px rgba(23, 43, 55, .05) }
.shop-chip img { width: 26px; height: 26px; border-radius: 50% }
.shop-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.skeleton { color: transparent !important; background: linear-gradient(90deg, #ebe8e1, #f4f2ed, #ebe8e1); background-size: 200% 100%;
  border-radius: 8px; animation: shimmer 1.2s infinite linear }
@keyframes shimmer { to { background-position: -200% 0 } }
.refresh { flex: none; width: 46px; height: 46px; border-radius: 50%; margin-top: 8px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center }
.refresh svg { width: 20px; height: 20px; fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.refresh.spin svg { animation: spin .8s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }

/* Carte du chiffre : bleu nuit, cercles fins, courbe orange */
.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 22px 22px 18px; color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-2) 90%); box-shadow: 0 16px 30px rgba(23, 45, 56, .18);
  display: flex; flex-direction: column; gap: 10px }
.hero::before { content: ""; position: absolute; width: 250px; height: 250px; right: -125px; top: -130px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.10); box-shadow: 0 0 0 30px rgba(255,255,255,.025), 0 0 0 64px rgba(255,255,255,.02) }
.hero::after { content: ""; position: absolute; width: 130px; height: 130px; left: -50px; bottom: -100px; border-radius: 50%; border: 1px solid rgba(255,255,255,.06) }
.hero > * { position: relative; z-index: 1 }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px }
.hero-label { font-size: 14px; color: #c9d5d6; font-weight: 600 }
.hero-trend { font-size: 13px; font-weight: 800; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.12); color: #a9e3c8; white-space: nowrap }
.hero-trend.down { color: #ffc2b0 }
.hero-amount { display: flex; align-items: baseline; gap: 6px; font-size: 42px; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums }
.hero-amount small { font-size: 15px; font-weight: 700; color: #c9d5d6; letter-spacing: 0 }
.hero-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px }
.hero-note { font-size: 13px; color: #aebcbf; line-height: 1.5 }
.spark { width: 150px; height: 54px; overflow: visible }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 108px }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px }
.kpi-label { font-size: 13px; font-weight: 700; color: var(--muted) }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; background: #f4f2ec; display: grid; place-items: center }
.kpi-ico svg { width: 17px; height: 17px; fill: none; stroke: #3f505a; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.kpi-value { display: flex; align-items: baseline; gap: 4px; font-size: 27px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums }
.kpi-value small { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 0 }

.section { display: flex; flex-direction: column; gap: 10px }
.section h2 { margin: 6px 2px 0; font-size: 17px; letter-spacing: -.01em }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; min-height: 68px }
.row-ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center }
.row-ico svg { width: 21px; height: 21px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.row-ico.red { background: var(--danger-soft) } .row-ico.red svg { stroke: var(--danger) }
.row-ico.orange { background: var(--accent-soft) } .row-ico.orange svg { stroke: var(--accent-dark) }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px }
.row-text strong { font-size: 15px }
.row-text small { font-size: 13px; color: var(--muted) }
.chev { width: 18px; height: 18px; fill: none; stroke: #8a949b; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }

.chart { display: flex; flex-direction: column; gap: 8px; padding: 16px 14px 12px }
.bars { height: 104px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end }
/* Même orange que le graphique du PC (DailyBarChart : #f97316), montée en cascade */
.bars span { display: block; border-radius: 6px 6px 2px 2px; background: #f97316; min-height: 4px;
  transform: scaleY(0); transform-origin: bottom; transition: transform .7s cubic-bezier(.22, 1, .36, 1) }
.bars.grow span { transform: scaleY(1) }
@media (prefers-reduced-motion: reduce) { .bars span { transition: none } }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted) }
.days span:last-child { color: var(--accent-dark) }
.updated { text-align: center; color: var(--muted); font-size: 12px; margin: 0 }

.soon h1, .page-title { margin: 6px 2px 0; font-size: 26px; letter-spacing: -.02em }
.group { display: flex; flex-direction: column; gap: 8px }
.group-title { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 4px 0 }
.group-note { margin: 0 4px; font-size: 13px; color: var(--muted); line-height: 1.45 }
.list { padding: 0; overflow: hidden }
.setting { display: flex; align-items: center; gap: 13px; padding: 14px 16px; min-height: 64px; width: 100%; text-align: left; background: none; border: 0 }
.setting + .setting { border-top: 1px solid var(--line) }
.set-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none }
.set-ico svg { width: 21px; height: 21px; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round }
.set-ico.money { background: var(--ok-soft) } .set-ico.money svg { stroke: var(--ok) }
.set-ico.alert { background: var(--accent-soft) } .set-ico.alert svg { stroke: var(--accent-dark) }
.set-ico.user, .set-ico.shop, .set-ico.misc { background: #f1efe9 } .set-ico.user svg, .set-ico.shop svg, .set-ico.misc svg { stroke: #3f505a }
.set-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px }
.set-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis }
.set-text small { font-size: 13px; color: var(--muted); line-height: 1.4; overflow: hidden; text-overflow: ellipsis }
.switch { flex: none; width: 52px; height: 32px; border-radius: 999px; border: 0; background: #cdd2d6; padding: 3px; display: flex; justify-content: flex-start; transition: background .2s }
.switch::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s }
.switch[aria-checked="true"] { background: var(--accent) }
.switch[aria-checked="true"]::before { transform: translateX(20px) }
.btn-logout { border: 1.5px solid #efc9c1; background: #fff; color: var(--danger); font-weight: 800; border-radius: 16px; padding: 15px; min-height: 52px; margin-top: 4px }
.soon p, .soon-text { margin: 0 2px; color: var(--muted); line-height: 1.5 }

/* ---------------------------------------------------------------- barre du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px max(10px, env(safe-area-inset-bottom)) }
.nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--muted); min-height: 52px; justify-content: center }
.nav button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.nav button.on { color: var(--accent-dark); font-weight: 800 }
