/* Suivi: iPhone-first PWA. iOS grouped lists, large titles, light and dark themes. */
:root {
  --bg: #f2f2f7; --card: #ffffff; --card-2: #f7f7fa; --fill: rgba(120,120,128,.12); --fill-2: rgba(120,120,128,.2);
  --label: #000000; --label-2: rgba(60,60,67,.62); --label-3: rgba(60,60,67,.36); --sep: rgba(60,60,67,.18);
  --accent: #6250d6; --accent-soft: rgba(98,80,214,.13); --accent-ink: #4b3bb8;
  --s-good: #0ca30c; --s-warn: #fab219; --s-serious: #ec835a; --s-crit: #d03b3b;
  --cal-awilix: #6250d6; --cal-perso: #2a78d6; --cal-soclipping: #eb6834;
  --src-client: #6250d6; --src-projet: #1baf7a; --src-awilix: #2a78d6; --src-crm: #e87ba4; --src-incident: #d03b3b; --src-perso: #8e8e93;
  --bar: #6250d6; --tabbar: rgba(249,249,249,.86); --nav: rgba(242,242,247,.86);
  --shadow: 0 1px 0 rgba(0,0,0,.04);
  --r: 14px; --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --card-2: #242426; --fill: rgba(118,118,128,.24); --fill-2: rgba(118,118,128,.36);
    --label: #ffffff; --label-2: rgba(235,235,245,.62); --label-3: rgba(235,235,245,.32); --sep: rgba(84,84,88,.6);
    --accent: #9085e9; --accent-soft: rgba(144,133,233,.18); --accent-ink: #b3abf2;
    --cal-awilix: #9085e9; --cal-perso: #3987e5; --cal-soclipping: #d95926;
    --src-client: #9085e9; --src-projet: #199e70; --src-awilix: #3987e5; --src-crm: #d55181; --src-incident: #e66767; --src-perso: #8e8e93;
    --bar: #9085e9; --tabbar: rgba(22,22,24,.86); --nav: rgba(0,0,0,.82);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  letter-spacing: -.01em; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
#view { min-height: 100vh; padding: calc(var(--safe-t) + 6px) 16px calc(var(--safe-b) + 96px); outline: none; transition: transform .25s ease; }
.hidden { display: none !important; }

/* ---------- navigation bar + large title */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(var(--safe-t) + 44px);
  padding: var(--safe-t) 12px 0; display: flex; align-items: center; justify-content: space-between;
  background: var(--nav); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent; transition: border-color .2s;
}
.navbar.scrolled { border-bottom-color: var(--sep); }
.navbar .nav-title { position: absolute; left: 70px; right: 70px; text-align: center; font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .18s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar.scrolled .nav-title { opacity: 1; }
.nav-side { display: flex; align-items: center; gap: 6px; min-width: 60px; }
.nav-side.right { justify-content: flex-end; }
.nav-btn { color: var(--accent); font-size: 17px; display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 4px; }
.nav-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-head { padding-top: 44px; margin-bottom: 14px; }
.eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label-2); margin: 0 0 2px; }
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .01em; margin: 0; }
.subtitle { color: var(--label-2); font-size: 15px; margin: 4px 0 0; }

