:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6d7179;
  --line: #dedede;
  --paper: #f7f4ef;
  --surface: #ffffff;
  --accent: #0b6b61;
  --accent-strong: #074842;
  --gold: #c49233;
  --rose: #b14a58;
  --danger: #a93636;
  --shadow: 0 14px 42px rgba(23, 23, 23, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  background: #151515;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: #141414;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.86rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
  text-align: left;
}

.nav-btn.active,
.nav-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.app {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.94;
  max-width: 760px;
}

h2 {
  margin-bottom: 12px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toolbar,
.hunt-builder {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(128px, 0.5fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.hunt-builder {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.4fr) minmax(140px, 0.5fr);
}

.search-runner {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 4px 12px 4px 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.check-row input {
  width: auto;
}

.runner-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.file-btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn,
.file-btn {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.danger-btn {
  background: #fff;
  color: var(--danger);
  border-color: rgba(169, 54, 54, 0.28);
}

.icon-btn {
  min-width: 42px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.lead-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.lead-card,
.panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lead-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.lead-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.lead-card h3 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.status-pill {
  align-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  background: #ece7df;
  color: #4a443a;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.score {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.score-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #ececec;
  overflow: hidden;
}

.score-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border-radius: 999px;
  padding: 5px 8px;
  background: #f0f2f1;
  color: #4c5552;
  font-size: 0.75rem;
  font-weight: 800;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.panel,
.empty-state {
  padding: 20px;
  margin-bottom: 18px;
}

.panel-head,
.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.query-list,
.match-grid,
.post-grid,
.research-links,
.search-queue,
.template-grid {
  display: grid;
  gap: 12px;
}

.query-item,
.match-card,
.post-card,
.research-link,
.queue-item,
.template-item,
.analysis-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfaf7;
}

.analysis-result {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.analysis-result:empty {
  display: none;
}

.query-item a {
  color: var(--accent);
  font-weight: 800;
  word-break: break-word;
}

.queue-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.queue-item.reviewed {
  opacity: 0.58;
}

.queue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.post-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.swipe-stage {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.swipe-card {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(23, 23, 23, 0.12);
  display: grid;
  align-content: start;
  gap: 14px;
}

.swipe-card h3 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.swipe-card a {
  color: var(--accent);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.swipe-count {
  justify-self: end;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f0f2f1;
  color: var(--muted);
  font-weight: 900;
  font-size: 0.78rem;
}

.swipe-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.post-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 0.35fr);
  gap: 12px;
  margin-bottom: 12px;
}

.post-card {
  display: grid;
  gap: 12px;
}

.match-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.match-card {
  display: grid;
  gap: 12px;
  background: #fff;
}

.match-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.match-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.post-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.post-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.post-text {
  color: #333;
  line-height: 1.55;
  white-space: pre-wrap;
}

.research-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.research-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.checklist ul {
  margin-bottom: 0;
  padding-left: 20px;
  color: #353535;
  line-height: 1.7;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-btn input {
  display: none;
}

.muted {
  color: var(--muted);
}

.empty-state {
  display: none;
  text-align: center;
}

.empty-state.active {
  display: block;
}

dialog {
  width: min(820px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.modal-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.hidden {
  display: none;
}

@media (max-width: 1040px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .lead-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 72px;
  }

  .app,
  .sidebar {
    padding: 18px;
  }

  .sidebar {
    gap: 14px;
    min-height: auto;
    padding-bottom: 10px;
  }

  .brand,
  .sidebar-card {
    display: none;
  }

  .nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 10;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(21, 21, 21, 0.96);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  }

  .nav-btn {
    min-height: 44px;
    padding: 10px 6px;
    text-align: center;
    font-size: 0.78rem;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .hunt-builder,
  .post-toolbar,
  .search-runner,
  .form-grid,
  .lead-grid,
  .match-grid,
  .research-link,
  .queue-item {
    grid-template-columns: 1fr;
  }

  .card-actions > *,
  .post-actions > *,
  .research-link > a,
  .queue-actions > * {
    flex: 1 1 100%;
    text-align: center;
  }

  .queue-actions {
    justify-content: stretch;
  }

  .swipe-card {
    min-height: 420px;
  }

  .swipe-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
