/* Competitor price service: admin and staff UI. One sans family, restrained colour, dense where it helps. */

:root {
  --bg: #f4f6f7; --surface: #ffffff; --surface-2: #eef1f3; --ink: #17202a; --mute: #5a6672; --faint: #8a95a0;
  --line: #e1e6ea; --line-strong: #cdd5db;
  --accent: #0b6e4f; --accent-hover: #095c42; --accent-ink: #ffffff; --accent-soft: #e2f2ea;
  --ok: #137a4f; --ok-soft: #e2f2ea; --warn: #9a5a06; --warn-soft: #fdf0d9; --bad: #b3261e; --bad-soft: #fbe6e4;
  --info: #1c5db0; --info-soft: #e3edfa; --log-bg: #11171d; --log-ink: #d7dee5; --log-mute: #7d8995;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .05);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  /* names the staff review page already uses */
  --card: var(--surface); --chip: var(--surface-2); --sel: var(--accent-soft); --warn-bg: var(--warn-soft); --warn-ink: var(--warn); --good: var(--ok);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --surface: #171e24; --surface-2: #1d262d; --ink: #e6ebef; --mute: #9aa6b1; --faint: #6f7b86;
    --line: #28333c; --line-strong: #364450;
    --accent: #3fcf93; --accent-hover: #5ad9a5; --accent-ink: #06281b; --accent-soft: #143a2b;
    --ok: #4cd694; --ok-soft: #143a2b; --warn: #f0b35c; --warn-soft: #3a2b12; --bad: #ff8a80; --bad-soft: #3d1a18;
    --info: #7db2f5; --info-soft: #172c47; --log-bg: #0b0f13; --log-ink: #d0d8df; --log-mute: #6c7883;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); font-variant-numeric: tabular-nums; }
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; }
h3 { font-size: .9rem; }
p { margin: 0 0 .6em; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--mute); }
.faint { color: var(--faint); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- shell ---- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface-2); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 650; letter-spacing: -.01em; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: var(--mute); font-size: .76rem; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--mute); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .72rem; padding: 0 7px; line-height: 18px; font-weight: 600; }
.nav .live { margin-left: auto; }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: .85rem; color: var(--mute); }
.side .who strong { display: block; color: var(--ink); font-weight: 600; }
.main { padding: 26px clamp(16px, 3vw, 40px) 64px; max-width: 1240px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--mute); max-width: 60ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; padding-top: 18px; }
  .steps li { grid-template-columns: 22px minmax(0, 1fr); }
  .steps .stats { grid-column: 2; justify-content: flex-start; gap: 4px 14px; }
  .check li { grid-template-columns: 22px minmax(0, 1fr); }
  .check .ms { grid-column: 2; }
  .panel-head { padding: 12px 14px; }
  .panel-body { padding: 14px; }
  .page-head { margin-bottom: 14px; }
  .log .ln { grid-template-columns: 58px minmax(0, 1fr); }
  .log .lv { display: none; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 10px 12px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .brand small, .side .who strong { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; gap: 8px; align-items: center; }
}

/* ---- panels, tables ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel + .panel, .panel + .grid, .grid + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { text-align: left; font-weight: 600; color: var(--mute); font-size: .78rem; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--surface-2); }
.t td.num, .t th.num { text-align: right; }
.t a.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.t a.row-link:hover { text-decoration: underline; }
.empty { padding: 34px 20px; text-align: center; color: var(--mute); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

dl.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: .9rem; }
dl.kv dt { color: var(--mute); }
dl.kv dd { margin: 0; }

/* ---- chips, notices ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--mute); white-space: nowrap; line-height: 20px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.live .dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .chip.live .dot { animation: none; } * { transition: none !important; } }
.notice { display: flex; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--info-soft); color: var(--ink); font-size: .9rem; border: 1px solid var(--line); }
.notice svg { color: var(--info); margin-top: 2px; }
.notice.warn { background: var(--warn-soft); } .notice.warn svg { color: var(--warn); }
.notice.bad { background: var(--bad-soft); } .notice.bad svg { color: var(--bad); }
.notice.ok { background: var(--ok-soft); } .notice.ok svg { color: var(--ok); }
.notice + .notice { margin-top: 8px; }
.stack > * + * { margin-top: 10px; }

/* ---- buttons, fields ---- */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; min-height: 36px; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .84rem; }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--accent-ink); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.primary).busy::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea { font: inherit; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); min-width: 0; width: 100%; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled { opacity: .55; }
label.field { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; }
.hint { color: var(--mute); font-size: .84rem; font-weight: 400; margin-top: 4px; }

/* ---- choice cards (radio/checkbox) ---- */
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.choice input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.choice strong { display: block; font-weight: 600; }
.choice span.d { color: var(--mute); font-size: .86rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } }

