:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --line: #dce3e5;
  --text: #172124;
  --muted: #647276;
  --brand: #cf3f4a;
  --brand-dark: #a82f38;
  --accent: #167a72;
  --warning: #8a5a12;
  --shadow: 0 18px 48px rgba(27, 43, 47, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: #b8c6ca;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.ghost {
  background: transparent;
}

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

textarea {
  min-height: 76px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(207, 63, 74, 0.09), rgba(22, 122, 114, 0.12)),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 28px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 16px;
}

.message {
  min-height: 20px;
  color: var(--brand-dark);
  font-size: 13px;
}

.error {
  color: var(--brand-dark);
}

.app {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: #edf3f3;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.notice {
  margin-bottom: 16px;
  border: 1px solid #e8cf99;
  border-radius: 8px;
  background: #fff8e7;
  color: var(--warning);
  padding: 12px 14px;
}

.view {
  display: grid;
  gap: 16px;
}

.toolbar,
.collect-grid,
.user-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.collect-grid {
  grid-template-columns: 2fr repeat(4, minmax(120px, 1fr));
}

.user-form {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.wide {
  grid-column: span 2;
}

.summary-strip,
.result-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.7;
}

.lead-list {
  display: grid;
  gap: 12px;
}

.lead-card {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.95fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.lead-main {
  display: grid;
  gap: 12px;
}

.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.comment-text {
  font-size: 16px;
  line-height: 1.65;
  word-break: break-word;
}

.note-title {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.lead-actions {
  display: grid;
  gap: 10px;
  align-content: start;
}

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

.status-new {
  background: #edf3f3;
  color: #506166;
}

.status-contacted {
  background: #e8f3f0;
  color: var(--accent);
}

.status-invalid {
  background: #f0eeee;
  color: #77706d;
}

.status-converted {
  background: #fdecee;
  color: var(--brand-dark);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.two-column > section,
.table-like {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.table-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 0.7fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row.header {
  color: var(--text);
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

@media (max-width: 920px) {
  .app {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .collect-grid,
  .user-form,
  .lead-card,
  .two-column,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .tabs {
    overflow-x: auto;
  }
}
