:root {
  --turquoise: #01aeab;
  --black: #000000;
  --white: #ffffff;
  --soft-gray: #d9d9d9;
  --panel: #f7fafa;
  --line: #c9d6d6;
  --text-muted: #4f5f5f;
  --warning: #8a5a00;
  --warning-bg: #fff6dd;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  --profile-adulto-bg: #ffd2a6;
  --profile-adulto-border: #e69a56;
  --profile-adolescente-bg: #ffe1c8;
  --profile-adolescente-border: #efb382;
  --profile-nino-2-5-4-bg: #fff6bf;
  --profile-nino-2-5-4-border: #eadb76;
  --profile-nino-5-7-bg: #fff0a6;
  --profile-nino-5-7-border: #e5cf5e;
  --profile-nino-8-11-bg: #ffe28a;
  --profile-nino-8-11-border: #d8b94f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.app-header {
  align-items: center;
  border-bottom: 4px solid var(--turquoise);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1440px;
  padding-bottom: 18px;
}

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

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

h1 {
  font-size: 2rem;
  line-height: 1.15;
  margin-bottom: 0;
}

.pilot-version {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  margin: 6px 0 0;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 0;
}

h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.status-pill {
  border: 1px solid var(--turquoise);
  border-radius: 999px;
  color: var(--turquoise);
  font-weight: 700;
  padding: 10px 14px;
  white-space: nowrap;
}

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

.edit-mode-button {
  min-height: 38px;
}

body:not(.admin-mode) .edit-mode-button {
  display: none;
}

.report-button {
  border-color: rgba(1, 174, 171, 0.45);
  color: var(--turquoise);
  min-height: 38px;
}

.edit-banner {
  align-items: center;
  background: #fff6dd;
  border: 1px solid rgba(138, 90, 0, 0.25);
  border-radius: 8px;
  color: var(--warning);
  display: grid;
  gap: 8px;
  grid-template-columns: max-content 1fr max-content;
  margin: 0 auto 16px;
  max-width: 1440px;
  padding: 10px 12px;
}

.edit-banner-actions {
  display: flex;
  gap: 8px;
}

.danger-button {
  border-color: rgba(138, 90, 0, 0.35);
  color: var(--warning);
}

.workspace {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1440px;
}

.filters-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters-panel {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.mode-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 9px 10px;
}

.mode-button.active {
  background: var(--turquoise);
  color: var(--white);
}

.mode-panel {
  display: grid;
  gap: 14px;
}

.internal-controls,
#quickReception,
#caseFields,
.guided-steps {
  display: none !important;
}

.guided-steps,
.guided-stage-block,
.profile-block,
.case-fields,
.quick-reception {
  display: grid;
  gap: 8px;
}

.case-fields {
  gap: 14px;
}

.stage-buttons {
  display: grid;
  gap: 8px;
}

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

.profile-button {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--black);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 9px;
}

.profile-adulto {
  background: var(--profile-adulto-bg);
  border-color: var(--profile-adulto-border);
}

.profile-adolescente {
  background: var(--profile-adolescente-bg);
  border-color: var(--profile-adolescente-border);
}

.profile-nino-2\.5-4 {
  background: var(--profile-nino-2-5-4-bg);
  border-color: var(--profile-nino-2-5-4-border);
}

.profile-nino-5-7 {
  background: var(--profile-nino-5-7-bg);
  border-color: var(--profile-nino-5-7-border);
}

.profile-nino-8-11 {
  background: var(--profile-nino-8-11-bg);
  border-color: var(--profile-nino-8-11-border);
}

.profile-button.active {
  border-color: var(--turquoise);
  box-shadow: inset 0 0 0 2px var(--turquoise);
  color: var(--black);
}

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

.quick-button {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 10px;
  text-align: left;
}

.quick-button.active {
  border-color: var(--turquoise);
  box-shadow: inset 4px 0 0 var(--turquoise);
}

