/* ClaireDD — feuille de style mobile-first (aucune dépendance externe) */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1a1f2b;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #7c3aed;
  --brand-ink: #ffffff;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #191c22; --ink: #f3f4f6; --muted: #9ca3af;
    --line: #2a2e37; --brand: #a78bfa; --brand-ink: #1a1030; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .4em; font-weight: 700; }
a { color: var(--brand); }
.hidden { display: none !important; }

/* Layout */
#app { max-width: 560px; margin: 0 auto; padding: 12px 12px calc(84px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; background: var(--bg);
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar .who { font-size: .8rem; color: var(--muted); }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }

/* Tiles (accueil) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.tile .label { font-size: .78rem; color: var(--muted); }
.tile .value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.tile.brand { background: var(--brand); color: var(--brand-ink); border: none; }
.tile.brand .label { color: var(--brand-ink); opacity: .85; }
.tile .sub { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.tile.brand .sub { color: var(--brand-ink); opacity: .8; }

/* Forms */
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
input[type=number], input[type=text], input[type=password], input[type=date], select {
  width: 100%; padding: 13px 14px; font-size: 1.05rem; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-check { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.inline-check input { width: 22px; height: 22px; accent-color: var(--brand); }
.inline-check label { margin: 0; font-size: .95rem; color: var(--ink); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; font-size: 1.05rem; font-weight: 700; border: none;
  border-radius: 14px; background: var(--brand); color: var(--brand-ink); cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn:active { transform: scale(.99); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Envelope summary box */
.env { border-radius: var(--radius); padding: 16px; margin: 14px 0; text-align: center; }
.env .label { font-size: .8rem; opacity: .8; }
.env .amount { font-size: 2rem; font-weight: 800; }
.env.pos { background: rgba(5,150,105,.12); color: var(--ok); }
.env.neg { background: rgba(220,38,38,.12); color: var(--bad); }
.breakdown { font-size: .82rem; color: var(--muted); }
.breakdown div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.breakdown .strong { color: var(--ink); font-weight: 700; }

/* Lists */
.list .item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: none; }
.item .meta { font-size: .8rem; color: var(--muted); }
.badge { font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--ink); }
.badge.css { background: rgba(217,119,6,.15); color: var(--warn); }
.badge.ok { background: rgba(5,150,105,.15); color: var(--ok); }
.badge.warn { background: rgba(217,119,6,.15); color: var(--warn); }

/* Journées */
.jitem { padding: 12px 0; border-bottom: 1px solid var(--line); }
.jitem:last-child { border-bottom: none; }
.jhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.jhead .badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.jactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.jactions .sbtn { padding: 8px 12px; border-radius: 10px; font-size: .82rem; font-weight: 700; border: 1.5px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.jactions .sbtn.brand { background: var(--brand); color: var(--brand-ink); border: none; }
.jactions a.sbtn { text-decoration: none; }
.jenv { display: flex; gap: 8px; margin-top: 8px; }
.jenv input { flex: 1; }
.pending-banner { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.pending-banner .big { font-size: 1.8rem; font-weight: 800; }
.pending-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.2); font-size: .9rem; }
.pending-line:last-child { border-bottom: none; }

/* Bottom nav */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-b));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .64rem; font-weight: 600; padding: 4px 4px; white-space: nowrap; flex: 1; }
.tabbar a.active { color: var(--brand); }
.tabbar .ic { font-size: 1.3rem; line-height: 1; }

/* Chart */
canvas { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
.scroll-x { overflow-x: auto; }

/* Login */
.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login-logo { text-align: center; font-size: 2.6rem; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: .9rem; z-index: 50; box-shadow: var(--shadow); }
.center { text-align: center; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.spinner { text-align:center; color: var(--muted); padding: 30px; }
