:root {
  --bg: #f6f7f6;
  --panel: #ffffff;
  --ink: #18201e;
  --muted: #66716e;
  --line: #e1e5e3;
  --accent: #176b5b;
  --accent-soft: #e3f1ed;
  --added: #e4f5e8;
  --added-ink: #1d6b33;
  --removed: #fbe7e6;
  --removed-ink: #a33a33;
  --changed: #fff4d6;
  --changed-ink: #8a6100;
  --danger: #b4372f;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615;
    --panel: #19201e;
    --ink: #e6ecea;
    --muted: #93a09c;
    --line: #2b3431;
    --accent: #4fc0a7;
    --accent-soft: #1d3530;
    --added: #173222;
    --added-ink: #7fd69a;
    --removed: #3a1d1b;
    --removed-ink: #f29b93;
    --changed: #3a3015;
    --changed-ink: #f0c96a;
    --danger: #e0675d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #0b1512; } }
button.danger { background: var(--danger); border-color: var(--danger); }
button.ghost { background: transparent; }
button.small, a.button.small { padding: 4px 9px; font-size: 13px; }
a.button { border: 1px solid var(--line); border-radius: 7px; color: inherit; text-decoration: none; }
a.button:hover { border-color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; font-weight: 500; }

.shell { display: grid; grid-template-columns: 290px 1fr; grid-template-rows: auto 1fr; height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brandmark { font-weight: 700; font-size: 16px; }
.brandmark span { color: var(--accent); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.warn { background: var(--changed); color: var(--changed-ink); }
.spacer { flex: 1; }

.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 8px; }
.sidebar input[type=search] { width: 100%; }
.sort { display: flex; justify-content: space-between; align-items: center; font-size: 12px; gap: 8px; }
.sort select { padding: 3px 6px; font-size: 12px; }
.brand-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.brand-list li {
  padding: 8px 10px; border-radius: 7px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
}
.brand-list li:hover { background: var(--accent-soft); }
.brand-list li[aria-selected=true] { background: var(--accent); color: #fff; }
.brand-list li[aria-selected=true] .muted { color: rgba(255,255,255,.8); }
.brand-list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-list .meta { grid-column: 1 / -1; font-size: 12px; }
.brand-list .groups { font-size: 12px; }

.main { overflow-y: auto; padding: 20px; min-width: 0; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }
.brand-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; margin-bottom: 16px; }
.brand-head .title { flex: 1 1 260px; }
.stamp { font-size: 13px; }
.site-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.site-row input { width: min(340px, 100%); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 0; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table.chart { border-collapse: collapse; min-width: 420px; width: 100%; max-width: 760px; font-variant-numeric: tabular-nums; }
table.chart th, table.chart td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.chart th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.chart td input { width: 84px; padding: 4px 6px; }
tr.added { background: var(--added); } tr.added td:first-child { color: var(--added-ink); font-weight: 600; }
tr.removed { background: var(--removed); color: var(--removed-ink); text-decoration: line-through; }
tr.removed td:first-child, tr.removed td:last-child { text-decoration: none; }
tr.changed { background: var(--changed); }
tr.kept td { color: var(--muted); }
.mode select { padding: 4px 6px; font-size: 13px; }
.was { display: block; font-size: 11px; color: var(--changed-ink); }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

.review { margin-top: 24px; border: 2px solid var(--accent); }
.review-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
.notes { background: var(--bg); border-radius: 7px; padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; }
.warnbox { background: var(--changed); color: var(--changed-ink); border-radius: 7px; padding: 8px 12px; margin: 8px 0; }
.problems { color: var(--danger); margin: 8px 0; padding-left: 18px; }
.group-review { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.group-review .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.summary { font-size: 13px; }
.summary b.add { color: var(--added-ink); } .summary b.rem { color: var(--removed-ink); } .summary b.chg { color: var(--changed-ink); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.crawl-log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 10px; border-radius: 7px; max-height: 220px; overflow: auto; white-space: pre-wrap; }

.history { margin-top: 28px; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); margin-top: 12px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { max-width: 100%; max-height: 260px; border-radius: 6px; margin-top: 8px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { border: none; padding: 0; background: transparent; max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: calc(100vw - 32px); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; min-height: 100vh; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .main { padding: 16px; }
}

.pending-badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--changed); color: var(--changed-ink); align-self: center; white-space: nowrap; }
.brand-list li[aria-selected=true] .pending-badge { background: #fff; }
#queue-btn.has-pending { background: var(--changed); color: var(--changed-ink); border-color: var(--changed-ink); font-weight: 600; }
.card.proposal { border: 2px solid var(--changed-ink); margin: 0 0 12px; }
.card.proposal h3 .badge { margin-left: 6px; vertical-align: 1px; }
.card.proposal p { margin: 6px 0; }
.danger-text { color: var(--danger); }
table.queue td { vertical-align: middle; }
