/* Kalis — carnet de boutique.
   Indigo du bazin teint, jaune mangue pour l'action principale, chiffres en Bricolage Grotesque,
   texte en Atkinson Hyperlegible (conçue pour la lisibilité, utile en plein soleil). */
:root {
  --indigo: #23306E;
  --indigo-2: #33449A;
  --mango: #F4B400;
  --mango-ink: #3A2A00;
  --bg: #F3F4F8;
  --surface: #FFFFFF;
  --ink: #1A1C2E;
  --ink-2: #555A73;
  --line: #DDE0EA;
  --gain: #0B8457;
  --debt: #C2362B;
  --warn-bg: #FFF4D1;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --display: "Bricolage Grotesque", "Arial Rounded MT Bold", system-ui, sans-serif;
  --text: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12142A; --surface: #1C1F3A; --ink: #F1F2F8; --ink-2: #A9AECB; --line: #2E3358;
    --indigo-2: #8C9BEA; --gain: #3DD598; --debt: #FF7A6E; --warn-bg: #3A3110; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12142A; --surface: #1C1F3A; --ink: #F1F2F8; --ink-2: #A9AECB; --line: #2E3358;
  --indigo-2: #8C9BEA; --gain: #3DD598; --debt: #FF7A6E; --warn-bg: #3A3110; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 var(--text);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--mango); outline-offset: 2px; }
a { color: var(--indigo-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- tête de page ---------- */
.top { background: var(--indigo); color: #fff; padding: 18px 16px 22px; padding-top: calc(18px + env(safe-area-inset-top)); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shop-name { font: 700 18px/1.2 var(--display); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync { font-size: 14px; opacity: .85; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5BE0A4; }
.sync.off::before { background: var(--mango); }
.cash { margin-top: 14px; }
.cash-label { font-size: 15px; opacity: .85; }
.cash-amount { font: 800 clamp(34px, 11vw, 46px)/1.05 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cash-amount small { font-size: .45em; font-weight: 700; margin-left: 6px; opacity: .8; letter-spacing: 0; }
.wax {
  height: 14px;
  background:
    linear-gradient(135deg, var(--mango) 25%, transparent 25%) -7px 0 / 14px 14px,
    linear-gradient(225deg, var(--mango) 25%, transparent 25%) -7px 0 / 14px 14px,
    linear-gradient(315deg, #fff 25%, transparent 25%) 0 0 / 14px 14px,
    linear-gradient(45deg, #fff 25%, transparent 25%) 0 0 / 14px 14px,
    var(--indigo);
}
.page-head { background: var(--indigo); color: #fff; padding: 18px 16px; padding-top: calc(18px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; }
.page-head h1 { font: 700 24px/1.2 var(--display); margin: 0; flex: 1; }
.back { background: none; border: 0; color: #fff; font-size: 26px; padding: 4px 8px 4px 0; line-height: 1; }

/* ---------- la phrase (élément central) ---------- */
.phrase { margin: -2px 12px 0; background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding: 16px; box-shadow: 0 10px 24px -18px rgba(35, 48, 110, .6); }
.phrase label { display: block; font: 700 19px/1.25 var(--display); margin-bottom: 10px; }
.phrase-box { display: flex; gap: 8px; align-items: stretch; }
.phrase-box input {
  flex: 1; min-width: 0; border: 2px solid var(--line); background: var(--bg); border-radius: var(--radius-sm);
  padding: 14px 12px; font-size: 18px;
}
.phrase-box input:focus { border-color: var(--indigo-2); outline: none; background: var(--surface); }
.mic, .go { border: 0; border-radius: var(--radius-sm); min-width: 54px; display: grid; place-items: center; }
.mic { background: var(--bg); border: 2px solid var(--line); color: var(--indigo-2); }
.mic.listening { background: var(--debt); border-color: var(--debt); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.go { background: var(--mango); color: var(--mango-ink); font-weight: 700; padding: 0 14px; }
@keyframes pulse { 50% { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .mic.listening { animation: none; } }
.hint { color: var(--ink-2); font-size: 15px; margin: 10px 2px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- sections ---------- */
.section { padding: 22px 16px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.section-title h2 { font: 700 20px/1.2 var(--display); margin: 0; }
.link-btn { background: none; border: 0; color: var(--indigo-2); font-weight: 700; padding: 4px 0; font-size: 16px; }

.today { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-radius: var(--radius-lg); }
.today > div { padding: 14px 12px; }
.today > div + div { border-left: 1px solid var(--line); }
.today .k { font-size: 14px; color: var(--ink-2); }
.today .v { font: 700 19px/1.2 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.v.in { color: var(--gain); } .v.out { color: var(--debt); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 96px; margin-top: 12px; padding: 0 2px; }
.week .bar { background: var(--indigo-2); border-radius: 6px 6px 2px 2px; min-height: 3px; opacity: .35; }
.week .bar.today { background: var(--mango); opacity: 1; }
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; font-size: 13px; color: var(--ink-2); text-align: center; margin-top: 4px; }

.owed { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; }
.owed-total { font: 800 30px/1.1 var(--display); color: var(--debt); font-variant-numeric: tabular-nums; }
.owed-sub { color: var(--ink-2); font-size: 15px; }

.rows { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; background: none; border: 0; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amt { font: 700 17px/1.2 var(--display); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row-amt.in { color: var(--gain); } .row-amt.out { color: var(--debt); } .row-amt.debt { color: var(--debt); }
.dot { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 15px var(--display); color: #fff; }
.t-sale { background: var(--gain); } .t-payment { background: #2C8FB8; } .t-credit { background: var(--debt); }
.t-expense { background: #7A5AA6; } .t-purchase { background: #B9771A; }
.avatar { background: var(--indigo-2); }
.wa-btn { text-decoration: none; flex: none; border: 0; background: #1FA855; color: #fff; border-radius: 999px; padding: 8px 12px; font-weight: 700; font-size: 14px; }
.empty { padding: 22px 16px; color: var(--ink-2); text-align: center; background: var(--surface); border-radius: var(--radius-lg); }
.empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }

.alert { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert + .alert { margin-top: 8px; }

/* ---------- formulaires ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; font-size: 16px; }
.input, select.input, textarea.input {
  width: 100%; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 13px 12px; font-size: 18px;
}
.input:focus { border-color: var(--indigo-2); outline: none; }
.input.big { font: 700 26px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: block; width: 100%; border: 0; border-radius: var(--radius-sm); padding: 15px 16px; font-weight: 700; font-size: 18px; text-align: center; text-decoration: none; }
.btn-main { background: var(--mango); color: var(--mango-ink); }
.btn-dark { background: var(--indigo); color: #fff; }
.btn-ghost { background: transparent; color: var(--indigo-2); border: 2px solid var(--line); }
.btn-wa { background: #1FA855; color: #fff; }
.btn-danger { background: transparent; color: var(--debt); border: 2px solid var(--line); }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: .5; }
.error { color: var(--debt); font-weight: 700; margin: 0 0 12px; }

.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.seg button { border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 2px; font-size: 13px; font-weight: 700; }
.seg button[aria-pressed="true"] { border-color: var(--indigo); background: var(--indigo); color: #fff; }

/* ---------- feuille du bas ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(18, 20, 42, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font: 700 22px/1.2 var(--display); margin: 0 0 14px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.understood { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; border-left: 5px solid var(--mango); }
.understood .q { color: var(--ink-2); font-size: 14px; }
.understood .a { font-weight: 700; }

/* ---------- navigation ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 560px; height: var(--nav-h); }
.nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--indigo-2); }
.nav button[aria-current="page"] svg { color: var(--mango); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 18px; width: max-content; font-weight: 700; display: flex; gap: 14px; align-items: center;
  max-width: calc(100vw - 32px);
}
#toast button { background: none; border: 0; color: var(--mango); font-weight: 700; padding: 0; }

/* ---------- accueil / connexion ---------- */
.welcome { min-height: 100vh; display: flex; flex-direction: column; }
.welcome-top { background: var(--indigo); color: #fff; padding: 48px 20px 28px; padding-top: calc(48px + env(safe-area-inset-top)); }
.wordmark { font: 800 64px/0.9 var(--display); letter-spacing: -0.04em; margin: 0; }
.wordmark span { color: var(--mango); }
.tagline { font: 500 21px/1.3 var(--display); margin: 14px 0 0; max-width: 22ch; }
.welcome-body { padding: 22px 16px 32px; flex: 1; }
.example { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 20px; font-size: 16px; }
.example b { color: var(--indigo-2); }
.switch { text-align: center; margin-top: 16px; }

.list-pad { padding: 16px; }
.search { margin-bottom: 12px; }
.balance-hero { background: var(--surface); border-radius: var(--radius-lg); padding: 18px 16px; margin-bottom: 14px; }
.balance-hero .v { font: 800 38px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.pro-tag { display: inline-block; background: var(--mango); color: var(--mango-ink); border-radius: 6px; padding: 1px 8px; font-size: 13px; font-weight: 700; vertical-align: middle; }
.menu .row-title { white-space: normal; }
.small { font-size: 14px; color: var(--ink-2); }
.report-num { font: 700 22px/1.2 var(--display); font-variant-numeric: tabular-nums; }
@media print {
  .nav, .page-head .back, .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- conversation à la voix dans la feuille ---------- */
.save-row { display: flex; gap: 10px; align-items: stretch; }
.save-row .btn { flex: 1; }
.big-mic { min-width: 64px; border-radius: var(--radius-sm); }
.save-row + .btn { margin-top: 10px; }
.voice-ask {
  background: var(--surface); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 12px;
  font-weight: 700; font-size: 18px; border-left: 5px solid var(--indigo-2);
}
.field > .tel-box { display: flex; align-items: stretch; margin-bottom: 0; font-weight: 400; }
.field .tel-code { display: grid; flex: none; place-items: center; padding: 0 12px; background: var(--bg); border: 2px solid var(--line); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-weight: 700; font-size: 18px; }
.tel-box .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; min-width: 0; }
.tel-box + .small { display: block; margin-top: 6px; }

/* ================= pour qui lit peu : images, gros boutons, écoute ================= */
.cash-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.listen { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); font-size: 24px; display: grid; place-items: center; }
.listen-dark { float: right; border-color: var(--line); background: var(--bg); }
.dot { font-size: 18px; }

/* le gros micro : l'action principale */
.mic-hero {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--indigo); color: #fff; border: 0; border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 12px;
}
.mic-ring { flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--mango); color: var(--mango-ink); display: grid; place-items: center; }
.mic-ring svg { width: 30px; height: 30px; }
.mic-ring.listening { background: var(--debt); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .mic-ring.listening { animation: none; } }
.mic-text b { display: block; font: 700 21px/1.2 var(--display); }
.mic-text span { display: block; font-size: 15px; opacity: .85; }
.phrase-box input { font-size: 17px; padding: 12px; }

/* les cinq types en images */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.tile { border: 0; border-radius: var(--radius-sm); padding: 10px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; color: var(--ink); }
.tile-ic { font-size: 28px; line-height: 1; }
.t-sale-soft { background: rgba(11,132,87,.14); background: color-mix(in srgb, var(--gain) 14%, var(--surface)); }
.t-credit-soft { background: rgba(194,54,43,.14); background: color-mix(in srgb, var(--debt) 14%, var(--surface)); }
.t-payment-soft { background: rgba(44,143,184,.16); background: color-mix(in srgb, #2C8FB8 16%, var(--surface)); }
.t-expense-soft { background: rgba(122,90,166,.16); background: color-mix(in srgb, #7A5AA6 16%, var(--surface)); }
.t-purchase-soft { background: rgba(185,119,26,.16); background: color-mix(in srgb, #B9771A 16%, var(--surface)); }

/* fiche de saisie */
.seg button { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.seg-ic { font-size: 22px; line-height: 1; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 16px; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 10px; max-height: 236px; overflow-y: auto; }
.prod { border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.prod[aria-pressed="true"] { border-color: var(--indigo); box-shadow: inset 0 0 0 2px var(--indigo); background: rgba(51,68,154,.1); background: color-mix(in srgb, var(--indigo-2) 10%, var(--surface)); }
.prod-ic { font-size: 30px; line-height: 1.1; }
.prod-name { font-weight: 700; font-size: 14px; text-align: center; overflow-wrap: anywhere; }
.prod-price { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.qty-row .field-label { flex: 1; }
.step { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font: 700 26px/1 var(--display); }
.qty-in { width: 76px; text-align: center; font: 700 22px/1 var(--display); }
.notes { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.note {
  border: 0; border-radius: 8px; padding: 10px 12px; font: 700 16px/1 var(--display); font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #DCEFE3, #BFE3CC); color: #0B4F33; border-left: 6px solid #0B8457;
}
.note-clear { background: var(--surface); color: var(--ink-2); border: 2px solid var(--line); border-left-width: 2px; }
.people { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px 2px; scrollbar-width: none; }
.people::-webkit-scrollbar { display: none; }
.person { flex: none; display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 14px 4px 4px; font-weight: 700; }
.person .dot { width: 32px; height: 32px; font-size: 15px; }
.person[aria-pressed="true"] { border-color: var(--indigo); background: rgba(51,68,154,.12); background: color-mix(in srgb, var(--indigo-2) 12%, var(--surface)); }

/* guide */
.guide { display: grid; gap: 10px; margin-bottom: 16px; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--radius-sm); padding: 12px; }
.guide-step p { margin: 2px 0 0; color: var(--ink-2); }
.guide-ic { font-size: 34px; line-height: 1; flex: none; }
