/* RoBa Deals - mobile-first styles. No external fonts or CDNs. */
:root {
  --bg: #f4f5fa; --surface: #ffffff; --surface-2: #eef0f8; --text: #14172a; --muted: #5a617c; --line: #dfe2ee;
  --accent: #5b3df5; --accent-ink: #ffffff; --accent-soft: rgba(91, 61, 245, .10);
  --green: #0f8f58; --green-bg: rgba(15, 143, 88, .13);
  --blue: #2a63e6; --blue-bg: rgba(42, 99, 230, .13);
  --yellow: #8a5d00; --yellow-bg: rgba(242, 178, 24, .22);
  --red: #c4303a; --red-bg: rgba(212, 58, 68, .13);
  --shadow: 0 1px 2px rgba(20, 23, 42, .06), 0 8px 24px rgba(20, 23, 42, .06);
  --radius: 16px; --tab-h: 62px;
  --s0: #5b3df5; --s1: #0f8f58; --s2: #d4741a; --s3: #c4303a; --s4: #1a8fb5; --s5: #8a5d00; --s6: #b0398a; --s7: #4a5470; --s8: #2a63e6;
}
:root[data-theme="dark"] {
  --bg: #0d1020; --surface: #161a2f; --surface-2: #1d2240; --text: #eceef9; --muted: #a0a7c4; --line: #272c4b;
  --accent: #9a86ff; --accent-ink: #12102a; --accent-soft: rgba(154, 134, 255, .14);
  --green: #3ddc97; --green-bg: rgba(61, 220, 151, .14);
  --blue: #7aa7ff; --blue-bg: rgba(122, 167, 255, .16);
  --yellow: #ffcd4a; --yellow-bg: rgba(255, 205, 74, .15);
  --red: #ff7b84; --red-bg: rgba(255, 123, 132, .15);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .28);
  --s0: #9a86ff; --s1: #3ddc97; --s2: #ff9f4a; --s3: #ff7b84; --s4: #5cd0f0; --s5: #ffcd4a; --s6: #f08ad0; --s7: #9aa3c4; --s8: #7aa7ff;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0d1020; --surface: #161a2f; --surface-2: #1d2240; --text: #eceef9; --muted: #a0a7c4; --line: #272c4b;
    --accent: #9a86ff; --accent-ink: #12102a; --accent-soft: rgba(154, 134, 255, .14);
    --green: #3ddc97; --green-bg: rgba(61, 220, 151, .14); --blue: #7aa7ff; --blue-bg: rgba(122, 167, 255, .16);
    --yellow: #ffcd4a; --yellow-bg: rgba(255, 205, 74, .15); --red: #ff7b84; --red-bg: rgba(255, 123, 132, .15);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .28);
    --s0: #9a86ff; --s1: #3ddc97; --s2: #ff9f4a; --s3: #ff7b84; --s4: #5cd0f0; --s5: #ffcd4a; --s6: #f08ad0; --s7: #9aa3c4; --s8: #7aa7ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.45;
  font: 16px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; margin-top: 1rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .err-text { color: var(--red); }
.num, .price, .stat-n, .mini strong { font-variant-numeric: tabular-nums; }
ul.plain { list-style: none; padding: 0; margin: .4rem 0; } ul.plain li { padding: .3rem 0; }
.inline { display: inline; margin: 0; }
.url { overflow-wrap: anywhere; }

/* ---------- top bar & navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; background: var(--bg); /* no backdrop-filter: it would make the fixed bottom nav position relative to the header */
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.05rem; letter-spacing: -.02em; }
.brand-text small { color: var(--muted); font-size: .72rem; }
.logo { width: 34px; height: 34px; flex: none; }
.l-ring { fill: none; stroke: var(--accent); stroke-width: 1.6; opacity: .55; }
.l-sweep { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.l-dot { fill: var(--green); }
.top-actions { display: flex; gap: .4rem; align-items: center; }
.icon-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; font-size: 1.1rem; cursor: pointer; }

.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 24px rgba(0,0,0,.08); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tab-h);
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.nav a .ico { font-size: 1.15rem; line-height: 1; }
.nav a[aria-current="page"] { color: var(--accent); }

