:root {
  --brand: #187974;
  --brand-dark: #0f5e5a;
  --brand-soft: #e8f4f2;
  --ink: #1e2423;
  --muted: #6f7774;
  --line: #e5e4df;
  --surface: #ffffff;
  --surface-soft: #f7f5f0;
  --surface-warm: #f2eee6;
  --danger: #a43d3d;
  --danger-soft: #fff1f1;
  --success: #176b47;
  --success-soft: #edf8f1;
  --shadow: 0 12px 32px rgba(35, 45, 43, .08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--surface-soft); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface-soft);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24,121,116,.12);
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 20px; accent-color: var(--brand); }
label > span { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: .89rem; font-weight: 700; }
label em { color: var(--muted); font-style: normal; font-weight: 500; }

.app-shell { min-height: 100vh; padding-bottom: calc(84px + var(--safe-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(247,245,240,.92);
  border-bottom: 1px solid rgba(229,228,223,.8);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark, .login-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--brand);
  color: white;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(24,121,116,.23);
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: .98rem; letter-spacing: -.01em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.profile-menu { position: relative; }
.profile-menu summary { list-style: none; cursor: pointer; }
.profile-menu summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dbeae8;
  color: var(--brand-dark);
  font-weight: 900;
}
.profile-popover {
  position: absolute;
  right: 0;
  top: 48px;
  width: 230px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.profile-name { font-weight: 800; }
.profile-role { color: var(--muted); font-size: .8rem; margin: 3px 0 10px; }
.profile-popover a, .link-button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  text-align: left;
  border-radius: 9px;
  color: var(--ink);
}
.profile-popover a:hover, .link-button:hover { background: var(--surface-soft); }

.main-content { width: min(100% - 28px, 1080px); margin: 0 auto; padding: 18px 0 30px; }
.page-hero { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin: 6px 0 20px; }
.compact-hero h1, .page-title-row h1 { margin: 3px 0 7px; font-size: clamp(1.65rem, 5vw, 2.4rem); line-height: 1.04; letter-spacing: -.035em; }
.compact-hero p, .page-title-row p { margin: 0; max-width: 680px; color: var(--muted); line-height: 1.5; }
.eyebrow { color: var(--brand-dark); text-transform: uppercase; letter-spacing: .11em; font-size: .7rem; font-weight: 900; }

.flash { margin: 8px 0 18px; padding: 13px 15px; border-radius: 13px; border: 1px solid; font-size: .92rem; }
.flash.success { background: var(--success-soft); border-color: #cce8d8; color: var(--success); }
.flash.error { background: var(--danger-soft); border-color: #f2cdcd; color: var(--danger); }
.flash.compact { margin: 0 0 14px; }
.flash ul { margin: 8px 0 0 18px; padding: 0; }

.search-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 4px 16px rgba(35,45,43,.03);
}
.fake-search > span:first-child { color: var(--ink); font-size: 1.4rem; }
.fake-search small { margin-left: auto; border-radius: 999px; background: var(--surface-warm); padding: 4px 8px; font-size: .68rem; font-weight: 800; }

.section-head { display: flex; align-items: end; justify-content: space-between; margin: 26px 0 12px; }
.section-head.spaced { margin-top: 32px; }
.section-head h2 { margin: 2px 0 0; font-size: 1.16rem; letter-spacing: -.02em; }
.text-link { color: var(--brand-dark); font-weight: 800; font-size: .87rem; }
.category-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.category-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.category-card:hover { transform: translateY(-1px); border-color: #d4d8d5; box-shadow: 0 8px 22px rgba(35,45,43,.05); }
.category-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: var(--surface-warm); font-size: 1.45rem; }
.category-icon.small { width: 38px; height: 38px; border-radius: 12px; font-size: 1.1rem; }
.category-card div { display: grid; gap: 3px; }
.category-card strong { font-size: .96rem; }
.category-card small, .setting-card small, .quick-action small, .editable-card small { color: var(--muted); font-size: .77rem; }
.chevron { color: #9ca39f; font-size: 1.65rem; font-weight: 300; }

.quick-action-grid { display: grid; gap: 10px; margin-top: 18px; }
.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.quick-action.accent { background: var(--brand); border-color: var(--brand); color: white; }
.quick-action.accent small { color: rgba(255,255,255,.76); }
.quick-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: rgba(24,121,116,.09); font-size: 1.25rem; }
.quick-action.accent .quick-icon { background: rgba(255,255,255,.15); }
.quick-action div { display: grid; gap: 3px; }

.settings-grid { display: grid; gap: 10px; }
.setting-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.setting-card > span { display: grid; place-items: center; width: 42px; height: 42px; background: var(--brand-soft); color: var(--brand-dark); border-radius: 13px; font-weight: 900; }
.setting-card div { display: grid; gap: 4px; }
.setting-card b { color: #9ca39f; font-size: 1.4rem; }

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(18px);
}
.bottom-nav a { display: grid; place-items: center; gap: 3px; min-height: 52px; border-radius: 13px; color: var(--muted); }
.bottom-nav a span { font-size: 1.08rem; line-height: 1; }
.bottom-nav a small { font-size: .68rem; font-weight: 750; }
.bottom-nav a.active { color: var(--brand-dark); background: var(--brand-soft); }

.page-title-row { margin: 4px 0 20px; }
.settings-form { display: grid; gap: 14px; }
.form-card, .create-panel, .editable-card, .info-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.form-card { padding: 16px; }
.card-heading { display: flex; gap: 12px; margin-bottom: 16px; }
.card-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px; background: var(--brand-soft); }
.card-heading h2 { margin: 0; font-size: 1rem; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.two-col, .three-col { display: grid; gap: 12px; }
.helper { margin: 12px 0 0; color: var(--muted); font-size: .78rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 850;
}
.btn.primary { background: var(--brand); color: white; box-shadow: 0 7px 18px rgba(24,121,116,.17); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--surface); border-color: var(--line); }
.btn.full, .full-on-mobile { width: 100%; }
.subnav-cards { display: grid; gap: 9px; margin-top: 24px; }
.subnav-cards a { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.subnav-cards a > span { font-size: 1.2rem; }
.subnav-cards div { display: grid; gap: 3px; }
.subnav-cards small { color: var(--muted); }
.subnav-cards b { color: #9ca39f; }

.create-panel { margin-bottom: 14px; overflow: hidden; }
.create-panel > summary { cursor: pointer; list-style: none; padding: 15px 16px; color: var(--brand-dark); font-weight: 850; }
.create-panel > summary::-webkit-details-marker, .editable-card > summary::-webkit-details-marker { display: none; }
.create-panel[open] > summary { border-bottom: 1px solid var(--line); background: var(--brand-soft); }
.inline-create-form { display: grid; gap: 12px; padding: 16px; }
.editable-list { display: grid; gap: 10px; }
.editable-card { overflow: hidden; }
.editable-card > summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  cursor: pointer;
  list-style: none;
}
.editable-card > summary > div { display: grid; gap: 3px; }
.editable-card[open] > summary { border-bottom: 1px solid var(--line); background: #fbfbf9; }
.edit-form { display: grid; gap: 13px; padding: 15px; }
.switch-row { display: flex; align-items: center; gap: 9px; min-height: 46px; }
.switch-row span { display: inline; margin: 0; font-size: .9rem; font-weight: 700; }
.align-end { align-items: end; }
.action-row { display: flex; justify-content: flex-end; }
.delete-zone { border-top: 1px solid var(--line); padding: 10px 15px 13px; }
.danger-link { border: 0; background: transparent; color: var(--danger); padding: 5px 0; font-size: .8rem; font-weight: 750; }
.unit-symbol { display: grid; place-items: center; min-width: 42px; height: 38px; padding: 0 8px; border-radius: 12px; background: var(--surface-warm); font-weight: 900; }
.info-card { margin-top: 16px; padding: 15px; }
.info-card strong { font-size: .9rem; }
.info-card p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.list-avatar { width: 38px; height: 38px; }

.empty-state {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 18px;
}
.empty-icon { font-size: 3.1rem; margin-bottom: 10px; }
.version-pill { display: inline-flex; background: var(--brand-soft); color: var(--brand-dark); padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 850; }
.empty-state h1 { margin: 12px 0 8px; font-size: 1.65rem; letter-spacing: -.03em; }
.empty-state p { max-width: 460px; margin: 0 0 18px; color: var(--muted); line-height: 1.55; }

.guest-body {
  background:
    radial-gradient(circle at top right, rgba(24,121,116,.14), transparent 38%),
    linear-gradient(145deg, #f9f7f2, #f1eee7);
}
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(100%, 410px); padding: 24px; border: 1px solid rgba(229,228,223,.9); border-radius: 26px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(35,45,43,.12); }
.login-logo { width: 54px; height: 54px; border-radius: 18px; font-size: 1.35rem; }
.login-heading { margin: 14px 0 22px; }
.login-heading h1 { margin: 0; font-size: 1.85rem; letter-spacing: -.04em; }
.login-heading p { margin: 5px 0 0; color: var(--muted); }
.stack-form { display: grid; gap: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row span { display: inline; margin: 0; color: var(--muted); font-weight: 600; font-size: .82rem; }
.login-note { margin: 17px 0 0; text-align: center; color: var(--muted); font-size: .74rem; }

@media (min-width: 640px) {
  .main-content { width: min(100% - 44px, 1080px); padding-top: 24px; }
  .topbar { padding-inline: max(22px, calc((100vw - 1080px) / 2)); }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-action-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: repeat(2, 1fr); }
  .three-col { grid-template-columns: repeat(3, 1fr); }
  .full-on-mobile { width: auto; justify-self: end; }
  .inline-create-form { grid-template-columns: minmax(180px, 2fr) minmax(100px, 1fr) auto; align-items: end; }
  .inline-create-form.unit-form { grid-template-columns: 1.3fr .7fr 1fr 1fr auto; }
  .inline-create-form.user-form { grid-template-columns: repeat(2, 1fr); }
  .inline-create-form.user-form button { grid-column: 1 / -1; justify-self: end; }
}

@media (min-width: 900px) {
  .app-shell { padding-bottom: 32px; }
  .bottom-nav { position: sticky; top: 68px; bottom: auto; width: min(100% - 44px, 1080px); margin: 8px auto 0; border: 1px solid var(--line); border-radius: 16px; padding: 6px; background: rgba(255,255,255,.88); }
  .bottom-nav a { grid-template-columns: auto auto; justify-content: center; gap: 7px; min-height: 44px; }
  .bottom-nav a small { font-size: .78rem; }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .login-card { padding: 30px; }
}

/* --- V0.1.4 · accueil épuré & navigation interne --- */
.app-shell.without-bottom-nav { padding-bottom: calc(24px + var(--safe-bottom)); }

.home-screen {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 4px 0 18px;
}
.home-greeting { margin: 2px 0 18px; }
.home-greeting h1 {
  margin: 0;
  font-size: clamp(1.55rem, 6vw, 2.2rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}
.home-search {
  position: relative;
  margin-bottom: 16px;
}
.home-search input {
  min-height: 56px;
  padding: 13px 16px 13px 48px;
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(35,45,43,.04);
  font-size: 1rem;
}
.home-search input::-webkit-search-cancel-button { opacity: .45; }
.home-search-icon {
  position: absolute;
  z-index: 2;
  left: 16px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--brand-dark);
  font-size: 1.45rem;
  pointer-events: none;
}
.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}
.home-action {
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(35,45,43,.035);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.home-action:active { transform: scale(.985); }
.home-action:hover { border-color: #d5d7d3; box-shadow: 0 9px 24px rgba(35,45,43,.06); }
.home-action-wide { grid-column: 1 / -1; }
.home-action-compact {
  min-height: 108px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
}
.home-action-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 10px 25px rgba(24,121,116,.18);
}
.home-action-primary:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.home-action-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 1.3rem;
  line-height: 1;
}
.home-action-primary .home-action-icon {
  background: rgba(255,255,255,.16);
  color: #fff;
}
.home-action strong {
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -.015em;
}
.home-action-wide strong { font-size: 1.05rem; }

.bottom-nav > a,
.bottom-more > summary {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 52px;
  border-radius: 13px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.bottom-more { position: relative; }
.bottom-more > summary::-webkit-details-marker { display: none; }
.bottom-more > summary span,
.bottom-nav > a span { font-size: 1.08rem; line-height: 1; }
.bottom-more > summary small,
.bottom-nav > a small { font-size: .68rem; font-weight: 750; }
.bottom-more.active > summary,
.bottom-more[open] > summary { color: var(--brand-dark); background: var(--brand-soft); }
.bottom-more-sheet {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.985);
  box-shadow: 0 18px 48px rgba(35,45,43,.16);
  backdrop-filter: blur(18px);
}
.bottom-more-sheet a {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border-radius: 12px;
}
.bottom-more-sheet a:hover { background: var(--surface-soft); }
.bottom-more-sheet a > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--brand-soft);
}
.bottom-more-sheet a > div { display: grid; gap: 2px; }
.bottom-more-sheet strong { font-size: .86rem; }
.bottom-more-sheet small { color: var(--muted); font-size: .72rem; }

