:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f0f4ef;
  --text: #18201d;
  --muted: #63706a;
  --line: #d9e1dc;
  --green: #174f3c;
  --green-2: #2e7a58;
  --blue: #27608f;
  --amber: #b56b18;
  --red: #a4362f;
  --shadow: 0 18px 50px rgba(24, 32, 29, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden,
.app-hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  transition: grid-template-columns 160ms ease;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 79, 60, 0.08), rgba(224, 180, 75, 0.14)),
    var(--bg);
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 18px;
}

.auth-brand {
  color: var(--text);
}

.auth-copy,
.auth-status {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-status {
  min-height: 1.3em;
  font-weight: 700;
}

.invite-notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.invite-notice strong {
  color: var(--text);
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  background: #14251f;
  color: #f7fbf8;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 0;
  overflow: auto;
}

body.sidebar-collapsed .sidebar {
  padding-inline: 12px;
  align-items: center;
}

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

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .brand > div:not(.brand-mark),
body.sidebar-collapsed .nav-button span:not(.nav-icon),
body.sidebar-collapsed .mode-box {
  display: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e0b44b;
  color: #14251f;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-name,
.brand-subtitle,
.eyebrow {
  margin: 0;
}

.brand-name {
  font-weight: 800;
}

.brand-subtitle {
  color: #b8c8bf;
  font-size: 0.86rem;
}

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

body.sidebar-collapsed .nav-list {
  width: 100%;
}

.nav-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d8e4de;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

body.sidebar-collapsed .nav-button {
  justify-content: center;
  padding-inline: 8px;
}

.sidebar-collapse-button,
.rail-collapse-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7fbf8;
  font-weight: 800;
  padding: 8px 10px;
}

body.sidebar-collapsed .sidebar-collapse-button {
  width: 44px;
  min-width: 44px;
  padding-inline: 0;
  overflow: hidden;
  white-space: nowrap;
}

.nav-button:hover,
.nav-button.active {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  font-weight: 800;
}

.mode-box {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 5px;
}

.mode-label,
.eyebrow,
label span,
.metric span,
.result-box span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.sidebar .mode-label {
  color: #b8c8bf;
}

.main {
  min-width: 0;
  padding: 24px;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow-x: hidden;
  overflow-y: auto;
}

.topbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

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

.account-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 1rem;
}

.client-picker {
  display: grid;
  gap: 6px;
  width: clamp(220px, 26vw, 300px);
  min-width: 220px;
  max-width: 300px;
}

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

textarea {
  resize: vertical;
}

.client-picker select {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
  min-height: 0;
  overflow: visible;
}

#assistantView.active {
  display: grid;
  height: 100%;
  overflow: hidden;
}

.assistant-layout,
.split-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.assistant-layout {
  height: 100%;
  min-height: 0;
  align-items: stretch;
  transition: grid-template-columns 160ms ease;
}

body.context-collapsed .assistant-layout {
  grid-template-columns: minmax(0, 1fr) 48px;
}

.documents-layout,
.product-catalog-layout {
  display: grid;
  height: 100%;
  min-height: 0;
}

.site-map-layout {
  display: grid;
  gap: 18px;
  height: auto;
  min-height: 0;
  align-items: start;
}

.lead-layout {
  display: grid;
  gap: 18px;
  height: auto;
  min-height: 0;
  align-items: start;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

#documentsView.active,
#productCatalogView.active {
  height: 100%;
  overflow: hidden;
}

#adminView.active {
  height: 100%;
  overflow: auto;
}

#siteMapView.active,
#leadGeneratorView.active {
  height: auto;
  overflow: visible;
  padding-bottom: 28px;
}

.documents-layout .panel,
.product-catalog-panel {
  min-height: 0;
  max-height: 100%;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  align-content: stretch;
}

.lead-control-panel .form-grid {
  grid-template-columns: minmax(200px, 1fr) minmax(180px, 0.7fr) minmax(130px, 0.35fr) minmax(170px, 0.7fr);
}

.lead-list-panel .lead-list,
.lead-control-panel .compact-list {
  min-height: 0;
  overflow: visible;
  padding-right: 4px;
}

