/* Cancale – style « Ardoise » */
:root {
  --bg: #12171C;
  --surface: #1B2229;
  --surface-2: #232C35;
  --ink: #EEF2F4;
  --muted: #9AA6B0;
  --line: #2A333C;
  --soft: #22303A;
  --accent: #7CC8A4;
  --accent-text: #8AD4B0;
  --accent-ink: #0B1A12;
  --warn: #F2A65E;
  --warn-soft: #3A2A1C;
  --danger: #F29B9B;
  --r: 20px;
  --fd: 'Space Grotesk', system-ui, sans-serif;
  --fb: 'Inter', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--fb); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; }
a { color: var(--accent-text); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(110px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

/* En-têtes */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 4px 6px; }
.top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.eyebrow { font-size: 13px; color: var(--muted); }
.ttl { font-family: var(--fd); font-weight: 600; font-size: 30px; letter-spacing: -.02em; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; text-decoration: none; flex: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--surface); color: var(--ink); display: grid; place-items: center; text-decoration: none; flex: none; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Cartes */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.hero { padding: 20px; }
.lbl { font-size: 13px; color: var(--muted); font-weight: 500; }
.big { font-family: var(--fd); font-size: 56px; font-weight: 600; line-height: 1; letter-spacing: -.03em; color: var(--accent-text); }
.big.neutral { color: var(--ink); }
.sub { font-size: 15px; }
.rowh { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 600; }
.rowh a { font-size: 14px; text-decoration: none; font-weight: 500; }
.t { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.m { font-size: 13px; color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.acc { color: var(--accent-text); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--accent-text); white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* Boutons */
.btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 700; font-size: 15px; }
.btn.small { min-height: 44px; align-self: flex-start; font-size: 14px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); font-weight: 600; }
.btn:disabled { opacity: .6; cursor: default; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/* Onglets segmentés */
.seg { display: flex; background: var(--surface); border-radius: 14px; padding: 4px; }
.segb { flex: 1; min-height: 40px; border: 0; border-radius: 11px; background: transparent; font-size: 14px; font-weight: 500; color: var(--muted); display: grid; place-items: center; text-decoration: none; }
.segb.on, .segb[aria-pressed="true"] { background: var(--soft); color: var(--ink); }

/* Listes */
.list, .ledger { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ledger { background: var(--surface); border-radius: var(--r); padding: 0 16px; }
.ledger li + li, .list li + li { border-top: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 0; color: inherit; text-decoration: none; }
.cat { width: 38px; height: 38px; border-radius: 12px; background: var(--soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.cat .ic { width: 18px; height: 18px; }
.amts { font-family: var(--fd); font-weight: 600; font-size: 16px; white-space: nowrap; text-align: right; }
.group { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 4px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* Soldes */
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.split > .full { grid-column: 1 / -1; }
.amt { font-family: var(--fd); font-size: 26px; font-weight: 600; }
.bar { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Bilan */
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: baseline; }
.barrow .bar { grid-column: 1 / -1; }
.bars { display: flex; flex-direction: column; gap: 14px; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 120px; }
.months .mcol { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.months .mbar { width: 100%; max-width: 18px; background: var(--accent); border-radius: 4px 4px 2px 2px; min-height: 2px; }
.months .mbar.zero { background: var(--soft); }
.months .mlbl { font-size: 11px; color: var(--muted); }
.delta { font-size: 14px; color: var(--muted); }

/* Filtres */
.filters { display: flex; gap: 8px; }
.filters select { flex: 1; min-width: 0; }

/* Formulaires */
form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lbl { font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 14px;
  min-height: 48px;
  padding: 0 14px;
  font: 16px var(--fb);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea { padding: 12px 14px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.amount-input { font-family: var(--fd); font-size: 44px; font-weight: 600; text-align: center; min-height: 80px; letter-spacing: -.02em; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
details { background: var(--surface); border-radius: 14px; padding: 0 14px; }
details[open] { padding-bottom: 14px; }
summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; }
details > .field + .field { margin-top: 12px; }
.error { color: var(--danger); font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }

/* Travaux */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; text-decoration: none; }
.chip.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
a.card { color: inherit; text-decoration: none; }
.tt { font-family: var(--fd); font-size: 19px; font-weight: 600; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 8px; background: var(--soft); color: var(--ink); }
.info { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; font-size: 15px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; text-align: right; }
.desc { white-space: pre-line; font-size: 15px; line-height: 1.5; }

/* Articles (matériel, courses) */
.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.check { width: 44px; height: 44px; flex: none; border: 0; background: none; display: grid; place-items: center; padding: 0; }
.check::before { content: ''; width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--muted); box-sizing: border-box; }
.check.on::before { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B1A12' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12l4 4 8-8'/%3E%3C/svg%3E") center / 16px no-repeat; border-color: var(--accent); }
.status-btn { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 0; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-btn.to_buy { background: var(--warn-soft); color: var(--warn); }
.status-btn.bought, .status-btn.on_site { background: var(--soft); color: var(--accent-text); }
.xbtn { width: 40px; height: 40px; flex: none; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.xbtn .ic { width: 18px; height: 18px; }
.buy-panel { background: var(--surface-2); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }
.add-row .btn { min-height: 48px; padding: 0 16px; }
.striked { text-decoration: line-through; color: var(--muted); }

/* Agenda */
:root { --c-u0: #7CC8A4; --c-u1: #8AB4F8; --c-friends: #F2A65E; --c-rental: #C9A7F5; --c-works: #9AA6B0; --c-closed: #5C6873; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-nav h2 { font-family: var(--fd); font-size: 20px; font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; font-weight: 600; }
.day { min-height: 54px; border-radius: 10px; background: var(--surface); padding: 5px 4px; display: flex; flex-direction: column; gap: 3px; color: var(--ink); text-decoration: none; font-size: 13px; }
.day.out { background: transparent; color: var(--muted); opacity: .5; }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day .n { font-weight: 600; padding-left: 2px; }
.sbar { height: 6px; border-radius: 3px; background: var(--c); }
.sbar.pending, .dot.pending { background: repeating-linear-gradient(135deg, var(--c) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--c); }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.stay-card { flex-direction: row; gap: 12px; align-items: flex-start; }
.stay-card .dot { margin-top: 5px; }
.warn-card { background: var(--warn-soft); color: var(--warn); }
.warn-card .m { color: var(--warn); }
.two-btn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Bouton flottant */
.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(92px + var(--safe-b)); width: 58px; height: 58px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 8px 24px -6px rgba(124, 200, 164, .45); z-index: 5; }
.fab .ic { width: 26px; height: 26px; }

/* Barre d'onglets */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); width: min(528px, calc(100% - 24px)); height: 64px; padding: 0 6px; display: flex; background: var(--surface-2); border-radius: 22px; z-index: 10; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tab.on { color: var(--accent-text); font-weight: 600; }

/* Connexion */
.login { min-height: 80dvh; justify-content: center; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 12px; }
.brand img { width: 72px; height: 72px; border-radius: 20px; }

/* Notification */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 500; z-index: 20; max-width: calc(100% - 32px); }
#toast.err { background: var(--danger); color: #2A0B0B; }
