:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --ink: #16231f;
  --muted: #64716d;
  --line: #d9e1de;
  --line-strong: #b9c8c2;
  --green: #4f7d67;
  --green-strong: #2f5f4b;
  --aqua: #dfeae5;
  --blue: #315f72;
  --amber: #8a641e;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(23, 39, 34, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    linear-gradient(rgba(79, 125, 103, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 125, 103, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 82% 10%, rgba(223, 234, 229, 0.86), transparent 28rem),
    radial-gradient(circle at 12% 90%, rgba(49, 95, 114, 0.08), transparent 24rem),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
}

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

button,
.button {
  border: 0;
  border-radius: 999px;
  padding: 0.66rem 1rem;
  min-height: 38px;
  background: var(--green);
  color: white;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 700;
  line-height: 1;
}

button:hover,
.button:hover {
  background: var(--green-strong);
}

button.secondary,
.button.secondary {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

button.secondary:hover,
.button.secondary:hover,
button.secondary.active {
  background: var(--aqua);
  border-color: var(--line-strong);
}

button.danger,
.badge.danger {
  background: #fff0ed;
  color: var(--red);
  border: 1px solid #f5c4bd;
}

button.slim,
.button.slim {
  min-height: 32px;
  padding: 0.48rem 0.75rem;
  font-size: 0.86rem;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 0.72rem 0.82rem;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 125, 103, 0.12);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

label span,
legend {
  color: var(--ink);
  font-weight: 750;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

h1 {
  font-size: clamp(1.8rem, 3.6vw, 3.15rem);
}

h2 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
}

h3 {
  font-size: 1.08rem;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1rem 0;
}

code,
pre {
  font-family: "SF Mono", "Menlo", monospace;
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(240px, 330px);
  align-items: center;
  gap: 1rem;
  min-height: 68px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 30px rgba(25, 52, 43, 0.06);
  position: sticky;
  top: 12px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 15px;
  background: linear-gradient(135deg, #8aa896, #315f72);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55), 0 8px 22px rgba(49, 95, 114, 0.16);
}

.mark::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  left: 8px;
  top: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.85);
}

.brand strong,
.item-title strong {
  display: block;
  font-weight: 850;
}

.brand small,
small {
  color: var(--muted);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 999px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
  padding: 0.62rem 0.9rem;
  font-weight: 800;
}

.nav a.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 10px rgba(25, 52, 43, 0.07);
}

.user-switch {
  display: grid;
  gap: 0.25rem;
  font-size: 0.78rem;
}

.user-switch select {
  min-height: 40px;
  padding-block: 0.55rem;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 18px 0 14px;
  padding: 4px 2px;
}

.page-heading p {
  max-width: 720px;
  margin-top: 0.42rem;
}

.eyebrow {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.panel,
.hero-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1rem;
}

.hero-card {
  padding: 1.25rem;
}

.page-message {
  margin-top: 0.75rem;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.workspace.two-columns {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.55fr);
}

.crm-workspace {
  grid-template-columns: 390px minmax(0, 1fr);
}

.sidebar,
.content {
  min-height: 520px;
}

.sidebar {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.content {
  display: grid;
  gap: 1rem;
}

.grid {
  display: grid;
  gap: 0.8rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three,
.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 0.85rem;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.section-title,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.section-title.tight {
  margin-bottom: 0.65rem;
}

.card-list,
.cases-list,
.forms-list,
.audit-list {
  display: grid;
  gap: 0.65rem;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.82rem;
  background: #fff;
  display: grid;
  gap: 0.42rem;
}

.item-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 125, 103, 0.10);
}

.as-button {
  width: 100%;
  color: var(--ink);
  background: #fff;
  text-align: left;
  justify-content: initial;
  border: 1px solid var(--line);
  min-height: auto;
  font-weight: inherit;
}

.as-button:hover {
  background: var(--surface-soft);
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.24rem 0.55rem;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  color: var(--green-strong);
  background: #edf5f1;
  border-color: #c8d8d1;
}

