:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --navy: #0b1f3a;
  --gold: #c8962d;
  --green: #0f766e;
  --red: #b42318;
  --amber: #b7791f;
  --blue: #1167a8;
  --shadow: 0 12px 28px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 13px;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

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

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.login {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #111111, #0b1f3a 70%, #3a270c);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card button {
  width: 100%;
  margin-top: 12px;
  background: var(--gold);
  color: #111;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  background: #111;
  color: #fff;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 24px;
}

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

.status-pill,
.tier {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef2f7;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.status-pill {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 14px;
  width: min(1500px, calc(100% - 24px));
  margin: 14px auto;
}

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

.sidebar {
  align-self: start;
  overflow: hidden;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metrics div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metrics strong {
  font-size: 24px;
  color: var(--navy);
}

.filters {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.lead-list {
  max-height: calc(100vh - 236px);
  overflow: auto;
}

.lead-empty {
  padding: 18px;
}

.lead-empty h3 {
  margin-bottom: 6px;
  color: var(--navy);
}

.lead-empty p {
  margin-bottom: 0;
  color: var(--muted);
}

.lead-item {
  width: 100%;
  border-bottom: 1px solid #edf1f6;
  background: #fff;
  color: var(--ink);
  text-align: left;
  border-radius: 0;
  padding: 13px;
}

.lead-item.active {
  background: #f8f1df;
}

.lead-item h3 {
  margin-bottom: 5px;
  color: var(--navy);
  font-size: 15px;
}

.lead-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 500;
}

.lead-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
}

.tier.a {
  background: #dcfce7;
  color: #166534;
}

.tier.b {
  background: #dbeafe;
  color: #1d4ed8;
}

.tier.c {
  background: #fef3c7;
  color: #92400e;
}

.tier.d {
  background: #fee2e2;
  color: #991b1b;
}

.detail {
  min-height: calc(100vh - 116px);
  padding: 18px;
}

.empty {
  display: grid;
  min-height: 420px;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.tier-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.tier-row strong {
  font-size: 30px;
  color: var(--navy);
}

.detail-head h2 {
  margin-bottom: 6px;
}

.detail-head p {
  color: var(--muted);
}

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

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--navy);
  font-weight: 800;
  text-decoration: none;
}

.ghost-link.disabled {
  color: var(--muted);
  pointer-events: none;
}

.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  padding: 16px;
}

.card h3 {
  color: var(--navy);
  margin-bottom: 10px;
}

.card h4 {
  margin: 15px 0 8px;
  color: #354052;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin-bottom: 6px;
}

.send-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.send-row button {
  background: var(--gold);
  color: #111;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.messages {
  display: grid;
  gap: 9px;
}

.message {
  max-width: 820px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f2f5f9;
  white-space: pre-wrap;
}

.message.out {
  margin-left: auto;
  background: #e8f6f3;
}

.message small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: 360px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
}

.manual-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 18px;
}

.manual-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.manual-head h2 {
  margin-bottom: 0;
}

.icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.manual-form {
  display: grid;
  gap: 14px;
}

.manual-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

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

.manual-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

@media (max-width: 980px) {
  .topbar,
  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .cards {
    grid-template-columns: 1fr;
  }

  .lead-list {
    max-height: 420px;
  }
}

@media (max-width: 560px) {
  .layout {
    width: calc(100% - 14px);
  }

  .topbar {
    padding: 14px;
  }

  .filters,
  .send-row,
  .form-grid,
  .detail-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .manual-actions {
    flex-direction: column;
  }
}
