:root {
  --primary: #06235a;
  --primary-hover: #041a44;
  --secondary: #0368cb;
  --hero-bg: linear-gradient(135deg, #06235a 0%, #0368cb 100%);
  --accent-teal: #049780;
  --accent-green: #37c76f;
  --accent: linear-gradient(90deg, var(--accent-teal), var(--accent-green));
  --blue-tint: #e8f2fc;
  --teal-tint: #e6f5f1;
  --page-bg: #f5f8fb;
  --surface: #ffffff;
  --border: #dce4ee;
  --border-strong: #8593a6;
  --text: #14213d;
  --text-muted: #5a6778;
  --on-primary: #ffffff;
  --on-primary-muted: #e8f2fc;
  --on-primary-overlay: rgba(255, 255, 255, 0.12);
  --error-text: #9d2c2c;
  --error-border: #efc2c2;
  --error-bg: #fff7f7;
  --backdrop: rgba(20, 33, 61, 0.45);
  --focus-ring: rgba(3, 104, 203, 0.2);
  --shadow: 0 20px 55px rgba(20, 33, 61, 0.2);
  --shadow-launcher: 0 8px 28px rgba(20, 33, 61, 0.3);
  --shadow-bubble: 0 2px 8px rgba(20, 33, 61, 0.08);
  --shadow-card: 0 1px 3px rgba(20, 33, 61, 0.06);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--page-bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  color: var(--on-primary);
  background: var(--primary);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Provider portal page ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav-bar {
  display: flex;
  align-items: center;
  min-height: 72px;
  gap: 32px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.wordmark-logo {
  display: block;
  width: auto;
  height: 40px;
}

.wordmark-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
}

.wordmark-product {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
}

.main-nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 28px;
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
}

.main-nav a {
  display: flex;
  align-items: center;
  border-bottom: 3px solid transparent;
  color: var(--text);
  transition: color 160ms ease, border-color 160ms ease;
}

.main-nav a:hover {
  color: var(--secondary);
}

.main-nav a[aria-current="page"] {
  color: var(--primary);
  border-bottom-color: var(--secondary);
}

.hero {
  padding-block: 56px 60px;
  color: var(--on-primary);
  background: var(--hero-bg);
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.15;
}

.hero-rule {
  width: 56px;
  height: 4px;
  margin: 16px 0 18px;
  border-radius: 2px;
  background: var(--accent);
}

.hero-copy {
  max-width: 600px;
  margin: 0 0 28px;
  color: var(--on-primary);
  font-size: 17px;
  line-height: 1.6;
}

.hero-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  color: var(--primary);
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  font-weight: 700;
  transition: background 160ms ease;
}

.hero-action:hover {
  background: var(--blue-tint);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding-block: 48px 72px;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 31px 28px 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
  content: "";
}

.card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--accent-teal);
  background: var(--teal-tint);
}

.card-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.card h2 {
  margin: 18px 0 8px;
  font-size: 18px;
}

.card p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
}

.card-link {
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
}

.card-link:hover {
  text-decoration: underline;
}

footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 24px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-links a:hover {
  color: var(--secondary);
  text-decoration: underline;
}

/* ---------- Chat widget ---------- */

.chat-launcher {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 28px;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  color: var(--on-primary);
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: var(--shadow-launcher);
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.chat-launcher:hover {
  background: var(--primary-hover);
  transform: translateY(-3px);
}

.chat-launcher svg {
  width: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.chat-backdrop {
  position: fixed;
  z-index: 25;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.chat-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.chat-widget {
  position: fixed;
  z-index: 30;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(760px, calc(100vw - 48px));
  height: min(720px, calc(100vh - 64px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.96);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.chat-widget.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.chat-brand {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-brand img {
  display: block;
  width: auto;
  height: 32px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 16px 18px;
  color: var(--on-primary);
  background: var(--primary);
}

.assistant-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface);
}

.assistant-avatar img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.chat-header h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.chat-header p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--on-primary-muted);
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
}

.close-chat {
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 0 0 3px;
  color: var(--on-primary);
  border: 0;
  border-radius: 50%;
  background: var(--on-primary-overlay);
  font-size: 26px;
  font-weight: 300;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 18px;
  background: var(--page-bg);
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.user {
  justify-content: flex-end;
}

.message {
  max-width: 84%;
  padding: 12px 15px;
  border-radius: 4px 14px 14px;
  background: var(--surface);
  box-shadow: var(--shadow-bubble);
}

.message-row.user .message {
  color: var(--text);
  border-radius: 14px 4px 14px 14px;
  background: var(--blue-tint);
  box-shadow: none;
}

.message.error {
  color: var(--error-text);
  border: 1px solid var(--error-border);
  background: var(--error-bg);
}

.message p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.message-row.assistant .message strong {
  .message-row.assistant .message .message-title {
  color: var(--primary);
  font-weight: 700;
}
}
.typing-cursor::after {
  display: inline-block;
  width: 2px;
  height: 14px;
  margin-left: 3px;
  background: var(--secondary);
  animation: blink 850ms infinite;
  content: "";
  vertical-align: -2px;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.chat-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.3px;
  text-align: center;
}

.chat-status::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.chat-status.pending {
  animation: status-pulse 1.4s ease-in-out infinite;
}

.chat-status.ready {
  color: var(--secondary);
}

.chat-status.failed {
  color: var(--error-text);
}

@keyframes status-pulse {
  50% {
    opacity: 0.45;
  }
}

.thinking {
  max-width: 84%;
  padding: 10px 14px;
  border-left: 3px solid var(--secondary);
  border-radius: 4px 10px 10px 4px;
  background: var(--blue-tint);
}

.thinking-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.thinking-label::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--secondary);
  content: "";
}

.thinking.active .thinking-label::before {
  animation: status-pulse 1.1s ease-in-out infinite;
}

.thinking-text {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.5;
  white-space: pre-wrap;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  opacity: 0.45;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 160ms;
}

.typing-dots span:nth-child(3) {
  animation-delay: 320ms;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px 8px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-form textarea {
  width: 100%;
  max-height: 110px;
  resize: none;
  padding: 11px 13px;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  line-height: 1.4;
}

.chat-form textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.send-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  color: var(--on-primary);
  border: 0;
  border-radius: 8px;
  background: var(--primary);
}

.send-button:not(:disabled):hover {
  background: var(--primary-hover);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.send-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.chat-footer-bar {
  background: var(--surface);
  padding: 3px 16px 8px;
}

.chat-disclaimer {
  margin: 0;
  color: var(--text-muted);
  font-size: 9px;
  text-align: left;
}

.chat-conversation-id {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
}

.conversation-id-text {
  color: var(--text-muted);
  font-size: 10px;
  font-family: monospace;
  user-select: all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.copy-id-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.copy-id-button:hover {
  background: var(--blue-tint);
  color: var(--secondary);
  border-color: var(--border-strong);
}

.dashboard-link {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--secondary);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.dashboard-link:hover {
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 32px, 1180px);
  }

  .main-nav {
    display: none;
  }

  .nav-bar {
    min-height: 64px;
  }

  .hero {
    padding-block: 40px 44px;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-block: 32px 48px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-widget {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }

  .chat-launcher {
    right: 18px;
    bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