.badge.warn {
  color: var(--amber);
  background: #fff7e8;
  border-color: #f2d7aa;
}

.notice,
.error,
.success,
.empty-state {
  border-radius: 18px;
  padding: 0.85rem;
}

.notice {
  color: #6a4a15;
  background: #fff8e8;
  border: 1px solid #f0dbb4;
}

.error {
  color: var(--red);
  background: #fff0ed;
  border: 1px solid #f5c4bd;
}

.success {
  color: var(--green-strong);
  background: #edf5f1;
  border: 1px solid #c8d8d1;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 150px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line-strong);
}

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

.filters {
  margin-bottom: 0.8rem;
}

.case-pipeline {
  display: flex;
  gap: 0.45rem;
  overflow: auto;
  padding-bottom: 0.6rem;
  margin-bottom: 0.6rem;
}

.pipeline-chip {
  min-width: max-content;
  min-height: 34px;
  padding: 0.46rem 0.65rem;
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.pipeline-chip b {
  margin-left: 0.35rem;
}

.pipeline-chip.active {
  background: var(--green);
  color: #fff;
}

.case-summary,
.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.case-summary > div,
.value-card {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  display: grid;
  gap: 0.25rem;
}

.case-summary span,
.value-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.operator-panel,
.data-panel,
.nested {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 1rem;
}

.form-builder-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}

.form-canvas,
.builder-tools {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-soft);
  padding: 1rem;
}

.builder-tools {
  position: sticky;
  top: 96px;
}

.question-list {
  display: grid;
  gap: 0.75rem;
  min-height: 180px;
  border-radius: 18px;
}

.question-list.drop-ready {
  outline: 2px dashed var(--green);
  outline-offset: 6px;
}

.question-card {
  background: #fff;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.question-card.dragging {
  opacity: 0.64;
  transform: scale(0.99);
  border-color: var(--green);
  box-shadow: 0 18px 42px rgba(79, 125, 103, 0.14);
}

.question-head,
.question-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.drag-handle {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: grab;
  letter-spacing: -0.22em;
}

.drag-handle:active {
  cursor: grabbing;
}

.question-number {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--aqua);
  color: var(--green-strong);
  font-weight: 900;
}

.compact-form {
  gap: 0.65rem;
}

.add-field-card {
  border: 0;
  padding: 0;
}

.field-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.palette-item {
  min-height: 34px;
  padding: 0.48rem 0.55rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  cursor: grab;
}

.palette-item:hover {
  background: var(--aqua);
}

.form-preview {
  border: 1px dashed var(--line-strong);
  background: #fff;
  border-radius: 22px;
  padding: 1rem;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check-line input {
  width: auto;
}

.checkbox-field {
  margin: 0;
}

.user-card {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--aqua);
  color: var(--green-strong);
  font-weight: 900;
}

.audit-row {
  display: grid;
  grid-template-columns: 1fr 220px minmax(220px, 0.8fr);
  gap: 0.8rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.audit-row > div {
  display: grid;
  gap: 0.2rem;
}

.audit-row code {
  color: var(--muted);
  word-break: break-word;
  font-size: 0.78rem;
}

.table,
.link-grid,
.steps {
  display: grid;
  gap: 0.65rem;
}

.link-grid,
.steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.step-card,
.link-card {
  color: var(--ink);
  text-decoration: none;
}

.step-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: #fff;
  display: grid;
  gap: 0.35rem;
}

.step-card b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--aqua);
  color: var(--green-strong);
}

.kpi {
  min-height: 118px;
  align-content: space-between;
}

.kpi strong {
  font-size: 2.35rem;
  letter-spacing: -0.06em;
}

.public-shell {
  width: min(760px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  align-items: center;
  margin: 0 auto;
  padding: 32px 0;
}

.public-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 2rem);
}

.public-card h1 {
  margin-bottom: 0.65rem;
}

.public-form {
  margin-top: 1.3rem;
}

