:root {
  --bg: #fcf8f4;
  --bg-soft: #f9f1ea;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --sidebar: #fdf8f4;
  --sidebar-accent: #f5e3d4;
  --sidebar-border: #ecd9cb;
  --text: #765d61;
  --text-strong: #7f6569;
  --text-muted: #b49ea0;
  --line: #ead9cd;
  --line-strong: #dcc7b8;
  --plum: #5f3340;
  --plum-soft: #e8d4df;
  --green: #1ca34a;
  --green-deep: #12863a;
  --lavender: #8d80eb;
  --shadow: 0 10px 24px rgba(97, 62, 69, 0.06);
  --sidebar-width: 232px;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fdfaf7 0%, var(--bg) 100%);
  overflow: hidden;
}

.page-shell {
  width: min(1720px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 10px 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

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

button {
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text-strong);
}

textarea {
  resize: vertical;
}

.view-selector-card {
  display: none;
}

.view-selector-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-switcher {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.96);
}

.mode-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

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

.app-frame {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 252, 249, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 14px 10px 16px;
  border-right: 1px solid var(--sidebar-border);
  background: linear-gradient(180deg, var(--sidebar) 0%, #fbf4ee 100%);
}

.sidebar-top,
.brand-lockup,
.workspace-header,
.workspace-actions,
.workspace-meta,
.canvas-toolbar,
.toolbar-actions,
.panel-header,
.profile-tile,
.prompt-bar,
.prompt-actions,
.patient-bar,
.session-indicators,
.tab-row,
.note-fields,
.checkbox-row {
  display: flex;
  align-items: center;
}

.sidebar-top,
.workspace-header,
.canvas-toolbar {
  justify-content: space-between;
}

.brand-lockup {
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--plum);
  font-size: 1.4rem;
  line-height: 1;
}

.brand-name {
  color: #4d2532;
  font-size: 0;
  font-weight: 800;
}

.brand-name::after {
  content: "Heidi";
  font-size: 1.15rem;
}

.primary-sidebar-button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--plum);
  color: #fff;
  font-weight: 700;
  text-align: left;
}

.sidebar-nav,
.sidebar-footer,
.input-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
  font-weight: 600;
}

.nav-item.active {
  background: var(--sidebar-accent);
  color: #4f3137;
}

.nav-item.small {
  font-weight: 500;
}

.sidebar-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 249, 0.88);
  padding: 14px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.connector-helper {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.sidebar-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
}

.profile-tile {
  gap: 12px;
  margin-top: 10px;
  padding: 10px 8px 0;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--plum);
  color: #fff;
  font-weight: 700;
  text-transform: lowercase;
}

.profile-name {
  color: #43262f;
  font-weight: 700;
  font-size: 0.92rem;
}

.profile-email {
  color: var(--text);
  font-size: 0.82rem;
}

.stacked-field {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--text);
}

.stacked-field span {
  font-weight: 600;
}

.connector-details summary,
.technical-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.technical-details {
  margin-top: 8px;
}

.technical-details pre {
  margin-top: 12px;
}

.mini-badge,
.status-badge,
.promo-pill,
.token-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.mini-badge,
.status-badge.muted,
.token-pill {
  background: #f4ebe3;
  color: var(--text);
}

.status-badge.success {
  background: rgba(28, 163, 74, 0.12);
  color: var(--green-deep);
}

.promo-pill {
  background: var(--lavender);
  color: #fff;
}

.workspace-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.workspace {
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.integration-rail {
  display: none;
  padding: 16px 18px 22px 0;
  gap: 16px;
  align-content: start;
}

.workspace-title-group {
  display: grid;
  gap: 10px;
}

.patient-bar {
  gap: 10px;
}

.patient-identifier {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 1.02rem;
  font-weight: 700;
  max-width: 420px;
  color: var(--text-strong);
}

.patient-dot {
  color: var(--text);
}

.workspace-meta {
  gap: 18px;
  color: var(--text);
  font-size: 0.95rem;
}

.workspace-actions {
  gap: 10px;
}

.session-indicators {
  align-self: flex-end;
  gap: 16px;
  margin: 6px 8px 10px 0;
  color: var(--text);
}

.tab-row {
  display: none;
}

.tab-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.tab-button.active {
  color: #4e2a31;
  border-color: var(--line-strong);
}

.ghost-tab {
  background: transparent;
}

.main-canvas {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 252, 249, 0.86);
  padding: 14px;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.canvas-caption {
  color: #977b7e;
  font-size: 0.95rem;
}

.toolbar-actions {
  gap: 10px;
}

.tab-panel {
  display: none;
  margin-top: 12px;
  flex: 1;
  min-height: 0;
}

.tab-panel.active {
  display: block;
}

.context-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.96fr) minmax(390px, 1.28fr) minmax(320px, 0.94fr);
  gap: 14px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
  box-shadow: 0 6px 20px rgba(97, 62, 69, 0.03);
  min-height: 0;
  overflow: auto;
}

