:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #23302a;
  --muted: #6b746e;
  --line: #e4dccb;
  --accent: #2f6b4f;
  --accent-ink: #fff;
  --soft: #eaf2ec;
  --warn: #9a5b12;
  --danger: #a3372b;
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a17; --card: #1f2520; --ink: #e8eee9; --muted: #9aa69e;
    --line: #333c35; --accent: #6fbf95; --accent-ink: #0f1a14; --soft: #24362c;
    --warn: #e0a85a; --danger: #ec7d70;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  max-width: 920px; margin: 0 auto; padding: 20px 16px 8px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 34px; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; letter-spacing: .3px; }
.tag { margin: 0; color: var(--muted); font-size: 14px; }
h2 { margin: 0 0 12px; font-size: 17px; font-family: Georgia, serif; }
main { max-width: 920px; margin: 0 auto; padding: 8px 16px 24px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 220px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.yield label { flex: 1 1 140px; }
input, select, button {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 4px 8px; min-height: 0; }
button.ghost:hover { color: var(--danger); }
.lang button { padding: 6px 10px; min-height: 0; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.warn { color: var(--warn); font-size: 13px; }

.results { display: grid; gap: 6px; margin-top: 10px; }
.result {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  text-align: left; width: 100%;
}
.result small { color: var(--muted); display: block; }
.badge { font-size: 11px; padding: 2px 6px; border-radius: 99px; background: var(--soft); color: var(--accent); white-space: nowrap; }

.line { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.line-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.line-head .name { flex: 1 1 200px; }
.line-head .qty { width: 96px; }
.line-head .unit { width: 92px; }
.line-head .pw { width: 104px; }
.line-sum { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.nutr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin-top: 8px; }
.nutr-grid input { width: 100%; }
details.per100 summary { cursor: pointer; font-size: 13px; color: var(--accent); margin-top: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-size: 24px; font-family: Georgia, serif; }
.kpi span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
td.sub { padding-left: 22px; color: var(--muted); }
thead th { font-size: 13px; color: var(--muted); font-weight: 600; }
pre { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; font-size: 13px; }
.actions { margin-top: 12px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.plain a { color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); }
footer { max-width: 920px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 13px; }
footer a { color: var(--accent); }
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; transition: transform .2s; font-size: 14px;
}
#toast.show { transform: translateX(-50%) translateY(0); }
@media (max-width: 560px) {
  .line-head .qty, .line-head .unit, .line-head .pw { flex: 1 1 30%; width: auto; }
  h1 { font-size: 24px; }
}

/* fixes */
[hidden] { display: none !important; }
label > input, label > select { width: 100%; min-width: 0; }
.row > input { min-width: 0; }
.lang { display: flex; gap: 4px; }
main, .card, .line { min-width: 0; }
@media (max-width: 560px) {
  #searchForm { flex-wrap: wrap; }
  #searchForm #q { flex: 1 1 100%; }
  #searchForm button { flex: 1 1 auto; }
  th, td { padding: 6px 4px; font-size: 14px; }
}

/* compte */
.top-right { display: flex; align-items: center; gap: 10px; position: relative; }
.account summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.account summary::-webkit-details-marker { display: none; }
.account summary::before { content: "👤 "; }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); width: min(300px, calc(100vw - 32px)); z-index: 10; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.account-menu form { display: grid; gap: 8px; }
.account-menu hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.logout { color: var(--danger); }
@media (max-width: 560px) { .top { flex-wrap: wrap; } }
@media (max-width: 560px) { .top-right { width: 100%; justify-content: flex-end; } }
