/* Maison — même langage visuel que le suivi de Léonore, teinte verte. */
:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #ebf1ed;
  --text: #1d2621;
  --muted: #66736b;
  --border: #dbe4de;
  --shadow: 0 1px 3px rgb(20 50 35 / 0.08), 0 4px 14px rgb(20 50 35 / 0.06);

  --accent: #1f8a70;
  --accent-bg: #dcf1ea;
  --danger: #d33a3a;
  --danger-bg: #fbe3e3;
  --warn: #c47a00;
  --warn-bg: #fdf0d6;

  /* Catégories */
  --cuisine: #e07a2e;   --cuisine-bg: #fdecdc;
  --buanderie: #2f8fdb; --buanderie-bg: #e1effb;
  --chauffage: #d9483b; --chauffage-bg: #fbe4e1;
  --securite: #8566d9;  --securite-bg: #ece6fb;
  --maison: #1f8a70;    --maison-bg: #dcf1ea;

  --radius: 16px;
  --tap: 52px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --surface: #1d2420;
    --surface-2: #26302a;
    --text: #e9f0eb;
    --muted: #9aa8a0;
    --border: #334039;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4);

    --accent: #4fd1a8;
    --accent-bg: #19352b;
    --danger: #ff6b6b;
    --danger-bg: #3d1f1f;
    --warn: #f2b84b;
    --warn-bg: #3a2e17;

    --cuisine: #ff9d57;   --cuisine-bg: #3d2b1e;
    --buanderie: #5eb0f2; --buanderie-bg: #1d2f40;
    --chauffage: #ff7a6e; --chauffage-bg: #3d221f;
    --securite: #a990f2;  --securite-bg: #2c2541;
    --maison: #4fd1a8;    --maison-bg: #19352b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; font-size: 16px; line-height: 1.4; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* --- En-tête et navigation ------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  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(10px);
}
.topbar h1 { font-size: 1.35rem; margin: 0; flex: 1; letter-spacing: -0.01em; min-width: 0; }
.topbar .sub { color: var(--muted); font-size: 0.85rem; font-weight: 400; display: block; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 22px; flex: none;
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; gap: 6px; font-size: 0.95rem; text-decoration: none; color: inherit;
}
.back-btn { font-size: 1.3rem; padding: 0; width: 44px; }