.step-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.step-button,
.stage-button {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.substage-button {
  margin-left: 18px;
  padding-left: 18px;
}

.stage-button.has-children {
  font-weight: 700;
}

.editing-active .stage-button {
  cursor: grab;
}

.editing-active .stage-button.dragging {
  opacity: 0.55;
}

.editing-active .stage-button.drag-over {
  border-color: var(--warning);
  box-shadow: inset 4px 0 0 var(--warning);
}

.step-button strong,
.step-button span,
.stage-button strong {
  display: block;
}

.step-button span,
.helper-text {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.context-note,
.case-warning,
.case-summary {
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 0;
  padding: 10px 12px;
}

.context-note {
  background: rgba(1, 174, 171, 0.1);
  border: 1px solid rgba(1, 174, 171, 0.28);
  color: #006b69;
}

.case-warning {
  background: var(--warning-bg);
  border: 1px solid rgba(138, 90, 0, 0.25);
  color: var(--warning);
  font-weight: 700;
}

.case-summary {
  background: var(--black);
  border: 1px solid var(--black);
  color: var(--white);
  font-weight: 700;
}

.step-button.active,
.stage-button.active {
  border-color: var(--turquoise);
  box-shadow: inset 4px 0 0 var(--turquoise);
}

.panel-heading,
.detail-header,
.section-title-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.detail-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: -2px;
}

.message-heading {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail-stage {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0;
}

.message-title-line {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message-title-line .message-id {
  margin: 0;
}

.message-toolbar {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: max-content minmax(120px, 1fr) max-content;
  margin-bottom: 8px;
}

.message-toolbar h3 {
  margin-bottom: 0;
}

.message-toolbar .active-profile-chip {
  justify-self: center;
}

.message-actions {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-end;
}

.active-profile-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--black);
  flex: 0 1 auto;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  padding: 6px 9px;
  white-space: nowrap;
}

.active-profile-chip.profile-theme-adulto {
  background: var(--profile-adulto-bg);
  border-color: var(--profile-adulto-border);
}

.active-profile-chip.profile-theme-adolescente {
  background: var(--profile-adolescente-bg);
  border-color: var(--profile-adolescente-border);
}

.active-profile-chip.profile-theme-nino-2-5-4 {
  background: var(--profile-nino-2-5-4-bg);
  border-color: var(--profile-nino-2-5-4-border);
}

.active-profile-chip.profile-theme-nino-5-7 {
  background: var(--profile-nino-5-7-bg);
  border-color: var(--profile-nino-5-7-border);
}

.active-profile-chip.profile-theme-nino-8-11 {
  background: var(--profile-nino-8-11-bg);
  border-color: var(--profile-nino-8-11-border);
}

.nav-button {
  flex: 0 0 154px;
  height: 46px;
  max-width: 154px;
  min-height: 46px;
  min-width: 154px;
  padding: 11px 12px;
  white-space: nowrap;
  width: 154px;
}

.follow-button {
  font-size: 0.78rem;
  line-height: 1.1;
  min-height: 30px;
  max-width: 132px;
  padding: 6px 10px;
}

label {
  color: var(--text-muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 6px;
}

select,
input {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--black);
  min-height: 46px;
  padding: 10px 12px;
  width: 100%;
}

select:focus,
input:focus,
button:focus {
  outline: 3px solid rgba(1, 174, 171, 0.28);
  outline-offset: 2px;
}

.ghost-button,
.primary-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  min-height: 46px;
  padding: 11px 16px;
}

.ghost-button {
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--black);
}

.primary-button {
  background: var(--turquoise);
  border: 1px solid var(--turquoise);
  color: var(--white);
}

.copy-main {
  font-size: 0.95rem;
  height: 46px;
  max-width: 154px;
  min-height: 46px;
  min-width: 154px;
  padding: 11px 12px;
  width: 154px;
}

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

.message-count {
  color: var(--text-muted);
  font-weight: 700;
  padding-top: 4px;
}

.message-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  max-height: 320px;
  overflow: auto;
  padding: 2px 4px 2px 2px;
}

.message-option {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  min-height: 0;
  padding: 9px;
  text-align: left;
}

.message-option strong {
  font-size: 0.9rem;
  line-height: 1.18;
}

.message-card-title {
  align-items: baseline;
  display: flex;
  gap: 8px;
  line-height: 1.2;
}

.message-card-title span {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.message-excerpt {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.28;
  margin: 5px 0 0;
}

.message-badge {
  background: rgba(1, 174, 171, 0.12);
  border-radius: 999px;
  color: #006b69;
  display: inline-block;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 700;
  margin: 5px 4px 0 0;
  padding: 3px 7px;
}

.badge-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
}

.message-option.active {
  background: rgba(1, 174, 171, 0.05);
  border-color: var(--turquoise);
  border-width: 2px;
  box-shadow: inset 4px 0 0 var(--turquoise), 0 0 0 2px rgba(1, 174, 171, 0.12);
}

.detail-panel {
  position: relative;
  min-height: 640px;
  padding: 16px;
}

.profile-blocker {
  align-items: flex-start;
  background: rgba(217, 217, 217, 0.86);
  border-radius: 8px;
  display: flex;
  inset: 0;
  justify-content: flex-start;
  padding: 28px 24px;
  position: absolute;
  text-align: center;
  z-index: 20;
}

.profile-blocker-content {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  max-width: 360px;
  padding: 22px;
  transform: translateX(-10px);
}

