:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --hl: #fbe3e3;          /* highlighted location rows */
  --avg: #fbefc4;         /* average row, as in the sheet */
  --critical: #d03b3b;
  --good: #0ca30c;
  /* sequential rank ramp: darker = better */
  --r1: #184f95; --r2: #2a78d6; --r3: #6da7ec; --r4: #b7d3f6; --r5: #e4eefb;
  --r-ink-dark: #0b0b0b; --r-ink-light: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-ink: #86b6ef;
    --hl: #3a2426; --avg: #3a3320;
    --r1: #86b6ef; --r2: #3987e5; --r3: #256abf; --r4: #184f95; --r5: #1f2d40;
    --r-ink-dark: #0b0b0b; --r-ink-light: #ffffff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.req { color: var(--critical); }

.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 7px 13px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; color: var(--text); display: inline-block;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--critical); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: default; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.topbar { flex-wrap: wrap; row-gap: 8px; }
.brand { margin-right: auto; }
/* Run progress gets its own full-width row under the buttons so SKU, keyword and time left all fit. */
.run-status { order: 3; flex-basis: 100%; display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text-2); font-size: 13px;
  padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.run-status:empty { display: none; }
.run-status .txt { flex: 1; min-width: 0; }
.run-status .bar { width: 140px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex: none; }
.run-status .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.run-status .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-status .run-sku { color: var(--text); font-size: 14px; padding: 1px 7px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.run-status .run-name { color: var(--text-2); }
.run-status .paused { color: var(--text); }
.round-badge { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: 12.5px; color: var(--text-2); white-space: nowrap; cursor: pointer; font-variant-numeric: tabular-nums; }
.round-badge:hover { background: var(--surface-2); }
.run-status { cursor: pointer; }
.run-status:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.round-badge .rb-day { font-weight: 600; color: var(--text); }
.round-badge .rb-bar { width: 72px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.round-badge .rb-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.round-badge.complete .rb-bar i { background: var(--good); }
.round-badge.complete .rb-pct { color: var(--good); font-weight: 600; }
.round-badge .rb-count b { color: var(--text); }
.round-badge .rb-failed { color: var(--critical); font-weight: 600; }
@media (max-width: 560px) { .round-badge .rb-bar, .round-badge .rb-pct { display: none; } }
@media (prefers-reduced-motion: reduce) { .round-badge .rb-bar i { transition: none; } }
@media (max-width: 800px) {
  .run-status .txt { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.35; }
  .run-status .txt .muted { display: inline; }
}
.checking-tag { font-size: 11px; font-weight: 700; color: var(--accent-ink); animation: pulse 1.4s ease-in-out infinite; }
.product-list li button.checking { box-shadow: inset 3px 0 0 var(--accent); }
.kw-card.checking { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow); }
.checking-now { font-size: 12px; font-weight: 600; color: var(--accent-ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .checking-tag, .checking-now { animation: none; } }
.top-actions { display: flex; gap: 8px; }

/* Layout */
.layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - var(--topbar-h, 53px)); align-items: start; }
/* The sidebar stays put under the top bar and scrolls on its own, instead of scrolling away with the page. */
.sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 16px 12px;
  position: sticky; top: var(--topbar-h, 53px); height: calc(100vh - var(--topbar-h, 53px)); overflow-y: auto; overscroll-behavior: contain; }
/* Selected-SKU bar: sticks under the top bar once the SKU heading has scrolled away */
.sku-bar { position: fixed; top: var(--topbar-h, 53px); left: 280px; right: 0; z-index: 4; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 28px; box-shadow: var(--shadow); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border); font-size: 13px; visibility: hidden; opacity: 0; transform: translateY(-6px);
  transition: opacity .15s, transform .15s, visibility .15s; }
.sku-bar.show { visibility: visible; opacity: 1; transform: none; }
.sku-bar b { font-variant-numeric: tabular-nums; }
.bar-menu { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; }
.bar-menu:hover { background: var(--surface-2); }
.bar-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 14.5px; }
.bar-title b { font-size: 15px; }
.bar-title .nm { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.bar-nav { display: inline-flex; gap: 2px; }
.bar-nav .btn { font-size: 20px; line-height: 1; padding: 4px 10px; color: var(--text); }
/* Sidebar search + the "you are here" flash from the bar's ☰ */
.side-search { width: 100%; font: inherit; font-size: 13.5px; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 7px 10px; margin: -4px 0 12px; }
.product-list li button.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); } }
@media (prefers-reduced-motion: reduce) { .product-list li button.flash { animation: none; outline: 2px solid var(--accent); } }

