/* =====================================================================
   Larder — Inventaire Maison · thème « garde-manger » (vert forêt + or)
   ===================================================================== */
:root {
  --bg: #1c2a20;
  --surface: #25342a;
  --surface-2: #2e4031;
  --raised: #38503c;
  --ink: #ECF3E8;
  --soft: #9DB39B;
  --line: rgba(255, 255, 255, 0.09);
  --green: #5BA85A;
  --green-dark: #43824a;
  --gold: #E0B84C;
  --gold-light: #F2D585;
  --info: #6FB7D8;
  --attention: #E0A341;
  --critique: #E0655F;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-light); }
button { font-family: inherit; }

/* ── Layout général ───────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--soft); margin-top: -2px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 11px 13px; margin-bottom: 3px;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--soft); font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.nav-item .ico { font-size: 17px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--raised); color: var(--ink); }
.nav-badge {
  margin-left: auto; background: var(--critique); color: #fff;
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px;
}
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--soft); }
.sidebar-foot .who { color: var(--ink); font-weight: 600; }
.foyer-switch { width: 100%; margin: 6px 0 14px; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: none;
  align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.content { padding: 26px 30px 60px; max-width: 1080px; margin: 0 auto; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: .2px; }
.page-head .spacer { flex: 1; }

/* ── Cartes & grilles ─────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.stat .label { font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 32px; font-weight: 800; margin-top: 4px; }
.stat .value.warn { color: var(--attention); }
.stat .value.crit { color: var(--critique); }

/* ── Tableaux / listes ────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 9px; }
.row {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px;
}
.row:hover { border-color: rgba(255,255,255,0.16); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; }
.row .sub { font-size: 12.5px; color: var(--soft); margin-top: 1px; }
.qty { font-weight: 800; font-size: 17px; white-space: nowrap; }
.qty.low { color: var(--attention); }
.qty.zero { color: var(--critique); }

.dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--soft);
}
.tag.cat { color: var(--ink); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Niveaux d'alerte ─────────────────────────────────────────────── */
.alert-row { border-left: 4px solid var(--soft); }
.alert-row.info { border-left-color: var(--info); }
.alert-row.attention { border-left-color: var(--attention); }
.alert-row.critique { border-left-color: var(--critique); }
.lvl-pill { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.lvl-pill.info { background: rgba(111,183,216,.18); color: var(--info); }
.lvl-pill.attention { background: rgba(224,163,65,.18); color: var(--attention); }
.lvl-pill.critique { background: rgba(224,101,95,.2); color: var(--critique); }

/* ── Boutons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--green); border-color: transparent; color: #0e1a12; }
.btn.gold { background: var(--gold); border-color: transparent; color: #2a2008; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--critique); border-color: rgba(224,101,95,.4); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }

/* ── Formulaires ──────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--soft); margin-bottom: 6px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 15px; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--green); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--soft); margin-top: 6px; }

/* ── Modale ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal {
  width: 100%; max-width: 480px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0 0 16px; font-size: 19px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ── Auth ─────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo img { width: 76px; height: 76px; border-radius: 18px; box-shadow: var(--shadow); }
.auth-logo .name { font-weight: 800; font-size: 22px; margin-top: 12px; }
.auth-logo .sub { color: var(--soft); font-size: 13px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--soft); }
.auth-switch button { background: none; border: 0; color: var(--gold-light); cursor: pointer; font-weight: 700; font-size: 13.5px; }

/* ── Divers ───────────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--soft); padding: 48px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--raised); color: var(--ink); padding: 12px 20px;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 200; font-weight: 600;
  border: 1px solid var(--line);
}
.toast.error { background: #3a2422; border-color: rgba(224,101,95,.5); }
.error-text { color: var(--critique); font-size: 13.5px; margin-top: 8px; }
.spinner { text-align: center; color: var(--soft); padding: 40px; }

/* ── Responsive (mobile) ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 80px; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .mobile-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--line); z-index: 30;
  }
  .mobile-tabs button {
    flex: 1; background: none; border: 0; color: var(--soft);
    padding: 9px 4px 7px; font-size: 10.5px; font-weight: 700; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
  }
  .mobile-tabs button .ico { font-size: 19px; }
  .mobile-tabs button.active { color: var(--gold-light); }
}
@media (min-width: 761px) { .mobile-tabs { display: none; } }