.profile-blocker-arrow {
  color: var(--turquoise);
  font-size: 3.4rem;
  font-weight: 700;
  line-height: 1;
}

.profile-blocker p {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.profile-blocker span {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.empty-state {
  align-items: center;
  display: grid;
  min-height: 560px;
  place-content: center;
  text-align: center;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

.message-detail {
  display: grid;
  gap: 6px;
}

.message-detail.no-selected-message .detail-header,
.message-detail.no-selected-message .copy-notice,
.message-detail.no-selected-message .case-warning,
.message-detail.no-selected-message .text-section,
.message-detail.no-selected-message .variables-section,
.message-detail.no-selected-message .preview-section,
.message-detail.no-selected-message .message-details {
  display: none !important;
}

.message-id {
  color: var(--turquoise);
  font-weight: 700;
  margin-bottom: 4px;
}

.copy-notice {
  color: var(--turquoise);
  font-weight: 700;
  min-height: 22px;
}

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

.info-grid div {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.info-grid span,
.section-title-row span {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.info-grid p {
  margin: 5px 0 0;
  white-space: pre-wrap;
}

.text-section,
.variables-section,
.edit-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 10px;
}

.editing-active .detail-panel {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(255, 246, 221, 0.9), var(--shadow);
}

.edit-panel {
  display: grid;
  gap: 10px;
}

.edit-panel textarea {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--black);
  min-height: 150px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

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

pre {
  background: var(--white);
  border: 1px solid var(--soft-gray);
  border-radius: 8px;
  margin: 0;
  min-height: 70px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

#baseMessage {
  font-size: 18px;
  height: 128px;
  line-height: 1.6;
  max-height: 128px;
  min-height: 128px;
  overflow-y: auto;
}

.available-section {
  background: var(--white);
  border: 2px solid rgba(1, 174, 171, 0.28);
  border-radius: 8px;
  padding: 10px;
}

.message-detail.profile-theme-adulto .text-section:first-of-type,
.detail-panel.profile-theme-adulto .available-section {
  border-color: var(--profile-adulto-border);
}

.message-detail.profile-theme-adolescente .text-section:first-of-type,
.detail-panel.profile-theme-adolescente .available-section {
  border-color: var(--profile-adolescente-border);
}

.message-detail.profile-theme-nino-2-5-4 .text-section:first-of-type,
.detail-panel.profile-theme-nino-2-5-4 .available-section {
  border-color: var(--profile-nino-2-5-4-border);
}

.message-detail.profile-theme-nino-5-7 .text-section:first-of-type,
.detail-panel.profile-theme-nino-5-7 .available-section {
  border-color: var(--profile-nino-5-7-border);
}

.message-detail.profile-theme-nino-8-11 .text-section:first-of-type,
.detail-panel.profile-theme-nino-8-11 .available-section {
  border-color: var(--profile-nino-8-11-border);
}

.preview-section pre {
  border-color: var(--turquoise);
  font-size: 18px;
  line-height: 1.6;
}

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

.variable-help {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.warning-text {
  background: var(--warning-bg);
  border: 1px solid rgba(138, 90, 0, 0.25);
  border-radius: 8px;
  color: var(--warning);
  margin: 12px 0 0;
  padding: 10px;
}

.warning-text:empty {
  display: none;
}

.message-details {
  background: var(--white);
  border: 1px solid rgba(201, 214, 214, 0.7);
  border-radius: 8px;
  padding: 10px 12px;
}

.message-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.message-details .case-summary {
  margin: 12px 0;
}

.report-dialog {
  border: 0;
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: 620px;
  padding: 0;
  width: min(620px, calc(100vw - 28px));
}

.report-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.report-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.report-card label {
  color: var(--text-muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 6px;
}

.report-card textarea {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 130px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

.report-context {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-muted);
  display: grid;
  font-size: 0.88rem;
  gap: 6px;
  padding: 10px 12px;
}

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

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .edit-banner,
  .edit-banner-actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .header-actions,
  .edit-banner-actions {
    flex-direction: column;
  }

  .workspace,
  .info-grid,
  .variables-grid {
    grid-template-columns: 1fr;
  }

  .message-list {
    max-height: 300px;
  }

  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .message-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .message-actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .message-actions button {
    flex: 1 1 auto;
  }

  .message-actions .nav-button {
    flex: 0 0 154px;
  }

  .active-profile-chip {
    flex: 1 1 100%;
    text-align: center;
    white-space: normal;
  }

  .mode-switch,
  .quick-buttons,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .message-actions .primary-button {
    width: auto;
  }

  #baseMessage,
  .preview-section pre {
    font-size: 16px;
    line-height: 1.55;
  }

  h1 {
    font-size: 1.55rem;
  }
}
