:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5e6b77;
  --line: #d9e0e7;
  --paper: #ffffff;
  --wash: #f4f7f9;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

h3 {
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.stats span,
.tag-list span,
.reply-status,
.alert-status,
.telegram-status,
.intake-status,
.manual-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.alert-status {
  border-color: #f2c076;
  background: #fff8eb;
  color: #7c4a03;
}

.telegram-status {
  border-color: #9cc4f5;
  background: #eef6ff;
  color: #1d4f8f;
}

.intake-status {
  border-color: #b8d6c5;
  background: #effaf3;
  color: #27613d;
}

.manual-status {
  border-color: var(--line);
  background: #f7f8fa;
  color: var(--muted);
}

.stats strong {
  color: var(--ink);
}

.notice {
  border: 1px solid #f2c076;
  border-radius: 8px;
  background: #fff8eb;
  padding: 12px 14px;
  color: #7c4a03;
}

.workspace,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 20px;
  box-shadow: 0 8px 26px rgba(23, 33, 43, 0.06);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

select,
input,
textarea,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
  background: var(--paper);
}

input {
  width: 100%;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 220px;
  padding: 14px;
  color: var(--ink);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

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

.notes-field {
  display: block;
  margin-top: 12px;
}

.notes-field textarea {
  min-height: 96px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

button {
  min-height: 44px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.compact-button {
  min-height: 38px;
  padding: 0 12px;
}

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

.status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-bar,
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-bar {
  margin-bottom: 14px;
}

.filter-bar a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: capitalize;
}

.filter-bar a.active,
button.active {
  border-color: var(--accent);
  background: #eef8f6;
  color: var(--accent-dark);
}

.dashboard {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading p {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--muted);
}

.lead-list,
.preview {
  display: grid;
  gap: 10px;
}

.lead-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 12px;
  text-decoration: none;
}

.lead-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.lead-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.row-statuses {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.score {
  display: inline-grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 900;
}

.score-hot {
  background: var(--danger);
}

.score-warm {
  background: var(--warn);
}

.score-cold {
  background: var(--muted);
}

.preview {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef8f6;
  padding: 14px;
}

.preview-row {
  box-shadow: none;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 22px;
  color: var(--muted);
}

.back-link {
  display: inline-block;
  margin-bottom: 22px;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.detail .topbar {
  align-items: center;
}

.jumbo {
  width: 86px;
  font-size: 1.7rem;
}

.fields {
  display: grid;
  gap: 12px;
  margin: 0;
}

.fields div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
}

.reply {
  margin-bottom: 0;
  font-size: 1.06rem;
  line-height: 1.55;
}

.status-actions {
  margin-bottom: 12px;
}

.status-actions button {
  text-transform: capitalize;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  color: #26323d;
  font: inherit;
  line-height: 1.55;
}

.reasons {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

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

.alert-events {
  margin-top: 18px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.event-row span,
.event-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.event-row p {
  margin: 10px 0 0;
  color: var(--warn);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(100%, 460px);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 2rem;
  line-height: 1.05;
}

.login-panel button {
  width: 100%;
  margin-top: 14px;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

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

  .workspace,
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

  .lead-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .row-statuses {
    grid-column: 2;
    justify-content: flex-start;
  }

  .compact {
    order: -1;
  }
}
