:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --dim: #6b7280;
  --line: #e5e7eb;
  --accent: #2f6df0;
  --ok: #137a4b;
  --ok-bg: #e6f4ec;
  --warn: #9a6500;
  --warn-bg: #fbf0d9;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --lock-bg: #ece8fd;
  --lock: #5b3fd6;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 10px; }

.loading { padding: 64px; text-align: center; color: var(--dim); }
.error-box { background: var(--bad-bg); color: var(--bad); padding: 12px 14px; border-radius: var(--radius); margin: 12px 0; }
.ok-box { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: var(--radius); margin: 10px 0; }
.dim { color: var(--dim); }
.bad { color: var(--bad); }
.strong { font-weight: 600; }
.count { color: var(--dim); font-weight: 400; font-size: 16px; }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 24px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; }
.brand span { color: var(--accent); }
.brand-lg { font-size: 24px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-tab { padding: 7px 14px; border-radius: 8px; color: var(--dim); font-weight: 600; }
.nav-tab:hover { background: var(--bg); text-decoration: none; }
.nav-tab.active { background: var(--accent); color: #fff; }
.session { display: flex; align-items: center; gap: 12px; }
.session-exp { color: var(--dim); font-size: 12px; }

.content { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }

/* ── buttons ── */
.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2257c9; }
.btn-ghost { border-color: transparent; color: var(--dim); }

/* ── login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 340px; box-shadow: 0 6px 30px rgba(0,0,0,.05); display: flex; flex-direction: column; gap: 12px; }
.login-sub { color: var(--dim); margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-note { color: var(--dim); font-size: 12px; margin: 4px 0 0; text-align: center; }

/* ── stat grid ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-val { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--dim); font-size: 12px; margin-top: 2px; }
.stat.ok .stat-val { color: var(--ok); }
.stat.warn .stat-val { color: var(--warn); }
.stat.muted .stat-val { color: var(--dim); }

.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
table.kv td:last-child { text-align: right; font-weight: 600; }

/* ── grid tables ── */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th { text-align: left; font-size: 12px; color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid.small td, table.grid.small th { padding: 7px 10px; font-size: 13px; }
.row-click { cursor: pointer; }
.row-click:hover { background: #f3f6fd; }

.logo, .thumb { width: 34px; height: 34px; border-radius: 7px; object-fit: contain; background: #fff; border: 1px solid var(--line); display: inline-block; }
.thumb { object-fit: cover; }
.logo-empty, .thumb-empty { background: repeating-linear-gradient(45deg, #f0f1f3, #f0f1f3 6px, #e7e9ec 6px, #e7e9ec 12px); }
.logo-sm { width: 22px; height: 22px; vertical-align: middle; }
.thumb-lg { width: 100%; height: 220px; border-radius: var(--radius); }

/* ── badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-lock { background: var(--lock-bg); color: var(--lock); }
.badge-muted { background: #eef0f2; color: var(--dim); }
.badge-soft { background: #eef6ff; color: var(--accent); }

/* ── filters ── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input, .filters select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.filters input[name="q"] { min-width: 220px; }
.pager { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

/* ── detail ── */
.back { display: inline-block; margin-bottom: 14px; color: var(--dim); font-weight: 600; }
.detail { display: grid; grid-template-columns: 360px 1fr; gap: 28px; align-items: start; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery-img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.gallery-img:not(:first-child) { width: calc(50% - 4px); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.field-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .03em; }
.field-val { font-weight: 500; word-break: break-word; }
.editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 8px; }
.editor label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.editor label.check { flex-direction: row; align-items: center; gap: 8px; }
.editor select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; max-width: 280px; }
.editor-note { color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; font-size: 12px; margin: 0 0 14px; }
.editor-actions { display: flex; align-items: center; gap: 12px; }
.err-inline { color: var(--bad); font-size: 13px; }

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; }
  .panel-row { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
}