.sku-bar .tag { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.sku-bar .sep { flex: 1; }
.sku-bar .avg .vs { color: var(--muted); font-size: 12px; }
.sku-bar .meta { color: var(--muted); font-size: 12px; }
.sku-bar .meta a { color: var(--accent-ink); text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .sku-bar { transition: none; } }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 10px; }
.sidebar-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.product-list { list-style: none; margin: 0; padding: 0; }
.product-list li button {
  width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
}
.product-list li button:hover { background: var(--surface-2); }
.product-list li button.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.product-list .sku { font-weight: 600; }
.product-list .name { grid-column: 1 / -1; color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-list .avg { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }
.product-list .avg b { color: var(--text); }
.product-list .avg .vs { color: var(--muted); font-size: 11.5px; }
.product-list .avg .delta { font-size: 11.5px; margin-left: 0; }
.product-list .avg .delta.same { color: var(--muted); }
.sidebar-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.product-list .empty { padding: 10px; color: var(--muted); font-size: 13px; }

.main { padding: 22px 28px 60px; min-width: 0; }

/* Sidebar: Overview link */
.nav-overview { width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 14px; font-weight: 600; cursor: pointer; text-align: left; }
.nav-overview .hint { margin-left: auto; font-weight: 400; }
.nav-overview:hover { background: var(--surface-2); }
.nav-overview.active { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent-ink); }

/* Sidebar TL / phase filters */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: -4px 0 14px; }
.filters label { display: grid; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filters select { font: inherit; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text);
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 6px; min-width: 0; }
.ov-sku .ov-tags { font-size: 11.5px; color: var(--muted); }