.done-card {
  text-align: center;
}

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

  .nav {
    justify-content: flex-start;
    overflow: auto;
  }

  .workspace,
  .workspace.two-columns,
  .crm-workspace,
  .form-builder-workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .builder-tools {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1360px);
    padding-top: 10px;
  }

  .page-heading {
    display: grid;
  }

  .grid.two,
  .grid.three,
  .stat-strip,
  .case-summary,
  .value-grid,
  .link-grid,
  .steps,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .field-palette {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }
}

/* Builder simplificado tipo Google Forms */
.tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  margin: 0.85rem 0;
}

.tabs a {
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
  padding: 0.48rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 800;
}

.tabs a.active,
.tabs a:hover {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 10px rgba(25, 52, 43, 0.07);
}

.form-builder-workspace {
  grid-template-columns: minmax(0, 1fr) 300px;
}

.form-canvas,
.builder-tools {
  border-radius: 18px;
  padding: 0.9rem;
}

.builder-tools {
  background: #fff;
}

.question-list {
  min-height: 128px;
}

.question-list.is-empty {
  min-height: 110px;
}

.question-list.is-empty .empty-state,
.question-list .empty-state {
  min-height: 104px;
  padding: 1rem;
}

.simple-question {
  padding: 1rem;
  gap: 0.8rem;
}

.question-main-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 180px;
  gap: 0.65rem;
  align-items: center;
}

.question-title-input {
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding-inline: 0;
  font-size: 1.02rem;
  font-weight: 750;
  background: transparent;
}

.question-title-input:focus {
  box-shadow: none;
  border-color: var(--green);
}

.question-type-select {
  min-height: 38px;
  padding-block: 0.52rem;
}

.answer-preview-line {
  padding-left: 3.2rem;
}

.fake-answer {
  display: block;
  width: min(420px, 100%);
  color: var(--muted);
  border-bottom: 1px dashed var(--line-strong);
  padding: 0.45rem 0 0.5rem;
}

.fake-answer.long {
  width: 100%;
}

.advanced-options {
  margin-left: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 0.55rem 0.7rem;
}

.advanced-options summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.advanced-options[open] {
  display: grid;
  gap: 0.75rem;
}

.advanced-options[open] summary {
  margin-bottom: 0.25rem;
}

.question-actions {
  margin-left: 3.2rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.field-palette {
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.palette-item {
  justify-content: flex-start;
  min-height: 34px;
  border-radius: 12px;
  padding-inline: 0.7rem;
  font-size: 0.84rem;
  background: var(--surface-soft);
}

.add-field-card .section-title h3 {
  font-size: 1rem;
}

.add-field-card .section-title p,
.add-field-card small {
  font-size: 0.86rem;
}

@media (max-width: 720px) {
  .question-main-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .question-type-select {
    grid-column: 2;
  }

  .answer-preview-line,
  .advanced-options,
  .question-actions {
    margin-left: 0;
    padding-left: 0;
  }
}

/* Catalogo principal de formularios */
.search-box {
  margin-bottom: 0.8rem;
}

.forms-catalog {
  display: grid;
  gap: 0.65rem;
}

.form-tile {
  width: 100%;
  min-height: auto;
  display: grid;
  gap: 0.65rem;
  text-align: left;
  justify-content: stretch;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  padding: 0.85rem;
  font-weight: inherit;
}

.form-tile:hover,
.form-tile.selected {
  background: var(--surface-soft);
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 125, 103, 0.08);
}

.form-tile p {
  margin-top: 0.3rem;
  font-size: 0.9rem;
}

.form-tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.form-tile-meta span {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0.24rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 800;
}

/* Vista Formularios mas sobria */
body:has(.forms-sidebar) .page-heading h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
}

body:has(.forms-sidebar) .page-heading {
  margin: 14px 0 10px;
}

.forms-sidebar,
.forms-detail {
  min-height: 0;
}

.forms-sidebar {
  padding: 0.9rem;
}

.forms-sidebar .section-title h2 {
  font-size: 1.45rem;
}

