/* ===========================================================
   DESIGN SYSTEM — inspiré Monument Valley + vintage
   Palette terre cuite / teal poussiéreux / crème chaude
   Typographie : SF Pro (système Apple / Windows fallback)
=========================================================== */

:root {
  color-scheme: light dark;

  /* Fonds chauds, papier vintage */
  --bg: #f5ede0;            /* crème très pâle — fond de page */
  --bg-grouped: #f5ede0;
  --surface: #fdfaf4;       /* blanc cassé chaud — cartes */
  --surface-secondary: #f0e8d8;
  --surface-elevated: #ffffff;

  /* Texte café foncé / sépia */
  --label: #1e1810;
  --label-secondary: rgba(30, 24, 16, 0.55);
  --label-tertiary: rgba(30, 24, 16, 0.36);
  --label-quaternary: rgba(30, 24, 16, 0.18);

  --separator: rgba(30, 24, 16, 0.12);
  --separator-opaque: #cec0a8;

  --fill-1: rgba(30, 24, 16, 0.05);
  --fill-2: rgba(30, 24, 16, 0.10);
  --fill-3: rgba(30, 24, 16, 0.18);

  /* Couleurs principales — palette Monument Valley */
  --accent: #b66b5a;          /* terre cuite */
  --accent-bg: rgba(182, 107, 90, 0.14);
  --green: #7d9b78;           /* sauge poussiéreuse */
  --green-bg: rgba(125, 155, 120, 0.18);
  --yellow: #d2a04a;          /* ocre miel */
  --yellow-bg: rgba(210, 160, 74, 0.20);
  --orange: #c98554;          /* terre brûlée */
  --orange-bg: rgba(201, 133, 84, 0.18);
  --red: #b54f44;             /* brique foncée */
  --red-bg: rgba(181, 79, 68, 0.14);
  --teal: #5d8a92;            /* canard poussiéreux */
  --indigo: #7a6f9e;          /* lavande poussiéreuse */
  --purple: #a08aaf;          /* mauve doux */
  --pink: #c98a8a;            /* rose ancien */

  --shadow-card: 0 1px 3px rgba(30, 24, 16, 0.07), 0 4px 14px rgba(30, 24, 16, 0.05);
  --shadow-elevated: 0 8px 24px rgba(30, 24, 16, 0.10);
  --shadow-lg: 0 16px 44px rgba(30, 24, 16, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --nav-blur: saturate(180%) blur(24px);

  /* SF Pro — identique à apple.com */
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display",
                  "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1610;
    --bg-grouped: #1c1610;
    --surface: #261f17;
    --surface-secondary: #2e261c;
    --surface-elevated: #322a1f;

    --label: #f0e8d8;
    --label-secondary: rgba(240, 232, 216, 0.62);
    --label-tertiary: rgba(240, 232, 216, 0.36);
    --label-quaternary: rgba(240, 232, 216, 0.18);

    --separator: rgba(240, 232, 216, 0.14);
    --separator-opaque: #4a3f30;

    --fill-1: rgba(240, 232, 216, 0.08);
    --fill-2: rgba(240, 232, 216, 0.14);
    --fill-3: rgba(240, 232, 216, 0.22);

    --accent: #d18374;
    --accent-bg: rgba(209, 131, 116, 0.20);
    --green: #9bb597;
    --green-bg: rgba(155, 181, 151, 0.22);
    --yellow: #e0b160;
    --yellow-bg: rgba(224, 177, 96, 0.22);
    --orange: #d99a6f;
    --orange-bg: rgba(217, 154, 111, 0.22);
    --red: #cd6e62;
    --red-bg: rgba(205, 110, 98, 0.20);

    --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.45);
    --shadow-elevated: 0 12px 30px rgba(0, 0, 0, 0.5);
  }
}

