:root {
  font-family: "Inter", "Liberation Sans", Arial, sans-serif;
  color: #1c2624;
  background: #f4f2ec;
  --ink: #1c2624;
  --muted: #4d5c58;
  --line: #cfd6d2;
  --forest: #16302b;
  --forest-mid: #234740;
  --surface: #ffffff;
  --accent: #a84410;
  --accent-hover: #8f380c;
  --wa: #14532d;
  --wa-hover: #166534;
  --radius: 3px;
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: #175246; text-underline-offset: 3px; }
button, a[href], select, summary, input[type="checkbox"] { cursor: pointer; }
:focus-visible { outline: 3px solid #a84410; outline-offset: 2px; }
[hidden] { display: none !important; }
button:disabled, input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

.site-header {
  background: var(--forest);
  border-top: 4px solid var(--accent);
  color: #ffffff;
}
.header-inner {
  max-width: 1480px;
  margin: auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand-name {
  display: block;
  font-size: clamp(19px, 2vw, 23px);
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.1;
}
.brand-name > span { color: #f2b483; margin-left: 5px; }
.brand-sub {
  display: block;
  font-size: 10px;
  letter-spacing: 1.2px;
  color: #d6e2df;
  margin-top: 5px;
}
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.container {
  max-width: 1480px;
  margin: auto;
  padding: 22px 24px 32px;
}
.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 28px);
  letter-spacing: -0.5px;
  line-height: 1.2;
}
h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}
.subhead { font-size: 14px; margin: 0 0 6px; color: var(--ink); }
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 74ch;
}

button, .btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid #9eb0aa;
  border-radius: var(--radius);
  padding: 9px 14px;
  min-height: 40px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
