/* QurBot storefront — one accent, one radius, one rhythm.
   Minimal on purpose: the product is a list of building materials and a price,
   and every ornament competes with those two things. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --ink: #16181d;
  --ink-2: #5b6169;
  --ink-3: #8b9199;
  --line: #e7e4de;
  --accent: #17694c;
  --accent-ink: #ffffff;
  --accent-soft: #e6f1eb;
  --warn: #8a5d0c;
  --warn-soft: #fdf2da;
  --danger: #a92c22;
  --danger-soft: #fbe9e7;

  --radius: 14px;
  --radius-sm: 10px;
  --gap: 16px;
  --shadow: 0 1px 2px rgba(16, 18, 20, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --surface: #171a1d;
    --surface-2: #1e2226;
    --ink: #edeef0;
    --ink-2: #a0a6ad;
    --ink-3: #7d848c;
    --line: #272c31;
    --accent: #4ec89a;
    --accent-ink: #07241a;
    --accent-soft: #17322a;
    --warn: #e0b062;
    --warn-soft: #2e2617;
    --danger: #ef8279;
    --danger-soft: #33201e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

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

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

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; font-weight: 640; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

.skip,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 680; letter-spacing: -0.02em; }
.brand:hover { color: inherit; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg);
}
.brand-name { font-size: 1.02rem; }

.topnav { display: flex; gap: 20px; margin-left: auto; font-size: .93rem; color: var(--ink-2); }
.topnav a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
.topnav a.is-active { color: var(--ink); font-weight: 560; box-shadow: inset 0 -2px 0 var(--accent); }

.topbar-side { display: flex; align-items: center; gap: 10px; }

.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; user-select: none;
  font-size: .8rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink-2);
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { color: var(--ink); }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 150px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(16, 18, 20, .1);
  padding: 5px; display: grid; gap: 2px; z-index: 30;
}
.menu-body a { padding: 8px 10px; border-radius: 7px; font-size: .9rem; }
.menu-body a:hover { background: var(--surface-2); color: var(--ink); }
.menu-body a.is-active { color: var(--accent); font-weight: 560; }

/* ── Layout ──────────────────────────────────────────────────────────── */

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: grid;
  gap: 28px;
}

.footer {
  max-width: 980px; margin: 0 auto;
  padding: 24px 16px calc(88px + env(safe-area-inset-bottom));
  color: var(--ink-3); font-size: .82rem;
  border-top: 1px solid var(--line);
}

.section { display: grid; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head .muted { font-size: .85rem; }

.muted { color: var(--ink-2); }
.tiny { font-size: .82rem; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Cards & lists ───────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.tight { padding: 14px; }

.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 720px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 4px; align-content: start;
  transition: border-color .15s ease, transform .15s ease;
}
.tile:hover { border-color: var(--accent); color: inherit; transform: translateY(-1px); }
.tile .tile-name { font-weight: 570; }

.list { display: grid; gap: 10px; }
.list-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between;
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-weight: 550; overflow-wrap: anywhere; }

.thumb {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; color: var(--ink-2); display: grid; gap: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 560; font-size: .93rem;
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
  text-align: center;
}
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 13px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: var(--line); background: transparent; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-icon { padding: 7px 10px; border-radius: 9px; line-height: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: .84rem; color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 600; letter-spacing: .01em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2);
}
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.count {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .7rem; font-weight: 700; font-style: normal;
  display: inline-flex; align-items: center; justify-content: center;
}

.price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.total-row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.total-row.grand { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-size: 1.08rem; font-weight: 680; }

/* ── Forms ───────────────────────────────────────────────────────────── */

label.field { display: grid; gap: 6px; font-size: .86rem; color: var(--ink-2); font-weight: 550; }

input[type="text"], input[type="tel"], input[type="number"], input[type="search"],
input[type="file"], select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; width: 100%;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }

.field-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-row > label.field { flex: 1; min-width: 130px; }

.radio-list { display: grid; gap: 8px; }
.radio-row {
  display: flex; gap: 11px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  background: var(--surface); cursor: pointer;
}
.radio-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-row input { margin-top: 3px; accent-color: var(--accent); }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.qty button {
  font: inherit; font-size: 1.05rem; line-height: 1; width: 34px; height: 34px;
  border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: 999px;
}
.qty button:hover { color: var(--accent); }
.qty input {
  width: 66px; border: 0; background: none; text-align: center; padding: 6px 0;
  font-variant-numeric: tabular-nums;
}

/* ── Tables (shop portal) ────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 560px; }
th, td { padding: 11px 14px; text-align: left; font-size: .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--ink-2); background: var(--surface-2); font-size: .8rem; letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
td input, td select { padding: 7px 9px; font-size: .88rem; }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; }

/* ── Hero (home) ─────────────────────────────────────────────────────── */

.hero { display: grid; gap: 18px; padding-top: 8px; }
.hero h1 { font-size: clamp(1.7rem, 4.4vw, 2.4rem); max-width: 18ch; }
.hero p { color: var(--ink-2); max-width: 56ch; }
.hero-form { display: grid; gap: 12px; }

.steps { counter-reset: step; }
.step { display: grid; gap: 4px; }
.step .step-no {
  width: 26px; height: 26px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .82rem; font-weight: 700;
}

/* ── Basket & quote (rendered by app.js) ─────────────────────────────── */

.line {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 10px;
}
.line.is-choose { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.line.is-unknown { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.line-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.line-name { font-weight: 550; overflow-wrap: anywhere; }
.line-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.variant-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.variant-tab {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 15px; font: inherit; font-size: .87rem; font-weight: 550; color: var(--ink-2); cursor: pointer;
}
.variant-tab.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.quote-lines { display: grid; gap: 2px; margin: 4px 0 12px; }
.quote-line { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .93rem; }
.quote-line:last-child { border-bottom: 0; }
.quote-line .q-name { overflow-wrap: anywhere; }
.quote-line .q-qty { color: var(--ink-3); font-size: .84rem; }

.notice { border-radius: var(--radius-sm); padding: 11px 14px; font-size: .88rem; }
.notice.ok { background: var(--accent-soft); color: var(--accent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }

.flash {
  max-width: 980px; margin: 12px auto -12px; padding: 11px 16px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--radius-sm); font-size: .9rem;
  width: calc(100% - 32px);
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: .88rem; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  max-width: min(92vw, 460px); text-align: center;
}

.sticky-actions {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom));
  display: grid; gap: 10px; z-index: 10;
}

/* ── Bottom tab bar ──────────────────────────────────────────────────── */

.tabbar { display: none; }

@media (max-width: 760px) {
  .topnav { display: none; }
  .page { padding-top: 20px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 3px; padding: 9px 4px 8px;
    font-size: .67rem; color: var(--ink-3); position: relative;
  }
  .tabbar a.is-active { color: var(--accent); }
  .tabbar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar .count { position: absolute; top: 4px; right: calc(50% - 20px); }
  .sticky-actions { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (min-width: 761px) {
  .footer { padding-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