.forms-sidebar .section-title p {
  font-size: 0.92rem;
}

.forms-sidebar details {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.7rem;
  background: var(--surface-soft);
  margin-bottom: 0.75rem;
}

.forms-sidebar summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.form-tile {
  border-radius: 16px;
  padding: 0.8rem;
  gap: 0.5rem;
}

.form-tile .item-title strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
  text-transform: none;
}

.form-tile p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.form-tile-meta span {
  background: #fff;
  border: 1px solid var(--line);
}

.form-slug {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.forms-catalog {
  gap: 0.5rem;
}

.search-box input {
  min-height: 42px;
  padding-block: 0.58rem;
}

/* Panel de tipos mas claro */
.add-field-card .section-title p {
  max-width: 260px;
}

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

.field-palette {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.palette-item {
  justify-content: flex-start;
  gap: 0.45rem;
  min-height: 36px;
  border-radius: 12px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.palette-item span {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--green-strong);
  font-size: 0.72rem;
  font-weight: 900;
}

.palette-item:hover,
.palette-item:focus {
  background: var(--surface-soft);
  border-color: var(--green);
}

.builder-tools .compact-form {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.question-list {
  position: relative;
}

.question-list.is-empty::before,
.question-list.drop-ready::before {
  content: 'Soltá acá para crear o reordenar preguntas';
  position: absolute;
  inset: 0.55rem;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.58);
}

.question-list.is-empty .empty-state {
  opacity: 0;
  pointer-events: none;
}

.question-list.drop-ready {
  outline: 2px solid var(--green);
  outline-offset: 4px;
}

/* Canvas de preguntas mas amplio */
.form-builder-workspace {
  grid-template-columns: minmax(720px, 1fr) 260px;
}

.form-canvas {
  min-height: 68vh;
  padding: 1.15rem;
}

.question-list {
  min-height: 56vh;
  align-content: start;
}

.question-list.is-empty {
  min-height: 56vh;
}

.simple-question {
  padding: 1.15rem 1.25rem;
}

.builder-tools {
  max-width: 280px;
}

.content.forms-detail {
  overflow-x: auto;
}

@media (max-width: 1180px) {
  .form-builder-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .builder-tools {
    max-width: none;
  }
}

/* Tablero de casos */
.case-dashboard {
  display: grid;
  gap: 1rem;
}

.case-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  min-height: 90px;
}

.case-toolbar h2 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
}

.case-filters {
  display: flex;
  align-items: end;
  gap: 0.65rem;
}

.case-filters label {
  min-width: 240px;
}

.case-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.case-metric {
  min-height: 90px;
  display: grid;
  align-content: space-between;
}

.case-metric span {
  color: var(--muted);
  font-weight: 800;
}

.case-metric strong {
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.case-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.case-column {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
  padding: 0.75rem;
}

.case-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.case-column-head strong {
  font-size: 0.92rem;
}

.case-column-head span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 900;
  font-size: 0.78rem;
}

.case-column-list {
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.case-board-card {
  width: 100%;
  min-height: auto;
  display: grid;
  gap: 0.35rem;
  text-align: left;
  justify-content: stretch;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 0.75rem;
  font-weight: inherit;
}

.case-board-card:hover,
.case-board-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 125, 103, 0.08);
  background: #fff;
}

.case-board-card .item-title span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.case-board-card p {
  font-size: 0.88rem;
}

.case-empty {
  min-height: 86px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  font-weight: 800;
  font-size: 0.85rem;
}

.case-detail-drawer {
  margin-top: 0.25rem;
}

