:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2024;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2f6f4f;
  --accent-soft: #e7f2ec;
  --danger: #b4443a;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card: #1e2226;
    --text: #e7e9ea;
    --muted: #9aa3ad;
    --line: #2c3238;
    --accent: #4caf7d;
    --accent-soft: #1c2b24;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ------- Top bar ------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-logout { margin: 0; }
.topbar-logout button { padding: 6px 10px; font-size: .8rem; }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.bell { position: relative; text-decoration: none; font-size: 1.3rem; }
.badge {
  position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ------- Layout ------- */
.content { max-width: 720px; margin: 0 auto; padding: 16px 16px 32px; }
h1 { font-size: 1.45rem; margin: 8px 0 16px; }
h2 { font-size: 1rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ------- Cards ------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.card.accent { background: var(--accent-soft); border-color: transparent; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.link { display: inline-block; margin-top: 8px; color: var(--accent); text-decoration: none; font-weight: 600; font-size: .9rem; }
.row-link { color: var(--text); text-decoration: none; font-weight: 500; }
.head-row { display: flex; align-items: center; justify-content: space-between; }
.tag {
  font-style: normal; font-size: .75rem; background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 999px; margin-right: 6px; white-space: nowrap;
}
.tag.due { background: #fdecea; color: #b4443a; }
.tag.soon { background: #e7f2ec; color: #2f6f4f; }
.tag.rec { background: #eef1f6; color: #4a5568; }
@media (prefers-color-scheme: dark) {
  .tag.due { background: #3a201d; }
  .tag.soon { background: #1c2b24; color: #4caf7d; }
  .tag.rec { background: #262b31; color: #9aa3ad; }
}

/* ------- Forms ------- */
input, textarea, button, select {
  font: inherit; width: 100%; border-radius: 10px; border: 1px solid var(--line);
  padding: 11px 12px; background: var(--bg); color: var(--text); margin-bottom: 10px;
}
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { font-size: .8rem; color: var(--muted); }
button {
  background: var(--accent); color: #fff; border: none; font-weight: 600;
  cursor: pointer; margin-bottom: 0;
}
button:active { opacity: .85; }
.mini { width: auto; padding: 7px 14px; font-size: .85rem; border-radius: 8px; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
form { margin: 0; }

/* ------- Notes / tasks / notifs ------- */
.note-content { white-space: pre-wrap; cursor: text; }
.note-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.note-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Édition en place : une seule des deux vues est visible à la fois. */
.note-edit { display: none; }
.note.editing .note-view { display: none; }
.note.editing .note-edit { display: block; }
.note-edit .note-actions { margin-top: 4px; }

.btn-link {
  display: inline-block; text-decoration: none; text-align: center; flex-shrink: 0;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; font-size: .85rem; font-weight: 600;
}
.head-row h1 { margin-bottom: 8px; }

.task { display: flex; align-items: center; gap: 12px; }
.task-main { flex: 1; }
.task-title { font-weight: 600; }
.task-meta { margin-top: 6px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.check { color: var(--accent); font-size: 1.3rem; }

/* ------- Modules finances / menu ------- */
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  text-decoration: none; color: var(--text);
}
.menu-title { font-weight: 600; }
.menu-val { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.menu-val form { margin: 0; }
.totals { display: flex; justify-content: space-around; text-align: center; gap: 8px; }
.totals strong { font-size: 1.15rem; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.card.done { opacity: .55; }
select { appearance: none; }

/* ------- Hub d'accueil ------- */
.hub-heading { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 22px 0 10px; }
.hub-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 0;
  text-decoration: none; color: var(--text);
}
.tile:active { border-color: var(--accent); }
.tile.wide { grid-column: 1 / -1; }
.tile-head { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.tile-icon { font-size: 1rem; }
.tile-value { font-size: 1.6rem; font-weight: 700; line-height: 1.25; margin-top: 4px; }
.tile-unit { font-size: .9rem; font-weight: 600; color: var(--muted); }
.tile-sub { font-size: .78rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-lines { margin-top: 6px; }
.tile-lines .row { padding: 5px 0; }

@media (min-width: 768px) {
  .hub-grid { grid-template-columns: repeat(3, 1fr); }
  .tile.wide { grid-column: span 2; }
}

/* ------- Navigation -------
   Mobile (< 768px) : volet latéral ouvert par le burger, pas de barre en bas.
   PC    (>= 768px) : tous les modules dans la barre du bas, pas de burger.        */

.burger, .drawer-close {
  font-size: 1.4rem; line-height: 1; cursor: pointer; user-select: none;
  color: var(--text); padding: 2px 4px;
}

.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: 264px; max-width: 82vw;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-100%); transition: transform .22s ease;
}
.drawer-toggle:checked ~ .drawer { transform: translateX(0); }

.drawer-overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.drawer-toggle:checked ~ .drawer-overlay { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 10px;
  text-decoration: none; color: var(--text); font-weight: 500;
}
.drawer-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.drawer-icon { font-size: 1.2rem; width: 26px; text-align: center; }
.badge.inline { position: static; margin-left: auto; }

.tabbar { display: none; }

@media (min-width: 768px) {
  .burger { display: none; }
  .drawer, .drawer-overlay { display: none; }

  .content { padding-bottom: 96px; }

  .tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    display: flex; justify-content: center; background: var(--card);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 0 1 110px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 10px; text-decoration: none; color: var(--muted); font-size: .7rem;
  }
  .tabbar a span { font-size: 1.25rem; }
  .tabbar a.active { color: var(--accent); }

  /* PC : la déconnexion rejoint la barre du bas, avec les modules */
  .topbar-logout { display: none; }
  .tabbar-logout { flex: 0 1 110px; display: flex; margin: 0; }
  .tabbar-logout button {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 10px; background: transparent; border: 0; border-radius: 0;
    color: var(--muted); font-size: .7rem; font-weight: inherit; cursor: pointer;
  }
  .tabbar-logout button span { font-size: 1.25rem; }
  .tabbar-logout button:hover { color: var(--danger); }
}

/* ------- Calendrier des trajets ------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-month { font-size: 1.05rem; text-transform: capitalize; }
.cal-arrow {
  text-decoration: none; color: var(--text); font-size: 1.4rem; line-height: 1;
  padding: 4px 14px; border: 1px solid var(--line); border-radius: 10px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .68rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal-day {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); text-decoration: none;
  font-weight: 700; font-size: .95rem;
}
.cal-day.out { border: none; }
.cal-day.has { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cal-day.miss { color: var(--danger); border-color: var(--danger); }
.cal-day.future { color: var(--muted); }
.cal-day.today { border-width: 2px; border-color: currentColor; font-weight: 800; }
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px;
  font-size: .78rem; color: var(--muted);
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dot.has { background: var(--accent); }
.dot.miss { background: var(--danger); }
.dot.future { background: var(--line); }
.trip-line { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-decoration: none; color: var(--text); }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.trip-company { display: flex; gap: 8px; margin-top: 8px; }
.trip-company select { margin: 0; }

/* ------- Réseaux sociaux ------- */
.post-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post-line a.post-title { text-decoration: none; color: var(--text); font-weight: 600; flex: 1; }
.variant-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.variant-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.variant-platform { font-size: 1.1rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 10px 0; }
.media-item { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.media-item img { display: block; width: 100%; height: 96px; object-fit: cover; }
.media-actions { display: flex; border-top: 1px solid var(--line); }
.media-actions a, .media-actions button {
  flex: 1; border: none; border-radius: 0; margin: 0; padding: 6px 0; font-size: .8rem;
  background: var(--card); color: var(--muted); text-decoration: none; text-align: center; cursor: pointer;
}
.media-actions a, .media-actions .media-save { border-right: 1px solid var(--line); }
.media-actions form button { color: var(--danger); }
.caption-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.copied { color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  text-decoration: none; font-size: .85rem; font-weight: 500;
}
.chip span { color: var(--muted); font-size: .75rem; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active span { color: #fff; opacity: .85; }
.account-row input { margin-bottom: 0; }
.account-rename { display: flex; align-items: center; gap: 8px; flex: 1; }
.account-rename input { margin-bottom: 0; }
.flash { border-color: var(--danger); color: var(--danger); }

/* ------- Page de connexion ------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 360px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-box .card { margin-bottom: 0; }
.login-box input { margin-bottom: 14px; }
.login-error { color: var(--danger); font-size: .85rem; margin: -6px 0 12px; }