@media (min-width: 640px) {
  .home-screen { padding-top: 16px; }
  .home-actions { gap: 14px; }
  .home-action { min-height: 98px; }
  .home-action-compact { min-height: 118px; }
}

@media (min-width: 900px) {
  .app-shell.without-bottom-nav { padding-bottom: 32px; }
  .bottom-more-sheet { bottom: auto; top: calc(100% + 10px); }
}

@media (min-width: 900px) {
  .bottom-more > summary {
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
  }
  .bottom-more > summary small { font-size: .78rem; }
}

/* --- V0.2.0 · matières premières --- */
.material-title-row { align-items: center; }
.material-add-desktop { display: none; white-space: nowrap; }
.simple-back-row { margin: 2px 0 14px; }
.simple-back-row a { color: var(--brand-dark); font-size: .85rem; font-weight: 800; }
.compact-material-title { margin-bottom: 16px; }

.material-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 0 15px;
}
.material-search > span {
  position: absolute;
  left: 15px;
  z-index: 2;
  color: var(--brand-dark);
  font-size: 1.35rem;
  pointer-events: none;
}
.material-search input { min-height: 54px; padding-left: 46px; padding-right: 44px; border-radius: 16px; }
.material-search > a {
  position: absolute;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.3rem;
}
.material-search > a:hover { background: var(--surface-soft); }
.material-list { display: grid; gap: 9px; padding-bottom: 76px; }
.material-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(35,45,43,.025);
}
.material-card:active { transform: scale(.992); }
.material-card.is-inactive { opacity: .58; }
.material-card-main { min-width: 0; display: grid; gap: 4px; }
.material-card-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .96rem; }
.material-card-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .73rem; }
.material-card-price { display: grid; justify-items: end; gap: 2px; }
.material-card-price strong { font-size: .96rem; }
.material-card-price small { color: var(--muted); font-size: .68rem; }
.material-fab {
  position: fixed;
  z-index: 45;
  right: 18px;
  bottom: calc(88px + var(--safe-bottom));
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 28px rgba(24,121,116,.28);
  font-size: 1.7rem;
  font-weight: 500;
}
.material-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 42px 18px;
  border: 1px dashed #d8d8d2;
  border-radius: 22px;
  background: rgba(255,255,255,.55);
}
.material-empty > span { font-size: 2rem; }
.material-empty h2 { margin: 10px 0 6px; font-size: 1.12rem; }
.material-empty p { max-width: 430px; margin: 0 0 18px; color: var(--muted); line-height: 1.5; font-size: .87rem; }

