:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --surface: #ffffff;
  --page: #f5f7fb;
  --primary: #2457d6;
  --accent: #7c3aed;
  --success: #16803b;
  --danger: #c2413b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

.app-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px max(24px, calc((100vw - 1180px) / 2));
  background: #10182c;
  color: #fff;
}

.app-header h1, .workspace h2, .dialog-head h2 { margin: 3px 0 0; }
.app-header h1 { font-size: 24px; }
.app-header nav { display: flex; gap: 8px; }
.eyebrow { font-size: 10px; letter-spacing: .16em; color: #94a8db; font-weight: 700; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 56px; }

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(16, 24, 44, .04);
}

.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 5px; font-size: 27px; }

.workspace {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(16, 24, 44, .05);
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
}

.workspace-head h2 { font-size: 20px; }
.workspace-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px;
  gap: 12px;
  padding: 0 24px 18px;
}

label { display: flex; flex-direction: column; gap: 6px; color: #4b5563; font-size: 12px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d8dce5;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input, select { height: 40px; padding: 0 11px; }
textarea { resize: vertical; padding: 10px 11px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 87, 214, .1); }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}
.button.primary { background: var(--primary); color: #fff; }
.button.accent { background: var(--accent); color: #fff; }
.button.secondary { background: #eef2ff; color: #24469c; }
.app-header .button.secondary { background: rgba(255,255,255,.12); color: #fff; }
.button.ghost { background: transparent; color: #c8d2e8; }
.button:disabled { cursor: not-allowed; opacity: .45; }

.lead-list { border-top: 1px solid var(--line); }
.lead-card {
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) minmax(210px, 1fr) 150px 180px;
  align-items: center;
  gap: 18px;
  padding: 17px 24px;
  border-bottom: 1px solid var(--line);
}
.lead-card:hover { background: #fafbfe; }
.lead-name { margin: 0 0 6px; font-size: 15px; }
.lead-address { color: var(--muted); font-size: 12px; line-height: 1.5; }
.meta-line { margin-top: 5px; color: #64748b; font-size: 12px; }
.phone-link { color: #1d4ed8; font-weight: 700; text-decoration: none; }
.phone-missing { color: #9ca3af; font-size: 12px; }
.eligibility { display: inline-flex; padding: 3px 7px; border-radius: 99px; background: #ecfdf3; color: var(--success); font-size: 11px; font-weight: 700; }
.lead-card select { height: 36px; }
.card-actions { display: flex; justify-content: flex-end; gap: 7px; }

.empty-state { padding: 64px 24px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 17px; }
.pagination span { color: var(--muted); font-size: 13px; }

dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(7, 12, 25, .58); backdrop-filter: blur(2px); }
.dialog-shell { margin: 0; }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.dialog-head h2 { font-size: 19px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f1f3f7; cursor: pointer; font-size: 24px; }
.dialog-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.full-width { grid-column: 1 / -1; }
.form-actions { align-items: flex-end; }
.form-actions .button { min-width: 120px; }
.call-section, .history-section { margin-top: 25px; padding-top: 21px; border-top: 1px solid var(--line); }
.call-section h3, .history-section h3 { margin: 0 0 15px; font-size: 16px; }
.history-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.history-note { margin: 7px 0 0; color: #374151; line-height: 1.6; white-space: pre-wrap; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 9px;
  background: #172033;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  font-size: 13px;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .lead-card { grid-template-columns: 1fr 160px; }
  .lead-contact { order: 3; }
  .card-actions { order: 4; }
}

@media (max-width: 560px) {
  .app-header { padding: 15px 16px; }
  .app-header h1 { font-size: 19px; }
  .app-header .button { padding: 0 10px; }
  main { padding: 16px 10px 40px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 13px; }
  .filters { grid-template-columns: 1fr; padding: 0 15px 15px; }
  .workspace-head { padding: 18px 15px 14px; }
  .lead-card { grid-template-columns: 1fr; gap: 11px; padding: 16px 15px; }
  .lead-contact, .card-actions { order: initial; }
  .card-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .dialog-body { padding: 18px 15px; }
}
