[hidden] { display: none !important; }

:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --ink: #111827;
  --muted: #4B5563;
  --line: #E5E7EB;
  --accent: #1D4ED8;
  --green: #15803D;
  --green-bg: #DCFCE7;
  --green-fg: #166534;
  --red: #B91C1C;
  --red-bg: #FEE2E2;
  --orange-bg: #FFEDD5;
  --orange-fg: #9A3412;
  --blue-bg: #DBEAFE;
  --blue-fg: #1E40AF;
  --purple-bg: #EDE9FE;
  --purple-fg: #5B21B6;
  --teal-bg: #CCFBF1;
  --teal-fg: #115E59;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

#app { display: flex; flex-direction: column; min-height: 100dvh; max-width: 720px; margin: 0 auto; }
#view { flex: 1; outline: none; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* header */
.head { padding: calc(env(safe-area-inset-top) + 24px) 20px 12px; display: flex; flex-direction: column; gap: 6px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.sub { margin: 0; font-size: 15px; color: var(--muted); }
.content { padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 20px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-title { margin: 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.section-title.urgent { color: var(--red); }
.empty { margin: 0; padding: 16px; border-radius: var(--radius); background: var(--surface); color: var(--muted); text-align: center; font-size: 15px; }

/* buttons */
.fab { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.fab svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: none; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.green { background: var(--green); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid #D1D5DB; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* cards / rows */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.row.center { align-items: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-title { font-size: 16px; font-weight: 600; }
.row-title.done { color: #6B7280; text-decoration: line-through; }
.row-meta { font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group .row { box-shadow: none; border-radius: 0; border-top: 1px solid #F3F4F6; }
.group .row:first-child { border-top: none; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px; }
.group-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.chev { width: 18px; height: 18px; stroke: #9CA3AF; stroke-width: 2; fill: none; stroke-linecap: round; flex-shrink: 0; }
.avatar { width: 44px; height: 44px; border-radius: 12px; background: #E5E7EB; color: #374151; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }

input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--green); flex-shrink: 0; cursor: pointer; }

/* tags & chips */
.tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
.t-POS, .c-orange { background: var(--orange-bg); color: var(--orange-fg); }
.t-Contrat, .c-blue { background: var(--blue-bg); color: var(--blue-fg); }
.t-Stats, .c-purple { background: var(--purple-bg); color: var(--purple-fg); }
.t-Visites, .c-teal { background: var(--teal-bg); color: var(--teal-fg); }
.t-Autre { background: #E5E7EB; color: #374151; }
.c-green { background: var(--green-bg); color: var(--green-fg); }
.c-red { background: var(--red-bg); color: #991B1B; }
.due-late { font-size: 13px; font-weight: 600; color: var(--red); }
.due { font-size: 13px; font-weight: 600; color: var(--muted); }

/* forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { min-height: 44px; padding: 10px 12px; border: 1px solid #D1D5DB; border-radius: 10px; background: #fff; font-size: 16px; color: var(--ink); font-weight: 400; width: 100%; }
textarea.input { min-height: 120px; line-height: 1.45; resize: vertical; }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.search input { flex: 1; border: none; outline: none; background: transparent; font-size: 16px; min-height: 42px; }
.search svg { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; }
.seg button { min-height: 44px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(17, 24, 39, .15); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv span:first-child { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kv span:last-child { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.full { grid-column: 1 / -1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* client page */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; text-decoration: none; font-size: 16px; font-weight: 500; align-self: flex-start; }
.back svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.client-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 12px) 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.client-id { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.client-id .avatar { width: 52px; height: 52px; border-radius: 14px; background: #1E3A8A; color: #fff; font-size: 18px; }
.client-id h1 { font-size: 24px; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.steps li { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.steps li::before { content: ""; height: 6px; border-radius: 3px; background: var(--line); }
.steps li.on { color: var(--ink); }
.steps li.on::before { background: var(--green); }
.steps.first li.on::before { background: #2563EB; }
.banner { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--green-bg); border: 1px solid #86EFAC; color: #14532D; font-size: 14px; }
.banner svg { width: 22px; height: 22px; stroke: var(--green); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hist-visit { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.hist-visit .when { font-size: 13px; font-weight: 600; color: var(--muted); }
.hist-visit p { margin: 0; font-size: 15px; line-height: 1.45; white-space: pre-line; }
.hist-contract { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: #F0FDF4; border: 1px solid #BBF7D0; }
.dot-ok { width: 28px; height: 28px; border-radius: 14px; background: var(--green); display: grid; place-items: center; flex-shrink: 0; }
.dot-ok svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* cœur client / hors contrat */
.heart { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; min-height: 44px; padding: 4px 6px; border: none; background: transparent; border-radius: 12px; cursor: pointer; color: #6B7280; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.heart svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linejoin: round; }
.heart.on { color: #BE123C; }
.heart.on svg { fill: #E11D48; stroke: #BE123C; }

/* historique : commandes POS et suppression */
.hist-pos { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: #FFF7ED; border: 1px solid #FED7AA; }
.hist-pos .when { font-size: 13px; font-weight: 600; color: var(--orange-fg); }
.hist-pos p { margin: 0; font-size: 15px; line-height: 1.45; white-space: pre-line; }
.icon-btn { width: 44px; height: 44px; margin: -10px -10px -10px 0; flex-shrink: 0; border: none; background: transparent; border-radius: 10px; display: grid; place-items: center; color: #6B7280; cursor: pointer; }
.icon-btn:hover { background: rgba(17, 24, 39, .06); color: var(--red); }
.icon-btn svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 6px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabbar a[aria-current=page] { color: var(--accent); }
.tabbar svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* dialog */
dialog { border: none; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: 0 20px 50px rgba(17, 24, 39, .25); }
dialog::backdrop { background: rgba(17, 24, 39, .4); }
#dlg-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
#dlg-form h2 { margin: 0; font-size: 20px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Ordinateur et iPad : menu sur le côté gauche au lieu d'en bas */
@media (min-width: 768px) {
  body { padding-left: calc(104px + env(safe-area-inset-left)); }
  .tabbar {
    top: 0; bottom: 0; right: auto;
    width: calc(104px + env(safe-area-inset-left));
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    align-content: start;
    gap: 6px;
    padding: calc(env(safe-area-inset-top) + 24px) 8px 24px calc(8px + env(safe-area-inset-left));
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .tabbar a { padding: 12px 4px; border-radius: 14px; font-size: 13px; }
  .tabbar a[aria-current=page] { background: #EFF4FF; }
  .tabbar svg { width: 26px; height: 26px; }
  #view { padding-bottom: 32px; }
}
