/* QuantityWise — shared stylesheet
   Single file, no build step, no external fonts. */

:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f4;
  --border: #dfe3e9;
  --border-strong: #c6ccd6;
  --text: #13171e;
  --muted: #5c6673;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fff1e9;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 22, 31, .06), 0 4px 14px rgba(16, 22, 31, .05);
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #161b22;
    --surface-2: #1c222b;
    --border: #262d38;
    --border-strong: #38414f;
    --text: #e6e9ee;
    --muted: #97a1b0;
    --accent: #fb7a3c;
    --accent-hover: #fd9764;
    --accent-soft: #2a1a12;
    --ok: #4ade80;
    --ok-soft: #12211a;
    --warn: #fbbf24;
    --warn-soft: #231c0e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #161b22;
  --surface-2: #1c222b;
  --border: #262d38;
  --border-strong: #38414f;
  --text: #e6e9ee;
  --muted: #97a1b0;
  --accent: #fb7a3c;
  --accent-hover: #fd9764;
  --accent-soft: #2a1a12;
  --ok: #4ade80;
  --ok-soft: #12211a;
  --warn: #fbbf24;
  --warn-soft: #231c0e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

/* `display: grid` on .row beats the UA sheet's [hidden] rule, which would
   otherwise leave hidden field groups visible. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.wrap--narrow { max-width: 760px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.6rem); margin-top: 2em; }
h3 { font-size: 1.1rem; margin-top: 1.8em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin-bottom: .35em; }
small { font-size: .85rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -.02em;
  flex: none;
}
.brand:hover { text-decoration: none; }
.brand svg { display: block; }

.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  font-size: .92rem;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}
.nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 14px;
    box-shadow: var(--shadow);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 11px 10px; font-size: 1rem; }
}

/* ---------- Layout blocks ---------- */

main { padding: 28px 0 56px; }

.breadcrumb {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

.lede { font-size: 1.08rem; color: var(--muted); max-width: 68ch; }

.hero { padding: 16px 0 8px; }
.hero h1 { max-width: 20ch; }

/* ---------- Calculator shell ---------- */

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin: 24px 0 8px;
}
@media (max-width: 900px) { .calc { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.panel__title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 14px;
}

.results {
  position: sticky;
  top: 76px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
@media (max-width: 900px) { .results { position: static; } }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label,
.field > .field__label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 5px;
}
.field__hint { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; margin-top: 3px; }

input[type="number"], input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  appearance: none;
}
textarea { min-height: 130px; resize: vertical; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c6673' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.row { display: grid; gap: 12px; }
.row--2 { grid-template-columns: 1fr 1fr; }
.row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .row--3 { grid-template-columns: 1fr 1fr; } }

.input-unit { position: relative; }
.input-unit input { padding-right: 46px; }
.input-unit__suffix {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .82rem;
  color: var(--muted);
  pointer-events: none;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.seg button {
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: 5px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: .92rem;
  margin-bottom: 9px;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; margin: 4px 0 0; flex: none; accent-color: var(--accent); }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--sm { padding: 5px 10px; font-size: .84rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- Result display ---------- */

.headline {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 4px;
}
.headline__label { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.headline__value {
  font-size: clamp(2rem, 1.5rem + 2vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}
.headline__value span { font-size: .45em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.headline__sub { font-size: .9rem; color: var(--muted); }

.outs { list-style: none; margin: 0; padding: 0; }
.outs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .93rem;
  margin: 0;
}
.outs li:last-child { border-bottom: 0; }
.outs .k { color: var(--muted); }
.outs .v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.outs li.is-total { border-top: 2px solid var(--border-strong); border-bottom: 0; margin-top: 6px; padding-top: 12px; font-size: 1.02rem; }

.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem;
  margin: 18px 0;
}
.note--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.note p:last-child { margin-bottom: 0; }
.note strong { font-weight: 650; }

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; margin: 18px 0; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  min-width: 460px;
}
caption {
  text-align: left;
  font-size: .85rem;
  color: var(--muted);
  padding-bottom: 8px;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Cards ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin: 24px 0; }
.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  color: var(--text);
}
.card:hover { text-decoration: none; border-color: var(--accent); background: var(--bg); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card p { margin: 0; font-size: .89rem; color: var(--muted); }
.card__icon { display: block; margin-bottom: 12px; color: var(--accent); }

/* ---------- FAQ ---------- */

.faq details {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 620;
  padding: 12px 0;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; font-weight: 400; line-height: 1; flex: none; }
.faq details[open] summary::after { content: "\2013"; }
.faq details > *:not(summary) { padding-bottom: 8px; color: var(--muted); font-size: .95rem; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 34px 0 40px;
  font-size: .9rem;
  color: var(--muted);
  margin-top: 40px;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 26px; }
.footer-grid h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text); margin-bottom: 10px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 7px; }
.footer-grid a { color: var(--muted); }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border);
  margin-top: 26px;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: .85rem;
}

/* ---------- Consent banner ---------- */

.consent {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 90;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  padding: 16px 18px;
  font-size: .88rem;
}
.consent[hidden] { display: none; }
.consent p { margin: 0 0 12px; }
.consent .btn-row { margin: 0; }

/* ---------- Ad slots (inactive until AdSense approval) ---------- */

.ad-slot { margin: 30px 0; text-align: center; min-height: 0; }
.ad-slot:empty { display: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; top: 0; }

.updated { font-size: .82rem; color: var(--muted); margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border); }

@media print {
  .site-header, .site-footer, .consent, .btn-row, .nav { display: none !important; }
  .calc { grid-template-columns: 1fr; }
  body { font-size: 12pt; }
}