/* ---------- layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 1rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .75rem; margin: .5rem 0 1rem; }
.crumbs { margin: .2rem 0 .4rem; font-size: .9rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; box-shadow: var(--shadow); }
.card.slim { padding: .6rem 1rem; }
.empty { text-align: center; padding: 2rem 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }

/* ---------- banners & badges ---------- */
.banner { border-radius: 12px; padding: .65rem .85rem; margin: 0 0 .75rem; font-size: .92rem; border: 1px solid var(--line); background: var(--surface-2); }
.banner strong { margin-right: .35rem; letter-spacing: .02em; }
.banner-demo { background: var(--yellow-bg); border-color: var(--yellow); color: var(--text); }
.banner-warn { background: var(--yellow-bg); border-color: var(--yellow); }
.banner-info { background: var(--blue-bg); border-color: var(--blue); }
.banner-ok { background: var(--green-bg); border-color: var(--green); }
.banner-err { background: var(--red-bg); border-color: var(--red); }
.badge, .chip, .tier { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.badge { font-size: .68rem; padding: .18rem .5rem; margin-right: .25rem; border: 1px solid currentColor; }
.b-demo { color: var(--yellow); background: var(--yellow-bg); } .b-live { color: var(--green); background: var(--green-bg); }
.b-stale { color: var(--red); background: var(--red-bg); } .b-unverified { color: var(--blue); background: var(--blue-bg); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .5rem 0; }
.chip { font-size: .7rem; padding: .22rem .6rem; background: var(--surface-2); color: var(--muted); }
.chip-green { background: var(--green-bg); color: var(--green); } .chip-blue { background: var(--blue-bg); color: var(--blue); }
.chip-yellow { background: var(--yellow-bg); color: var(--yellow); } .chip-red { background: var(--red-bg); color: var(--red); }
.tier { font-size: .74rem; padding: .28rem .7rem; }
.tier-green { background: var(--green-bg); color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.tier-blue { background: var(--blue-bg); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.tier-yellow { background: var(--yellow-bg); color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.tier-red { background: var(--red-bg); color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.tiers { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.warn { display: block; color: var(--yellow); font-size: .82rem; font-weight: 600; margin: .15rem 0; }
.stale-note { color: var(--red); margin: .3rem 0 0; }
.last-known { background: var(--surface-2); border-radius: 10px; padding: .5rem .65rem; margin: .4rem 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 0 0 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .8rem; display: flex; flex-direction: column; }
.stat:last-child { grid-column: span 2; }
.stat-n { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.stat-l { color: var(--muted); font-size: .8rem; } .stat-bad .stat-n { color: var(--red); }

/* ---------- family cards ---------- */
.family { position: relative; display: flex; flex-direction: column; gap: .5rem; margin: 0; transition: transform .15s; }
.family.is-paused { opacity: .78; }
.family-head { display: flex; gap: .75rem; align-items: center; }
.family-title { min-width: 0; } .family-title h2 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.family-title p { margin: .1rem 0 0; }
.stretched { color: var(--text); text-decoration: none; } .stretched::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.thumb { width: 52px; height: 52px; flex: none; border-radius: 14px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  display: grid; place-items: center; overflow: hidden; font-weight: 800; color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.price-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.price { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
.price.none { font-size: 1.15rem; color: var(--muted); } .price.is-stale { opacity: .6; text-decoration: line-through; text-decoration-thickness: 1px; }
.retailer { margin: .1rem 0; } .second { margin: .2rem 0 0; }
.family-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 2; }
.more { font-weight: 700; text-decoration: none; padding: .5rem 0; }
.chips .badge { margin: 0; }

/* ---------- product page ---------- */
.offers { display: grid; gap: .75rem; grid-template-columns: 1fr; margin-top: .5rem; }
.offer { display: flex; gap: .75rem; border: 1px solid var(--line); border-radius: 14px; padding: .8rem; background: var(--surface-2); }
.offer-rank { font-weight: 800; color: var(--accent); font-size: 1.2rem; }
.offer-main { min-width: 0; flex: 1; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .75rem; margin: .6rem 0; }
.facts dt { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; } .facts dd { margin: 0; overflow-wrap: anywhere; }
.status-facts { grid-template-columns: 1fr; margin-top: 1rem; }
.hist-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: .85rem; min-width: 46px; min-height: 40px; border-radius: 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .8rem 0; }
.mini { background: var(--surface-2); border-radius: 12px; padding: .55rem .6rem; display: flex; flex-direction: column; min-width: 0; }
.mini-l { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mini strong { font-size: 1.05rem; } .mini small { color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.legend button { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: .35rem .7rem; font: inherit; font-size: .8rem; min-height: 36px; cursor: pointer; }
.legend button[aria-pressed="false"] { opacity: .45; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.chart-wrap { position: relative; width: 100%; }
.chart { width: 100%; min-height: 220px; } .chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; } .chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .thr { stroke-dasharray: 4 4; stroke-width: 1.2; opacity: .8; } .chart .gap-tick { stroke: var(--muted); stroke-width: 2; opacity: .6; }
.chart .line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; } .chart .line.main { stroke-width: 2.8; }
.chart .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-empty { padding: 2rem 0; text-align: center; color: var(--muted); }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: 10px; padding: .45rem .6rem; font-size: .78rem; max-width: 220px; }
.tip b { display: block; margin-bottom: .15rem; } .tip .row { display: flex; justify-content: space-between; gap: .75rem; } .tip .gap { color: var(--muted); }

.controls { display: grid; gap: .75rem; }
.toggle { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem .8rem; background: var(--surface-2); border-radius: 12px; }
.inline-input { display: flex; align-items: center; gap: .4rem; } .inline-input input { width: 6.5rem; }
.variants { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.variant { border: 1px solid var(--line); border-radius: 12px; padding: .6rem .75rem; display: flex; flex-direction: column; gap: .5rem; }
.variant.is-off { opacity: .6; } .variant-main { display: flex; flex-direction: column; } .variant-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: flex-start; }
.edit-variant { width: 100%; } .edit-variant > summary { display: inline-flex; list-style: none; cursor: pointer; } .edit-variant form { margin-top: .6rem; }
.danger-zone { border-color: var(--red); }
details > summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
details.slim { margin-top: .6rem; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; } .tbl th, .tbl td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card:has(.tbl) { overflow-x: auto; }
.archive-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); }

/* ---------- forms & buttons ---------- */
.stack { display: flex; flex-direction: column; gap: .8rem; } .row2, .row3 { display: grid; gap: .8rem; grid-template-columns: 1fr; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; }
input, select, textarea { font: inherit; font-size: 16px; /* 16px prevents iOS focus-zoom */ color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: .65rem .75rem; min-height: 46px; width: 100%; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
label.check { flex-direction: row; align-items: center; gap: .6rem; font-weight: 600; } label.check input { width: 22px; height: 22px; min-height: 0; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: .8rem; margin: 0; min-width: 0; } legend { font-weight: 800; padding: 0 .4rem; }
.field-err { color: var(--red); font-weight: 600; font-size: .85rem; }
.variant-row { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; padding: .6rem; border: 1px dashed var(--line); border-radius: 12px; } .variant-row label:first-child { grid-column: span 2; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 700; font-size: .92rem; text-decoration: none; cursor: pointer;
  padding: .6rem 1rem; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-on { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.btn-danger { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.btn-sm { min-height: 40px; padding: .4rem .8rem; font-size: .84rem; }
.login { max-width: 420px; margin: 8vh auto 0; }

/* ---------- larger screens ---------- */
@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .nav { position: static; display: flex; gap: .25rem; background: transparent; border: 0; box-shadow: none; padding: 0; }
  .nav a { flex-direction: row; gap: .4rem; min-height: 40px; padding: 0 .8rem; border-radius: 10px; font-size: .9rem; }
  .nav a[aria-current="page"] { background: var(--accent-soft); }
  .topbar { padding-left: max(1rem, calc((100vw - 1100px) / 2 + 1rem)); padding-right: max(1rem, calc((100vw - 1100px) / 2 + 1rem)); }
  .grid { grid-template-columns: repeat(2, 1fr); } .stats { grid-template-columns: repeat(5, 1fr); } .stat:last-child { grid-column: auto; }
  .offers { grid-template-columns: repeat(2, 1fr); } .facts { grid-template-columns: repeat(3, 1fr); } .status-facts { grid-template-columns: repeat(3, 1fr); }
  .row2 { grid-template-columns: 1fr 1fr; } .row3 { grid-template-columns: repeat(3, 1fr); }
  .variant-row { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; } .variant-row label:first-child { grid-column: auto; }
  .variant { flex-direction: row; justify-content: space-between; align-items: center; } .controls { grid-template-columns: 1fr 1fr; } .controls .toggle:last-child { grid-column: span 2; }
  .family:hover { transform: translateY(-2px); }
}
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- utilities added last ---------- */
[hidden] { display: none !important; }
.chart .s0 { stroke: var(--s0); } .chart .s1 { stroke: var(--s1); } .chart .s2 { stroke: var(--s2); } .chart .s3 { stroke: var(--s3); }
.chart .s4 { stroke: var(--s4); } .chart .s5 { stroke: var(--s5); } .chart .s6 { stroke: var(--s6); } .chart .s7 { stroke: var(--s7); } .chart .s8 { stroke: var(--s8); }
.chart .dot { stroke: none; } .chart .dot.s0 { fill: var(--s0); } .chart .dot.s1 { fill: var(--s1); } .chart .dot.s2 { fill: var(--s2); } .chart .dot.s3 { fill: var(--s3); }
.chart .dot.s4 { fill: var(--s4); } .chart .dot.s5 { fill: var(--s5); } .chart .dot.s6 { fill: var(--s6); } .chart .dot.s7 { fill: var(--s7); } .chart .dot.s8 { fill: var(--s8); }
.chart .thr.g { stroke: var(--green); } .chart .thr.b { stroke: var(--blue); } .chart .thr.y { stroke: var(--yellow); }
.legend .sw.s0 { background: var(--s0); } .legend .sw.s1 { background: var(--s1); } .legend .sw.s2 { background: var(--s2); } .legend .sw.s3 { background: var(--s3); }
.legend .sw.s4 { background: var(--s4); } .legend .sw.s5 { background: var(--s5); } .legend .sw.s6 { background: var(--s6); } .legend .sw.s7 { background: var(--s7); } .legend .sw.s8 { background: var(--s8); }
