:root {
  --ink: #16181D;
  --paper: #F1F3EF;
  --panel: #FFFFFF;
  --line: #DADCD3;
  --muted: #6B6F65;
  --accent: #E2572B;
  --accent-ink: #FFFFFF;
  --good: #2E7D5B;
  --bad: #B3402A;
  --radius: 3px;
  --font-ui: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.nav-links { display: flex; gap: 22px; flex-wrap: wrap; margin-left: auto; }
.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); border-bottom-color: var(--accent); }
.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 7px;
  border-radius: var(--radius);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.brand-name { font-weight: 600; font-size: 17px; }
.brand-name b { color: var(--accent); font-weight: 600; }

.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: #F5F5F2; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #CB4A22; }
.btn-ghost { border-color: var(--line); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  max-width: 1240px;
  margin: 24px auto;
  padding: 0 20px;
  align-items: start;
}
.bulk-layout { grid-template-columns: 1.3fr 0.7fr; }
.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  font-family: var(--font-ui);
  background: none;
  border: none;
  padding: 8px 4px 12px;
  margin-right: 18px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.section-title { font-size: 17px; margin: 0 0 6px; }

/* ---------- Fields ---------- */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field span { font-weight: 500; }
.field input, .field select, .field textarea {
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #FBFBF9;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.hint.small { margin-top: 10px; }

.status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-mono);
}
.status-idle { background: #F1F1EC; color: var(--muted); }
.status-good { background: #E7F3EC; color: var(--good); border: 1px solid #C4E1CF; }
.status-bad { background: #FBEAE5; color: var(--bad); border: 1px solid #F0C5B8; }

/* ---------- Preview ---------- */
.preview-panel { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 16px; }
.preview-stage {
  background: repeating-conic-gradient(#F6F6F2 0% 25%, #EFEFE9 0% 50%) 50% / 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}

.preview-label {
  background: #fff;
  border: 1px solid #B9BBB1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  padding: 10px 12px;
  width: 260px;
  min-height: 150px;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pl-name { font-weight: 600; font-size: 13.5px; }
.pl-brand { font-size: 11px; color: var(--muted); }
.pl-price { font-weight: 700; font-size: 14px; margin-top: 3px; }
.pl-meta { font-size: 10.5px; color: var(--ink); }
.pl-origin { font-size: 10.5px; color: var(--muted); }
.pl-barcode { margin-top: auto; width: 100%; object-fit: contain; min-height: 40px; }

.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-actions .btn { flex: 1; }

/* ---------- Bulk view ---------- */
.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px;
  margin: 16px 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.dropzone.drag { border-color: var(--accent); color: var(--accent); }

.csv-result { margin-top: 10px; }
.csv-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pill { font-family: var(--font-mono); font-size: 12px; padding: 4px 10px; border-radius: 20px; }
.pill-good { background: #E7F3EC; color: var(--good); }
.pill-bad { background: #FBEAE5; color: var(--bad); }

.csv-table-wrap { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.csv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--font-mono); }
.csv-table th, .csv-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.csv-table th { background: #F6F6F2; position: sticky; top: 0; }
.row-invalid { color: var(--bad); }
.row-valid { color: var(--good); }

/* ---------- Footer ---------- */
.footer { max-width: 1240px; margin: 10px auto 40px; padding: 0 20px; color: var(--muted); font-size: 12px; }
.footer-links { margin-top: 6px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ink); }

/* ---------- Content pages (homepage, guides, templates, rules, static) ---------- */
.content-wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.content-wrap.wide { max-width: 1180px; }

.breadcrumb { font-size: 12.5px; color: var(--muted); margin: 22px 0 0; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

.hero { padding: 56px 0 40px; }
.hero h1 { font-size: 38px; line-height: 1.15; margin: 0 0 14px; max-width: 720px; }
.hero p.lede { font-size: 16.5px; color: var(--muted); max-width: 620px; margin: 0 0 26px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cta-row .btn { padding: 12px 20px; }

.section { padding: 36px 0; border-top: 1px solid var(--line); }
.section h2 { font-size: 24px; margin: 0 0 6px; }
.section p.section-lede { color: var(--muted); margin: 0 0 24px; max-width: 640px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.card:hover { border-color: var(--accent); }
.card h3 { font-size: 15.5px; margin: 0 0 6px; }
.card p { font-size: 13px; color: var(--muted); margin: 0; }
.card .card-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li {
  counter-increment: step;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 14px 52px;
  position: relative;
  background: var(--panel);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px; top: 14px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
.steps li h4 { margin: 0 0 4px; font-size: 14.5px; }
.steps li p { margin: 0; font-size: 13.5px; color: var(--muted); }

.prose { max-width: 720px; }
.prose h2 { font-size: 22px; margin: 34px 0 10px; }
.prose h3 { font-size: 17px; margin: 24px 0 8px; }
.prose p { margin: 0 0 14px; color: #2A2C27; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 20px; color: #2A2C27; }
.prose li { margin-bottom: 6px; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 13.5px; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border: 1px solid var(--line); }
.prose th { background: #F6F6F2; }

.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: #FBF9F6;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin: 0 0 22px;
}
.callout strong { display: block; margin-bottom: 3px; }

.source-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 22px;
}
.source-box b { color: var(--ink); }

.faq-item { border-top: 1px solid var(--line); padding: 16px 0; }
.faq-item:last-child { padding-bottom: 0; }
.faq-item h4 { margin: 0 0 6px; font-size: 15px; }
.faq-item p { margin: 0; color: var(--muted); font-size: 13.5px; }

.page-footer-cta {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  background: var(--panel);
  margin: 40px 0;
}
.page-footer-cta h3 { margin: 0 0 8px; font-size: 19px; }
.page-footer-cta p { color: var(--muted); margin: 0 0 16px; }

.reviewed-line { font-size: 12px; color: var(--muted); margin-top: -8px; margin-bottom: 26px; }

@media (max-width: 880px) {
  .nav-links { order: 3; width: 100%; margin-left: 0; gap: 16px; }
  .hero h1 { font-size: 28px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .layout, .bulk-layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .field-grid { grid-template-columns: 1fr; }
  .topbar { padding: 14px 16px; }
}

/* ---------- CMS additions: nav dropdowns, ads ---------- */
.nav-group { position: relative; }
.nav-sub { display: none; position: absolute; top: 100%; left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 0; min-width: 190px; z-index: 20; }
.nav-group:hover .nav-sub, .nav-group:focus-within .nav-sub { display: block; }
.nav-sub a { display: block; padding: 7px 16px; border-bottom: 0; white-space: nowrap; }
.ad-slot { max-width: 980px; margin: 18px auto; padding: 0 20px; text-align: center; overflow: hidden; }
.ad-label { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 4px; }
@media (max-width: 880px) { .ad-hide-mobile { display: none; } }
@media (min-width: 881px) { .ad-hide-desktop { display: none; } }
.maintenance { text-align: center; padding: 18vh 20px; }

/* ---- content blocks from the visual editor ---- */
.prose .alignleft { text-align: left; } .prose .aligncenter { text-align: center; } .prose .alignright { text-align: right; }
.prose img { max-width: 100%; height: auto; }
.prose blockquote { margin: 0 0 16px; padding: 4px 16px; border-left: 3px solid var(--accent); color: #3a3c36; }
.prose pre { background: #f3f4ef; padding: 12px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.callout-info { border-left-color: #2f6db5; background: #eaf1fa; } .callout-warn { border-left-color: #c58a12; background: #fbf1da; } .callout-ok { border-left-color: var(--good); background: #e4f2ea; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin: 0 0 16px; }
.tool-embed-wrap { margin: 20px 0; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); overflow: hidden; }
.tool-embed-frame { display: block; width: 100%; border: 0; min-height: 200px; }
.tool-embed-open { margin: 0; padding: 8px 12px; font-size: 12px; border-top: 1px solid var(--line); background: var(--paper); }
body.is-embed { min-height: 0 !important; background: #fff; }
body.is-embed .layout { padding-top: 12px; }
.prose:has(.tool-embed-wrap) { max-width: none; }
.prose:has(.tool-embed-wrap) > :not(.tool-embed-wrap):not(.cols):not(.card-grid):not(table) { max-width: 720px; }

/* tools directory + tool interfaces */
.dir-search { display: flex; gap: 8px; max-width: 460px; margin: 16px 0 0; }
.dir-search input[type=search] { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; min-width: 0; }
.dir-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.dir-cats .btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.empty-state { text-align: center; padding: 40px 12px; }
.dir-pager { text-align: center; margin-top: 18px; }
.tool-external { margin: 16px 0; }
.tool-interface { margin: 16px 0; }
.tool-embed-fixed { width: 100%; border: 1px solid var(--line); background: #fff; }