/* ===========================================================
   RESET / BASE
=========================================================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image:
    /* Texture vintage : halo doré très subtil, quasi-invisible */
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(210, 160, 74, 0.06), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(125, 155, 120, 0.04), transparent 70%),
    repeating-linear-gradient(0deg, rgba(67, 49, 27, 0.006) 0px, rgba(67, 49, 27, 0.006) 1px, transparent 1px, transparent 3px);
  background-attachment: fixed;
  color: var(--label);
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: contain;
}
@media (prefers-color-scheme: dark) {
  html, body {
    background-image:
      radial-gradient(ellipse 80% 60% at 50% 0%, rgba(209, 131, 116, 0.10), transparent 70%),
      radial-gradient(ellipse 60% 40% at 100% 100%, rgba(155, 181, 151, 0.06), transparent 70%);
  }
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input { font-family: inherit; }
input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
a { color: var(--accent); text-decoration: none; }

/* Safe area for PWA */
.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ===========================================================
   NAV BAR (style iOS)
=========================================================== */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 237, 224, 0.82);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  border-bottom: 0.5px solid transparent;
  transition: border-color .2s, background .2s;
}
.nav-bar.scrolled { border-bottom-color: var(--separator); }
@media (prefers-color-scheme: dark) {
  .nav-bar { background: rgba(28, 22, 16, 0.85); }
}
.nav-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  gap: 8px;
  padding-top: calc(6px + env(safe-area-inset-top));
  max-width: 768px;
  margin: 0 auto;
}
.nav-bar.wide .nav-row { max-width: 1100px; }
.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  font-size: 17px;
  font-weight: 400;
  padding: 6px 4px 6px 0;
  margin-left: -4px;
  min-height: 32px;
}
.nav-back:active { opacity: 0.55; }
.nav-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--label);
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 15px;
  padding: 6px 4px;
  min-height: 32px;
  font-weight: 400;
}
.nav-action:active { opacity: 0.55; }
.nav-role-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--accent-bg);
  color: var(--accent);
}
.nav-role-badge.staff { background: var(--green-bg); color: var(--green); }
.nav-role-badge.pending { background: var(--orange-bg); color: var(--orange); }

/* ===========================================================
   LARGE TITLE + CONTAINER
=========================================================== */
.page { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.container { max-width: 768px; margin: 0 auto; padding: 0 16px; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.large-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--label);
  line-height: 1.1;
  padding: 12px 0 10px;
}
.subtitle {
  font-size: 14px;
  color: var(--label-secondary);
  font-style: italic;
  margin-top: -4px;
  padding-bottom: 18px;
  letter-spacing: 0.1px;
}
.nav-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ===========================================================
   SECTION — bloc centré, même largeur que le contenu
=========================================================== */
.page-section {
  max-width: 768px;
  margin: 12px auto 0;
  padding: 0 16px 24px;
  background: transparent;   /* pas de fond propre : c'est la list-group qui le porte */
}
.page-section .list-section {
  width: 100%;
  margin-bottom: 0;
}
.page-section .list-group {
  width: 100%;
}

/* ===========================================================
   LISTES GROUPÉES (style Réglages iOS)
=========================================================== */
.list-section { margin-bottom: 28px; }
.list-section-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--label-secondary);
  text-transform: uppercase;
  padding: 0 16px 8px;
  margin-top: 4px;
}
.list-group {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 0.5px solid var(--separator);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 52px;
  background: var(--surface);
  position: relative;
}
.list-row + .list-row::before {
  content: "";
  position: absolute;
  left: 60px;
  right: 0;
  top: 0;
  height: 0.5px;
  background: var(--separator);
}
.list-row.pressable { cursor: pointer; transition: background 0.12s; }
.list-row.pressable:active { background: var(--fill-1); }
.list-footer {
  font-size: 13px;
  color: var(--label-secondary);
  padding: 6px 16px 0;
  line-height: 1.35;
}

.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;            /* cercle vintage type "monnaie ancienne" */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;                /* emojis plus discrets */
  flex-shrink: 0;
  background: var(--fill-1);
  border: 1px solid var(--separator);
  filter: saturate(0.75);         /* désature les emojis pour le ton vintage */
}
.list-icon.accent { background: var(--accent-bg); color: var(--accent); border-color: rgba(182, 107, 90, 0.25); }
.list-icon.green { background: var(--green-bg); color: var(--green); border-color: rgba(125, 155, 120, 0.30); }
.list-icon.orange { background: var(--orange-bg); color: var(--orange); border-color: rgba(201, 133, 84, 0.30); }
.list-icon.red { background: var(--red-bg); color: var(--red); border-color: rgba(181, 79, 68, 0.30); }
.list-icon.indigo { background: rgba(122, 111, 158, 0.16); color: var(--indigo); border-color: rgba(122, 111, 158, 0.28); }