/* Overview page */
.ov { display: grid; gap: 18px; }
.ov h1 { margin: 0 0 2px; font-size: 22px; font-weight: 650; }
.ov h1 + p { margin: 0; font-size: 13px; }
.ov-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.ov-fig { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 1px; }
.ov-fig span { font-size: 12.5px; color: var(--text-2); }
.ov-fig b { font-size: 24px; font-variant-numeric: tabular-nums; }
.ov-fig small { font-size: 12px; color: var(--muted); }
.ov-fig.good b { color: var(--good); } .ov-fig.bad b { color: var(--critical); }
.ov-fig .bad { color: var(--critical); font-weight: 600; }
.ov-movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.ov-movers section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.ov-movers h2 { font-size: 14.5px; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.ov-movers ul { list-style: none; margin: 0; padding: 0; }
.ov-movers li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 6px; border-radius: 8px; cursor: pointer; }
.ov-movers li:hover, .ov-movers li:focus { background: var(--surface-2); }
.ov-movers li.none { cursor: default; color: var(--muted); font-size: 13px; display: block; }
.ov-movers .what { min-width: 0; display: grid; }
.ov-movers .kw { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.ov-movers .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-movers .path { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-chg { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; display: inline-block; min-width: 56px; text-align: center; }
.ov-chg.up { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.ov-chg.down { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.ov-chg.same, .ov-chg.none { color: var(--muted); background: var(--surface-2); }
.ov-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ov-controls input, .ov-controls select { font: inherit; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 10px; }
.ov-controls input { flex: 1 1 220px; min-width: 0; }
.ov-seg { display: inline-flex; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 2px; gap: 2px; }
.ov-seg button { font: inherit; font-size: 13px; border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.ov-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.ov-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow-x: auto; }
.ov-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; min-width: 860px; }
.ov-table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); text-align: right; padding: 8px 12px; white-space: nowrap; }
.ov-table td { text-align: right; padding: 8px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
.ov-table .left { text-align: left; }
.ov-table tbody tr { cursor: pointer; }
.ov-table tbody tr:hover td, .ov-table tbody tr:focus td { background: var(--surface-2); }
.ov-table td.big { font-size: 15px; font-weight: 700; }
.ov-sku { display: grid; max-width: 300px; }
.ov-sku span { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.ov-paused { font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.ov-spark { display: block; width: 120px; height: 30px; }
.ov-spark .a { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.ov-spark .l { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.ov-spark .e { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.kw-moves { font-weight: 700; font-size: 12.5px; display: inline-flex; gap: 6px; }
.kw-moves .up { color: var(--good); } .kw-moves .down { color: var(--critical); }
.ov-done { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.ov-done .bar { width: 44px; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.ov-done .bar i { display: block; height: 100%; background: var(--accent); }
.ov-done.full .bar i { background: var(--good); }

/* Today's checks status (Overview) */
.ov-checks { container-type: inline-size; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; scroll-margin-top: calc(var(--topbar-h, 56px) + 12px); }
.ck-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ck-head h2 { font-size: 14.5px; margin: 0; }
.ck-head h2 .muted { font-weight: 400; font-size: 13px; }
.ck-bar { display: flex; height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.ck-bar i { display: block; height: 100%; }
.ck-bar .ranked, .ck-stats .sw.ranked { background: var(--accent); }
.ck-bar .nf { background: var(--r4); }
.ck-bar .fail, .ck-stats .sw.fail { background: var(--critical); }
.ck-stats .sw.todo { background: var(--border); }
.ck-stats .sw.ok { background: var(--good); }
.ck-stats { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13.5px; }
.ck-stats > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ck-stats b { font-variant-numeric: tabular-nums; }
.ck-stats .bad b { color: var(--critical); }
.ck-stats .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ck-none { margin: 0; font-size: 13px; color: var(--good); }
.ck-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); max-height: 360px; overflow: hidden auto; }
.ck-list li { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(0, 1.6fr) auto auto; gap: 12px; align-items: center;
  padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.ck-list li:hover, .ck-list li:focus { background: var(--surface-2); }
.ck-list small { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-list .ck-sku, .ck-list .ck-kw { min-width: 0; }
.ck-list .ck-kw { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-list .ck-why { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-list .ck-tries { font-size: 12.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ck-tag { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; margin-right: 4px; }
.ck-tag.blocked { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.ck-tag.error { color: #b06a00; background: color-mix(in srgb, #e89a1a 18%, transparent); }
.ov-failed { font-size: 11.5px; font-weight: 700; color: var(--critical); }
.round-badge .rb-failed { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
@container (max-width: 760px) {
  .ck-list li { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 2px 12px; }
  .ck-list .ck-sku { grid-area: 1 / 1; } .ck-list .ck-kw { grid-area: 2 / 1; }
  .ck-list .ck-why { grid-area: 1 / 2; } .ck-list .ck-tries { grid-area: 2 / 2; white-space: normal; }
  .ck-list .btn { grid-area: 1 / 3 / span 2; }
}
@container (max-width: 440px) {
  .ck-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .ck-list .ck-sku { grid-area: 1 / 1; } .ck-list .ck-kw { grid-area: 2 / 1; }
  .ck-list .ck-why { grid-area: 3 / 1; } .ck-list .ck-tries { grid-area: 4 / 1; }
  .ck-list .btn { grid-area: 1 / 2 / span 4; }
}

/* Product header */
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.p-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 650; }
.p-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.p-meta a { color: var(--accent-ink); text-decoration: none; }
.p-meta a:hover { text-decoration: underline; }
.p-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-actions select { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 8px; }

.legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin: 0 0 16px; }
.legend .sw { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--border); }

/* At-a-glance keyword table (top of a SKU page) */
.kw-summary { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 20px; overflow-x: auto; }
.kw-summary table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.kw-summary th { text-align: right; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 8px 16px; white-space: nowrap; }
.kw-summary th:first-child { text-align: left; }
.kw-summary th .muted { font-weight: 500; }
.kw-summary td { padding: 7px 16px; border-top: 1px solid var(--border); }
.kw-summary td.kw { color: var(--text); }
.kw-summary td.num { text-align: right; white-space: nowrap; }
.kw-summary td.muted { color: var(--muted); }
.kw-summary tr[data-jump] { cursor: pointer; }
.kw-summary tr[data-jump]:hover td, .kw-summary tr[data-jump]:focus td { background: var(--surface-2); }
.kw-summary .delta { font-size: 12.5px; font-weight: 600; margin: 0; }
.kw-summary .delta.up { color: var(--good); }
.kw-summary .delta.down { color: var(--critical); }
.kw-summary .delta.same { color: var(--muted); }
.kw-summary tr.total td { font-weight: 700; background: var(--avg); }

/* Keyword block */
.kw-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.kw-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.kw-head .kw-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kw-head h3 { font-size: 16px; font-weight: 600; }
.kw-head .spacer { flex: 1; }
.kw-head .latest { font-size: 13px; color: var(--text-2); }
.kw-head .latest b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.kw-head .latest .vs { color: var(--muted); font-size: 12.5px; }
.delta { font-size: 12px; font-weight: 600; margin-left: 4px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }

.kw-body { display: grid; grid-template-columns: minmax(0, 1fr); }
.trend { padding: 10px 16px 0; }
.trend svg { display: block; width: 100%; height: 130px; overflow: visible; }
.trend .gridline { stroke: var(--border); stroke-width: 1; }
.trend .axis-text { fill: var(--muted); font-size: 11px; }
.trend .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend .xhair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }

.grid-wrap { overflow-x: auto; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 0; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid thead th { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 8px 6px; background: var(--surface-2); }
table.grid th.fc, table.grid td.fc { text-align: left; padding: 6px 10px 6px 16px; position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 600; }
table.grid thead th.fc { background: var(--surface-2); }
table.grid td.zip { color: var(--text-2); padding: 6px 12px; text-align: left; font-size: 13px; }
table.grid td.zip small { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; }
table.grid tr.hl td.fc { background: var(--hl); }
table.grid tr.off td { opacity: .45; }
table.grid td.c { padding: 3px; min-width: 64px; }
.cell {
  display: flex; align-items: center; justify-content: center; height: 30px; border-radius: 6px; font-weight: 600; font-size: 13.5px; cursor: default;
}
.cell.b1 { background: var(--r1); color: var(--r-ink-light); }
.cell.b2 { background: var(--r2); color: var(--r-ink-light); }
.cell.b3 { background: var(--r3); color: var(--r-ink-dark); }
.cell.b4 { background: var(--r4); color: var(--r-ink-dark); }
.cell.b5 { background: var(--r5); color: var(--text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cell.b1, :root:not([data-theme="light"]) .cell.b2 { color: #0b0b0b; }
  :root:not([data-theme="light"]) .cell.b3, :root:not([data-theme="light"]) .cell.b4 { color: #fff; }
}
.cell.nf { color: var(--muted); font-weight: 500; font-size: 12.5px; border: 1px dashed var(--border); }
.cell.err { color: var(--critical); font-weight: 600; }
.cell.none { color: var(--border); }
.cell:hover { outline: 2px solid var(--text-2); outline-offset: 1px; }
table.grid tr.avg td { background: var(--avg); font-weight: 700; padding: 8px 6px; border-bottom: 0; }
table.grid tr.avg td.fc { background: var(--avg); }
.kw-empty { padding: 22px 16px; color: var(--muted); }
.kw-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px; }

.empty-state { max-width: 520px; margin: 60px auto; text-align: center; color: var(--text-2); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; font-size: 20px; }
.empty-state p { margin: 0 0 18px; }

/* Tooltip */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; max-width: 280px;
}
.tooltip .v { font-size: 15px; font-weight: 700; }
.tooltip .k { color: var(--text-2); }
.tooltip:has(.kw-tip) { max-width: 420px; }
.kw-tip { border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kw-tip th { font-size: 11px; font-weight: 600; color: var(--muted); text-align: right; padding: 0 0 4px 12px; }
.kw-tip th:first-child { text-align: left; padding-left: 0; }
.kw-tip td { padding: 2px 0 2px 12px; }
.kw-tip td.kw { padding-left: 0; color: var(--text-2); max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-tip td.num { text-align: right; white-space: nowrap; }
.kw-tip td.muted { color: var(--muted); }
.kw-tip .delta.up { color: var(--good); }
.kw-tip .delta.down { color: var(--critical); }
.kw-tip .delta.same { color: var(--muted); }
.kw-tip tr.total td { border-top: 1px solid var(--border); padding-top: 5px; font-weight: 700; color: var(--text); }

/* Dialogs */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form, dialog .dlg-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { font-size: 17px; }
dialog label { display: block; font-weight: 500; font-size: 13px; }
dialog label > input:not([type=checkbox]):not([type=radio]), dialog label > textarea, dialog label > select { display: block; width: 100%; margin-top: 4px; }
dialog .loc-field textarea { width: 100%; }
dialog label.check { flex-direction: row; align-items: center; gap: 8px; }
dialog input:not([type=checkbox]):not([type=radio]), dialog textarea, dialog select { border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 8px 10px; font-weight: 400; }
dialog textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.form-error { color: var(--critical); margin: 0; font-size: 13px; }
.loc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.loc-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 6px; }
.loc-table td { padding: 4px 6px; border-top: 1px solid var(--border); }
.loc-table input:not([type=checkbox]) { width: 100%; padding: 5px 8px !important; }
.loc-table td.city { color: var(--text-2); font-size: 12px; }
.loc-table .sel { width: 28px; }
.loc-table tr.selected td { background: color-mix(in srgb, var(--critical) 8%, transparent); }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--critical) 8%, var(--surface)); font-size: 13px; font-weight: 500; }
.bulk-bar[hidden] { display: none; }
.bulk-bar #loc-bulk-count { flex: 1; }
.loc-add { display: grid !important; grid-template-columns: 1fr auto; align-items: end; gap: 8px; padding: 0 !important; }
.loc-field { display: flex; flex-direction: column; gap: 4px; }
.loc-field-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.loc-field-head label { flex: 1; }
.loc-field-head select { max-width: 45%; font-size: 12.5px; padding: 5px 8px !important; }
.loc-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.menu-btn { display: none; }
.drawer-backdrop { display: none; }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 800px) {
  /* Top bar: [☰ brand · progress] / [4 actions] / [status] */
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; row-gap: 8px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--border);
    border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; flex: none; }
  .brand { font-size: 15px; gap: 8px; }
  .brand svg { width: 22px; height: 22px; }
  .round-badge { margin-left: auto; padding: 4px 9px; }
  .top-actions { order: 2; flex-basis: 100%; display: grid; grid-template-columns: auto auto repeat(4, minmax(0, 1fr)); gap: 6px; }
  .top-actions .whatsnew-btn { padding: 7px 9px; justify-content: center; }
  .top-actions .btn { padding: 7px 4px; font-size: 13px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
  .run-status { order: 3; flex-basis: 100%; font-size: 12.5px; padding: 6px 8px; }
  .run-status .bar { width: 56px; }

  /* Product list becomes a slide-out drawer */
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(330px, 88vw); height: auto; z-index: 40;
    padding-top: calc(16px + env(safe-area-inset-top, 0px)); border-right: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,.25);
    transform: translateX(-102%); transition: transform .2s ease; overflow-y: auto; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open { overflow: hidden; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.4); }
  .drawer-backdrop[hidden] { display: none; }

  .main { padding: 14px 12px 48px; }
  .row2 { grid-template-columns: 1fr; }
  .sku-bar { left: 0; padding: 7px 12px; gap: 8px; }
  /* [☰  SKU name…  ‹ ›  ↑] / [today vs yesterday] */
  .sku-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "menu title nav top" "avg avg avg avg"; gap: 4px 8px; align-items: center; }
  .sku-bar .bar-menu { grid-area: menu; width: 40px; height: 40px; }
  .sku-bar .bar-title { grid-area: title; display: grid; gap: 0; line-height: 1.25; font-size: 13px; }
  .sku-bar .bar-title .nm { max-width: none; font-size: 12.5px; }
  .sku-bar .bar-nav { grid-area: nav; }
  .sku-bar .bar-nav .btn { font-size: 22px; padding: 6px 10px; }
  .sku-bar .avg { grid-area: avg; font-size: 12.5px; }
  .sku-bar > .btn { grid-area: top; }
  .side-search { font-size: 16px; }  /* no iPhone zoom on tap */
  .sku-bar .meta, .sku-bar .tag, .sku-bar .sep { display: none; }

  /* SKU page */
  .p-head { gap: 10px; margin-bottom: 12px; }
  .p-head h1 { font-size: 18px; }
  .p-meta { gap: 4px 12px; font-size: 12.5px; }
  .p-actions { gap: 6px; }
  .p-actions .btn, .p-actions select { font-size: 13px; padding: 6px 9px; }
  .legend { font-size: 11.5px; gap: 6px 10px; margin-bottom: 12px; }
  .kw-card { border-radius: 10px; margin-bottom: 14px; }
  .kw-head { padding: 10px 12px; gap: 8px; }
  .kw-head h3 { font-size: 15px; }
  .kw-head .latest b { font-size: 16px; }
  .trend { padding: 8px 10px 0; }
  table.grid th.fc, table.grid td.fc { padding-left: 10px; }
  table.grid td.c { min-width: 52px; }
  .cell { height: 28px; font-size: 13px; }
  .kw-summary th, .kw-summary td { padding: 7px 10px; }
  .kw-summary { font-size: 13px; }

  /* Overview */
  .ov h1 { font-size: 20px; }
  .ov-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ov-figures .ov-fig:first-child { grid-column: 1 / -1; }  /* round progress full width, then a 2×2 */
  .ov-fig { padding: 10px 12px; }
  .ov-fig b { font-size: 20px; }
  .ov-movers { grid-template-columns: 1fr; }
  .ov-movers li { grid-template-columns: minmax(0, 1fr) auto; }
  .ov-movers li .path { grid-column: 1; font-size: 12px; }
  .ov-movers li .ov-chg { grid-row: 1 / span 2; grid-column: 2; }
  .ov-controls input { flex-basis: 100%; }

  /* The three-row top bar scrolls away on phones to free the screen; the SKU bar then sits at the very top. */
  .topbar { position: static; }
  .sku-bar { top: 0; padding-top: calc(7px + env(safe-area-inset-top, 0px)); }
  .kw-summary th .muted { display: none; }
  .kw-summary th, .kw-summary td { padding: 7px 8px; }
  .kw-summary th { white-space: normal; }
  .kw-summary td.kw { overflow-wrap: anywhere; }
}

/* Overview table as stacked cards on phones */
@media (max-width: 640px) {
  .ov-table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .ov-table { min-width: 0; display: block; }
  .ov-table thead { display: none; }
  .ov-table tbody { display: grid; gap: 8px; }
  .ov-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas:
      "sku t chg" "spark spark y" "kw est done"; gap: 4px 10px; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
  .ov-table td { border: 0; padding: 0; white-space: normal; }
  .ov-table .c-sku { grid-area: sku; min-width: 0; }
  .ov-table .c-t { grid-area: t; font-size: 18px; }
  .ov-table .c-chg { grid-area: chg; }
  .ov-table .c-spark { grid-area: spark; }
  .ov-table .c-spark .ov-spark { width: 100%; max-width: 240px; }
  .ov-table .c-y { grid-area: y; font-size: 12.5px; }
  .ov-table .c-kw { grid-area: kw; text-align: left; font-size: 12.5px; }
  .ov-table .c-done { grid-area: done; }
  .ov-table .c-est { grid-area: est; font-size: 12.5px; }
  .ov-table [data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 11.5px; font-weight: 400; }
  .ov-table .c-kw::before { content: "keywords "; }
  .ov-table tbody tr:hover td, .ov-table tbody tr:focus td { background: none; }
  .ov-table tbody tr:hover { background: var(--surface-2); }
  .ov-sku { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

.steps { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.steps a { color: var(--accent-ink); font-weight: 600; }
.import-input { display: flex; align-items: center; gap: 10px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#import-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; white-space: pre; }
.imp-summary { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.imp-summary span { padding: 3px 9px; border-radius: 999px; background: var(--surface-2); font-weight: 500; }
.imp-summary .err { color: var(--critical); }
.imp-table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.imp-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; padding: 6px 8px; color: var(--text-2); }
.imp-table td { padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.imp-table .new { color: var(--good); font-weight: 600; }
.imp-table .errtxt { color: var(--critical); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.tag.create { background: color-mix(in srgb, var(--good) 18%, transparent); }
.tag.update { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tag.unchanged { background: var(--surface-2); color: var(--muted); }
.tag.error { background: color-mix(in srgb, var(--critical) 18%, transparent); color: var(--critical); }
.imp-rowerrs { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--critical); }
.imp-done { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--good) 12%, var(--surface)); font-size: 13.5px; }
.radio-group { display: flex; flex-direction: column; gap: 8px; }
dialog label.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
dialog label.radio:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
dialog label.radio input { margin-top: 3px; }
dialog label.radio .hint { display: block; margin-top: 2px; }
.data-folder { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.data-folder code { font-size: 12px; color: var(--text-2); word-break: break-all; }
.data-folder .btn { justify-self: start; }
.data-folder input { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 8px; min-width: 0; }
/* FC stock badge in the grid's FC column */
.stk { display: inline-block; min-width: 16px; margin-left: 6px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 17px;
  text-align: center; font-variant-numeric: tabular-nums; vertical-align: 1px; cursor: help; }
.stk.in { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.stk.out { color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent); }
.stk.unk { color: #b06a00; background: color-mix(in srgb, #e89a1a 18%, transparent); }
dialog.confirm { width: min(400px, calc(100vw - 32px)); }
dialog.confirm p { margin: 0; font-size: 14.5px; }
.btn.primary.destructive { background: var(--critical); border-color: var(--critical); }
@media (max-width: 900px) and (min-width: 801px) { .run-status .run-name { display: none; } }

/* Locations card (SKU page): tracked locations with FC stock on a ledger date, other FCs, add */
.loc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px;
  margin: 0 0 18px; display: grid; gap: 12px; min-width: 0; }
.lc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.lc-head h2 { font-size: 15px; margin: 0 0 2px; }
.lc-head p { margin: 0; font-size: 12.5px; }
.lc-day { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.lc-day select { font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 8px; }
.lc-table-wrap { overflow-x: auto; }
.lc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.lc-table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); text-align: left; padding: 7px 10px; white-space: nowrap; }
.lc-table td { padding: 7px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.lc-table .num { text-align: right; }
.lc-table tr.off td { color: var(--muted); }
.lc-table tfoot td { background: var(--surface-2); font-weight: 600; }
.lc-city { color: var(--text-2); }
.lc-qty { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; font-weight: 700; font-size: 12.5px; text-align: center; cursor: help; }
.lc-qty.in { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.lc-qty.out { color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent); }
.lc-qty.unk { color: #b06a00; background: color-mix(in srgb, #e89a1a 18%, transparent); }
.lc-others h3 { font-size: 13.5px; margin: 0 0 8px; font-weight: 600; }
.lc-others h3 .muted { font-weight: 400; }
.lc-others ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.lc-others li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; min-width: 0; }
.lc-o-fc { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.lc-zip { width: 64px; font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 3px 6px; }
.lc-zip.bad { border-color: var(--critical); }
.lc-others p { margin: 0; font-size: 13px; }
.lc-add { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.lc-add label { font-size: 13px; font-weight: 600; }
.lc-add-row { display: flex; gap: 8px; align-items: flex-start; }
.lc-add textarea { flex: 1; min-width: 0; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 6px 8px; resize: vertical; }
.lc-add .form-error { margin: 0; }
.p-meta a.stock-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.p-meta a.stock-link:hover { color: var(--accent-ink); }
#loc-card { scroll-margin-top: calc(var(--topbar-h, 56px) + 60px); }
.lc-fczip { display: block; font-size: 11.5px; color: var(--muted); cursor: help; }
/* Paused SKU / keyword / location */
.paused-tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; color: #b06a00; text-transform: uppercase;
  background: color-mix(in srgb, #e89a1a 16%, transparent); border-radius: 999px; padding: 1px 7px; vertical-align: 1px; }
.kw-card.paused { opacity: .72; }
.kw-card.paused:hover, .kw-card.paused:focus-within { opacity: 1; }
.btn.resume { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.lc-on .btn { margin-left: 8px; padding: 2px 8px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); font-size: 13.5px; padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
/* Reordering keyword cards */
.kw-grip { flex: none; align-self: center; display: inline-grid; place-items: center; width: 24px; height: 32px; margin: 0 2px 0 -6px; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: grab; touch-action: none; }
.kw-grip:hover, .kw-grip:focus-visible { background: var(--surface-2); color: var(--text); }
.kw-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
body.kw-sorting, body.kw-sorting * { cursor: grabbing !important; user-select: none; }
body.kw-sorting .kw-card .kw-body, body.kw-sorting .kw-card .kw-empty { display: none; }
body.kw-sorting .kw-card { margin-bottom: 8px; transition: none; }
.kw-card.dragging { box-shadow: 0 0 0 2px var(--accent), 0 10px 28px rgba(0,0,0,.18); position: relative; z-index: 3; }
/* Settings → Account & users */
.account .acct-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account .acct-head .btn { margin-left: auto; }
.account .acct-row { display: flex; gap: 6px; flex-wrap: wrap; }
.account .acct-row input { flex: 1 1 140px; min-width: 0; font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 6px 8px; }
.acct-users { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.acct-users li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.acct-users li .btn { margin-left: auto; }
.acct-msg { margin: 0; font-size: 12.5px; color: var(--good); }
.acct-msg.bad { color: var(--critical); }

/* Overview: alerts, health, weekly button */
.ov-head { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap-reverse; }
.ov-head > div:last-child { min-width: 0; flex: 1 1 320px; }
.ov-alerts, .ov-health { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.ov-alerts h2, .ov-health h2 { font-size: 14.5px; margin: 0; }
.ov-alerts h2 .muted { font-weight: 400; font-size: 13px; }
.ov-health { border-color: color-mix(in srgb, #e89a1a 45%, var(--border)); background: color-mix(in srgb, #e89a1a 7%, var(--surface)); }
.ov-health ul { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.al-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.al-chip { font-size: 12px; border-radius: 999px; padding: 2px 9px; background: var(--surface-2); color: var(--text-2); }
.al-chip b { color: var(--text); }
.al-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.al-list li { display: grid; grid-template-columns: auto minmax(0, 1.2fr) auto minmax(0, 2fr); gap: 4px 10px; align-items: center; padding: 7px 4px;
  border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.al-list li:hover, .al-list li:focus { background: var(--surface-2); }
.al-sev { width: 9px; height: 9px; border-radius: 50%; }
.al-sev.high { background: var(--critical); } .al-sev.medium { background: #e89a1a; } .al-sev.low { background: var(--muted); }
.al-what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-what small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.al-type { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; color: var(--text-2); background: var(--surface-2); }
.al-type.page1, .al-type.nostock { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.al-type.drop, .al-type.stockout { color: #b06a00; background: color-mix(in srgb, #e89a1a 16%, transparent); }
.al-text { color: var(--text-2); min-width: 0; }
@container (max-width: 640px) { .al-list li { grid-template-columns: auto minmax(0, 1fr) auto; } .al-text { grid-column: 2 / -1; } }
.ov-alerts { container-type: inline-size; }

/* Weekly report */
.wk-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wk-actions select { font: inherit; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 10px; }
.ov-table td.bad { color: var(--critical); font-weight: 600; }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }

/* Events */
.ev-kind { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; background: var(--surface-2); color: var(--text-2); }
.ev-kind.price { color: #7a4fc7; background: color-mix(in srgb, #7a4fc7 14%, transparent); }
.ev-kind.coupon { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.ev-kind.ads { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ev-kind.stock { color: #b06a00; background: color-mix(in srgb, #e89a1a 16%, transparent); }
.ev-strip { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; margin: -6px 0 16px; }
.ev-item { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 6px; background: var(--surface); }
.ev-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 4px; }
.ev-del:hover { color: var(--critical); }
table.grid th.has-ev { position: relative; color: #7a4fc7; }
.ev-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #7a4fc7; margin-left: 4px; vertical-align: 2px; }
.trend .ev-line { stroke: #7a4fc7; stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.trend .ev-flag { fill: #7a4fc7; }
.trend .ev-flag.coupon { fill: var(--good); } .trend .ev-flag.ads { fill: var(--accent); } .trend .ev-flag.stock { fill: #e89a1a; }

/* 0 stock at that FC that day */
.cell.oos { box-shadow: inset 0 -3px 0 var(--critical); }

/* Keyword target, search volume, competitors */
.kw-target { font: inherit; font-size: 12px; font-weight: 600; border: 1px dashed var(--border); background: none; color: var(--text-2); border-radius: 999px; padding: 2px 9px; cursor: pointer; }
.kw-target.on { border-style: solid; color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.kw-target.off { border-style: solid; color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); }
.kw-target.none { color: var(--muted); }
.kw-target-edit { display: inline-flex; gap: 4px; align-items: center; }
.kw-target-edit input { width: 70px; font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 6px; }
.kw-sqp { font-size: 12.5px; color: var(--text-2); }
.tgt { font-weight: 700; font-size: 12.5px; }
.tgt.on { color: var(--good); } .tgt.off { color: var(--critical); }
.comp-panel { padding: 10px 16px 14px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.comp-panel p { margin: 0; font-size: 12.5px; }
.comp-wrap { overflow-x: auto; }
.comp-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 560px; }
.comp-table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 6px 10px; text-align: right; white-space: nowrap; }
.comp-table td { padding: 6px 10px; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
.comp-table .left { text-align: left; white-space: normal; }
.comp-table td.left a { color: var(--text); text-decoration: none; }
.comp-table td.left a:hover { text-decoration: underline; }
.comp-table small { display: block; color: var(--muted); font-size: 11.5px; }
.comp-table tr.ours td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Settings additions */
.acct-users select, #user-role { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 6px; }
.role-tag { font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; }
.sqp-box { margin-top: 4px; }

/* Access: only admins manage people; viewers see no editing controls */
body:not(.role-admin) .admin-only { display: none !important; }
body.role-viewer #btn-run-all, body.role-viewer #btn-import, body.role-viewer #btn-add-product,
body.role-viewer [data-act="add-keywords"], body.role-viewer [data-act="add-product"], body.role-viewer [data-act="del-keyword"],
body.role-viewer [data-act="edit-product"], body.role-viewer [data-act="locations"], body.role-viewer [data-act="run-keyword"],
body.role-viewer [data-act="run-product"], body.role-viewer [data-act="pause-product"], body.role-viewer [data-act="pause-keyword"],
body.role-viewer [data-act="add-event"], body.role-viewer [data-retry], body.role-viewer #lc-add-form, body.role-viewer [data-lc-add],
body.role-viewer .lc-zip, body.role-viewer [data-lc-toggle], body.role-viewer .kw-grip, body.role-viewer .ev-del,
body.role-viewer #form-settings > :not(h3):not(.account):not(.dlg-actions), body.role-viewer #form-settings .dlg-actions button[value="save"] { display: none !important; }
body.role-viewer .kw-target { pointer-events: none; }
body.role-viewer .kw-target.none { display: none; }

/* What's new */
.whatsnew-btn { position: relative; }
.wn-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); }
dialog.whatsnew { max-width: min(920px, calc(100vw - 32px)); }
.wn-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wn-head h3 { margin: 0; }
.wn-day { display: grid; gap: 14px; padding: 6px 0 14px; border-top: 1px solid var(--border); }
.wn-day h4 { margin: 10px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.wn-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.wn-item:not(:has(.wn-shot)) { grid-template-columns: minmax(0, 1fr); }
.wn-text h5 { margin: 0 0 4px; font-size: 15px; font-weight: 650; display: flex; gap: 8px; align-items: center; }
.wn-text p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-2); max-width: 62ch; }
.wn-new { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 7px; }
.wn-shot { padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; display: block; width: 100%; }
.wn-shot img { display: block; width: 100%; height: auto; max-height: 260px; object-fit: cover; object-position: top left; }
.wn-shot.zoomed { grid-column: 1 / -1; cursor: zoom-out; }
.wn-shot.zoomed img { max-height: none; object-fit: contain; }
@media (max-width: 700px) { .wn-item { grid-template-columns: minmax(0, 1fr); } }
.whatsnew-btn { display: inline-flex; align-items: center; gap: 6px; }
.whatsnew-btn svg { color: var(--accent); }
@media (max-width: 640px) { .whatsnew-btn .wn-label { display: none; } .whatsnew-btn { padding-inline: 10px; } }

/* Keyword ideas and click estimates */
.ideas-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 20px; display: grid; gap: 8px; min-width: 0; }
.ideas-card:empty { display: none; }
.ideas-card h2 { font-size: 14.5px; margin: 0; }
.ideas-card h2 .muted { font-weight: 400; font-size: 12.5px; }
.ideas-empty { margin: 0; font-size: 13px; }
.ideas-card:has(.ideas-empty) { box-shadow: none; padding: 9px 14px; }
.ideas-table td:last-child { white-space: nowrap; }
.ideas-table select { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 6px; max-width: 120px; }
.kw-summary small.gain, small.gain { color: var(--good); font-size: 11.5px; }

/* Collapse / expand cards */
.cl-toggle { margin-left: auto; flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px;
  background: none; color: var(--muted); cursor: pointer; }
.cl-toggle:hover, .cl-toggle:focus-visible { background: var(--surface-2); color: var(--text); }
.cl-toggle svg { transition: transform .15s ease; }
.is-collapsed .cl-toggle svg, .cl-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
h2.cl-header, .cl-header { display: flex; align-items: center; gap: 8px; }
.ck-head.cl-header { flex-wrap: wrap; }
.is-collapsed:not(.kw-summary) > :not(.cl-header) { display: none !important; }
.kw-summary.is-collapsed tbody { display: none; }
.kw-summary thead th.cl-header { display: table-cell; }
.kw-summary thead th.cl-header .cl-toggle { margin-left: 6px; vertical-align: middle; width: 24px; height: 24px; }
.kw-card.is-collapsed .kw-head { border-bottom: 0; }
.kw-card.is-collapsed { margin-bottom: 10px; }
.kw-bulk { display: flex; align-items: center; gap: 6px; margin: -6px 0 10px; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .cl-toggle svg { transition: none; } }
.kw-head > .cl-toggle { margin-left: -8px; margin-right: -6px; }

/* Change requests */
.requests-btn { border-color: color-mix(in srgb, #e89a1a 55%, var(--border)); }
.requests-btn b { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: #e89a1a; color: #fff; font-size: 12px; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.req { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 12px; align-items: start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.req.pending { border-color: color-mix(in srgb, #e89a1a 50%, var(--border)); }
.req-main { display: grid; gap: 3px; min-width: 0; }
.req-main b { font-size: 14px; font-weight: 600; color: var(--text); }
.req-main small { color: var(--muted); font-size: 12px; }
.req-main details { font-size: 12px; color: var(--text-2); }
.req-main details pre { max-height: 220px; overflow: auto; background: var(--surface-2); border-radius: 6px; padding: 6px 8px; margin: 4px 0 0; font-size: 11.5px; white-space: pre-wrap; word-break: break-word; }
.req-status { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.req.pending .req-status { color: #b06a00; background: color-mix(in srgb, #e89a1a 16%, transparent); }
.req.approved .req-status { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.req.rejected .req-status, .req.failed .req-status { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.req-acts { display: flex; gap: 6px; }
@media (max-width: 640px) { .req { grid-template-columns: minmax(0, 1fr) auto; } .req-acts, .req [data-req-cancel] { grid-column: 1 / -1; } }

.acct-users { gap: 0; }
.acct-users li { display: grid; gap: 5px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.acct-users li:first-child { padding-top: 2px; }
.acct-users .u-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-users .u-top .btn { margin-left: auto; }
.account .acct-users input.user-email { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 4px 8px; width: 100%; max-width: 320px; min-height: 0; }

.ov-requests .req-list { margin-top: 4px; }
.ov-requests .req-none { margin: 4px 0 0; font-size: 13px; }
.ov-requests .req-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 8px; }
.requests-btn { border-color: var(--border); }
.requests-btn.has-pending { border-color: color-mix(in srgb, #e89a1a 55%, var(--border)); }
