/* SalumiLab — shared styles. Mobile-first, no framework. */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --ink: #221c18;
  --ink-2: #4f4640;
  --ink-3: #7a6f67;
  --line: #e2d9cd;
  --accent: #8c2f24;        /* cured-meat red */
  --accent-ink: #ffffff;
  --ok: #1f6b3a;
  --ok-bg: #e4f2e8;
  --warn: #8a5a00;
  --warn-bg: #fbf0d6;
  --bad: #a3221a;
  --bad-bg: #fbe3e0;
  --chart-line: #8c2f24;
  --chart-target: #7a6f67;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171311;
    --surface: #211b18;
    --surface-2: #2a2320;
    --ink: #f2ebe4;
    --ink-2: #cfc4ba;
    --ink-3: #a0948a;
    --line: #3a312c;
    --accent: #e0806f;
    --accent-ink: #1a1210;
    --ok: #7fd09a;
    --ok-bg: #16301f;
    --warn: #f0c060;
    --warn-bg: #33280f;
    --bad: #ff8e82;
    --bad-bg: #3a1714;
    --chart-line: #e0806f;
    --chart-target: #a0948a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171311; --surface: #211b18; --surface-2: #2a2320;
  --ink: #f2ebe4; --ink-2: #cfc4ba; --ink-3: #a0948a; --line: #3a312c;
  --accent: #e0806f; --accent-ink: #1a1210;
  --ok: #7fd09a; --ok-bg: #16301f; --warn: #f0c060; --warn-bg: #33280f;
  --bad: #ff8e82; --bad-bg: #3a1714;
  --chart-line: #e0806f; --chart-target: #a0948a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.site-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-head .wrap { display: flex; align-items: center; gap: 12px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: .01em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 14px; padding: 6px 0; }
.site-nav a { color: var(--ink-2); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 24px 0 8px; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
.lede { color: var(--ink-2); margin: 0 0 16px; }

.disclaimer {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink-2);
  margin: 16px 0;
}
.disclaimer strong { color: var(--ink); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

/* Forms */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--ink-3); font-size: 13px; }
input, select, button { font: inherit; color: inherit; }
input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.combo { display: flex; gap: 6px; }
.combo input { flex: 1 1 auto; min-width: 0; }
.combo select { flex: 0 0 auto; width: auto; }
fieldset { border: 0; padding: 0; margin: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500; margin: 0;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  background: var(--bg); cursor: pointer; min-height: 44px;
}
.seg input { accent-color: var(--accent); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }

button, .btn {
  min-height: 44px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); padding: 4px; min-height: 0; }

/* Results */
.result { font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--ink-3); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.key td { font-weight: 700; }
.table-scroll { overflow-x: auto; }

.status {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  border: 1px solid transparent;
}
.status .title { font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.status p { margin: 6px 0 0; }
.status.ok { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.status.warn { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.status.bad { background: var(--bad-bg); color: var(--bad); border-color: currentColor; }
.status .body { color: var(--ink); }

.ppm-row { margin: 10px 0; }
.ppm-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.ppm-row .big { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; margin-top: 4px; }
.meter > i { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.meter.low > i { background: var(--warn); }
.meter.over > i { background: var(--bad); }

.why { color: var(--ink-2); }
.notes { font-size: 14px; color: var(--ink-2); }
.notes ol { padding-left: 20px; }
.notes li { margin: 6px 0; }
sup a { text-decoration: none; }

.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 16px 0 32px; font-size: 13px; color: var(--ink-3); }

.tiles { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile:hover { border-color: var(--accent); }
.tile h2 { margin: 0 0 4px; color: var(--accent); }
.tile p { margin: 0; color: var(--ink-2); font-size: 14px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 13px;
  white-space: nowrap; transform: translate(-50%, -115%); display: none;
}