.list-text { flex: 1; min-width: 0; }
.list-title {
  font-size: 16px;
  color: var(--label);
  font-weight: 500;
  letter-spacing: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-subtitle {
  font-size: 13px;
  color: var(--label-secondary);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-chevron {
  color: var(--label-tertiary);
  font-size: 14px;
  flex-shrink: 0;
  margin-left: 4px;
}
.list-value {
  color: var(--label-secondary);
  font-size: 17px;
}

/* ===========================================================
   CARTES EN VEDETTE (dashboard)
=========================================================== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 720px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) {
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Sections du dashboard avec en-tête */
.dash-section {
  margin-bottom: 28px;
}
.dash-section:last-child { margin-bottom: 12px; }
.dash-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--label-secondary);
  text-transform: uppercase;
  padding: 0 4px 10px;
}

/* Bouton accueil dans la nav-bar */
.nav-action.nav-home {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border-radius: 8px;
}
.nav-action.nav-home:active { opacity: 0.55; background: var(--fill-1); }
.nav-action.nav-home svg { width: 22px; height: 22px; }
.tile {
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: left;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease;
}
.tile:active { transform: scale(0.98); }
.tile.accent { background: linear-gradient(135deg, #c9826f, #a35a4a); }       /* terracotta */
.tile.indigo { background: linear-gradient(135deg, #8a7ab2, #6a5d92); }       /* lavande poussiéreuse */
.tile.green  { background: linear-gradient(135deg, #97b394, #6e8c6b); }       /* sauge */
.tile.orange { background: linear-gradient(135deg, #d8a865, #b87f3e); }       /* ocre miel */
.tile.teal   { background: linear-gradient(135deg, #6fa3aa, #4a7e86); }       /* canard poussiéreux */
.tile .tile-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.tile .tile-title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.tile .tile-subtitle { font-size: 13px; opacity: 0.8; margin-top: 2px; }

/* ===========================================================
   STEPPER (−/+)
=========================================================== */
.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--fill-1);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.stepper button {
  width: 36px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 17px;
  transition: background 0.1s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.stepper button:active { background: var(--fill-2); }
.stepper button:disabled { color: var(--label-tertiary); }
.stepper .sep { width: 1px; height: 18px; background: var(--separator); flex-shrink: 0; }
.stepper input {
  width: 44px;
  height: 34px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  color: var(--label);
  letter-spacing: -0.3px;
}
.stepper input:focus { outline: none; }

/* ===========================================================
   BADGE DE STATUT STOCK
=========================================================== */
.status-bar {
  width: 3px;
  border-radius: 2px;
  align-self: stretch;
  margin-right: 4px;
  flex-shrink: 0;
}
.status-bar.green { background: var(--green); }
.status-bar.yellow { background: var(--yellow); }
.status-bar.orange { background: var(--orange); }
.status-bar.red { background: var(--red); }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.green { background: var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.orange { background: var(--orange); }
.status-dot.red { background: var(--red); }

.qty-indicator {
  font-size: 13px;
  font-weight: 500;
  color: var(--label-secondary);
  letter-spacing: -0.1px;
}
.qty-indicator.green { color: var(--green); }
.qty-indicator.yellow { color: #b88700; }
.qty-indicator.orange { color: var(--orange); }
.qty-indicator.red { color: var(--red); font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .qty-indicator.yellow { color: var(--yellow); }
}

/* ===========================================================
   BOUTONS
=========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.1px;
  transition: all 0.15s ease;
  min-height: 44px;
  touch-action: manipulation;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary {
  background: var(--accent);
  color: #fbf6ec;
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 2px 6px rgba(182, 107, 90, 0.25);
}
.btn-primary:hover { background: #a55b4d; }
.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--separator);
}
.btn-secondary:hover { background: var(--surface-elevated); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-destructive { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 15px; min-height: 34px; border-radius: 10px; }

/* ===========================================================
   FORMULAIRES
=========================================================== */
.field {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.field-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  min-height: 48px;
}
.field-row + .field-row { border-top: 0.5px solid var(--separator); }
.field-label {
  font-size: 17px;
  color: var(--label);
  letter-spacing: -0.2px;
  min-width: 110px;
}
.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--label);
  font-size: 17px;
  letter-spacing: -0.2px;
}
.field input::placeholder { color: var(--label-tertiary); }

/* ===========================================================
   BANDEAU D'ALERTE
=========================================================== */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--red-bg);
  border: 1px solid rgba(181, 79, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  color: var(--red);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}
.alert-banner.info { background: var(--accent-bg); color: var(--accent); }
.alert-banner.success { background: var(--green-bg); color: var(--green); }
.alert-banner.warning { background: var(--orange-bg); color: var(--orange); }
.alert-banner .banner-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.alert-banner strong { font-weight: 600; }

/* ===========================================================
   CONTRÔLE SEGMENTÉ
=========================================================== */
.segmented {
  display: inline-flex;
  background: var(--fill-1);
  padding: 2px;
  border-radius: 9px;
  margin-bottom: 16px;
}
.segmented button {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  letter-spacing: -0.1px;
  min-height: 30px;
  transition: background 0.15s;
}
.segmented button.active {
  background: var(--surface);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* ===========================================================
   CARTE (générique)
=========================================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

/* ===========================================================
   VUE GÉNÉRALE — grille des stocks
=========================================================== */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 4px;
}
.stock-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}
.stock-cell.green { background: var(--green); }
.stock-cell.yellow { background: var(--yellow); color: #222; }
.stock-cell.orange { background: var(--orange); }
.stock-cell.red { background: var(--red); }

/* ===========================================================
   TOAST
=========================================================== */
#toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast-bubble {
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-elevated);
  animation: toastIn 0.25s ease-out;
  max-width: min(420px, calc(100vw - 32px));
  text-align: center;
}
.toast-bubble.error { background: rgba(255, 59, 48, 0.95); }
.toast-bubble.success { background: rgba(52, 199, 89, 0.95); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===========================================================
   DIVERS
=========================================================== */
.fade-in { animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--fill-1);
  color: var(--label-secondary);
}
.chip.accent { background: var(--accent-bg); color: var(--accent); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.orange { background: var(--orange-bg); color: var(--orange); }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--fill-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--label-secondary); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.center { text-align: center; }

.icon-xs { width: 16px; height: 16px; }
.icon-sm { width: 20px; height: 20px; }
.icon-md { width: 24px; height: 24px; }
.icon-lg { width: 32px; height: 32px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--label-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* Select natif style iOS */
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--fill-1);
  border: none;
  padding: 8px 32px 8px 12px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--label);
  font-family: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238e8e93' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Checkbox iOS style */
.toggle-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--fill-1);
  border-radius: 10px;
  font-size: 15px;
  color: var(--label);
  cursor: pointer;
  transition: background 0.12s;
}
.toggle-check input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-check .checkmark {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--label-tertiary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.15s;
}
.toggle-check input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-check input:checked + .checkmark::after {
  content: "";
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* ============================================
   SEARCH BAR (iOS style)
============================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--fill-1);
  border-radius: 10px;
  margin-bottom: 12px;
  transition: background 0.15s;
}
.search-bar:focus-within {
  background: var(--fill-2);
}
.search-bar svg {
  flex-shrink: 0;
  color: var(--label-tertiary);
  width: 18px;
  height: 18px;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--label);
  padding: 2px 0;
  min-width: 0;
}
.search-bar input::placeholder {
  color: var(--label-tertiary);
}
.search-bar .clear-btn {
  background: var(--label-tertiary);
  color: #fff;
  border: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.search-bar .clear-btn:hover { background: var(--label-secondary); }

/* ============================================
   FILTER CHIPS (toggleable, horizontal scroll)
============================================ */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  margin: 0 -16px 12px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  background: var(--fill-1);
  color: var(--label);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.filter-chip:active { transform: scale(0.96); }
.filter-chip.active {
  background: var(--accent);
  color: #fff;
}
.filter-chip.alert.active {
  background: var(--red);
  color: #fff;
}

/* ============================================
   TOOLBAR (search + action button)
============================================ */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar .search-bar { flex: 1; margin: 0; }

/* ============================================
   MULTI-SELECT (dashboard property selection)
============================================ */
.list-row.selectable {
  position: relative;
}
.list-row .select-box {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--label-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 4px;
  transition: all 0.15s;
}
.list-row .select-box.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.list-row .select-box.checked::after {
  content: "";
  width: 6px;
  height: 10px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px, -1px);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 500;
  animation: fade-in 0.2s ease;
}
.selection-bar .selection-count { font-weight: 600; }
.selection-bar button {
  background: rgba(255,255,255,0.22);
  border: none;
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.selection-bar button:active { background: rgba(255,255,255,0.32); }

/* Alert row — fond rouge pour rendre l'alerte très visible */
.list-row.row-alert {
  background: var(--red-bg);
  border-left: 3px solid var(--red);
}
.list-row.row-alert .list-title { color: var(--red); font-weight: 600; }
.list-row.row-alert .list-subtitle { color: var(--red); opacity: 0.85; }
.list-row.row-alert .status-bar { display: none; }

/* Order summary (bon de commande) */
.order-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.order-qty {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.order-meta { font-size: 13px; color: var(--label-secondary); }

/* Bouton danger (rouge) */
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-danger:active { opacity: 0.7; }
.btn-danger:hover { background: var(--red); color: #fff; }

/* Modal-style nav action buttons (Annuler / Enregistrer en haut) */
.nav-cancel,
.nav-save {
  display: inline-flex;
  align-items: center;
  font-size: 17px;
  padding: 6px 8px;
  min-height: 32px;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}
.nav-cancel { color: var(--accent); font-weight: 400; }
.nav-save { color: var(--accent); font-weight: 600; }
.nav-cancel:active,
.nav-save:active { opacity: 0.55; }
.nav-save:disabled { opacity: 0.35; cursor: default; }

/* Sticky bottom action bar (toujours accessible sans scroll) */
.sticky-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(245, 237, 224, 0.96);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  border-top: 0.5px solid var(--separator);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  .sticky-actions { background: rgba(28, 22, 16, 0.94); }
}
.sticky-actions-inner {
  display: flex;
  gap: 10px;
  max-width: 768px;
  margin: 0 auto;
  padding: 10px 16px;
}
@media (prefers-color-scheme: dark) {
  .sticky-actions { background: rgba(0, 0, 0, 0.85); }
}
.sticky-actions .btn { flex: 1; min-height: 48px; font-size: 16px; font-weight: 600; }

/* Quand une page a une sticky-actions, on réserve la place en bas */
.page.has-sticky-actions { padding-bottom: 96px; }

/* Touch-target plus grand pour le retour */
.nav-back { min-height: 40px; padding: 8px 6px 8px 0; }

/* ============================================
   STOCK GÉNÉRAL — tableau de bord
============================================ */
.stats-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-tile {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  border: 1.5px solid transparent;
  transition: all 0.15s;
}
.stat-tile.red { background: var(--red-bg); border-color: var(--red); }
.stat-tile.orange { background: var(--orange-bg); border-color: var(--orange); }
.stat-tile.green { background: var(--green-bg); border-color: var(--green); }
.stat-tile .stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--label);
}
.stat-tile.red .stat-value { color: var(--red); }
.stat-tile.orange .stat-value { color: var(--orange); }
.stat-tile.green .stat-value { color: var(--green); }
.stat-tile .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--label-secondary);
  margin-top: 4px;
}

