/* Chrono Maxxweb — clair par défaut, sombre auto. Chiffres tabulaires partout. */
:root {
  --bg: #F7F8FA; --card: #FFFFFF; --text: #14161C; --muted: #6B7280;
  --line: #E7E9EF; --accent: #4F46E5; --accent-soft: #EEF0FE;
  --run: #059669; --run-soft: #E7F6F0; --danger: #DC2626; --danger-soft: #FDECEC;
  --money: #0E7C5B; --shadow: 0 1px 2px rgba(15, 20, 40, .05), 0 8px 24px rgba(15, 20, 40, .06);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1016; --card: #171A22; --text: #EDEFF5; --muted: #8B91A3;
    --line: #262B38; --accent: #7C74F5; --accent-soft: #232042;
    --run: #34D399; --run-soft: #12291F; --danger: #F87171; --danger-soft: #331A1A;
    --money: #4ADE9E; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
dialog:not([open]) { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
small { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; max-width: 860px; margin: 0 auto; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.brand-dot.running { background: var(--run); box-shadow: 0 0 0 4px var(--run-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px; box-shadow: var(--shadow); }
.tabs button {
  border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: 13.5px;
}
.tabs button.active { background: var(--accent); color: #fff; }

.tab { max-width: 860px; margin: 0 auto; padding: 8px 20px 48px; }

/* ---------- Timer ---------- */
.timer-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  padding: 28px 24px; text-align: center; margin-bottom: 16px; transition: border-color .3s;
}
.timer-card.running { border-color: var(--run); }
.timer-display {
  font-size: clamp(52px, 14vw, 84px); font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.timer-card.running .timer-display { color: var(--run); }
.timer-meta { color: var(--muted); margin: 6px 0 18px; font-size: 14.5px; min-height: 20px; }
.timer-form { display: flex; gap: 10px; max-width: 520px; margin: 0 auto 16px; }
.timer-form select { flex: 0 0 42%; }
.timer-form input { flex: 1; }
.timer-actions { display: flex; gap: 10px; justify-content: center; align-items: center; }
.btn-timer {
  border: 0; border-radius: 99px; padding: 14px 44px; font-size: 17px; font-weight: 700; color: #fff;
  background: var(--run); transition: transform .1s, background .2s;
}
.btn-timer.stop { background: var(--danger); }
.btn-timer:active { transform: scale(.97); }

/* ---------- Bento stats ---------- */
.bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-card.accent .stat-value { color: var(--money); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.client-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.client-bar-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.client-bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.client-bar-track { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.client-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s ease; }
.client-bar-row .val { font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Sessions ---------- */
.section { margin-bottom: 24px; }
.session-list, .invoice-list, .client-list { display: flex; flex-direction: column; gap: 8px; }
.session-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.session-row:hover { border-color: var(--accent); }
.session-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.session-row .who { font-weight: 700; flex: none; }
.session-row .what { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.session-row .dur { font-variant-numeric: tabular-nums; font-weight: 700; flex: none; }
.session-row .eur { font-variant-numeric: tabular-nums; color: var(--money); font-weight: 600; flex: none; }
.session-row .live { color: var(--run); font-weight: 700; }
.session-row .billed-tag { font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 2px 6px; flex: none; }
.empty { color: var(--muted); text-align: center; padding: 22px; font-size: 14px; }

/* ---------- Résumés ---------- */
.period-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 99px; padding: 7px 14px; font-weight: 600; font-size: 13.5px;
}
.chips button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.custom-range { display: flex; gap: 8px; align-items: center; }
.check { font-size: 13.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.report-totals {
  display: flex; gap: 18px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.report-totals b { font-size: 19px; }
.report-totals .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.report-client {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px;
}
.report-client-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.report-client-head .name { font-size: 17px; font-weight: 800; flex: 1; }
.report-client-head .nums { font-variant-numeric: tabular-nums; color: var(--muted); }
.report-client-head .eur { font-variant-numeric: tabular-nums; color: var(--money); font-weight: 800; font-size: 17px; }
.report-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.report-detail { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 13.5px; }
.report-detail .session-row { box-shadow: none; }
.invoice-row {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px;
}
.invoice-row .who { font-weight: 700; }
.invoice-row .period { color: var(--muted); flex: 1; }
.invoice-row .eur { font-variant-numeric: tabular-nums; color: var(--money); font-weight: 700; }
.abby-badge { font-size: 11px; background: var(--run-soft); color: var(--run); border-radius: 6px; padding: 2px 7px; font-weight: 700; }

/* ---------- Clients ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.client-card {
  display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; cursor: pointer;
}
.client-card:hover { border-color: var(--accent); }
.client-card .avatar {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; flex: none; font-size: 16px;
}
.client-card .info { flex: 1; min-width: 0; }
.client-card .name { font-weight: 700; }
.client-card .meta { font-size: 13px; color: var(--muted); }
.client-card .rate { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- Réglages ---------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 10px;
}

/* ---------- Inputs & boutons ---------- */
.input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px;
}
.input.slim { width: auto; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn-primary {
  border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700;
  padding: 11px 18px; font-size: 14.5px;
}
.btn-primary.full, .btn-ghost.full { width: 100%; }
.btn-ghost {
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text);
  font-weight: 600; padding: 10px 16px; font-size: 14px;
}
.btn-ghost.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-small { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 8px 12px; font-weight: 600; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 10px; }

/* ---------- Login ---------- */
#login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  padding: 36px 32px; width: 360px; text-align: center; display: flex; flex-direction: column; gap: 12px;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 0; font-size: 21px; }
.login-card p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

/* ---------- Modales ---------- */
.modal { border: 0; border-radius: 20px; background: var(--card); color: var(--text); box-shadow: var(--shadow); padding: 24px; width: min(440px, 92vw); }
.modal::backdrop { background: rgba(10, 12, 20, .5); backdrop-filter: blur(3px); }
.modal h3 { margin: 0 0 16px; }
.modal label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.modal label .input, .modal label select { margin-top: 5px; font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.modal-actions.column { flex-direction: column; }
.modal-actions .spacer { flex: 1; }
.inv-summary { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-line; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 20px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 100; max-width: 90vw;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; }
  .tabs { width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; padding: 8px 4px; }
  .tab { padding: 4px 14px 40px; }
  .bento { grid-template-columns: 1fr 1fr; }
  .stat-card.accent { grid-column: 1 / -1; }
  .timer-form { flex-direction: column; }
  .timer-form select { flex: 1; }
  .client-bar-row { grid-template-columns: 90px 1fr auto; }
}