main { flex: 1; padding: 4px 16px calc(100px + env(safe-area-inset-bottom)); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav-inner { display: flex; width: 100%; max-width: 640px; }
.bottomnav a { flex: 1; text-align: center; padding: 10px 0 12px; color: var(--muted); text-decoration: none; font-size: 0.8rem; }
.bottomnav a .ico { display: block; font-size: 1.4rem; line-height: 1.2; }
.bottomnav a.active { color: var(--accent); font-weight: 700; }

/* --- Blocs communs ---------------------------------------------------------- */
.section-title {
  font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 22px 2px 8px; display: flex; align-items: center; gap: 8px;
}
.section-title .count {
  background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: 0.75rem;
}
.section-title.late { color: var(--danger); }
.section-title.late .count { background: var(--danger-bg); }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  border: 1.5px solid var(--border); box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { font-size: 1.05rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty .big { font-size: 2.6rem; display: block; margin-bottom: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.8rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.pill.late { background: var(--danger); color: #fff; }
.pill.today { background: var(--warn); color: #fff; }
.pill.soon { background: var(--warn-bg); color: var(--warn); }
.pill.later { background: var(--surface-2); color: var(--muted); }
.pill.pro { background: var(--securite-bg); color: var(--securite); }
.pill.ok { background: var(--accent-bg); color: var(--accent); }
@media (prefers-color-scheme: dark) { .pill.late, .pill.today { color: #141917; } }

/* Teinte par catégorie : --c / --c-bg */
.cat-cuisine { --c: var(--cuisine); --c-bg: var(--cuisine-bg); }
.cat-buanderie { --c: var(--buanderie); --c-bg: var(--buanderie-bg); }
.cat-chauffage { --c: var(--chauffage); --c-bg: var(--chauffage-bg); }
.cat-securite { --c: var(--securite); --c-bg: var(--securite-bg); }
.cat-maison { --c: var(--maison); --c-bg: var(--maison-bg); }

.app-ico {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; background: var(--c-bg, var(--surface-2));
}

/* --- Ligne d'entretien (accueil, appareil) ------------------------------------ */
.task-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 0; border-left: 5px solid var(--c, var(--border));
  border-radius: 14px; padding: 10px 10px 10px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow); text-align: left; color: inherit; text-decoration: none;
}
.task-row .body { flex: 1; min-width: 0; }
.task-row .title { font-weight: 700; }
.task-row .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 3px; font-size: 0.85rem; color: var(--muted); }
.check-btn {
  width: 46px; height: 46px; border-radius: 23px; flex: none;
  border: 2px solid var(--accent); background: transparent; color: var(--accent);
  font-size: 1.3rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.check-btn:active { background: var(--accent); color: var(--surface); }

/* --- Appareils ------------------------------------------------------------------ */
.app-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.app-card .body { flex: 1; min-width: 0; }
.app-card .name { font-weight: 700; }
.app-card .sub { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hero {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--c-bg); border-radius: var(--radius); margin-bottom: 12px;
}
.hero .app-ico { width: 60px; height: 60px; font-size: 2.2rem; background: var(--surface); }
.hero h2 { margin: 0; font-size: 1.35rem; }
.hero .sub { color: var(--muted); font-size: 0.9rem; }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 0.88rem; }
dl.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; margin: 0; }

.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.doc-row:first-of-type { border-top: 0; }
.doc-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.doc-row .x { border: 0; background: none; color: var(--muted); font-size: 1.2rem; padding: 4px 8px; }

/* --- Catalogue -------------------------------------------------------------------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cat-item {
  position: relative; min-height: 96px; padding: 12px 10px;
  border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 700; text-align: center; box-shadow: var(--shadow);
}
.cat-item .ico { font-size: 1.9rem; }
.cat-item small { font-weight: 500; color: var(--muted); font-size: 0.78rem; }
.cat-item .have {
  position: absolute; top: -8px; right: 6px; font-size: 0.68rem; padding: 2px 7px;
  border-radius: 999px; background: var(--accent); color: var(--surface);
}
.cat-item:active { border-color: var(--accent); background: var(--accent-bg); }

/* --- Fiche entretien ------------------------------------------------------------------ */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step; position: relative; padding: 10px 10px 10px 48px; margin-bottom: 6px;
  background: var(--surface-2); border-radius: 12px; cursor: pointer;
}
.steps li::before {
  content: counter(step); position: absolute; left: 10px; top: 9px;
  width: 28px; height: 28px; border-radius: 14px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem;
}
.steps li.checked { opacity: 0.55; text-decoration: line-through; }
.steps li.checked::before { content: "✓"; background: var(--accent); color: var(--surface); }
ul.supplies { margin: 0; padding-left: 20px; }
ul.supplies li { margin: 3px 0; }

.due-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }

.hist-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); }
.hist-row:first-child { border-top: 0; }
.hist-row .d { font-weight: 800; min-width: 5.6em; font-variant-numeric: tabular-nums; }
.hist-row .body { flex: 1; min-width: 0; }
.hist-row .note { color: var(--muted); font-style: italic; white-space: pre-wrap; font-size: 0.9rem; }
.hist-row .x { border: 0; background: none; color: var(--muted); font-size: 1.1rem; padding: 2px 6px; }
.who {
  font-size: 0.72rem; font-weight: 800; color: var(--muted);
  width: 24px; height: 24px; border-radius: 12px; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}