/* ---- progress steps ---- */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.steps li:last-child { border-bottom: 0; }
.steps .state { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); color: var(--faint); }
.steps .state svg { width: 13px; height: 13px; stroke-width: 2.4; }
.steps li.running .state { border-color: var(--info); color: var(--info); }
.steps li.running .state::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--info); animation: pulse 1.4s ease-in-out infinite; }
.steps li.ok .state { border-color: var(--ok); background: var(--ok); color: #fff; }
.steps li.warn .state, .steps li.manual .state { border-color: var(--warn); color: var(--warn); }
.steps li.bad .state { border-color: var(--bad); background: var(--bad); color: #fff; }
.steps .name { font-weight: 600; }
.steps .sub { color: var(--mute); font-size: .84rem; }
.steps .stats { display: flex; gap: 16px; font-size: .84rem; color: var(--mute); flex-wrap: wrap; justify-content: flex-end; }
.steps .stats b { color: var(--ink); font-weight: 600; }
.bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s ease-out; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; color: var(--mute); background: none; border: 0; padding: 12px 12px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .n { background: var(--surface-2); border-radius: 999px; font-size: .72rem; padding: 0 7px; line-height: 18px; color: var(--mute); }

/* ---- live log ---- */
.log-tools { display: flex; gap: 8px; align-items: center; padding: 10px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.log-tools input[type=search] { max-width: 240px; padding: 6px 10px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: .84rem; font-weight: 600; background: var(--surface); color: var(--mute); border: 0; padding: 5px 11px; cursor: pointer; border-right: 1px solid var(--line-strong); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.log { background: var(--log-bg); color: var(--log-ink); font: 12.5px/1.6 var(--mono); max-height: 62vh; min-height: 200px; overflow: auto; padding: 8px 0; border-radius: 0 0 12px 12px; }
.log .ln { display: grid; grid-template-columns: 68px 54px minmax(0, 1fr); gap: 0 10px; padding: 0 14px; }
.log .ln:hover { background: rgba(255, 255, 255, .04); }
.log .t { color: var(--log-mute); }
.log .lv { color: var(--log-mute); text-transform: uppercase; font-size: 10.5px; padding-top: 1px; letter-spacing: .04em; }
.log .m { white-space: pre-wrap; word-break: break-word; }
.log .ln.warn .lv, .log .ln.warn .m { color: #f0b35c; }
.log .ln.error .lv, .log .ln.error .m { color: #ff8a80; }
.log .ln.section { margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 6px; }
.log .ln.section .m { color: #fff; font-weight: 600; }
.log mark { background: #5b4a00; color: #fff; border-radius: 2px; }
.log-empty { padding: 20px 16px; color: var(--log-mute); }

/* ---- skeleton ---- */
.sk { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sheen 1.4s linear infinite; border-radius: 6px; min-height: 14px; }
@keyframes sheen { to { background-position: -200% 0; } }

/* ---- checks (connection test) ---- */
.check { padding: 0; margin: 0; list-style: none; }
.check li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.check li:last-child { border-bottom: 0; }
.check .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); }
.check .ic svg { width: 13px; height: 13px; stroke-width: 2.4; }
.check li.ok .ic { background: var(--ok); color: #fff; }
.check li.bad .ic { background: var(--bad); color: #fff; }
.check li.warn .ic { background: var(--warn); color: #fff; }
.check .nm { font-weight: 600; }
.check .dt { color: var(--mute); font-size: .86rem; word-break: break-word; }
.check .hn { font-size: .86rem; margin-top: 4px; }
.check li.bad .hn { color: var(--bad); }
.check li.warn .hn { color: var(--warn); }
.check .ms { color: var(--faint); font-size: .8rem; }

/* ---- results ---- */
.delta.up { color: var(--bad); } .delta.down { color: var(--ok); }
.tag { font-size: .74rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--mute); }
.tag.sale { background: var(--info-soft); color: var(--info); }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-height: 280px; overflow: auto; }
.suggest button { display: block; width: 100%; text-align: left; font: inherit; border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--ink); border-bottom: 1px solid var(--line); }
.suggest button:hover, .suggest button:focus-visible { background: var(--surface-2); }
.suggest button:last-child { border-bottom: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: .84rem; }
.pill button { border: 0; background: none; cursor: pointer; color: var(--mute); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.pill button:hover { background: var(--line); color: var(--ink); }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 50; max-width: min(420px, 90vw); }

/* mobile overrides that must come after the base rules */
@media (max-width: 900px) {
  .steps .stats { justify-content: flex-start; }
}
.proxy-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin: 1rem 0; }
.proxy-fields > div { min-width: 0; }
.proxy-fields input { min-height: 2.75rem; width: 100%; font-size: 1rem; }
.proxy-save { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.proxy-save button { min-height: 2.75rem; }
@media (min-width: 768px) { .proxy-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