.panel-vendor {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.panel-note {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.panel-inputs {
  grid-column: 3;
  grid-row: 1;
}

.panel-payload {
  grid-column: 3;
  grid-row: 2;
}

.rail-panel {
  min-height: 0;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel-label {
  margin: 0 0 4px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

.panel h2 {
  margin: 0;
  color: #654f54;
  font-size: 1.02rem;
}

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

.vendor-section {
  display: grid;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid #f0e4da;
}

.vendor-section:first-child {
  padding-top: 0;
}

.vendor-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.vendor-section-title {
  color: #6270a5;
  font-size: 0.88rem;
  font-weight: 700;
}

.vendor-demographics,
.vendor-copy {
  color: #50393f;
  line-height: 1.6;
}

.vendor-primary {
  font-size: 1.18rem;
  font-weight: 700;
  color: #48353a;
}

.vendor-detail-grid {
  display: grid;
  grid-template-columns: minmax(84px, auto) 1fr;
  gap: 4px 14px;
  font-size: 0.88rem;
}

.vendor-detail-grid span {
  color: var(--text-muted);
}

.vendor-detail-grid strong {
  color: #4f3940;
}

.vendor-list {
  margin: 0;
  padding-left: 20px;
  color: #4f3940;
  display: grid;
  gap: 6px;
  line-height: 1.4;
}

.vendor-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: #4f3940;
}

.vendor-inline span {
  color: var(--text);
}

.data-row {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fcf7f2;
}

.data-row-label {
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.data-row-value {
  color: var(--text-strong);
  font-size: 0.94rem;
}

.empty-state {
  color: var(--text-muted);
  padding: 14px;
  border-radius: 14px;
  background: #fcf7f2;
}

.short-field {
  max-width: 160px;
}

.note-fields {
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.checkbox-row {
  gap: 10px;
  color: var(--text-strong);
  font-weight: 500;
}

.checkbox-row input {
  width: auto;
}

.payload-summary,
.plain-panel {
  padding: 12px 14px;
  border-radius: 14px;
  background: #fcf7f2;
  color: var(--text);
  line-height: 1.5;
}

.role-callout {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #e6d8c9;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf9 0%, #f9f1e8 100%);
  color: #6b565b;
  font-size: 0.86rem;
  line-height: 1.48;
}

pre {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 16px;
  background: #2d1d23;
  color: #f7efe9;
  font-size: 0.78rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100%;
  overflow: auto;
}

.panel-payload pre {
  background: #fffdfa;
  color: #3d4950;
  border: 1px solid #eef0eb;
  max-height: 100%;
}

.clinician-mode .config-only {
  display: none !important;
}

.configuration-mode .workspace-wrap {
  grid-template-columns: minmax(0, 7fr) minmax(320px, 3fr);
}

.configuration-mode .integration-rail {
  display: none;
}

.note-preview-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
}

.note-preview-card {
  min-height: 100%;
}

.note-preview h3 {
  margin: 0 0 12px;
  color: #53363d;
  font-size: 1.08rem;
}

.note-preview > p {
  color: #4b3a3e;
  line-height: 1.6;
  margin: 0 0 10px;
}

.note-preview-section {
  margin-top: 14px;
}

.note-preview-section strong {
  display: block;
  margin-bottom: 4px;
  color: #2f7a63;
  font-size: 1rem;
}

.note-preview-section p {
  margin: 0;
  color: #4e3e42;
  line-height: 1.55;
  font-size: 0.92rem;
}

.prompt-bar {
  align-self: center;
  justify-content: space-between;
  width: min(940px, calc(100% - 80px));
  margin-top: 12px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 250, 0.96);
  box-shadow: 0 14px 30px rgba(97, 62, 69, 0.08);
}

.prompt-placeholder {
  color: var(--text);
  font-size: 0.98rem;
}

.prompt-actions {
  gap: 12px;
}

.icon-button,
.soft-button,
.secondary-button,
.success-button,
.success-dropdown {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 10px 12px;
}

.success-button,
.success-dropdown {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-weight: 700;
}

.success-dropdown {
  padding-inline: 10px;
}

.secondary-button {
  background: #dfcfd6;
  color: #fff;
  border-color: #dfcfd6;
  font-weight: 700;
}

.soft-button.emphasized {
  background: rgba(28, 163, 74, 0.1);
  border-color: rgba(28, 163, 74, 0.18);
  color: var(--green-deep);
}

.subtle-button {
  background: #fffdfa;
}

.payload-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 12px;
  margin-top: 12px;
}

.validate-button {
  background: #fffdfa;
  color: var(--green-deep);
  border-color: rgba(28, 163, 74, 0.2);
  font-weight: 700;
}

.payload-send-button {
  width: 100%;
}

.ghost,
.danger {
  background: transparent;
}

.danger {
  color: #cb5c59;
}

@media (max-width: 1380px) {
  .context-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel-vendor,
  .panel-note,
  .panel-payload {
    grid-column: auto;
    grid-row: auto;
  }

  .panel-inputs,
  .panel-payload {
    grid-column: 2;
  }
}

@media (max-width: 1024px) {
  html,
  body {
    overflow: auto;
  }

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .workspace {
    padding: 14px;
  }

  .main-canvas,
  .context-grid,
  .panel {
    min-height: unset;
    height: auto;
  }

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

  .panel-inputs,
  .panel-payload {
    grid-column: auto;
    grid-row: auto;
  }

  .configuration-mode .workspace-wrap {
    grid-template-columns: 1fr;
  }

  .configuration-mode .integration-rail {
    padding: 0 14px 20px;
  }

  .workspace-header,
  .workspace-meta,
  .session-indicators,
  .note-fields,
  .prompt-bar,
  .toolbar-actions {
    flex-wrap: wrap;
  }

  .prompt-bar {
    width: 100%;
  }

  .page-shell {
    width: min(100vw - 16px, 1720px);
    padding-top: 8px;
    height: auto;
  }
}