/* Carte de logement */
.global-card {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--separator);
  transition: border-color 0.15s;
}
.global-card.has-alerts { border-color: var(--red); border-width: 1.5px; }

.global-card-head {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  gap: 10px;
}
.global-card-head:active { background: var(--fill-1); }

.global-card-counters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 16px 14px;
  border-bottom: 0.5px solid var(--separator);
}
.counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: var(--fill-1);
}
.counter.red { background: var(--red-bg); }
.counter.red .counter-value { color: var(--red); }
.counter.orange { background: var(--orange-bg); }
.counter.orange .counter-value { color: var(--orange); }
.counter.green { background: var(--green-bg); }
.counter.green .counter-value { color: var(--green); }
.counter.muted .counter-value { color: var(--label-tertiary); }
.counter-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.counter-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--label-secondary);
  margin-top: 4px;
}

.global-card-alerts {
  padding: 12px 16px 14px;
  background: linear-gradient(180deg, var(--red-bg), transparent 60%);
}
.global-card-alerts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 8px;
}
.global-card-alert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 0.5px solid var(--separator);
}
.global-card-alert-row:last-of-type { border-bottom: none; }
.alert-name {
  flex: 1;
  color: var(--label);
}
.alert-qty {
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
  font-size: 13px;
  white-space: nowrap;
  margin-left: 12px;
}
.alert-qty b { color: var(--red); font-weight: 700; }

.global-card-lows {
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.global-card-ok {
  padding: 12px 16px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--green);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* breakdown per-property in aggregated stock row */
.breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--label-secondary);
}
.breakdown span { white-space: nowrap; }
.breakdown b { color: var(--label); font-weight: 600; }
