:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #0e1726;
  --ink-2: #4b5565;
  --muted: #8b94a3;
  --line: #e5e8ee;
  --accent: #ff7a1a;
  --accent-ink: #ffffff;
  --ok: #1f8a4c;
  --err: #b6341a;
  --warn: #c47b00;
  --working: #2f5fd1;
  --shadow: 0 1px 2px rgba(14,23,38,.06), 0 8px 24px rgba(14,23,38,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 5;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { font-weight: 700; letter-spacing: .02em; }
.link-admin {
  color: #cbd2db; text-decoration: none; font-size: 14px;
  border: 1px solid #2c3a52; padding: 6px 10px; border-radius: 6px;
}
.link-admin:hover { color: #fff; border-color: #44546f; }

.container {
  max-width: 560px; margin: 0 auto; padding: 16px;
}
.container.wide { max-width: 1200px; }

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

/* ---------- capture page ---------- */

.field { display: block; margin-bottom: 10px; }
.field > span {
  display: block; font-size: 12px; color: var(--ink-2);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em;
}
.field input, .field textarea, .filter-bar input, .filter-bar select {
  width: 100%;
  font: inherit;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.capture-zone { margin: 18px 0; }
.big-btn {
  display: block; width: 100%; padding: 28px 20px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 14px; text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.big-btn:active { transform: translateY(1px); }
.cam-icon { display: block; font-size: 38px; line-height: 1; margin-bottom: 8px; }
.big-btn-text { display: block; font-size: 19px; font-weight: 700; }
.big-btn-sub { display: block; font-size: 13px; opacity: .85; margin-top: 4px; }

.status {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.status.working { background: #eef3ff; border-color: #c8d6ff; color: var(--working); }
.status.ok      { background: #eaf6ee; border-color: #c4e5cf; color: var(--ok); }
.status.err     { background: #fdecea; border-color: #f3c1b8; color: var(--err); }

.thumb-wrap { text-align: center; margin: 0 -4px 12px; }
.thumb-wrap img { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); }

.price-block {
  margin: 14px -4px 4px;
  padding: 14px;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.price-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-2); margin-bottom: 4px;
}
.price-value {
  font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.2;
}
.price-value.muted { color: var(--ink-2); font-size: 16px; font-weight: 500; }
.price-value.err   { color: var(--err); font-size: 16px; font-weight: 500; }
.price-meta { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.price-sources { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.price-sources li {
  padding: 4px 0; border-top: 1px dashed var(--line);
  display: flex; gap: 8px; align-items: baseline;
}
.price-sources li:first-child { border-top: 0; }
.src-price { font-weight: 600; color: var(--ink); min-width: 70px; }
.src-cond {
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: #fff5e0; color: var(--warn); border: 1px solid #ffe1a3;
  text-transform: uppercase; letter-spacing: .04em;
}
.price-sources a { color: var(--working); text-decoration: none; }
.price-sources a:hover { text-decoration: underline; }
button.small { padding: 6px 10px; font-size: 13px; margin-top: 8px; }

.row-actions { display: flex; gap: 10px; margin-top: 12px; }
button, .csv-import {
  font: inherit; cursor: pointer;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
button.primary, .filter-actions a.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  font-weight: 600;
}
button.primary:disabled { opacity: .55; cursor: default; }
button.ghost, .filter-actions a.ghost, label.ghost {
  background: #fff; color: var(--ink-2);
}
button.danger {
  background: #fff; color: var(--err); border-color: #f3c1b8;
}

.recent { margin-top: 22px; }
.recent h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 0 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.recent-list li.empty { color: var(--muted); text-align: center; }
.recent-title { font-weight: 600; }
.recent-sub { font-size: 13px; color: var(--ink-2); }

.hidden { display: none !important; }

/* ---------- admin ---------- */

.filter-bar { padding: 12px 14px; }
.filter-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.filter-row #q { flex: 2 1 280px; }
.filter-row #siteFilter { flex: 1 1 200px; }
.filter-row .check { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; }
.filter-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-actions a { text-decoration: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; }
.filter-actions a.ghost { color: var(--ink-2); }
.bulk-status { margin-top: 10px; padding: 8px 10px; background: #eef3ff; color: var(--working); border-radius: 6px; font-size: 14px; }

.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid th { background: #fafbfd; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.grid td.num, .grid th.num { text-align: right; white-space: nowrap; }
.grid td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--ink-2); }
.grid td.empty { text-align: center; color: var(--muted); padding: 30px; }
.grid td.err { text-align: center; color: var(--err); padding: 30px; }
.thumb-sm { height: 36px; width: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.row-btn { padding: 6px 10px; font-size: 13px; margin-right: 4px; }
.row-btn.research { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; margin-left: 4px; }
.tag.override { background: #fff5e0; color: var(--warn); border: 1px solid #ffe1a3; }
.muted { color: var(--muted); }

.drawer {
  position: fixed; inset: 0; background: rgba(14,23,38,.45);
  display: flex; justify-content: flex-end; z-index: 50;
}
.drawer-inner {
  width: 520px; max-width: 100%;
  background: #fff; height: 100%;
  overflow: auto; padding: 20px 24px 80px;
  position: relative;
}
.drawer-close {
  position: absolute; top: 10px; right: 14px;
  background: transparent; border: 0; font-size: 28px; line-height: 1;
  color: var(--ink-2); cursor: pointer;
}
.thumb-lg { max-width: 100%; max-height: 280px; border-radius: 6px; border: 1px solid var(--line); margin: 8px 0 14px; display: block; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 16px; }
.kv { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.kv input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-top: 4px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.kv input.saved { background: #eaf6ee; }
.cand-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.cand-table th, .cand-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.cand-table .num { text-align: right; white-space: nowrap; }
.drawer-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .grid th:nth-child(6), .grid td:nth-child(6),
  .grid th:nth-child(8), .grid td:nth-child(8) { display: none; }
  .drawer-inner { width: 100%; }
}