@media (max-width: 900px) {
  .case-toolbar,
  .case-filters {
    display: grid;
  }

  .case-filters label {
    min-width: 0;
  }

  .case-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Login */
.session-chip {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.session-chip div {
  display: grid;
  gap: 0.1rem;
  padding-left: 0.55rem;
}

.session-chip strong {
  font-size: 0.9rem;
}

.session-chip small {
  font-size: 0.76rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 80% 18%, rgba(223, 234, 229, 0.9), transparent 28rem),
    var(--bg);
}

.login-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 1.35rem;
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-panel .mark {
  width: 52px;
  height: 52px;
}

.login-panel h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.login-users {
  display: grid;
  gap: 0.65rem;
}

.login-user-card {
  width: 100%;
  min-height: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  justify-content: stretch;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  padding: 0.8rem;
  font-weight: inherit;
}

.login-user-card:hover {
  background: var(--surface-soft);
  border-color: var(--green);
}

.login-user-card div:not(.avatar) {
  display: grid;
  gap: 0.15rem;
}

.login-user-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.login-user-card em {
  font-style: normal;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 0.3rem 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

/* Ajuste para que el tablero entre en pantalla */
.case-dashboard {
  gap: 0.75rem;
}

.case-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.case-metric {
  min-height: 72px;
  padding: 0.8rem;
}

.case-metric strong {
  font-size: 1.65rem;
}

.case-board {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 0.55rem;
  overflow-x: visible;
}

.case-column {
  min-height: calc(100vh - 360px);
  max-height: calc(100vh - 300px);
  padding: 0.55rem;
  border-radius: 16px;
  overflow: hidden;
}

.case-column-head {
  margin-bottom: 0.5rem;
}

.case-column-head strong {
  font-size: 0.82rem;
  white-space: nowrap;
}

.case-column-head span {
  min-width: 22px;
  height: 22px;
  font-size: 0.72rem;
}

.case-column-list {
  max-height: calc(100vh - 365px);
  overflow: auto;
  gap: 0.45rem;
}

.case-empty {
  min-height: 64px;
  font-size: 0.78rem;
}

.case-board-card {
  padding: 0.62rem;
  border-radius: 14px;
}

.case-board-card p,
.case-board-card small {
  font-size: 0.78rem;
}

@media (max-width: 1200px) {
  .case-board {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }
}

@media (max-width: 760px) {
  .case-board {
    grid-template-columns: 1fr;
  }

  .case-column {
    min-height: auto;
    max-height: none;
  }

  .case-column-list {
    max-height: none;
  }
}

/* Evitar overflow horizontal en Formularios */
.app-shell,
.workspace,
.content,
.forms-detail,
.form-builder-workspace,
.form-canvas,
.builder-tools {
  min-width: 0;
}

.workspace {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
}

.forms-detail {
  max-width: 100%;
  overflow: hidden;
}

.form-builder-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  max-width: 100%;
}

.forms-detail > .section-title {
  align-items: start;
}

.forms-detail > .section-title .inline {
  justify-content: flex-end;
  max-width: 42%;
}

.forms-detail > .section-title .inline .button,
.forms-detail > .section-title .inline button {
  white-space: normal;
  text-align: center;
  max-width: 220px;
}

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

  .form-builder-workspace {
    grid-template-columns: 1fr;
  }

  .forms-detail > .section-title {
    display: grid;
  }

  .forms-detail > .section-title .inline {
    max-width: none;
    justify-content: flex-start;
  }
}

/* Firma */
.jsv-signature {
  margin-top: 1.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0.72;
}

.login-panel .jsv-signature,
.public-card .jsv-signature {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

/* Demo controls */
.session-chip {
  max-width: 460px;
}

.session-chip #reset-demo {
  background: #fff;
}

.login-panel > #reset-demo {
  width: 100%;
}

@media (max-width: 760px) {
  .session-chip {
    justify-self: stretch;
    border-radius: 18px;
    display: grid;
    grid-template-columns: 1fr auto auto;
  }
}

/* Formularios activos */
.active-forms-view {
  margin-top: 1rem;
}

.active-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.active-form-card {
  display: grid;
  gap: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 1rem;
}

.active-form-card code {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0.55rem;
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .active-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Footer demo controls */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1.4rem;
  padding: 0.9rem 0;
}

.app-footer .jsv-signature {
  margin-top: 0;
}

.app-footer {
  flex-direction: column-reverse;
  gap: 0.45rem;
}
