/* Page iPhone du CRM : charte Freenematic (anthracite, rouge REC, blanc chaud, gris pierre, vert mousse). */
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("fonts/Poppins-SemiBold.ttf") format("truetype"); }

:root {
  --bg: #F5F4F0; --surface: #FFFFFF; --surface-2: #ECEAE4; --fg: #1C1C1C; --muted: #5A5A56; --line: #D9D6CE;
  --rec: #C6102A; --due: #B00E25; --due-bg: #FBE3E6; --moss: #4F6B4D; --amber: #9A5B00; --blue: #1F6A8C;
  --s-a_appeler: #5A5A56; --s-a_relancer: #9A5B00; --s-rdv: #1F6A8C; --s-offre: #6B4BA0; --s-client: #4F6B4D; --s-surveiller: #2F7A6E; --s-perdu: #8A8983;
  --display: "Poppins", -apple-system, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #1F1F1D; --surface-2: #292927; --fg: #F5F4F0; --muted: #A6A59E; --line: #3A3A37;
    --rec: #D42A41; --due: #FF7A8A; --due-bg: #3F1E24; --moss: #9DB39A; --amber: #E0A24A; --blue: #6DB3D6;
    --s-a_appeler: #A6A59E; --s-a_relancer: #E0A24A; --s-rdv: #6DB3D6; --s-offre: #B49AE0; --s-client: #9DB39A; --s-surveiller: #6FC2B3; --s-perdu: #77766F;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--body); overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--rec); outline-offset: 2px; }

.mark { width: 56px; height: 56px; color: var(--fg); }
.mark.small { width: 26px; height: 26px; flex: none; }

/* Connexion */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 10px; }
.login-card h1 { font: 600 26px/1.2 var(--display); margin: 8px 0 18px; }
.login-card label { font-size: 13px; color: var(--muted); }
.err { color: var(--due); min-height: 1.4em; margin: 0; font-size: 14px; }

/* Structure */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.top h1 { flex: 1; min-width: 0; margin: 0; font: 600 20px/1.2 var(--display); }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sync.err { color: var(--due); }
main { padding: 12px 16px calc(env(safe-area-inset-bottom) + 92px); max-width: 720px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 48px;
  background: none; border: 0; font-size: 11px; color: var(--muted); cursor: pointer;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--rec); font-weight: 600; }

/* Éléments */
.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
a.btn { color: var(--fg); }
.btn.primary, a.btn.primary { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--rec); padding-inline: 4px; }
.btn.danger { color: var(--due); border-color: var(--due); background: none; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=tel], input[type=email], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--rec); flex: none; margin: 2px 0 0; }

.stats { display: flex; gap: 22px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.stat b { display: block; font: 600 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stat.alert b { color: var(--due); }

.group { margin: 18px 0 6px; display: flex; align-items: baseline; gap: 8px; }
.group::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--g, var(--muted)); align-self: center; }
.group h2 { margin: 0; flex: 1; font: 600 16px/1.3 var(--display); }
.group small { color: var(--muted); font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 12px 14px; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer;
}
.row:first-child { border-top: 0; }
.row.due { background: var(--due-bg); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .name.task { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row .name.task.open { -webkit-line-clamp: unset; }
.row .meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .note { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row .when.late { color: var(--due); font-weight: 600; }
.row.done .name { text-decoration: line-through; color: var(--muted); }
.kind { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 6px; font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }

.searchbar { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin: 0 -16px 6px; padding-inline: 16px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: none; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
.chip .n { opacity: .65; font-variant-numeric: tabular-nums; }

.addtask { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.addtask input[type=text] { flex: 1 1 100%; min-width: 0; }
.addtask input[type=date] { flex: 1 1 0; min-width: 0; }
.addtask .btn { flex: none; }

.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

/* Fiche */
.sheet {
  width: 100%; max-width: 720px; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0;
  background: var(--bg); color: var(--fg);
}
.sheet::backdrop { background: rgb(0 0 0 / .35); }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { flex: 1; min-width: 0; margin: 0; font: 600 18px/1.25 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 14px 16px calc(env(safe-area-inset-bottom) + 32px); display: grid; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input { flex: 1; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notes { white-space: pre-wrap; font-size: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }
.why { white-space: pre-line; font-size: 14px; overflow-wrap: anywhere; }
.saved { font-size: 12px; color: var(--moss); min-height: 1.2em; }

/* Prestas */
.month { padding: 12px 14px; border-top: 1px solid var(--line); }
.month:first-child { border-top: 0; }
.month .line { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.month b { font: 600 17px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 10px; margin: 8px 0 4px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; }
.bar .paid { background: var(--moss); left: 0; }
.bar .due { background: color-mix(in srgb, var(--amber) 55%, transparent); }
.bar .goal { border-left: 2px dashed var(--fg); opacity: .5; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.paid-l { color: var(--moss); } .due-l { color: var(--amber); }