.lead-tabs-panel,
.site-tabs-panel {
  display: grid;
  gap: 18px;
  overflow: visible;
}

.lead-tabs-top,
.site-tabs-top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}

.lead-tab-list,
.site-tab-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
  padding: 5px;
}

.lead-tab-button,
.site-tab-button {
  border: 0;
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 14px;
  background: transparent;
  color: var(--green);
  font-weight: 800;
}

.lead-tab-button.active,
.lead-tab-button[aria-selected="true"],
.site-tab-button.active,
.site-tab-button[aria-selected="true"] {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(24, 32, 29, 0.12);
}

.lead-tab-panel,
.site-tab-panel {
  display: none;
  gap: 16px;
}

.lead-tab-panel.active,
.site-tab-panel.active {
  display: grid;
}

.site-tab-panel[hidden] {
  display: none !important;
}

.site-tabs-panel .site-tab-panel:not(.active) {
  display: none !important;
}

.lead-jobs-drawer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px 12px;
}

.lead-jobs-drawer summary {
  cursor: pointer;
  font-weight: 800;
}

.seen-before-pill {
  border-radius: 999px;
  background: #e7eef8;
  color: var(--blue);
  padding: 2px 8px;
  font-weight: 800;
}

.equations-layout {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.2fr);
}

#conversationsView.active,
#equationsView.active,
#settingsView.active {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

#conversationsView.active,
#equationsView.active {
  overflow: hidden;
}

#conversationsView.active .split-layout,
#equationsView.active .equations-layout {
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

#conversationsView.active .panel,
#equationsView.active .panel {
  min-height: 0;
  max-height: 100%;
  align-content: start;
  overflow: auto;
}

#conversationsView.active .panel:first-child,
#equationsView.active .panel:first-child {
  grid-template-rows: auto auto minmax(0, 1fr);
}

#conversationsView.active .item-list,
#equationsView.active .item-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.assistant-main,
.panel,
.context-rail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.answer-panel {
  padding: 18px;
  overflow: auto;
  min-height: 0;
}

.conversation-stream {
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.chat-message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.chat-message.user {
  grid-template-columns: minmax(0, 1fr) 36px;
}

.chat-message.user .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.chat-message.user .message-content {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  max-width: min(720px, 100%);
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.chat-message.user .message-avatar {
  background: var(--blue);
}

.chat-message.note .message-avatar {
  background: var(--amber);
}

.message-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.message-meta strong {
  color: var(--text);
}

.message-bubble {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  line-height: 1.55;
  box-shadow: 0 6px 22px rgba(24, 32, 29, 0.07);
  overflow-wrap: anywhere;
}

.chat-message.user .message-bubble {
  background: #eaf3fb;
  border-color: #c9deef;
}

.chat-message.pending .message-bubble {
  background: #f8faf7;
}

.message-bubble p {
  margin: 0;
}

.message-bubble p + p {
  margin-top: 0.8rem;
}

.assistant-response {
  display: grid;
  gap: 12px;
}

.assistant-response > * {
  min-width: 0;
}

.response-heading {
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--green);
  font-size: 1rem;
  line-height: 1.25;
}

.response-heading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.response-paragraph {
  color: var(--text);
}

.response-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 7px;
}

.response-list li {
  padding-left: 2px;
}

.response-list li::marker {
  color: var(--green-2);
}

.response-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.response-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.response-table th,
.response-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.response-table th {
  background: var(--panel-soft);
  color: var(--green);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 850;
}

.response-table tr:last-child td {
  border-bottom: 0;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #c9deef;
  border-radius: 999px;
  background: #eef6fc;
  color: var(--blue);
  padding: 1px 7px;
  margin: 0 1px;
  font-size: 0.78em;
  font-weight: 800;
  white-space: nowrap;
}

.citation-link {
  text-decoration: none;
  cursor: pointer;
}

.citation-link:hover,
.citation-link:focus-visible {
  border-color: var(--blue);
  background: #dff0fb;
  outline: none;
}

.source-reference-modal {
  width: min(760px, 100%);
}

.source-reference-text {
  white-space: pre-wrap;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  padding: 12px;
  margin: 0;
  font: inherit;
  color: var(--text);
  line-height: 1.45;
}

