:root {
  --ink: #09244d;
  --ink-soft: #37506f;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --teal: #0c8f8b;
  --teal-dark: #066c69;
  --gold: #b9862d;
  --rose: #b65a62;
  --green: #4f7d4b;
  --shadow: 0 18px 50px rgba(18, 33, 56, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

body.splash-lock {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 36%, rgba(214, 180, 112, 0.22), transparent 38%),
    linear-gradient(180deg, #faf7f2 0%, #f5f1e8 100%);
  transition: opacity 700ms ease, visibility 700ms ease;
}

.splash-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.splash-content {
  display: grid;
  justify-items: center;
  max-width: 760px;
  text-align: center;
  animation: splashRise 900ms ease both;
}

.splash-logo {
  width: min(190px, 44vw);
  height: auto;
  margin-bottom: 20px;
  filter: drop-shadow(0 22px 30px rgba(92, 62, 24, 0.22));
}

.splash-eyebrow {
  margin-bottom: 10px;
  color: #8a6426;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.splash-content h1 {
  max-width: 720px;
  font-size: clamp(2.1rem, 6vw, 4.5rem);
  line-height: 1.02;
}

.splash-tagline {
  max-width: 620px;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.5;
}

.splash-support {
  margin-top: 12px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

@keyframes splashRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: #fff;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.brand-lockup,
.chat-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-logo.small {
  width: 38px;
  height: 38px;
}

.powered-lockup {
  display: none;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.powered-lockup .brand-logo {
  width: 20px;
  height: 20px;
}

.chat-powered {
  margin-top: 5px;
  text-transform: none;
  letter-spacing: 0;
}

.chat-powered .brand-logo.small {
  width: 18px;
  height: 18px;
}

.business-logo {
  display: none;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  color: #fff;
  background: #0f766e;
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.business-logo.small {
  width: 42px;
  height: 42px;
  font-size: 0.95rem;
}

body.business-brand-mode .business-logo {
  display: grid;
}

body.business-brand-mode .brand-logo {
  width: 20px;
  height: 20px;
}

body.business-brand-mode .brand-logo.small {
  width: 18px;
  height: 18px;
}

body.business-brand-mode .brand-lockup h1,
body.business-brand-mode .chat-identity h3 {
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.05;
}

body.business-brand-mode .brand-subtitle,
body.business-brand-mode .chat-powered + p {
  color: var(--ink-soft);
}

body.business-brand-mode .powered-lockup {
  display: flex;
}

body.business-brand-mode #chat-subtitle:empty {
  display: none;
}

body.business-brand-mode .brand-subtitle:empty {
  display: none;
}

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

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

.brand-lockup p,
.chat-header p,
.profile-card dd,
.eyebrow {
  color: #7c8798;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: #eef2f5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-button,
.nav-item,
.chip,
.secondary-button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
}

.mode-button {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 700;
}

.mode-button.active {
  color: #fff;
  background: var(--ink);
}

.workflow-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px;
  text-align: left;
  border-radius: 8px;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  background: var(--ink-soft);
  border-radius: 50%;
  font-weight: 800;
}

.nav-item.active {
  color: var(--ink);
  background: #eef7f7;
}

.nav-item.active span {
  background: var(--teal);
}

.profile-card,
.location-card,
.auth-card,
.starter-panel,
.chat-panel,
.panel-wide,
.insight-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.profile-card {
  padding: 18px;
}

.profile-card h2,
.location-card h2,
.auth-card h2 {
  margin-bottom: 16px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.location-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.location-card p {
  color: var(--ink-soft);
  line-height: 1.35;
}

.location-card label {
  font-size: 0.9rem;
}

.location-card input[type="text"] {
  min-height: 44px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.location-actions {
  display: grid;
  gap: 8px;
}

.location-actions .secondary-button {
  width: 100%;
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.auth-card p {
  color: var(--ink-soft);
  line-height: 1.35;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  font-size: 0.9rem;
}

.auth-card .secondary-button,
.auth-card .primary-button {
  width: 100%;
}

dl {
  display: grid;
  gap: 14px;
  margin: 0;
}

dt {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 32px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1180px;
  margin: 0 auto 22px;
  text-align: center;
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.view {
  display: none;
  width: 100%;
  max-width: 1180px;
  min-height: 0;
  margin: 0 auto;
}

.view.active {
  display: block;
  height: 100%;
}

.intake-layout,
.matches-grid,
.care-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 22px;
  min-height: 0;
  height: 100%;
}

.intake-layout.chat-first {
  grid-template-columns: minmax(320px, 880px);
  justify-content: center;
}

.intake-layout.guided-open {
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 420px);
}

.intake-layout.guided-open .chat-panel {
  order: 1;
}

.intake-layout.guided-open .starter-panel {
  order: 2;
}

.intake-layout.guided-open .chat-header {
  grid-template-columns: 1fr auto;
}

.intake-layout.guided-open .chat-mode-switch {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

.intake-layout.guided-open .chat-reset {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

.starter-panel,
.chat-panel,
.panel-wide,
.insight-panel {
  box-shadow: var(--shadow);
}

.starter-panel {
  display: grid;
  gap: 18px;
  align-self: start;
  max-height: 100%;
  padding: 24px;
  overflow: auto;
}

.starter-panel.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.starter-panel h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  color: #00183a;
  background: #fff;
  border: 1px solid #cbd3df;
  border-radius: 8px;
}

select:focus,
input:focus {
  border-color: var(--teal);
  outline: 2px solid rgba(12, 143, 139, 0.16);
}

.primary-button {
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  display: grid;
  padding: 18px 22px;
  align-items: center;
  grid-template-columns: 1fr minmax(280px, 390px) auto;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-mode-switch {
  width: min(310px, 100%);
  flex: 0 0 auto;
}

.chat-reset {
  flex: 0 0 auto;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 22px;
  overflow: auto;
}

.message {
  max-width: 78%;
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.45;
}

.message.bot {
  align-self: flex-start;
  background: #edf6f5;
  border: 1px solid #c7e8e5;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--ink);
}

.message.system {
  align-self: center;
  max-width: 92%;
  color: #59677c;
  background: #f4f6f9;
  border: 1px dashed #cbd3df;
}

.reply-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.option-row {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
}

.chip.active,
.chip:hover {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.chip.recommended {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 10px 22px rgba(12, 143, 139, 0.18);
}

.chip.recommended:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.matches-grid,
.care-grid {
  grid-template-columns: 1fr 330px;
}

.panel-wide,
.insight-panel {
  padding: 22px;
}

.section-heading {
  margin-bottom: 18px;
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

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

.provider-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.provider-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.provider-card p {
  color: var(--ink-soft);
  line-height: 1.4;
}

.score {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-weight: 800;
}

.insight-panel ul {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.task-column {
  min-height: 360px;
  padding: 12px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-column h4 {
  margin: 0 0 12px;
}

.task-card {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
}

.task-card strong {
  font-size: 0.95rem;
}

.task-card span,
.risk-item {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.35;
}

.risk-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.risk-item:last-child {
  border-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px 24px 24px 344px;
  background: rgba(9, 36, 77, 0.48);
}

.modal-backdrop.is-hidden {
  display: none;
}

.sales-modal {
  position: relative;
  width: min(780px, 100%);
  max-height: min(90vh, 760px);
  padding: 28px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(6, 24, 52, 0.28);
}

.modal-brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 44px 18px 0;
}

.modal-brand-lockup .business-logo {
  display: grid;
}

.modal-brand-lockup h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.05;
}

.modal-powered {
  display: flex;
  margin-top: 6px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--ink-soft);
  background: #f3f6f8;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
}

.sales-modal h2 {
  max-width: 680px;
  margin: 0 42px 12px 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
}

.modal-lede {
  max-width: 680px;
  color: var(--ink-soft);
  line-height: 1.55;
}

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

.price-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.price-card.featured {
  border-color: rgba(12, 143, 139, 0.45);
  background: #edf6f5;
}

.price-card span {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.price-card strong {
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.price-card p {
  color: var(--ink-soft);
  line-height: 1.35;
}

.sales-points {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 760px) {
  .modal-backdrop {
    padding: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .side-panel {
    position: static;
    overflow: visible;
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

  .intake-layout,
  .matches-grid,
  .care-grid,
  .task-board {
    grid-template-columns: 1fr;
  }

  .intake-layout.guided-open {
    grid-template-columns: 1fr;
  }

  .view.active,
  .intake-layout,
  .matches-grid,
  .care-grid {
    height: auto;
  }

  .chat-panel {
    height: min(720px, calc(100vh - 36px));
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .modal-backdrop {
    padding: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: none;
  }

  .workspace {
    padding: 24px;
  }

  .intake-layout.guided-open {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  }

  .chat-header {
    grid-template-columns: 1fr auto;
  }

  .chat-mode-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .chat-reset {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: auto;
  }
}

@media (max-width: 640px) {
  .workspace,
  .side-panel {
    padding: 18px;
  }

  .topbar,
  .chat-header,
  .reply-box,
  .provider-card {
    grid-template-columns: 1fr;
  }

  .chat-header {
    align-items: stretch;
  }

  .chat-mode-switch {
    grid-column: auto;
    grid-row: auto;
  }

  .chat-reset {
    grid-column: auto;
    grid-row: auto;
    justify-self: stretch;
    width: 100%;
  }

  .reply-box {
    display: grid;
  }

  .message {
    max-width: 100%;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .sales-modal {
    padding: 22px;
  }

  .modal-actions {
    display: grid;
  }
}
