/* Cockpit — charte graphique. Deux thèmes pilotés par l'attribut data-theme sur <html>. */
:root {
  --bg: #F3F5F8; --card: #FFFFFF; --ink: #0E1A2B; --muted: #55637A; --line: #DDE3EC; --line-strong: #C5CEDB;
  --soft: #F3F5F8; --track: #E4E9F0; --action: #1D4FD8; --action-ink: #FFFFFF; --link: #1D4FD8; --needle: #F28C28;
  --late-bg: #FFF1E6; --late-ink: #A8430A; --late-bar: #C2540E; --ok-bg: #E3F4EF; --ok-ink: #0B6B5A;
  --info-bg: #E8EEFC; --info-ink: #1A3FAE; --neutral-bg: #EBEEF3; --neutral-ink: #3D4A5F;
  --free: #CFE8E0; --busy: #0E1A2B; --overlay: rgba(14, 26, 43, .45); --shadow: 0 10px 30px rgba(14, 26, 43, .18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0B1422; --card: #172538; --ink: #EEF2F7; --muted: #A3B2C7; --line: #26364D; --line-strong: #3A4C66;
  --soft: #1F2F46; --track: #26364D; --action: #2F62DD; --action-ink: #FFFFFF; --link: #8FB0FF; --needle: #F7A24B;
  --late-bg: #3A2413; --late-ink: #FFB37A; --late-bar: #F28C28; --ok-bg: #12352E; --ok-ink: #7FD9C2;
  --info-bg: #1A2B52; --info-ink: #A9C1FF; --neutral-bg: #22324A; --neutral-ink: #C6D1E0;
  --free: #1E4A40; --busy: #C6D1E0; --overlay: rgba(0, 0, 0, .6); --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
h2 { font-family: var(--display); font-size: 15px; font-weight: 600; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.boot { text-align: center; color: var(--muted); padding: 40vh 20px 0; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.header { position: sticky; top: 0; z-index: 5; background: var(--bg); height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 18px; font-weight: 700;
  color: var(--ink); text-decoration: none; }
.brand svg { display: block; }
:root[data-theme="dark"] .brand svg, :root[data-theme="dark"] .login > svg { border-radius: 28%; box-shadow: 0 0 0 1px var(--line-strong); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; color: var(--ink); border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.icon-btn:active { background: var(--track); }
.avatar { border-radius: 50%; color: #FFFFFF; font-family: var(--display); font-weight: 600; display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0; text-decoration: none; width: 34px; height: 34px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.xl { width: 76px; height: 76px; font-size: 30px; }
:root[data-theme="dark"] .avatar { box-shadow: 0 0 0 1px var(--line-strong); }
main { flex: 1; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 calc(84px + env(safe-area-inset-bottom)); }
.footer.no-nav { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.linklike { background: none; border: none; padding: 0; color: var(--link); text-decoration: underline; font-size: inherit; }
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 6;
  background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom); }
.nav a { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.nav a.on { color: var(--link); }

.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.wrap { flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex;
  flex-direction: column; gap: 10px; }
.sep { height: 1px; background: var(--line); }
.group-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-ink); }
.chip.late { background: var(--late-bg); color: var(--late-ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.info { background: var(--info-bg); color: var(--info-ink); }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; font-size: 14px; font-weight: 600; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn.danger { color: var(--late-ink); border-color: var(--late-ink); }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; }
.btn:active { filter: brightness(.94); }
.tile { width: 38px; height: 38px; border-radius: 10px; background: var(--soft); color: var(--ink); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; }
.banner { border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; background: var(--ok-bg); color: var(--ok-ink); }
.banner.late { background: var(--late-bg); color: var(--late-ink); }
.banner.info { background: var(--info-bg); color: var(--info-ink); }
.big { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.unit { font-size: 14px; color: var(--muted); margin-left: 6px; font-weight: 400; letter-spacing: 0; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 8px; border-radius: 999px; background: var(--action); }
.bar.ink > span { background: var(--ink); }
.bar.late > span { background: var(--late-bar); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
:root[data-theme="dark"] .stat { background: var(--card); border: 1px solid var(--line); }
.stat .v { font-family: var(--display); font-size: 18px; font-weight: 600; margin-top: 2px; }
.quick { background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; min-height: 64px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 600;
  color: var(--ink); text-decoration: none; }
.quick svg { color: var(--link); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--track); border-radius: 12px; padding: 3px; }
.seg button { min-height: 40px; border: none; border-radius: 10px; background: transparent; font-size: 13px; font-weight: 600; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--card); }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.tab { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card);
  color: var(--ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.switch { width: 46px; height: 28px; border-radius: 999px; border: none; background: #8A96A8; position: relative; padding: 0; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF; transition: left .15s; }
.switch[aria-pressed="true"] { background: var(--action); }
.switch[aria-pressed="true"]::after { left: 20px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { display: flex; flex-direction: column; gap: 4px; background: none; border: none; padding: 0; color: var(--ink); }
.day .dl { text-align: center; font-size: 11px; color: var(--muted); }
.day .dn { text-align: center; font-size: 13px; font-weight: 600; border-radius: 8px; padding: 2px 0; }
.day.today .dn { background: var(--action); color: var(--action-ink); }
.slot { display: block; height: 14px; border-radius: 4px; background: var(--free); }
.slot.busy { background: var(--busy); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; background: var(--free); }
.legend i.busy { background: var(--busy); }
.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--track); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--link); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--link); }
.chart .ref { fill: none; stroke: var(--needle); stroke-width: 2; stroke-dasharray: 5 5; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.k-read { color: var(--link); font-weight: 600; }
.k-ref { color: var(--late-ink); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; font-size: 14px; }
.list-item { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.item-btn { background: none; border: none; padding: 0; text-align: left; color: inherit; display: block; width: 100%; }
.news a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.wx-now { display: flex; align-items: center; gap: 8px; }
.wx-temp { font-family: var(--display); font-size: 20px; font-weight: 600; }

/* connexion */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 12vh 20px 20px; gap: 12px; text-align: center; }
.login h1 { font-size: 30px; }
.profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: 100%; margin-top: 24px; }
.profile-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px 12px; display: flex;
  flex-direction: column; align-items: center; gap: 10px; color: var(--ink); }
.profile-card .n { font-size: 17px; font-weight: 600; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.codes span { background: var(--soft); border-radius: 8px; padding: 8px; text-align: center; }

/* feuilles (formulaires en bas d'écran) */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: var(--card); padding-top: 8px; z-index: 1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
.input { min-height: 46px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg); padding: 10px 12px;
  width: 100%; font-size: 16px; color: var(--ink); -webkit-appearance: none; appearance: none; }
textarea.input { min-height: 84px; resize: vertical; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.months { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.months button { min-height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 12px; font-weight: 600; color: var(--ink); padding: 0; }
.months button[aria-pressed="true"] { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
.toast.err { background: var(--late-ink); color: #FFFFFF; }
:root[data-theme="dark"] .toast.err { background: #FFB37A; color: #1A1206; }
.changelog li { margin: 6px 0; }
.changelog ul { margin: 0; padding-left: 18px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