/* ---------- sections, grouped cards */
.section { margin: 24px 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 8px; }
.section-head h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: .01em; }
.section-head .more { font-size: 15px; }
.section-head h3 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--label-2); margin: 0; letter-spacing: .02em; }
.group { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.group + .group { margin-top: 12px; }
.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 44px; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--inset, 16px); border-top: .5px solid var(--sep); }
.row.tap:active { background: var(--fill); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 17px; line-height: 22px; }
.row .sub { font-size: 14px; line-height: 18px; color: var(--label-2); margin-top: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.row .trail { color: var(--label-2); font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.chev { width: 8px; height: 14px; stroke: var(--label-3); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.empty { padding: 22px 16px; text-align: center; color: var(--label-2); font-size: 15px; }
.foot { font-size: 13px; color: var(--label-2); margin: 8px 16px 0; line-height: 1.35; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border-radius: var(--r); padding: 12px 12px 11px; text-align: left; box-shadow: var(--shadow); min-width: 0; }
.tile:active { transform: scale(.98); }
.tile .t-label { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .t-value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; }
.tile .t-sub { font-size: 12px; color: var(--label-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--label-2); }
.status i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- hero (MRR) */
.hero { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.hero .h-label { font-size: 15px; color: var(--label-2); }
.hero .h-value { font-size: 48px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.hero .h-value small { font-size: 20px; font-weight: 600; color: var(--label-2); letter-spacing: 0; }
.hero .h-sub { font-size: 14px; color: var(--label-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: var(--fill); font-size: 13px; font-weight: 500; color: var(--label); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- charts (single series, one hue) */
.bars { margin-top: 14px; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 10px; font-size: 14px; }
.bar-row .b-name { color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 16px; border-radius: 0 4px 4px 0; background: var(--bar); min-width: 3px; flex: none; }
.bar-val { font-size: 13px; color: var(--label-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 132px; margin-top: 16px; padding-bottom: 20px; position: relative; border-bottom: .5px solid var(--sep); }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; min-width: 0; }
.col .c-bar { width: 100%; max-width: 24px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.col .c-lab { position: absolute; bottom: -19px; font-size: 11px; color: var(--label-2); }
.col .c-val { font-size: 10px; color: var(--label-2); margin-bottom: 3px; white-space: nowrap; opacity: 0; transition: opacity .15s; }
.col.on .c-val, .col.peak .c-val { opacity: 1; }
.chart-tip { font-size: 13px; color: var(--label-2); margin-top: 6px; min-height: 18px; }
.table-toggle { font-size: 14px; margin-top: 10px; display: inline-block; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.data td, table.data th { padding: 6px 0; border-bottom: .5px solid var(--sep); text-align: left; }
table.data th { color: var(--label-2); font-weight: 500; }
table.data td:last-child, table.data th:last-child { text-align: right; }

/* ---------- rings */
.ring { position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--accent-soft); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s cubic-bezier(.2,.8,.2,1); }
.ring.done .fill { stroke: var(--s-good); }
.ring.late .fill { stroke: var(--s-warn); }
.ring .ring-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rings-strip { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px; scroll-snap-type: x proximity; scrollbar-width: none; }
.rings-strip::-webkit-scrollbar { display: none; }
.ring-card { flex: none; width: 128px; background: var(--card); border-radius: var(--r); padding: 12px; scroll-snap-align: start; box-shadow: var(--shadow); text-align: left; }
.ring-card:active { transform: scale(.98); }
.ring-card .rc-name { font-size: 15px; font-weight: 600; margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-card .rc-sub { font-size: 12px; color: var(--label-2); margin-top: 2px; }

/* ---------- tasks */
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.6px solid var(--label-3); flex: none; display: flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s; }
.check svg { width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check svg { opacity: 1; }
.task.done .title { color: var(--label-2); text-decoration: line-through; text-decoration-color: var(--label-3); }
.task .check-hit { padding: 10px; margin: -10px; }
.prio { color: var(--accent); font-weight: 700; font-size: 15px; letter-spacing: -1px; }
.src { display: inline-flex; align-items: center; gap: 5px; }
.src i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.due.late { color: var(--s-crit); font-weight: 500; }
.due.today { color: var(--accent-ink); font-weight: 500; }
.task.leaving { animation: leave .45s ease forwards; }
@keyframes leave { 60% { opacity: .6; } 100% { opacity: 0; transform: translateX(16px); } }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--card); font-size: 15px; display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow); color: var(--label); }
.chip.on { background: var(--label); color: var(--bg); }
.chip .n { color: var(--label-2); font-variant-numeric: tabular-nums; }
.chip.on .n { color: var(--bg); opacity: .7; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 14px; }
.segmented button { height: 30px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmented button.on { background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented button.on { background: #636366; } }

.fab { position: fixed; right: 18px; bottom: calc(var(--safe-b) + 66px); z-index: 25; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(98,80,214,.38); }
.fab svg { width: 26px; height: 26px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.fab:active { transform: scale(.94); }

/* ---------- stepper (monthly items) */
.stepper { display: flex; align-items: center; background: var(--fill); border-radius: 9px; height: 32px; flex: none; }
.stepper button { width: 38px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 500; color: var(--label); }
.stepper button:active { background: var(--fill-2); border-radius: 9px; }
.stepper .val { min-width: 44px; text-align: center; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.client-card .cc-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }

/* ---------- agenda */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--label-2); margin: 0 4px 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.day-head { position: sticky; top: calc(var(--safe-t) + 44px); z-index: 5; background: var(--bg); padding: 14px 4px 6px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; }
.day-head span { color: var(--label-2); font-weight: 400; }
.ev { align-items: stretch; }
.ev .ev-time { width: 54px; flex: none; font-size: 15px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.ev .ev-time small { display: block; color: var(--label-2); font-size: 13px; }
.ev .ev-bar { width: 4px; border-radius: 2px; flex: none; }
.ev.past { opacity: .5; }
.ev.now .ev-time { color: var(--accent-ink); font-weight: 600; }
.meet-btn { flex: none; align-self: center; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--fill); font-size: 12px; font-weight: 600; color: var(--label-2); }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- crm */
.avatar { width: 36px; height: 36px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--fill); color: var(--label-2); }
.quote { font-size: 14px; color: var(--label-2); margin-top: 4px; line-height: 1.35; }

/* ---------- client detail */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv .tile .t-value { font-size: 19px; white-space: normal; }
.services { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.link-row .title { color: var(--accent); }
.notes { white-space: pre-wrap; font-size: 15px; line-height: 1.4; padding: 12px 16px; color: var(--label); }
.big-ring { display: flex; align-items: center; gap: 16px; padding: 16px; }
.big-ring .br-txt .v { font-size: 28px; font-weight: 700; }
.big-ring .br-txt .s { font-size: 14px; color: var(--label-2); margin-top: 2px; }

/* ---------- sheet */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.36); z-index: 50; opacity: 0; transition: opacity .25s; }
.backdrop.on { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: calc(100vh - var(--safe-t) - 12px); background: var(--bg); border-radius: 14px 14px 0 0; transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.9,.25,1); display: flex; flex-direction: column; }
.sheet.on { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; flex: none; }
.sheet-head .sh-title { font-weight: 600; font-size: 17px; }
.sheet-head .nav-btn { min-width: 70px; }
.sheet-head .nav-btn.strong { font-weight: 600; justify-content: flex-end; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(var(--safe-b) + 20px); -webkit-overflow-scrolling: touch; }
.field { display: block; width: 100%; border: 0; outline: 0; background: transparent; color: var(--label); font: inherit; font-size: 17px; padding: 0; }
textarea.field { resize: none; min-height: 84px; line-height: 1.35; }
select.field { -webkit-appearance: none; appearance: none; text-align: right; color: var(--label-2); direction: rtl; }
input[type="date"].field { text-align: right; color: var(--accent-ink); min-height: 22px; }
.form-label { font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: .02em; margin: 20px 16px 6px; }
.row .lbl { flex: none; }
.danger { color: var(--s-crit); }
.btn-block { width: 100%; height: 50px; border-radius: 12px; background: var(--card); font-size: 17px; font-weight: 500; color: var(--accent); margin-top: 12px; }
.btn-block.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-block.danger { color: var(--s-crit); }

/* ---------- login */
.login { min-height: 82vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 12px; }
.login img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 24px rgba(98,80,214,.35); }
.login h1 { font-size: 28px; margin: 20px 0 6px; }
.login p { color: var(--label-2); margin: 0 0 24px; font-size: 15px; }
.login .group { width: 100%; max-width: 380px; }
.login .row input { font-size: 17px; }
.login .btn-block { max-width: 380px; }
.login .err { color: var(--s-crit); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* ---------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(var(--safe-b) + 2px); background: var(--tabbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--sep);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; color: #8e8e93; font-size: 10px; font-weight: 500; padding-top: 1px; }
.tabbar a svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on svg { stroke-width: 2.2; }
.badge { position: absolute; top: -2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--s-crit); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; font-style: normal; }
.badge:empty { display: none; }
body.no-tabs .tabbar, body.no-tabs .fab { display: none; }

/* ---------- toast, pull to refresh */
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 74px); transform: translate(-50%, 20px); z-index: 60; background: rgba(30,30,32,.94); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 15px; display: flex; gap: 14px; align-items: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #b3abf2; font-weight: 600; }
#ptr { position: fixed; top: calc(var(--safe-t) + 50px); left: 50%; transform: translate(-50%, -60px); z-index: 15; width: 34px; height: 34px; border-radius: 50%; background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,.15); display: flex; align-items: center; justify-content: center; opacity: 0; }
.ptr-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.4px solid var(--accent-soft); border-top-color: var(--accent); }
#ptr.loading .ptr-spinner { animation: spin .8s linear infinite; }
.sync-line { text-align: center; font-size: 12px; color: var(--label-3); margin-top: 28px; }
.sync-line .warn { color: var(--s-serious); }
@media (min-width: 700px) { #view { max-width: 640px; margin: 0 auto; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