/* --- Calendrier ---------------------------------------------------------------------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; font-size: 1.15rem; }
.cal-head h2::first-letter { text-transform: uppercase; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal button {
  aspect-ratio: 1 / 1.05; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--surface); padding: 4px 2px 2px; display: flex; flex-direction: column; align-items: center;
  font-weight: 600; font-size: 0.9rem; min-width: 0;
}
.cal button.out { opacity: 0.35; }
.cal button.today { border-color: var(--accent); color: var(--accent); font-weight: 800; }
.cal button.sel { background: var(--accent); color: var(--surface); }
.cal .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; margin-top: auto; min-height: 7px; }
.cal .dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--accent); }
.cal .dots i.late { background: var(--danger); }
.cal .dots i.done { background: var(--muted); opacity: 0.6; }
.cal button.sel .dots i { background: var(--surface); }
.cal .more { font-size: 0.6rem; line-height: 7px; color: var(--muted); }
.day-list h3 { font-size: 1rem; margin: 18px 2px 8px; }
.day-list h3::first-letter { text-transform: uppercase; }
.task-row.done { opacity: 0.6; }

/* --- Formulaires --------------------------------------------------------------------- */
.field { margin: 14px 0; }
.field > label, .label {
  display: block; font-size: 0.78rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px;
}
.field .hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
input.text, textarea, select, input[type="date"], input[type="number"] {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); font-size: 1.05rem;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .field { margin: 0; }
.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.fields-row .field { margin: 0; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); font-size: 0.9rem; font-weight: 700;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--surface); }

.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 1.4rem;
}
.icon-pick button.on { border-color: var(--accent); background: var(--accent-bg); }

.btn {
  min-height: var(--tap); border-radius: 14px; border: 0; padding: 0 18px;
  font-weight: 800; font-size: 1.02rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: inherit;
}
.btn.primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #141917; } }
.btn.ghost { background: var(--surface); border: 1.5px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.small { min-height: 40px; font-size: 0.9rem; padding: 0 14px; }
.btn:disabled { opacity: 0.5; }
.btn.block { width: 100%; }

.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  display: flex; justify-content: center;
}
.save-bar .inner { width: 100%; max-width: 608px; display: flex; gap: 10px; }
.save-bar .btn.primary { flex: 1; }

/* --- Feuille du bas (« C'est fait ») ------------------------------------------------- */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 4px; font-size: 1.2rem; }

/* --- Divers -------------------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; transition: all 0.2s; z-index: 80; max-width: 92vw; text-align: center;
  display: flex; align-items: center; gap: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast.error { background: var(--danger); color: #fff; }
#toast button { border: 0; background: none; color: var(--accent); font-weight: 800; padding: 4px; }
@media (prefers-color-scheme: light) { #toast button { color: #7ee8c6; } }

.who-screen { padding-top: 15vh; text-align: center; }
.who-screen .btn { width: 100%; margin-bottom: 12px; font-size: 1.2rem; min-height: 64px; }

.overlay { position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / 0.5); display: flex; align-items: center; justify-content: center; padding: 24px; }
.overlay .box { background: var(--surface); border-radius: var(--radius); padding: 20px; max-width: 360px; text-align: center; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px; }
.tile { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 10px; text-align: center; text-decoration: none; color: inherit; }
.tile .tv { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .tl { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.tile.late .tv { color: var(--danger); }
.tile.soon .tv { color: var(--warn); }
.tile.ok .tv { color: var(--accent); }

/* Sous-onglets d'un module */
.subtabs { display: flex; gap: 4px; max-width: 640px; margin: 0 auto; padding: 0 16px 6px; overflow-x: auto; scrollbar-width: none; }
.subtabs a { flex: 1; text-align: center; white-space: nowrap; padding: 7px 10px; border-radius: 999px; font-size: 0.88rem; font-weight: 600; color: var(--muted); text-decoration: none; background: var(--surface); border: 1.5px solid var(--border); }
.subtabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Cartes de module sur l'accueil */
.module-card { display: block; background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px; padding: 14px; margin: 8px 0; color: inherit; text-decoration: none; }
.module-card.alert { border-color: var(--danger); }
.module-card.soon { opacity: .6; }
.mc-head { display: flex; align-items: center; gap: 12px; }
.mc-head > div { flex: 1; min-width: 0; }
.mc-ico { font-size: 1.8rem; }
.mc-title { font-weight: 800; font-size: 1.1rem; }
.mc-sub { color: var(--muted); font-size: 0.88rem; }
.module-card.alert .mc-sub { color: var(--danger); font-weight: 600; }
.mc-go { font-size: 1.6rem; color: var(--muted); }
