:root {
  --ink: #2a231c;
  --ink-muted: #786d5c;
  --bg: #f3efe2;
  --surface: #fffdf8;
  --line: #e4dcc8;
  --accent: #520018;
  --accent-tint: #f1e1e5;
  --olive: #6b6438;
  --olive-tint: #ebe9d9;
  --danger: #a3341f;
  --danger-tint: #f5e2dc;
  --success: #5c6b2f;
  --success-tint: #ebe9d9;
  --gold: #8a6113;
  --gold-tint: #fbeecb;
  --font-display: "Prata", Georgia, "Times New Roman", serif;
  --font-body: "Questrial", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.5rem;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent);
  text-decoration: none;
}
.brand-mark { display: inline-flex; line-height: 0; }
.brand-word {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.brand-word-thin { font-weight: 400; color: var(--ink-muted); font-size: 0.85em; margin-left: 0.15em; }

.topbar nav { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.topbar .who { color: var(--ink-muted); }
.topbar a { color: var(--accent); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.3rem;
  padding: 0.55rem 1.5rem;
  background: var(--olive-tint);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}
.admin-nav a {
  color: var(--olive);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid transparent;
}
.admin-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.page { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; margin: 0 0 1.2rem; color: var(--ink); }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; margin: 2rem 0 0.8rem; color: var(--ink); }

table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; background: var(--surface); }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { color: var(--ink-muted); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }

form.inline { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1.5rem; }
form.inline label { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--ink-muted); gap: 0.25rem; }

input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

input, select, button {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button:hover { opacity: 0.92; }
button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--danger); }

/* Row-level Edit/Delete icon buttons (small bordered squares) — replaces
   plain text "Edit"/"Delete" links on the Brands, Categories, Competitors,
   Reps, and SKUs admin lists. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn-edit { border: 1px solid var(--accent); color: var(--accent); }
.icon-btn-edit:hover { background: var(--accent-tint); opacity: 1; }
.icon-btn-delete { border: 1px solid var(--danger); background: var(--danger); color: white; }
.icon-btn-delete:hover { opacity: 0.85; }
.icon-btn-row { display: inline-flex; gap: 0.4rem; align-items: center; white-space: nowrap; }

/* Categories page: subcategories collapsed by default, opened by clicking
   the category's own summary line. */
.subcat-disclosure { margin-top: 0.8rem; }
.subcat-disclosure > summary {
  cursor: pointer;
  list-style: none;
  color: var(--ink-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.subcat-disclosure > summary::-webkit-details-marker { display: none; }
.subcat-disclosure > summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}
.subcat-disclosure[open] > summary::before { transform: rotate(90deg); }
.subcat-disclosure > summary:hover { color: var(--accent); }

.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-not_started { background: var(--danger-tint); color: var(--danger); }
.pill-imported { background: var(--gold-tint); color: var(--gold); }
.pill-pwa_active { background: var(--success-tint); color: var(--success); }

/* Contact (CRM) lead-status pills — competitor contacts only. */
.pill-prospect { background: var(--gold-tint); color: var(--gold); }
.pill-contacted { background: var(--accent-tint); color: var(--accent); }
.pill-qualified { background: var(--success-tint); color: var(--success); }
.pill-not_interested { background: var(--danger-tint); color: var(--danger); }

/* Contacts admin page: the add-contact form's fields lay out in a
   responsive grid rather than wrapping unpredictably like a plain
   form.inline row, since it has more fields than most admin add-forms. */
.contact-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}
.contact-form-grid label { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--ink-muted); gap: 0.25rem; min-width: 0; }
.contact-form-grid select, .contact-form-grid input { min-width: 0; width: 100%; }
.contact-form-grid input[type="checkbox"] { width: 1.15rem; flex: none; }
.contact-form-grid label.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-start;
  align-self: end;
}
.contact-form-grid label[hidden] { display: none; }

.flashes { margin-bottom: 1.2rem; }
.flash { padding: 0.6rem 0.9rem; border-radius: 4px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash-success { background: var(--success-tint); color: var(--success); }
.flash-error { background: var(--danger-tint); color: var(--danger); }

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.9rem 1.2rem; min-width: 120px; }
.stat .n { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; }
.stat .label { font-size: 0.75rem; color: var(--ink-muted); text-transform: uppercase; }

/* Analytics: promo-mix / placement-readiness bars — a label, an inline
   track, and a count, so a 0% row still reads as "no data" rather than
   collapsing into nothing. */
.bar-row { display: grid; grid-template-columns: 11rem 1fr 3.5rem; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem; font-size: 0.88rem; }
.bar-row .bar-label { color: var(--ink); }
.bar-track { background: var(--line); border-radius: 999px; height: 0.55rem; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.bar-row .bar-count { text-align: right; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.analytics-note { font-size: 0.85rem; color: var(--ink-muted); margin: 0.4rem 0 1.1rem; }
.spread-pct { font-variant-numeric: tabular-nums; font-weight: 600; }

.login-box { max-width: 360px; margin: 4rem auto; }
.login-box form { display: flex; flex-direction: column; gap: 0.8rem; }

.build-info {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  padding: 1rem 1.5rem 1.5rem;
  font-variant-numeric: tabular-nums;
}
.build-info .build-version { color: var(--gold); font-weight: 700; }
/* Ownership notice, sitting above the build metadata: slightly larger and
   darker than the build line so it reads as a statement rather than as more
   deploy trivia. */
.build-info .copyright-line { color: var(--ink); font-size: 0.8rem; margin-bottom: 0.3rem; }

.brand-logo-thumb {
  max-height: 28px;
  max-width: 84px;
  vertical-align: middle;
  margin-right: 0.5rem;
  object-fit: contain;
}

/* Password reveal.

   The toggle sits inside the field rather than beside it so the login form
   keeps its single narrow column. It is a real <button> so it is reachable
   by keyboard and announced by screen readers, and it is explicitly
   type="button": inside a form, a button with no type defaults to submit,
   which would mean pressing Enter in the password box tried to reveal the
   password instead of signing in. */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 4rem; }
.pw-toggle {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  color: var(--ink-muted);
  border: none;
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--accent); opacity: 1; }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