.material-form { display: grid; gap: 12px; width: min(100%, 720px); }
.material-form-card,
.material-advanced,
.material-active-toggle {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
}
.material-form-card { display: grid; gap: 15px; }
.material-form-grid { display: grid; gap: 14px; }
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 42px; }
.input-with-unit b { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.material-advanced { padding: 0; overflow: hidden; }
.material-advanced > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  list-style: none;
  cursor: pointer;
  font-weight: 800;
}
.material-advanced > summary::-webkit-details-marker { display: none; }
.material-advanced > summary span { color: var(--muted); font-size: .74rem; font-weight: 600; }
.material-advanced-content { display: grid; gap: 14px; padding: 0 16px 16px; }
.material-submit { margin-top: 2px; min-height: 52px; }
.material-card-heading h2 { margin: 0 0 4px; font-size: 1rem; }
.material-card-heading p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.price-mode-options { display: grid; gap: 8px; }
.price-mode-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
}
.price-mode-option input { width: 19px; height: 19px; min-height: 19px; accent-color: var(--brand); }
.price-mode-option > span { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
.price-mode-option small { color: var(--muted); font-size: .72rem; }
.price-mode-option.is-disabled { opacity: .48; cursor: default; background: var(--surface-soft); }
.material-active-toggle { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; cursor: pointer; }
.material-active-toggle > input { margin-top: 2px; }
.material-active-toggle > span { display: grid; gap: 3px; margin: 0; }
.material-active-toggle small { color: var(--muted); font-size: .73rem; font-weight: 500; line-height: 1.4; }

.material-detail-hero {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}
.material-detail-hero.is-inactive { opacity: .68; }
.material-detail-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.material-reference { display: inline-block; margin-bottom: 5px; color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.material-detail-heading h1 { margin: 0; font-size: clamp(1.45rem, 6vw, 2rem); letter-spacing: -.035em; }
.compact-button { min-height: 38px; padding: 8px 11px; font-size: .78rem; }
.material-main-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; margin-top: 24px; }
.material-main-price strong { font-size: clamp(1.8rem, 8vw, 2.65rem); line-height: 1; letter-spacing: -.05em; }
.material-main-price > span { color: var(--muted); font-weight: 700; }
.material-main-price small { flex-basis: 100%; margin-top: 4px; color: var(--brand-dark); font-size: .74rem; font-weight: 800; }
.material-inactive-note { margin-top: 14px; color: var(--danger); font-size: .78rem; font-weight: 700; }
.material-price-sources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.material-price-sources > div { min-width: 0; padding: 11px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; }
.material-price-sources span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .64rem; }
.material-price-sources strong { font-size: .79rem; white-space: nowrap; }
.material-info-list { margin-top: 13px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.material-info-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 14px; border-bottom: 1px solid var(--line); }
.material-info-list > div:last-child { border-bottom: 0; }
.material-info-list span { color: var(--muted); font-size: .78rem; }
.material-info-list strong { text-align: right; font-size: .82rem; }
.material-info-list .material-note-row { display: block; }
.material-note-row p { margin: 6px 0 0; white-space: pre-wrap; line-height: 1.5; font-size: .84rem; }
.material-future-note { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; margin-top: 12px; padding: 13px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-dark); }
.material-future-note > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.7); }
.material-future-note > div { display: grid; gap: 2px; }
.material-future-note small { color: #427773; font-size: .72rem; line-height: 1.35; }

@media (min-width: 640px) {
  .material-add-desktop { display: inline-flex; }
  .material-fab { display: none; }
  .material-list { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 0; }
  .material-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .material-price-sources { gap: 10px; }
  .material-price-sources > div { padding: 14px 12px; }
  .material-price-sources span { font-size: .7rem; }
  .material-price-sources strong { font-size: .9rem; }
}

@media (min-width: 900px) {
  .material-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- V0.2.1 · accès accueil, profil & enchaînement matières --- */
.profile-trigger {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.88);
  color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(35,45,43,.045);
}
.profile-trigger svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.profile-menu[open] .profile-trigger { background: var(--brand-soft); border-color: #cde1de; }
.profile-popover { padding: 8px; width: 238px; }
.profile-header { padding: 9px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.profile-role { margin-bottom: 0; }
.profile-action {
  display: grid !important;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px !important;
  border-radius: 11px !important;
  font-size: .86rem;
  font-weight: 750;
}
.profile-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.profile-action.profile-logout { color: #7f3434; }
.profile-popover form { margin: 0; }

.material-submit-actions {
  display: grid;
  gap: 9px;
}
.material-submit-actions .material-submit { width: 100%; margin: 0; }
.material-next-actions {
  display: grid;
  gap: 9px;
  margin: 10px 0 2px;
}
.field-helper {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.4;
}
.field-helper a { color: var(--brand-dark); font-weight: 800; }
.supplier-symbol {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 900;
}
.compact-empty { min-height: 230px; }

@media (min-width: 640px) {
  .material-submit-actions { grid-template-columns: 1fr 1fr; }
  .material-next-actions { grid-template-columns: auto auto; justify-content: start; }
  .supplier-create-form { grid-template-columns: 1.2fr 1.4fr auto; }
}

/* --- V0.2.2 · conditionnement d’achat & fournisseur sans perte de saisie --- */
.optional-label {
  margin-left: 5px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 650;
}
.purchase-card { gap: 14px; }
.purchase-price-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid #c9e3df;
  border-radius: 15px;
  background: var(--brand-soft);
}
.purchase-price-preview[hidden] { display: none; }
.purchase-price-preview span { color: var(--brand-dark); font-size: .76rem; font-weight: 750; }
.purchase-price-preview strong { color: var(--brand-dark); font-size: 1rem; white-space: nowrap; }
.supplier-inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; margin-top: -4px; }
.text-action {
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-size: .76rem;
  font-weight: 800;
  cursor: pointer;
}
.muted-action { color: var(--muted); }
.legacy-price-warning {
  padding: 9px 10px;
  border-radius: 11px;
  background: #fff6dd;
  color: #735d1d !important;
  font-weight: 650;
}
.inline-back-form { margin: 0; }
.link-button {
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-size: .83rem;
  font-weight: 800;
  cursor: pointer;
}

/* --- V0.3.0 · recettes, rendements et sous-recettes --- */
.eyebrow { margin: 0 0 5px; color: var(--brand-dark); font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.page-title-row > p:not(.eyebrow), .recipe-title-row p { color: var(--muted); }
.recipe-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.recipe-title-row h1, .recipe-show-head h1, .recipe-builder-head h1 { margin: 2px 0 5px; letter-spacing: -.035em; }
.recipe-title-row p { margin: 0; }
.recipe-search { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 9px; padding: 0 14px; margin: 0 0 12px; min-height: 50px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.recipe-search span { color: var(--muted); font-size: 1.25rem; }
.recipe-search input { width: 100%; min-height: 48px; border: 0; background: transparent; padding: 0; box-shadow: none; }
.recipe-search input:focus { outline: 0; }
.filter-chips { display: flex; gap: 7px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .76rem; font-weight: 800; }
.filter-chip.active { border-color: rgba(24,121,116,.22); background: var(--brand-soft); color: var(--brand-dark); }
.soft-empty { min-height: 48vh; display: grid; place-items: center; align-content: center; gap: 9px; text-align: center; padding: 30px 15px; }
.soft-empty > div { font-size: 2.5rem; }
.soft-empty h2 { margin: 0; font-size: 1.25rem; }
.soft-empty p { max-width: 420px; margin: 0 0 7px; color: var(--muted); line-height: 1.5; }
.recipe-card-list { display: grid; gap: 11px; }
.recipe-list-card { display: grid; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: 0 5px 18px rgba(35,45,43,.025); }
.recipe-list-card.is-inactive { opacity: .58; }
.recipe-list-top { display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center; }
.recipe-category-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-warm); font-size: 1.3rem; }
.recipe-list-copy { display: grid; gap: 3px; min-width: 0; }
.recipe-list-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-list-copy small { color: var(--muted); }
.recipe-list-cost { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 11px; border-top: 1px solid var(--line); }
.recipe-list-cost div { display: grid; gap: 3px; }
.recipe-list-cost span { color: var(--muted); font-size: .7rem; }
.recipe-list-cost strong { font-size: .93rem; }
.recipe-warning-mini { color: #9b6513; font-size: .72rem; font-weight: 800; }

.recipe-create-form { display: grid; gap: 12px; max-width: 650px; margin: 0 auto; }
.recipe-essential-card { display: grid; gap: 14px; }
.compact-heading { margin-bottom: 12px; }
.recipe-output-fields, .recipe-quantity-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(100px, .8fr); gap: 10px; }
.field-with-suffix { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #fff; }
.field-with-suffix input { border: 0; border-radius: 0; box-shadow: none; }
.field-with-suffix > span { padding: 0 13px; color: var(--muted); font-size: .8rem; font-weight: 800; }
.recipe-optional-panel { margin-bottom: 0; }
.one-column { grid-template-columns: 1fr !important; }
.recipe-next-button { min-height: 54px; font-size: .94rem; }

.recipe-builder-head, .recipe-show-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 13px; margin: 2px 0 16px; }
.recipe-builder-head p, .recipe-show-head p { margin: 0; color: var(--muted); font-size: .82rem; }
.back-link { display: inline-flex; margin-bottom: 7px; color: var(--brand-dark); font-size: .78rem; font-weight: 850; }
.builder-cost-badge { flex: 0 0 auto; display: grid; gap: 2px; min-width: 118px; padding: 11px 13px; border-radius: 16px; background: var(--brand); color: white; text-align: right; }
.builder-cost-badge span, .builder-cost-badge small { color: rgba(255,255,255,.8); font-size: .66rem; }
.builder-cost-badge strong { font-size: 1.18rem; }
.recipe-warning-box { display: grid; gap: 4px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #efd7ae; border-radius: 15px; background: #fff8e9; color: #80540f; font-size: .78rem; }
.recipe-warning-box strong { margin-bottom: 2px; }
.recipe-builder-section { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; }
.recipe-builder-section > summary { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 14px; cursor: pointer; list-style: none; }
.recipe-builder-section > summary::-webkit-details-marker { display: none; }
.recipe-builder-section > summary > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-warm); }
.recipe-builder-section > summary > div { display: grid; gap: 2px; }
.recipe-builder-section > summary small { color: var(--muted); font-size: .71rem; }
.recipe-builder-section > summary b { color: #9ca39f; font-size: 1rem; transition: transform .15s ease; }
.recipe-builder-section[open] > summary b { transform: rotate(180deg); }
.recipe-builder-section[open] > summary { border-bottom: 1px solid var(--line); }
.builder-section-body { padding: 13px; }
.builder-line-list { display: grid; gap: 8px; margin-bottom: 11px; }
.builder-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; border: 1px solid #efeee9; border-radius: 13px; background: #fbfaf7; }
.builder-line > div:first-child { display: grid; gap: 2px; min-width: 0; }
.builder-line small { color: var(--muted); font-size: .69rem; }
.builder-line-price { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.builder-line-price strong { font-size: .84rem; }
.tiny-delete { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 9px; background: #f3efeb; color: #9a5d54; font-size: 1.05rem; }
.builder-add-panel { border: 1px dashed #d8d7d0; border-radius: 14px; overflow: hidden; }
.builder-add-panel > summary { padding: 12px 13px; cursor: pointer; list-style: none; color: var(--brand-dark); font-size: .8rem; font-weight: 850; }
.builder-add-panel > summary::-webkit-details-marker { display: none; }
.builder-add-panel[open] > summary { border-bottom: 1px dashed #d8d7d0; background: var(--brand-soft); }
.builder-add-form { display: grid; gap: 11px; padding: 13px; }
.inline-options { border-top: 1px solid var(--line); padding-top: 7px; }
.inline-options > summary { cursor: pointer; color: var(--muted); font-size: .75rem; font-weight: 800; }
.inline-options label { margin-top: 9px; }
.form-hint { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.warning-text { color: #8b611b; }
.warning-text a { text-decoration: underline; }
.step-list { display: grid; gap: 8px; margin-bottom: 11px; }
.step-card { display: grid; grid-template-columns: 28px 1fr 26px; gap: 9px; align-items: start; padding: 10px; border-radius: 13px; background: #fbfaf7; border: 1px solid #efeee9; }
.step-card > span, .recipe-production-steps > div > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-dark); font-size: .74rem; font-weight: 900; }
.step-card p { margin: 4px 0 0; font-size: .8rem; line-height: 1.5; white-space: pre-line; }
.compact-add-form { padding-inline: 0; padding-bottom: 0; }
.builder-finish { margin: 16px 0 5px; }

.recipe-show-category { display: inline-flex; margin: 1px 0 4px; padding: 5px 8px; border-radius: 999px; background: var(--surface-warm); color: var(--muted); font-size: .7rem; font-weight: 800; }
.recipe-cost-hero { display: grid; place-items: center; padding: 22px 15px; margin-bottom: 12px; border-radius: 22px; background: linear-gradient(145deg, var(--brand), #125e5a); color: white; text-align: center; box-shadow: 0 12px 28px rgba(24,121,116,.16); }
.recipe-cost-hero span { color: rgba(255,255,255,.78); font-size: .75rem; }
.recipe-cost-hero strong { margin: 3px 0; font-size: 2.15rem; letter-spacing: -.05em; }
.recipe-cost-hero small { color: rgba(255,255,255,.78); }
.cost-breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.cost-breakdown-grid > div { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.cost-breakdown-grid span, .cost-breakdown-grid small { color: var(--muted); font-size: .68rem; }
.cost-breakdown-grid strong { font-size: .96rem; }
.recipe-read-section { margin: 22px 0; }
.recipe-read-section h2 { margin: 0 0 9px; font-size: 1rem; }
.recipe-description { margin: 0; padding: 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); line-height: 1.55; white-space: pre-line; }
.muted-text { color: var(--muted); }
.recipe-read-list { display: grid; gap: 7px; }
.recipe-read-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.recipe-read-list > div span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 780; }
.recipe-read-list > div strong { font-size: .8rem; }
.recipe-read-list > div small { grid-column: 1 / -1; color: var(--muted); font-size: .68rem; }
.recipe-read-list > div.is-subrecipe { background: #f7fbfa; }
.recipe-production-steps { display: grid; gap: 8px; }
.recipe-production-steps > div { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.recipe-production-steps p { margin: 4px 0 0; line-height: 1.55; white-space: pre-line; }
.recipe-show-actions { margin-top: 22px; }

@media (min-width: 700px) {
  .recipe-card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recipe-create-form { margin-top: 8px; }
  .cost-breakdown-grid { grid-template-columns: repeat(4, 1fr); }
}

/* V0.3.1 — création de catégorie directement dans une recette */
.inline-category-field { display: grid; gap: 8px; }
.category-select-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: end; }
.category-select-row > label { min-width: 0; }
.inline-category-plus { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 0; border: 1px solid rgba(24,121,116,.2); border-radius: 13px; background: var(--brand-soft); color: var(--brand-dark); font-size: 1.35rem; font-weight: 700; cursor: pointer; }
.inline-category-plus:active { transform: scale(.97); }
.inline-category-create { display: grid; grid-template-columns: minmax(0, 1fr) auto 38px; gap: 7px; align-items: center; padding: 9px; border: 1px solid rgba(24,121,116,.18); border-radius: 14px; background: #f7fbfa; }
.inline-category-create[hidden] { display: none !important; }
.inline-category-create input { min-width: 0; }
.inline-category-confirm { min-height: 42px; padding-inline: 12px; }
.inline-category-cancel { width: 38px; height: 38px; border: 0; border-radius: 10px; background: #eceae5; color: var(--muted); font-size: 1.15rem; cursor: pointer; }
.inline-category-status { grid-column: 1 / -1; min-height: 0; color: var(--muted); font-size: .7rem; }
.inline-category-status.is-error { color: #a14034; }
.inline-category-status.is-success { color: var(--brand-dark); }
