:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-alt: #f0ece3;
  --ink: #252525;
  --muted: #6f6b63;
  --line: #ded8cc;
  --teal: #167d7f;
  --teal-dark: #0d5c5f;
  --gold: #b67818;
  --red: #b8463b;
  --green: #3f7d45;
  --shadow: 0 18px 45px rgba(40, 35, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

.app {
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto 20px;
  max-width: 1440px;
}

.eyebrow {
  color: var(--gold);
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  font-weight: 800;
}

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

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.button.primary {
  background: var(--teal);
  color: white;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.wide {
  width: 100%;
}

.workspace {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1440px;
}

.main-column,
.side-column {
  min-width: 0;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 96px;
  padding: 14px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric[data-tone="teal"] strong {
  color: var(--teal);
}

.metric[data-tone="gold"] strong {
  color: var(--gold);
}

.metric[data-tone="green"] strong {
  color: var(--green);
}

.metric[data-tone="red"] strong {
  color: var(--red);
}

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

.panel-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: space-between;
  padding: 16px;
}

.panel-header p,
.status-text {
  color: var(--muted);
  font-size: 18px;
  margin-top: 4px;
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  padding: 16px;
}

.tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  padding: 16px 16px 0;
}

.tab-button {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  min-height: 42px;
  padding: 0 12px;
}

.tab-button.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 20px;
  font-weight: 800;
  gap: 6px;
  text-transform: uppercase;
}

input,
select,
textarea {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  text-transform: none;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 125, 127, 0.16);
  outline: 0;
}

.leads-cards {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.lead-card {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

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

.lead-card-company {
  display: block;
  font-size: 16px;
  line-height: 1.3;
}

.lead-card-city {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.lead-card-meta {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}

.lead-card-meta div {
  display: grid;
  gap: 4px;
}

.lead-card-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.lead-card-meta dd {
  margin: 0;
}

.lead-card-actions {
  margin-top: 14px;
}

.lead-action-button {
  min-height: 38px;
}

.helper-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.table-wrap {
  display: none;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-size: 18px;
}

.priority {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  height: 26px;
  justify-content: center;
  line-height: 26px;
  min-width: 34px;
}

.priority-a {
  background: #ffe2de;
  color: var(--red);
}

.priority-b {
  background: #fff0cf;
  color: var(--gold);
}

.priority-c {
  background: #dff2e2;
  color: var(--green);
}

.status-pill {
  background: #edf6f6;
  border-radius: 999px;
  color: var(--teal-dark);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.form-panel form,
.import-panel form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.import-panel {
  margin-top: 16px;
}

.json-example {
  background: #fff8e8;
  border: 1px solid #ead7aa;
  border-radius: 8px;
  color: #5f4a1c;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 10px;
}

.toast {
  background: var(--ink);
  border-radius: 10px;
  bottom: 24px;
  color: white;
  left: 50%;
  max-width: min(520px, calc(100vw - 40px));
  opacity: 0;
  padding: 13px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 16px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty-state {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

@media (min-width: 720px) {
  .app {
    padding: 20px;
  }

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

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

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

  .tabs {
    padding-left: 18px;
    padding-right: 18px;
  }

  .panel-header {
    flex-direction: row;
  }

  .leads-cards {
    display: none;
  }

  .table-wrap {
    display: block;
  }
}

@media (min-width: 1100px) {
  .app {
    padding: 24px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .metrics {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
  }

  .filters {
    align-items: end;
    grid-template-columns: 180px 180px minmax(220px, 1fr);
    padding: 16px 18px;
  }

  .panel-header,
  .form-panel form,
  .import-panel form {
    padding-left: 18px;
    padding-right: 18px;
  }

  .import-panel {
    margin-top: 20px;
  }
}
