:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1f2a2a;
  --ink-2: #5b6665;
  --line: #e3e0d8;
  --brand: #1f5c55;
  --brand-ink: #ffffff;
  --brand-soft: #e3efec;
  --accent: #b3742a;
  --danger: #a8362f;
  --danger-soft: #f7e6e4;
  --ok: #2f7a45;
  --ok-soft: #e4f2e8;
  --warn-soft: #fbf0dc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 30, .06), 0 2px 8px rgba(20, 30, 30, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1a; --surface: #1c2424; --surface-2: #222b2b; --ink: #e8ecea; --ink-2: #9fabaa; --line: #2f3a3a;
    --brand: #5fb3a6; --brand-ink: #0e1716; --brand-soft: #1f3532; --accent: #e0a85e;
    --danger: #e57b72; --danger-soft: #3a2422; --ok: #6fc28a; --ok-soft: #1f3326; --warn-soft: #3a3020;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand small { display: block; font-weight: 400; color: var(--ink-2); font-size: .78rem; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 19px; height: 19px; flex: none; }
.side .who { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.side .who strong { color: var(--ink); display: block; }
main { padding: 28px clamp(16px, 4vw, 40px) 100px; max-width: 1000px; width: 100%; }
.tabbar { display: none; }

@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; }
  main { padding: 18px 16px 96px; }
  .shell .mtop { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: .86rem; }
  .mtop .brand { padding: 0; font-size: .95rem; }
  .mtop .brand img { width: 26px; height: 26px; }
  .mtop nav { display: flex; gap: 12px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--ink-2); text-decoration: none; padding: 4px 0; }
  .tabbar a.on { color: var(--brand); }
  .tabbar svg { width: 22px; height: 22px; }
}

/* Composants */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: .84rem; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: .84rem; }
.btn:disabled { opacity: .55; cursor: default; }
label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }

.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.pill.transmission { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.decision { background: var(--warn-soft); color: var(--accent); border-color: transparent; }
.pill.consigne { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.action, .pill.a_faire { background: var(--surface-2); }
.pill.en_cours { background: var(--warn-soft); color: var(--accent); border-color: transparent; }
.pill.fait { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.entry-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .84rem; color: var(--ink-2); margin-bottom: 4px; }
.entry-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.youth-link { font-weight: 600; text-decoration: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }

.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--ink-2); font-size: .86rem; }
.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

/* Messagerie */
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 360px; }
@media (max-width: 760px) { .chat { height: calc(100vh - 230px); } }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 2px 10px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.msg.me { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.msg .meta { font-size: .76rem; color: var(--ink-2); margin-bottom: 2px; }
.composer { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; height: 44px; }
.channels { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.channels a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .88rem; }
.channels a.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Pointage */
.clock { display: flex; align-items: center; gap: 16px; }
.clock .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); flex: none; }
.clock .dot.on { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); }
.big-status { text-align: center; padding: 30px 10px; }
.big-status .mark { font-size: 3.4rem; line-height: 1; margin-bottom: 10px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { padding: 0 0 20px; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-size: .9rem; }
.notice { background: var(--warn-soft); border-radius: 9px; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; }
.success { background: var(--ok-soft); color: var(--ok); border-radius: 9px; padding: 10px 12px; margin-bottom: 12px; }
.lock svg { width: 18px; height: 18px; flex: none; }
.mtop { display: none; }
.lock { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--ink-2); margin-bottom: 12px; }
.empty { color: var(--ink-2); padding: 14px 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; font-weight: 600; max-width: calc(100% - 32px); }
