:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f3ed;
  color: #111827;
  --navy: #0d2a4c;
  --navy-2: #123a6f;
  --orange: #f68b1f;
  --orange-2: #e67e1a;
  --yellow: #f1b800;
  --green: #166534;
  --green-2: #15803d;
  --gold: #f68b1f;
  --red: #b42318;
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --surface: #ffffff;
  --surface-2: #f5f3ed;
  --shadow: 0 18px 44px rgba(13, 42, 76, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 42, 76, 0.09), rgba(246, 139, 31, 0.11)),
    var(--surface-2);
}

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

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(14px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar > div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 42px;
  flex: 0 0 58px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(13, 42, 76, 0.12);
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(13, 42, 76, 0.12);
}

.brand-mark img {
  width: 50px;
  height: auto;
}

.brand-mark.large {
  width: 88px;
  height: 64px;
  margin-bottom: 14px;
}

.brand-mark.large img {
  width: 78px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
}

h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 0.98rem;
}

.topbar .account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.topbar select {
  width: min(45vw, 210px);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.api-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.api-pill.online {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.api-pill.offline {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.app-layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px clamp(12px, 3vw, 28px) 92px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab.active {
  background: var(--navy);
  color: #fff;
}

.command-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: var(--shadow);
}

.command-band h2 {
  margin-bottom: 5px;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
}

.command-band p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
}

.command-band .eyebrow {
  color: var(--orange);
}

.command-chip {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat,
.lead-list,
.lead-detail,
.simulator,
.activity-view,
.preview-box,
.answers,
.conversation,
.activity-grid > section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 14px;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--orange);
}

.stat strong {
  display: block;
  font-size: 1.55rem;
  color: var(--navy);
}

.stat span,
small {
  color: var(--muted);
}

.split-view {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 14px;
  min-width: 0;
}

.lead-list,
.lead-detail,
.simulator,
.activity-view {
  min-width: 0;
  padding: 14px;
}

.section-head,
.detail-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lead-card {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lead-card.selected {
  border-color: var(--orange);
  box-shadow: inset 3px 0 0 var(--orange);
}

.lead-card-main,
.lead-card-side {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.lead-card-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-card-side {
  align-items: flex-end;
  flex: 0 0 auto;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.new {
  background: #fef3c7;
  color: #92400e;
}

.status.assigned,
.status.contacted {
  background: #dcfce7;
  color: #166534;
}

.status.quotation-required,
.status.follow-up {
  background: #dbeafe;
  color: #1d4ed8;
}

.status.won {
  background: #bbf7d0;
  color: #14532d;
}

.status.lost {
  background: #fee2e2;
  color: #991b1b;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 800;
}

.primary-button {
  padding: 0 16px;
  background: var(--orange);
  color: #fff;
}

.secondary-button {
  padding: 0 16px;
  background: #fff;
  color: var(--navy);
  border-color: var(--navy);
}

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

.error-banner {
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 750;
}

.icon-button {
  width: 38px;
  background: #fff;
  color: var(--red);
  border-color: var(--line);
}

.wide {
  width: 100%;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}

label,
fieldset {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

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

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

.answers,
.conversation,
.preview-box {
  padding: 12px;
  margin-top: 12px;
  box-shadow: none;
}

.answers > div,
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

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

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.message {
  max-width: 88%;
  padding: 10px;
  border-radius: 8px;
}

.message p {
  margin-bottom: 5px;
}

.message.inbound {
  align-self: flex-start;
  background: #f1f5f9;
}

.message.outbound {
  align-self: flex-end;
  background: #dff5e8;
}

.reply-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.question-stack {
  display: grid;
  gap: 12px;
}

fieldset {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

legend {
  padding: 0 5px;
  color: var(--ink);
  font-weight: 850;
}

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

.choice {
  position: relative;
}

.choice input {
  position: absolute;
  opacity: 0;
}

.choice span {
  display: block;
  min-height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.choice input:checked + span {
  border-color: var(--orange);
  background: #fff7ed;
  color: var(--navy);
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.activity-grid > section {
  padding: 12px;
  box-shadow: none;
}

.activity-item span {
  color: var(--muted);
  text-align: right;
}

.danger-text {
  color: var(--red) !important;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

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

.error-text {
  margin: 10px 0 0;
  color: var(--red);
  font-size: 0.88rem;
}

@media (max-width: 840px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .split-view,
  .activity-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .split-view > *,
  .activity-grid > * {
    min-width: 0;
  }

  .lead-detail {
    min-height: 60vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar select {
    width: 100%;
  }

  .topbar .account-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head,
  .detail-header,
  .action-row,
  .command-band {
    align-items: stretch;
    flex-direction: column;
  }

  .command-chip {
    max-width: none;
  }

  .action-row > * {
    width: 100%;
  }

  .lead-card {
    align-items: stretch;
    flex-direction: column;
  }

  .lead-card-side {
    align-items: flex-start;
  }
}
