:root {
  --brown: #6b3f22;
  --brown-dark: #4a2b18;
  --brown-light: #f0e2ce;
  --cream: #faf3e7;
  --tan: #c9a876;
  --red-fr: #a32d2d;
  --red-light: #fcebeb;
  --text: #3a2a1c;
  --text-muted: #85705a;
  --border: #e0cfb5;
  --card: #ffffff;
  --bg: var(--cream);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 80px;
}

header {
  background: var(--brown);
  color: var(--brown-light);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
header .brand .logo-badge {
  background: var(--cream);
  border-radius: 50%;
  padding: 4px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
header .brand img {
  height: 100%;
  width: 100%;
  object-fit: contain;
}
header h1 { font-size: 17px; margin: 0; font-weight: 600; }
header button { background: none; border: none; color: var(--brown-light); font-size: 14px; }

main { padding: 16px; max-width: 700px; margin: 0 auto; }

.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.category-col { min-width: 0; }

/* Sur grand écran (PC), les catégories s'affichent côte à côte, toutes visibles en même temps */
@media (min-width: 860px) {
  main { max-width: 1180px; }
  .categories-grid {
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
  }
  .category-col {
    flex: 1 1 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
  }
  .category-col .card {
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 12px 0;
    margin-bottom: 0;
  }
  .category-col .card:last-child { border-bottom: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.product-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.product-info { flex: 1; }
.product-name { font-weight: 600; font-size: 16px; }
.product-cat { font-size: 12px; color: var(--text-muted); }
.stock-badge {
  font-size: 20px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--brown-light);
  color: var(--brown);
  min-width: 60px;
  text-align: center;
}
.stock-badge.low {
  background: var(--red-light);
  color: var(--red-fr);
}
.product-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
button {
  font-family: inherit;
  cursor: pointer;
}
.btn {
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
}
.btn-primary { background: var(--brown); color: var(--cream); border-color: var(--brown); }
.btn-danger { background: var(--red-fr); color: white; border-color: var(--red-fr); }
.btn-block { width: 100%; padding: 12px; font-size: 16px; font-weight: 600; }

.btn-in { background: var(--brown-light); color: var(--brown-dark); border-color: var(--tan); }
.btn-out { background: var(--red-light); color: var(--red-fr); border-color: var(--red-fr); }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 10px;
  background: white;
  color: var(--text);
}
label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 10;
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--text-muted);
}
.tabbar button.active { color: var(--brown); font-weight: 600; }

.hidden { display: none !important; }

.login-box { max-width: 360px; margin: 40px auto; padding: 24px; text-align: center; }
.login-box img { height: 90px; margin-bottom: 8px; }
.login-box h1 { font-size: 28px; margin: 0 0 24px; color: var(--brown); }
.flag-stripe {
  display: flex;
  height: 4px;
  width: 120px;
  margin: 0 auto 24px;
  border-radius: 2px;
  overflow: hidden;
}
.flag-stripe span { flex: 1; }
.flag-stripe .blue { background: #1c2f5e; }
.flag-stripe .white { background: #faf3e7; }
.flag-stripe .red { background: var(--red-fr); }

.error-msg { color: var(--red-fr); font-size: 14px; margin: 8px 0; }

.movement-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.movement-item:last-child { border-bottom: none; }
.movement-item .qty.in { color: var(--brown-dark); }
.movement-item .qty.out { color: var(--red-fr); }

.section-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--brown);
  letter-spacing: 0.02em;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--tan);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(58,42,28,0.45);
  display: flex; align-items: flex-end;
  z-index: 100;
}
.modal-sheet {
  background: var(--cream);
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-sheet h3 {
  color: var(--brown);
  font-size: 20px;
  font-weight: 700;
}