.source-highlight {
  outline: 3px solid rgba(46, 122, 88, 0.35);
  box-shadow: 0 0 0 6px rgba(46, 122, 88, 0.12);
}

.response-callout {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green-2);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.response-callout h4 {
  margin: 0;
  color: var(--green);
  font-size: 0.95rem;
}

.response-callout.escalation-note,
.response-callout.warning,
.response-callout.warnings,
.response-callout.action-required {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.response-callout.escalation-note h4,
.response-callout.warning h4,
.response-callout.warnings h4,
.response-callout.action-required h4 {
  color: var(--amber);
}

.response-model-profile {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.thinking-header,
.thinking-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.thinking-steps {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.thinking-steps span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-2);
  margin-right: 8px;
}

.thinking-context {
  margin-top: 12px;
  justify-content: flex-start;
}

.thinking-context span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 0.84rem;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-2);
  animation: pulse-dot 1.1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.prompt-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  overflow: hidden;
}

.prompt-details summary {
  cursor: pointer;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

.prompt-details pre {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #111a17;
  color: #e6f1eb;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.ask-box {
  border-top: 1px solid var(--line);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.ask-actions,
.panel-header,
.modal-actions,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.hidden {
  display: none !important;
}

.ask-button-row {
  justify-content: flex-end;
  margin-left: auto;
}

.input-mode-toggle {
  white-space: nowrap;
}

.input-mode-toggle.is-active {
  border-color: var(--green-2);
  background: #e8f4ec;
  color: var(--green);
}

textarea[data-input-mode="enter-submit"] {
  min-height: 54px;
}

.lead-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lead-detail-content,
.lead-source-list,
.lead-draft-list,
.lead-timeline,
.lead-task-list {
  display: grid;
  gap: 12px;
}

.lead-draft-body {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 10px;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-x: auto;
}

.lead-detail-panel .site-section {
  margin-top: 0;
}

.settings-check {
  align-items: flex-start;
  background: #fff7e9;
  border: 1px solid #efd4a8;
  border-radius: 8px;
  padding: 12px;
}

.settings-check span {
  color: #6f4b15;
  text-transform: none;
  font-size: 0.92rem;
  font-weight: 700;
}

.status-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
}

.secondary-button {
  background: #e7eee9;
  color: var(--green);
}

.danger-button {
  background: #f5e2df;
  color: var(--red);
  margin-top: 18px;
}

.compact-button {
  margin-top: 0;
}

.icon-button {
  width: 38px;
  padding: 0;
  background: #edf1ee;
  color: var(--text);
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.detail-panel {
  min-height: 420px;
}

.context-rail {
  padding: 18px;
  display: grid;
  gap: 18px;
  align-self: stretch;
  max-height: 100%;
  overflow: auto;
  position: sticky;
  top: 0;
}

.rail-collapse-button {
  background: var(--green);
  border-color: transparent;
  color: #ffffff;
  justify-self: stretch;
}

body.context-collapsed .context-rail {
  padding: 8px;
  align-content: start;
  overflow: hidden;
}

body.context-collapsed .context-rail .rail-section {
  display: none;
}

body.context-collapsed .rail-collapse-button {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  min-height: 130px;
  width: 32px;
  justify-self: center;
  padding: 10px 4px;
}

.rail-section {
  display: grid;
  gap: 10px;
}

.search-input {
  background: #f9faf8;
}

.item-list,
.document-grid,
.source-list,
.chat-history,
.call-notes {
  display: grid;
  gap: 10px;
}

.document-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-content: start;
}

.documents-layout .document-grid {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.item-card,
.document-card,
.source-card,
.message-card,
.admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  display: grid;
  gap: 8px;
}

.item-card.active {
  border-color: var(--green-2);
  background: #eef7f1;
}

.item-card button,
.document-card button {
  justify-self: start;
}

.document-actions {
  justify-content: flex-start;
}

.admin-layout .panel {
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.admin-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.permission-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf8;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.permission-check input {
  width: auto;
  min-height: auto;
}

.permission-summary {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #e8f2ec;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.warning {
  background: #fff0d7;
  color: var(--amber);
}

.status-pill.verified {
  background: #dff3e6;
  color: var(--green);
}

.status-pill.blocked {
  background: #f7e2df;
  color: var(--red);
}

.equation-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 10px;
  align-items: end;
}

.lead-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, auto) minmax(150px, auto) minmax(160px, auto);
  gap: 10px;
  align-items: end;
}