button:hover:not(:disabled), .btn-link:hover { background: #eaece7; border-color: #6b807a; }
.btn-primary, .btn-link-accent {
  background: var(--accent);
  color: #ffffff;
  border-color: #823209;
}
.btn-primary:hover:not(:disabled), .btn-link-accent:hover { background: var(--accent-hover); border-color: #6b2907; }
.btn-quiet { background: transparent; border-color: #aebcb7; color: var(--forest); }
.btn-compact { min-height: 34px; padding: 5px 10px; font-size: 12px; }
.btn-danger { color: #8c1d18; background: #fdeceb; border-color: #cc8b87; }
.btn-danger:hover:not(:disabled) { background: #f9d8d5; }

.banner {
  border-radius: var(--radius);
  padding: 11px 15px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
}
.banner-error { background: #fdeceb; color: #8c1d18; border: 1px solid #d49087; border-left: 4px solid #8c1d18; }
.banner-ok { background: #e8f5ee; color: #14532d; border: 1px solid #95c5a7; border-left: 4px solid #14532d; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--forest-mid);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.kpi-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid #dfe5e2;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  margin-bottom: -2px;
  color: var(--muted);
  padding: 9px 12px;
  min-height: 40px;
}
.tab-btn[aria-selected="true"] {
  color: var(--forest);
  border-bottom-color: var(--accent);
}

label {
  display: grid;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #2f423d;
  min-width: 0;
}
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #a8b7b2;
  border-radius: var(--radius);
  background: #faf9f6;
  color: var(--ink);
  padding: 8px 10px;
  min-height: 38px;
  font-size: 13px;
}
textarea { resize: vertical; line-height: 1.45; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.full-span { grid-column: 1 / -1; }
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--ink);
}
.check-row input { width: 18px; height: 18px; min-height: 18px; flex-shrink: 0; accent-color: var(--forest); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.query-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #faf9f6;
  border-radius: var(--radius);
  padding: 12px;
}
.query-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.query-box pre {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.manual-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.template-box { display: flex; flex-direction: column; gap: 10px; }
.preview-card {
  background: #f4f7f5;
  border: 1px solid #c7d6ce;
  border-left: 3px solid var(--wa);
  padding: 10px 12px;
  border-radius: var(--radius);
}
.preview-card p { margin: 5px 0 0; font-size: 12px; white-space: pre-wrap; word-break: break-word; }

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 410px;
  overflow-y: auto;
}
.job-card {
  border: 1px solid var(--line);
  background: #faf9f6;
  border-radius: var(--radius);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.job-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.job-name { font-weight: 700; font-size: 13px; color: var(--ink); word-break: break-word; }
.job-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 2px;
  background: #dfe7e4;
  color: var(--forest);
  flex-shrink: 0;
}
.job-badge.status-running { background: #fce4d4; color: #7c2d08; }
.job-badge.status-completed { background: #dff2e7; color: #14532d; }
.job-badge.status-paused { background: #e8e5dc; color: #4a4435; }
.job-badge.status-cancelled { background: #f0e4e4; color: #7a2622; }
.job-badge.status-failed { background: #fdeceb; color: #8c1d18; }
.progress-track {
  width: 100%;
  height: 7px;
  background: #dfe5e2;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--forest);
  transition: width 0.2s;
}
.job-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-bar { margin-bottom: 16px; padding: 14px 18px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.count-badge {
  background: var(--forest);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 860px; }
thead th {
  background: var(--forest);
  color: #ffffff;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  padding: 11px 12px;
  letter-spacing: 0.3px;
}
tbody td {
  padding: 12px;
  border-top: 1px solid #e3e8e5;
  vertical-align: top;
  font-size: 13px;
}
tbody tr:nth-child(even) { background: #fafaf8; }
tbody tr.status-contacted, tbody tr.status-interested { background: #f2f9f4; }
tbody tr.status-active_shipper { background: #edf5fb; }
tbody tr.status-opted_out { opacity: 0.72; }

.biz-name { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.meta { font-size: 12px; color: var(--muted); }
.biz-address { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; }

.score-pill {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 2px;
  background: #e5ebe8;
  color: var(--ink);
}
.score-high { background: #dff2e7; color: #14532d; }
.score-medium { background: #fce7d6; color: #7c2d08; }
.score-reasons {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.contact-list { display: flex; flex-direction: column; gap: 9px; }
.contact-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.contact-num { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--wa);
  color: #ffffff;
  border: 1px solid #0e3d21;
  border-radius: var(--radius);
  padding: 7px 12px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.wa-btn:hover { background: var(--wa-hover); }
.opted-out-tag {
  font-size: 11px;
  font-weight: 700;
  color: #8c1d18;
  background: #fdeceb;
  padding: 3px 7px;
  border-radius: 2px;
}
.review-tag {
  display: inline-block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #7c2d08;
  background: #fce7d6;
  padding: 2px 7px;
  border-radius: 2px;
}
.competitor-tag {
  display: inline-block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #1e3a5f;
  background: #dbeafe;
  padding: 2px 7px;
  border-radius: 2px;
}

.ms-stack { display: flex; flex-direction: column; gap: 12px; }
.ms-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0;
  min-width: 0;
}
.ms-fieldset legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--forest);
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-legend-actions { display: inline-flex; gap: 6px; }
.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.chip-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  background: #faf9f6;
  border: 1px solid #d5ddd9;
  border-radius: var(--radius);
  padding: 5px 8px;
}
.chip-check input { width: 16px; height: 16px; min-height: 16px; flex-shrink: 0; }
.cat-tree {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.cat-group {
  border: 1px solid #dfe5e2;
  border-radius: var(--radius);
  background: #faf9f6;
  padding: 6px 8px;
}
.cat-group summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--forest);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-toggles { display: flex; flex-direction: column; gap: 6px; }
.detail-drawer { margin-top: 16px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.detail-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf9f6;
  padding: 10px 12px;
  font-size: 12px;
}
.detail-card h3 { margin: 0 0 6px; font-size: 13px; color: var(--forest); }
.detail-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 5px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

.source-link { display: block; font-size: 12px; word-break: break-all; margin-top: 3px; }
.outreach-stack { display: flex; flex-direction: column; gap: 7px; }
.note-row { display: flex; gap: 6px; }
.note-row input { min-height: 34px; padding: 5px 8px; font-size: 12px; }
.empty-cell { text-align: center; padding: 28px 16px; color: var(--muted); }

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.site-footer > span:first-child { font-weight: 700; color: var(--forest); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media (max-width: 1080px) {
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .console-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .manual-split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .header-inner { padding: 14px 14px; }
  .container { padding: 16px 12px 24px; }
  .intro-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .filter-grid { grid-template-columns: 1fr; }
  button, .btn-link, .wa-btn, .btn-compact { min-height: 44px; }
  .header-actions { width: 100%; }
  .header-actions a { flex: 1 1 auto; }
  .wa-btn { width: 100%; }
  .note-row { flex-direction: column; }
  .table-wrap { overflow: visible; background: transparent; border: 0; }
  table, tbody { display: block; width: 100%; min-width: 0; }
  thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
  }
  tbody td { display: block; border: 0; padding: 0; }
}

.auth-gate { max-width: 440px; margin: 48px auto; padding: 0 16px; }
.auth-card { padding: 24px; }
.auth-card h1 { font-size: 1.35rem; margin: 0 0 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
