:root {
  --blue: #032489;
  --blue-dark: #02175a;
  --blue-soft: #edf2ff;
  --gold: #ffb100;
  --gold-soft: #fff5d9;
  --green: #0d8a4b;
  --red: #c43c3c;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --background: #f6f8fc;
  --shadow: 0 12px 35px rgba(16, 24, 40, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--background);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 12px clamp(16px, 4vw, 52px);
  color: white;
  background: linear-gradient(120deg, var(--blue-dark), var(--blue));
  border-bottom: 4px solid var(--gold);
}

.brand, .topbar-actions, .inline-actions, .section-heading, .table-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: var(--blue);
  background: var(--gold);
  font-weight: 900;
  font-size: 22px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}

.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; font-size: 32px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .03em; }
.brand-name strong { color: var(--gold); }
.brand-subtitle { color: rgba(255,255,255,.72); font-size: 12px; }

.page-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 24px auto 52px;
}

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

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  padding: clamp(24px, 4vw, 44px);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  bottom: -130px;
  border-radius: 50%;
  background: var(--gold-soft);
  z-index: 0;
}

.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 7px 0 12px; max-width: 800px; font-size: clamp(28px, 4vw, 48px); line-height: 1.08; }
.hero p { margin: 0; max-width: 760px; color: var(--muted); font-size: 16px; line-height: 1.65; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; min-width: max-content; }
.eyebrow { display: inline-block; color: var(--blue); font-weight: 800; font-size: 12px; letter-spacing: .12em; }

.button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 10px 17px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 8px 18px rgba(3,36,137,.2); }
.button-secondary { color: var(--blue); background: var(--blue-soft); border: 1px solid #ccd7ff; }
.button-small { min-height: 34px; padding: 7px 10px; font-size: 12px; border-radius: 9px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-muted { color: #475467; background: #f2f4f7; }
.badge-active { color: #05603a; background: #dff8eb; }
.badge-warning { color: #8b5600; background: var(--gold-soft); }
.badge-danger { color: #9b1c1c; background: #fee4e2; }
.badge-clicked { color: var(--blue); background: var(--blue-soft); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.stat-card { padding: 20px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card strong { display: block; margin: 7px 0 3px; color: var(--blue-dark); font-size: 30px; }
.stat-card small { color: #98a2b3; }
.stat-highlight { border-color: #ffdc83; background: linear-gradient(145deg, #fff, var(--gold-soft)); }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  gap: 18px;
}
.campaign-panel, .audience-panel, .leads-panel { padding: 24px; }
.section-heading { justify-content: space-between; margin-bottom: 20px; }
.section-heading h2 { margin: 4px 0 0; font-size: 23px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full-width { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 11px;
  color: var(--ink);
  background: white;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(3,36,137,.1); }
textarea { resize: vertical; line-height: 1.5; }

.message-analysis {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 18px 0;
  padding: 17px;
  border-radius: 14px;
  background: #f8f9fc;
  border: 1px solid var(--line);
}
.message-analysis span { color: var(--muted); font-size: 12px; font-weight: 700; }
.message-analysis p { margin: 7px 0 0; white-space: pre-wrap; line-height: 1.55; }
.message-numbers { min-width: 150px; text-align: right; }
.message-numbers span { display: block; margin-bottom: 5px; }

.audience-rule {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: #effbf5;
  border: 1px solid #bfefd6;
  border-radius: 14px;
}
.audience-rule.rule-excluded { background: #fff7f6; border-color: #ffd0cc; }
.rule-icon { display: grid; place-items: center; flex: 0 0 28px; height: 28px; border-radius: 50%; color: white; background: var(--green); font-weight: 900; }
.rule-excluded .rule-icon { background: var(--red); }
.audience-rule p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.audience-panel label { margin-top: 18px; }
.audience-panel .inline-actions { margin-top: 16px; }
.helper-text { color: var(--muted); font-size: 12px; line-height: 1.5; }

.leads-panel { margin-top: 18px; }
.table-heading { align-items: flex-end; }
.table-controls { width: min(100%, 520px); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8f9fc; color: #475467; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.lead-name { font-weight: 800; }
.lead-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.message-cell { max-width: 440px; white-space: pre-wrap; color: #475467; line-height: 1.45; }
.action-stack { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-state { padding: 42px; text-align: center; color: var(--muted); }

.toast {
  position: fixed;
  top: 92px;
  right: 20px;
  z-index: 100;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 12px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9b1c1c; }
.toast.success { background: #05603a; }

.hidden { display: none !important; }
.icon-button { border: 0; background: transparent; font-size: 28px; color: var(--muted); }
dialog { width: min(620px, calc(100% - 28px)); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 80px rgba(16,24,40,.25); }
dialog::backdrop { background: rgba(3, 15, 53, .55); backdrop-filter: blur(3px); }
.dialog-card { padding: 24px; }
.dialog-card p { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.import-preview { margin-top: 14px; padding: 14px; min-height: 52px; border: 1px dashed #b9c0cc; border-radius: 12px; color: var(--muted); background: #fafbfc; white-space: pre-wrap; }

.claim-page { display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #eef3ff, var(--background) 58%); }
.claim-card { width: min(520px, 100%); padding: 38px; text-align: center; border-radius: 26px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.claim-card .brand-mark { margin: 0 auto 18px; }
.claim-card h1 { margin: 9px 0 10px; font-size: 32px; }
.claim-card p { color: var(--muted); line-height: 1.6; }
.loading-bar { height: 8px; margin: 24px 0; overflow: hidden; border-radius: 999px; background: #edf0f5; }
.loading-bar span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--gold); animation: loading 1.1s infinite ease-in-out; }
@keyframes loading { from { transform: translateX(-110%); } to { transform: translateX(360%); } }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
  .page-shell { width: min(100% - 18px, 1480px); margin-top: 10px; }
  .hero { align-items: flex-start; flex-direction: column; gap: 22px; }
  .hero-actions, .hero-actions .button { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 25px; }
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .message-analysis { flex-direction: column; }
  .message-numbers { text-align: left; }
  .section-heading.table-heading { align-items: flex-start; flex-direction: column; }
  .table-controls { width: 100%; flex-direction: column; }
  .stacked-mobile { flex-direction: column; }
  .stacked-mobile .button { width: 100%; }
}