.compact-select {
  display: grid;
  gap: 6px;
}

.compact-select span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.equation-list-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.verified-banner,
.form-error {
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}

.verified-banner {
  background: #e8f4ec;
  color: var(--green);
}

.form-error {
  background: #f7e2df;
  color: var(--red);
}

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

.form-grid label,
.stacked-field {
  display: grid;
  gap: 7px;
}

.formula-strip,
.result-box,
.call-status {
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.formula-strip {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color: #20352c;
}

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

.result-box {
  display: grid;
  gap: 6px;
}

.result-box strong {
  font-size: 1.7rem;
  color: var(--blue);
}

.drop-zone {
  min-height: 160px;
  border: 1.5px dashed #9eb1a8;
  border-radius: 8px;
  background: #f8faf7;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.drop-zone.dragover {
  border-color: var(--green-2);
  background: #eef7f1;
}

.drop-zone strong {
  color: var(--text);
}

.site-map-panel,
.site-results-panel {
  display: grid;
  gap: 14px;
}

.site-search-row,
.site-map-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.site-search-results {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.site-search-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.site-search-result:hover,
.site-search-result:focus-visible {
  border-color: var(--green-2);
  background: #f3f8f4;
  outline: none;
}

.site-search-result span {
  color: var(--muted);
  font-size: 0.82rem;
}

.secondary-button.is-active {
  border-color: var(--green-2);
  background: #e8f4ec;
  color: var(--green);
}

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

.site-coordinate-grid label {
  display: grid;
  gap: 7px;
}

.site-map-canvas {
  height: min(58vh, 560px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #dfe8e2;
}

.site-map-canvas.manual-map {
  display: grid;
  place-items: center;
  padding: 20px;
}

.site-map-canvas.tile-fallback-active::after {
  content: "Base map tiles unavailable. Showing local coordinate grid.";
  position: absolute;
  z-index: 650;
  left: 12px;
  bottom: 12px;
  max-width: min(340px, calc(100% - 24px));
  border: 1px solid rgba(23, 79, 60, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 8px 10px;
  pointer-events: none;
}

.site-map-fallback {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.site-result-panel,
.product-match-panel,
.saved-site-section {
  display: grid;
  gap: 12px;
}

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

.site-profile-card,
.recommendation-card,
.risk-flag {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.site-profile-card > span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
}

.site-section {
  display: grid;
  gap: 10px;
}

.site-section h3,
.saved-site-section h2 {
  margin: 0;
  font-size: 1rem;
}

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

.site-field-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.site-field-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
}

.site-field-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.risk-flag-list,
.checklist-list,
.recommendation-list {
  display: grid;
  gap: 8px;
}

.product-catalog-list {
  display: grid;
  gap: 10px;
}

.product-catalog-list {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding-right: 4px;
}

.product-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-spec-preview {
  color: var(--muted);
  line-height: 1.45;
  max-height: 5.8em;
  overflow: hidden;
}

.risk-flag {
  border-left: 4px solid var(--blue);
}

.risk-flag.warning {
  border-left-color: var(--amber);
  background: #fff9ef;
}

.risk-flag.critical,
.recommendation-card.not_recommended {
  border-left-color: var(--red);
  background: #fff7f6;
}

.recommendation-card {
  border-left: 4px solid var(--green-2);
}

.recommendation-card.verification_required {
  border-left-color: var(--amber);
  background: #fffbf2;
}

.checklist-list span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  padding: 9px 10px;
}

.disclaimer-banner {
  border: 1px solid #efd4a8;
  border-radius: 8px;
  background: #fff7e9;
  color: #6f4b15;
  padding: 11px 12px;
  font-weight: 700;
  line-height: 1.4;
}

.compact-header {
  align-items: flex-start;
}

.compact-empty {
  min-height: 120px;
}

.link-button {
  display: inline-flex;
  justify-self: start;
  text-decoration: none;
  align-items: center;
}

.file-button input {
  display: none;
}

.answer-block {
  display: grid;
  gap: 14px;
}

.answer-body {
  white-space: pre-wrap;
  line-height: 1.55;
}

.citations {
  display: grid;
  gap: 8px;
}

.citation {
  border-left: 4px solid var(--blue);
  background: #eef5fa;
  padding: 10px 12px;
  border-radius: 6px;
}

.document-summary,
.warning-list {
  color: var(--muted);
  font-size: 0.9rem;
}

.warning-list {
  display: grid;
  gap: 4px;
}

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

.metric {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 1.5rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 16, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
    gap: 12px;
    overflow: visible;
  }

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

  body.sidebar-collapsed .sidebar {
    align-items: stretch;
  }

  body.sidebar-collapsed .brand > div:not(.brand-mark),
  body.sidebar-collapsed .nav-button span:not(.nav-icon) {
    display: inline;
  }

  body.sidebar-collapsed .mode-box {
    display: none;
  }

  .brand {
    display: none;
  }

  .auth-brand {
    display: flex;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    flex: 0 0 auto;
  }

  .mode-box {
    display: none;
  }

  .sidebar-collapse-button {
    display: none;
  }

  .main {
    height: auto;
    min-height: 0;
    overflow: visible;
    display: block;
  }

  .assistant-layout,
  .split-layout,
  .settings-grid,
  .equations-layout,
  .site-map-layout,
  .product-catalog-layout,
  .lead-layout,
  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "list"
      "detail";
  }

  .lead-control-panel .form-grid {
    grid-template-columns: 1fr;
  }

  body.context-collapsed .assistant-layout {
    grid-template-columns: 1fr;
  }

  .assistant-main {
    min-height: auto;
    height: auto;
  }

  #assistantView.active,
  #documentsView.active,
  #productCatalogView.active,
  #siteMapView.active,
  #leadGeneratorView.active,
  #conversationsView.active,
  #equationsView.active,
  #settingsView.active,
  .documents-layout,
  .product-catalog-layout,
  .site-map-layout,
  .lead-layout {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .documents-layout .panel,
  #productCatalogView.active .panel,
  #siteMapView.active .panel,
  #leadGeneratorView.active .panel {
    max-height: none;
    overflow: visible;
  }

  #conversationsView.active .split-layout,
  #equationsView.active .equations-layout {
    height: auto;
  }

  #conversationsView.active .panel,
  #equationsView.active .panel {
    max-height: none;
    overflow: visible;
  }

  .documents-layout .document-grid,
  .product-catalog-panel .product-catalog-list,
  #conversationsView.active .item-list,
  #equationsView.active .item-list,
  .lead-list-panel .lead-list,
  .lead-control-panel .compact-list {
    overflow: visible;
    padding-right: 0;
  }

  .answer-panel {
    max-height: 65vh;
  }

  .site-map-canvas {
    min-height: 340px;
  }

  .context-rail {
    position: static;
    max-height: none;
  }

  body.context-collapsed .context-rail {
    padding: 12px;
  }

  body.context-collapsed .context-rail .rail-section {
    display: none;
  }

  body.context-collapsed .rail-collapse-button {
    writing-mode: horizontal-tb;
    min-height: 40px;
    width: 100%;
  }
}

@media (max-width: 660px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .topbar-actions,
  .panel-header,
  .ask-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .account-menu {
    justify-content: space-between;
  }

  .topbar-actions,
  .client-picker {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .lead-tabs-top,
  .site-tabs-top {
    align-items: stretch;
    flex-direction: column;
  }

  .lead-tab-list,
  .site-tab-list {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .lead-tab-button,
  .site-tab-button {
    width: 100%;
  }

  .form-grid,
  .equation-form,
  .metrics-grid,
  .site-coordinate-grid,
  .site-profile-grid,
  .site-field-grid,
  .equation-filter-row,
  .lead-filter-row {
    grid-template-columns: 1fr;
  }

  .site-search-row,
  .site-map-actions {
    grid-template-columns: 1fr;
  }

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