@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --table-subtle: #f8fafc;
  --border: #ebe9e4;
  --text-primary: #1b1a17;
  --text-secondary: #6e6b64;
  --text-muted: #9d9a92;
  --accent: #bd7b4f;
  --positive: #4f7d5e;
  --danger: #b0544a;

  --bg-subtle: var(--surface-subtle);
  --surface-soft: var(--surface-subtle);
  --surface-hover: var(--surface-subtle);
  --line: var(--border);
  --line-strong: #dedbd3;
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --muted: var(--text-secondary);
  --muted-light: var(--text-muted);
  --accent-soft: rgba(189, 123, 79, 0.08);
  /* Dorado apagado, solo para el target: lo separa del total sin gritar. */
  --gold: #a8853a;
  --gold-line: rgba(168, 133, 58, 0.4);
  --gold-soft: rgba(168, 133, 58, 0.07);
  --blue-soft: #f2f5f7;
  --blue-line: #e0e5e8;
  --blue-ink: #55626b;
  --danger-soft: rgba(176, 84, 74, 0.1);
  --warning: #a3663d;
  --success: var(--positive);
  --shadow-sm: 0 1px 2px rgba(20, 18, 15, 0.04);
  --shadow-md: 0 14px 38px rgba(20, 18, 15, 0.08);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --workspace-max: 1128px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text-xs: 10px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-lg: 15px;
  --text-xl: 20px;
  --text-2xl: 28px;
  --lh-tight: 1.15;
  --lh-body: 1.45;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 260ms;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-body);
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

input,
select,
textarea,
.money-input,
.square-meter-input,
.inline-number,
.total-pill,
.financial-amounts strong,
.summary-card strong,
.rail-stats strong,
.project-meta strong {
  font-variant-numeric: tabular-nums;
}

button {
  color: inherit;
}

button,
[data-action],
[data-budget],
[data-method],
[data-panel],
[data-render-unit] {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(189, 123, 79, 0.28);
  outline-offset: 2px;
}

svg {
  display: block;
  flex: 0 0 auto;
}

::selection {
  background: rgba(189, 123, 79, 0.18);
}

.openai-app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.openai-main {
  min-width: 0;
  background: var(--bg);
  padding: 32px clamp(28px, 4vw, 72px) 64px;
}

.workspace-main {
  overflow-x: auto;
}

.workspace-shell {
  width: min(100%, var(--workspace-max));
  margin: 0 auto;
  border: 1px solid rgba(235, 233, 228, 0.88);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(20, 18, 15, 0.05);
  overflow: hidden;
  padding: 30px 28px 0;
}

.side-rail {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 18px 16px;
}

.rail-brand {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 11px;
  padding: 0 4px;
}

.rail-brand strong {
  display: block;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 680;
  line-height: 1.15;
}

.rail-brand span:not(.mark-dot) {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.mark-dot {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
}

.mark-dot::after {
  content: "P";
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.rail-new,
.button,
.tab-button,
.view-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0 10px;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 620;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.workspace-page-head .view-button,
.workspace-page-head .danger-button,
.budget-toolbar .tab-button {
  min-height: 28px;
  padding-inline: 9px;
}

.rail-new {
  width: 100%;
  justify-content: flex-start;
  min-height: 34px;
  border-color: transparent;
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

.rail-new:hover,
.button.primary:hover {
  background: #2a2925;
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.button:not(.primary):hover,
.tab-button:hover,
.view-button:hover,
.ghost-button:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.tab-button.active,
.view-button.active {
  border-color: transparent;
  background: var(--surface-subtle);
  color: var(--ink);
  box-shadow: none;
}

.danger-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.danger-button:hover {
  border-color: rgba(176, 84, 74, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
}

.rail-block {
  display: grid;
  min-height: 0;
  gap: 7px;
}

.rail-label,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rail-label {
  padding: 0 6px;
}

.rail-label small,
.section-title small {
  color: var(--muted-light);
  font-weight: 560;
}

.rail-projects {
  display: grid;
  gap: 4px;
}

.rail-project {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
}

.rail-project:hover {
  background: var(--surface-subtle);
}

.rail-project.selected {
  border-color: transparent;
  background: var(--surface-subtle);
  box-shadow: none;
}

.rail-project span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-project small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-stats {
  display: grid;
  gap: 4px;
  margin-top: auto;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  padding: 12px;
}

.rail-stats span,
.rail-stats small {
  color: var(--muted);
  font-size: 11px;
}

.rail-stats strong {
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 690;
  line-height: var(--lh-tight);
}

.rail-sync {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 131, 99, 0.1);
}

.page-head {
  display: flex;
  max-width: 1180px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 24px;
}

.workspace-page-head {
  width: 100%;
  max-width: none;
  align-items: center;
  margin: 0 0 22px;
}

.page-head h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f4f4;
  padding: 2px;
}

.sort-toggle button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  font-size: var(--text-sm);
  font-weight: 620;
  cursor: pointer;
}

.sort-toggle button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.back-link {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: var(--text-sm);
  cursor: pointer;
}

.back-link:hover {
  color: var(--ink);
}

.title-input {
  display: block;
  width: min(560px, calc(100vw - 40px));
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 0 3px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}

.title-input:hover,
.title-input:focus {
  border-color: var(--line);
  background: var(--surface);
}

.top-actions,
.tabs,
.budget-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.top-actions {
  align-items: center;
}

.workspace-page-head .view-button {
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
  min-height: 30px;
}

.workspace-page-head .view-button.active {
  border-bottom-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

.workspace-page-head .view-button:hover {
  background: transparent;
  color: var(--ink);
}

.overview-strip,
.summary-grid,
.finance-grid,
.project-grid {
  width: 100%;
  max-width: 1180px;
  margin-right: auto;
  margin-left: auto;
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.overview-strip article,
.summary-card,
.financial-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: none;
}

.overview-strip article {
  min-height: 88px;
  padding: 14px;
}

.overview-strip span,
.summary-card label,
.financial-card label {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 610;
}

.overview-strip strong,
.summary-card strong,
.financial-amounts strong {
  display: block;
  color: var(--ink);
  font-weight: 690;
  line-height: var(--lh-tight);
}

.overview-strip strong {
  margin-top: 10px;
  font-size: 22px;
}

.section-title {
  max-width: 1180px;
  margin: 0 auto 8px;
  padding: 0 2px;
}

.section-title span {
  color: var(--ink-soft);
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.project-card,
.create-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  min-height: 74px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    transform var(--dur-2) var(--ease-out);
}

.project-card:hover,
.create-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.project-card.selected {
  border-color: var(--line-strong);
  background: #fff;
}

.folder-icon,
.round-icon {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
}

.project-main {
  min-width: 0;
}

.project-main h2 {
  margin: 0 0 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 690;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-main span,
.project-meta span {
  color: var(--muted);
  font-size: var(--text-sm);
}

.project-meta {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 128px;
}

.project-meta strong {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 690;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button,
.arrow-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.icon-button.compact {
  width: 30px;
  height: 30px;
}

.icon-button:hover,
.arrow-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink);
}

.project-card.selected .arrow-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.create-card {
  grid-template-columns: 36px minmax(0, 1fr);
  border-style: dashed;
  color: var(--muted);
  font-weight: 650;
}

.budget-toolbar {
  width: 100%;
  max-width: none;
  margin: 0 0 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.budget-toolbar .tabs {
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.budget-toolbar .tab-button {
  border-radius: 999px;
  background: transparent;
}

.budget-toolbar .tab-button.active {
  background: var(--surface-subtle);
}

.separator {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.summary-section {
  display: grid;
  width: 100%;
  max-width: none;
  gap: 30px;
  margin: 0;
}

.summary-stack {
  display: grid;
  gap: 12px;
}

.summary-grid {
  display: grid;
  gap: 12px;
  max-width: none;
}

.primary-summary-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.secondary-summary-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  display: grid;
  min-height: 96px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 16px 14px;
  box-shadow: 0 2px 5px rgba(20, 18, 15, 0.055);
}

.summary-card label {
  display: flex;
  min-height: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #637083;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-card strong {
  margin-top: 9px;
  font-size: 16px;
  font-weight: 700;
}

.summary-card small {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.total-base-card strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.total-base-card {
  grid-column: auto;
}

.land-card,
.square-meter-card {
  display: grid;
  align-content: start;
  gap: 7px;
}

.money-input,
.square-meter-input,
.inline-number {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  padding: 0 7px;
}

.money-input {
  min-height: 32px;
}

.compact-money-input {
  width: 100%;
}

.money-input input,
.square-meter-input input,
.inline-number input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  outline: 0;
}

.money-input:focus-within,
.square-meter-input:focus-within,
.inline-number:focus-within {
  border-color: rgba(189, 123, 79, 0.48);
  box-shadow: 0 0 0 3px rgba(189, 123, 79, 0.09);
}

.money-input span,
.square-meter-input span,
.inline-number span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.readonly-money {
  background: var(--surface-subtle);
}

.readonly-money input {
  color: var(--muted);
}

.square-meter-input {
  width: max-content;
  min-height: 26px;
}

.square-meter-input input {
  width: 54px;
  text-align: right;
}

.inline-number {
  min-height: 26px;
  padding-right: 6px;
}

.inline-number input,
.percent-input {
  width: 44px;
  text-align: right;
}

.percent-input {
  min-height: 22px;
}

.finance-panel {
  max-width: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.finance-panel-head {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 0;
  background: transparent;
  padding: 0 2px 12px;
}

.finance-panel-head span,
.finance-scale span,
.financial-fieldset span,
.financial-amounts span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.finance-panel-head strong {
  display: block;
  color: var(--ink);
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.finance-scale {
  display: flex;
  gap: 12px;
}

.finance-head-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 26px;
}

/* Impuestos al vender, por casa: lo que ya se desconto de mi retorno. */
.impuestos-casa {
  display: grid;
  justify-items: end;
  gap: 3px;
  text-align: right;
}

.impuestos-casa > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.finance-panel-head .impuestos-casa strong {
  display: inline;
  margin-top: 0;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

.impuestos-casa small {
  color: var(--muted-light);
  font-size: 11px;
}

/* % de compras con factura: de ahi sale el credito de IVA. */
.impuestos-factura {
  display: flex;
  align-items: center;
  gap: 6px;
}

.finance-panel-head .impuestos-factura span {
  font-size: 11px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  max-width: none;
}

.financial-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px 16px;
  box-shadow: 0 2px 5px rgba(20, 18, 15, 0.055);
}

.financial-card:last-child {
  border-right: 1px solid var(--line);
}

.financial-card label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #637083;
  font-size: 11px;
  font-weight: 600;
}

.financial-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.financial-fieldset,
.financial-amounts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.financial-fieldset > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.financial-fieldset .money-input {
  min-width: 0;
}

.financial-amounts > div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.financial-amounts strong {
  font-size: 14px;
  font-weight: 500;
}

.owner-profit-card {
  border-color: rgba(189, 123, 79, 0.18);
  background:
    linear-gradient(180deg, rgba(189, 123, 79, 0.06), transparent 92%),
    rgba(255, 255, 255, 0.84);
}

.owner-profit-card label,
.owner-profit-card strong {
  color: var(--accent);
}

/* Escenario 2: mismo panel, separado del 1 por una linea para que se lea como otra
   cuenta y no como una continuacion de la anterior. */
/* Mi retorno en negativo: la venta no llega a cubrir lo pactado con el inversor. */
.owner-profit-card.is-negative {
  border-color: rgba(176, 84, 74, 0.22);
  background:
    linear-gradient(180deg, rgba(176, 84, 74, 0.07), transparent 92%),
    rgba(255, 255, 255, 0.84);
}

.owner-profit-card.is-negative label,
.owner-profit-card.is-negative strong {
  color: var(--danger);
}

/* Notas de la variante: se ven como una linea y se agrandan al hacer clic. */
.method-notes {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(150px, 0.6fr) minmax(170px, 0.7fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface, #fff);
  padding: 8px 28px 10px;
}

.method-note {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.method-note > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.method-note textarea {
  width: 100%;
  height: 30px;
  min-height: 30px;
  overflow: hidden;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface, #fff);
  color: var(--ink);
  padding: 6px 9px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  transition: height 140ms ease, border-color 120ms ease;
}

.method-note textarea::placeholder {
  color: var(--muted-light, #9aa0a6);
}

.method-note textarea:hover {
  border-color: var(--ink-soft, #666);
}

/* Al hacer clic se abre grande */
.method-note textarea:focus,
.method-note textarea.is-open {
  height: 168px;
  overflow: auto;
  outline: none;
  border-color: var(--accent);
}

/* Miniaturas de imagenes de la variante */
.method-images {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

.method-images-loading {
  color: var(--muted);
  font-size: 12px;
}

.method-thumb {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 38px;
}

.method-thumb img {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
  cursor: zoom-in;
  transition: border-color .12s, transform .05s;
}

.method-thumb img:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.method-thumb-del {
  position: absolute;
  top: -5px;
  right: -5px;
  display: none;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #b42318;
  color: #fff;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.method-thumb:hover .method-thumb-del {
  display: flex;
}

.method-add-image {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}

.method-add-image:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.method-add-image input {
  display: none;
}

/* Documentos de la variante: PDF, Markdown y SVG, uno por chip. */
.method-docs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.method-doc {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
  transition: border-color .12s;
}

.method-doc:hover {
  border-color: var(--accent);
}

.method-doc-open {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.method-doc.pdf .method-doc-open > svg {
  color: var(--danger);
}

.method-doc.md .method-doc-open > svg {
  color: var(--blue-ink);
}

.method-doc.svg .method-doc-open > svg {
  color: var(--positive);
}

.method-doc-name {
  overflow: hidden;
  max-width: 130px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.method-doc-open small {
  color: var(--muted-light);
  font-size: 10px;
  white-space: nowrap;
}

.method-doc-del {
  display: none;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border: 0;
  border-radius: 50%;
  background: #b42318;
  color: #fff;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.method-doc:hover .method-doc-del {
  display: flex;
}

.method-add-doc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}

.method-add-doc:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.method-add-doc input {
  display: none;
}

@media (max-width: 700px) {
  .method-notes { grid-template-columns: 1fr; padding: 8px 12px 10px; }
  .method-doc-name { max-width: 180px; }
}

/* Manija para reordenar items arrastrando (aparece al pasar el mouse por la fila) */
.item-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.item-cell input {
  flex: 1 1 auto;
  min-width: 0;
}

.drag-handle {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--muted);
  cursor: grab;
  opacity: 0;
  transition: opacity 120ms ease;
}

.edit-row:hover .drag-handle {
  opacity: 0.5;
}

.drag-handle:hover {
  opacity: 1;
}

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

/* Con el orden por costo puesto no se puede arrastrar: lo que se ve en pantalla no
   es el orden guardado, asi que soltar el item lo dejaria en otro lugar. */
.drag-handle.is-disabled,
.drag-handle.is-disabled:hover {
  cursor: not-allowed;
  opacity: 0.25;
}

.edit-row.is-dragging {
  opacity: 0.4;
}

.edit-row.is-drag-over {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

/* Contenedor con scroll horizontal: si la pantalla es angosta, en vez de cortar
   las ultimas columnas se puede desplazar y se ven todas. */
.budget-scroll {
  margin: 0 -28px;
  overflow-x: auto;
  overflow-y: visible;
}

.budget-table {
  min-width: 1060px;
}

/* Header e items del presupuesto: diez columnas de datos, tres de planificacion de
   compra (dia de obra, dias antes, dia de pedido) y la de acciones. El cronograma de
   dias reusa .edit-row pero no lleva las de plan, de ahi el :not con schedule. */
.table-header,
.edit-row:not([data-schedule-id]) {
  display: grid;
  grid-template-columns:
    minmax(128px, 1.15fr)
    minmax(58px, 0.34fr)
    minmax(50px, 0.26fr)
    minmax(78px, 0.42fr)
    minmax(88px, 0.46fr)
    minmax(86px, 0.85fr)
    minmax(94px, 0.9fr)
    minmax(66px, 0.34fr)
    40px
    minmax(66px, 0.38fr)
    minmax(156px, 0.8fr)
    74px;
  align-items: center;
  column-gap: 6px;
}

/* La fila de etapa y el cronograma de dias conservan el grid original de 10 columnas.
   La etapa usa spans propios; el cronograma de dias no tiene columnas de plan. */
.stage-row,
.edit-row[data-schedule-id] {
  display: grid;
  grid-template-columns:
    minmax(160px, 1.35fr)
    minmax(68px, 0.4fr)
    minmax(56px, 0.28fr)
    minmax(96px, 0.48fr)
    minmax(104px, 0.5fr)
    minmax(140px, 1.1fr)
    minmax(140px, 1.1fr)
    minmax(70px, 0.34fr)
    minmax(92px, 0.46fr)
    62px;
  align-items: center;
  column-gap: 10px;
}

/* Blindaje: si un hijo tiene una columna anterior a la del hijo de antes, grid lo
   manda a una fila nueva y la etapa se parte en dos lineas. Fijando la fila 1 no
   puede pasar, sin importar el orden del HTML. */
.stage-row > * {
  grid-row: 1;
}

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

.row-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

/* Menu flotante "mover a otra etapa" */
.move-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.move-item-menu {
  position: fixed;
  z-index: 61;
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.16);
}

.move-item-menu-title {
  padding: 6px 8px 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.move-item-menu .move-option {
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
}

.move-item-menu-empty {
  padding: 8px 10px 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.table-header {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  max-width: none;
  min-height: 42px;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fbfcfd;
  color: var(--muted);
  margin: 30px 0 0;
  padding: 0 28px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  backdrop-filter: none;
}

.stages {
  width: 100%;
  max-width: none;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--surface);
  margin: 0;
}

.stage {
  background: transparent;
}

.stage-row {
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0 28px;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.stage-row:hover {
  background: var(--table-subtle);
}

/* La fila de la etapa queda blanca tambien cuando esta abierta. */
.stage.open .stage-row {
  background: var(--surface, #fff);
}

.stage-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 500;
}

.stage-title > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  color: var(--muted-light);
  transform: rotate(0deg);
  transition: transform 150ms ease;
}

.stage.open .chevron {
  transform: rotate(90deg);
}

.stage-desc {
  grid-column: 3 / 6;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nombre, descripcion y tipo se editan directo en la fila grande de la etapa. */
.stage-name-input,
.stage-desc-input,
.stage-type-select {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 6px 8px;
  font-family: inherit;
  cursor: text;
}

.stage-name-input {
  flex: 1 1 auto;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

.stage-desc-input {
  grid-column: 2 / 5;
  color: var(--muted);
  font-size: 13px;
}

.stage-type-select {
  grid-column: 5 / 7;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

.stage-row .total-pill {
  grid-column: 7 / 9;
}

/* En la fila de etapa todo va un punto mas chico: son diez columnas en una linea. */
.stage-row .total-pill {
  gap: 5px;
  min-height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

/* Al pie de una tarjeta del resumen: la misma cuenta de arriba, pero con targets.
   En el HTML ya va ultima en las tres tarjetas, asi que no hace falta reordenar. */
.card-target {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 7px;
  border-top: 1px dashed var(--gold-line);
  padding-top: 6px;
}

.card-target > span {
  flex: 0 0 auto;
  color: var(--gold);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-target strong {
  margin-top: 0;
  color: var(--ink);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

/* El total base es la tarjeta grande: su target va del mismo tamano que el total. */
.total-base-card .card-target strong {
  font-size: 17px;
}

/* La tarjeta de metro cuadrado separa a sus hijos con gap, no con margenes: ahi el
   margen de arriba sobra y dejaria el doble de aire. */
.square-meter-card .card-target {
  margin-top: 0;
}

/* La fila secundaria crece: tres de sus cuatro tarjetas ganaron una linea. Se le da
   el alto a todas para que la de dias de obra no quede corta al lado. */
.secondary-summary-row .summary-card {
  min-height: 132px;
}

/* Sin comparacion contra el total a proposito: mientras haya etapas sin target
   cargado, cualquier "sobra/excede" seria un numero que enganna. */

/* --- Switch on/off de la etapa ------------------------------------------- */
/* Apagada: la etapa sigue existiendo y se puede editar, pero no suma al total. */
.stage-switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-subtle);
  padding: 0;
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out);
}

.stage-switch:hover {
  border-color: var(--muted-light);
}

.stage-switch.on {
  border-color: var(--positive);
  background: var(--positive);
}

.stage-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-1) var(--ease-out);
}

.stage-switch.on .stage-switch-knob {
  transform: translateX(16px);
}

/* Etapa apagada: gris y apagada. Se atenuan los hijos y no la fila entera, para
   que el switch y el basurero sigan a la vista para poder volver a prenderla. */
.stage.off .stage-title,
.stage.off .stage-desc-input,
.stage.off .stage-type-select,
.stage.off .stage-row .total-pill,
.stage.off .stage-body {
  opacity: 0.45;
  filter: grayscale(1);
}

.stage.off .stage-row {
  background: var(--surface-subtle);
}

.stage.off .stage-row .total-pill {
  text-decoration: line-through;
}

.stage-name-input:hover,
.stage-desc-input:hover,
.stage-type-select:hover {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.stage-name-input:focus,
.stage-desc-input:focus,
.stage-type-select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface, #fff);
}

.total-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.stage-body {
  display: none;
  background: var(--table-subtle);
}

.stage.open .stage-body {
  display: block;
}

.method-bar,
.section-bar,
.add-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  border-bottom: 1px solid var(--line);
  background: var(--table-subtle);
  padding: 5px 28px;
}

/* --- Proveedores: agenda de contactos de la etapa, sin precios --- */
.proveedores-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--muted);
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.proveedores-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.proveedores-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.proveedores-panel {
  border-bottom: 1px solid var(--line);
  background: var(--surface, #fff);
  padding: 12px 28px 4px;
}

.proveedores-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.proveedores-head span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.proveedores-head small {
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 400;
}

.proveedor-row {
  display: grid;
  grid-template-columns:
    minmax(120px, 1fr)
    minmax(120px, 0.8fr)
    minmax(120px, 1fr)
    minmax(160px, 1.6fr)
    36px;
  align-items: center;
  column-gap: 10px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.proveedor-row:last-of-type {
  border-bottom: 0;
}

.proveedor-header {
  min-height: 26px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted-light);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.proveedor-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
}

.proveedor-row input:hover {
  border-color: var(--line);
}

.proveedor-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface, #fff);
}

.proveedor-phone {
  display: flex;
  align-items: center;
  gap: 4px;
}

.proveedor-wa {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--positive);
}

.proveedor-wa:hover {
  background: var(--surface-subtle);
}

.proveedor-row .icon-button {
  width: 26px;
  height: 26px;
}

/* En celular las filas se apilan y cada campo muestra su etiqueta. */
@media (max-width: 700px) {
  .proveedores-panel {
    padding: 12px;
  }

  .proveedor-header {
    display: none;
  }

  .proveedor-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 0;
  }

  .proveedor-row > div::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted-light);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
  }

  .proveedor-row .icon-button {
    justify-self: end;
  }
}

/* --- Subetapas: mini-etapas dentro de una etapa, con sus propias variantes --- */
.substage {
  border-top: 1px solid var(--line);
  background: var(--surface, #fff);
}

.substage-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  padding: 2px 28px 2px 44px;
  cursor: pointer;
}

.substage-row:hover {
  background: var(--table-subtle);
}

.substage-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.substage-title .chevron {
  transform: rotate(0deg);
}

.substage.open .substage-title .chevron {
  transform: rotate(90deg);
}

.substage-name-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
}

.substage-name-input:hover {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.substage-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface, #fff);
}

.substage-row .total-pill {
  min-height: 26px;
  font-size: 12.5px;
}

.substage-body {
  display: none;
}

.substage.open .substage-body {
  display: block;
}

/* Los items de una subetapa van con una sangria extra para verse anidados. El
   encabezado repetido lleva la misma sangria: si no, sus titulos caen 16px corridos
   respecto de las columnas que rotulan. */
.substage-body .edit-row,
.substage-body .add-line,
.substage-body .method-bar,
.substage-body .table-header-interno {
  padding-left: 44px;
}

/* Filas de "Agregar item / mano de obra / dia": blancas y compactas. */
.add-line {
  min-height: 26px;
  background: var(--surface, #fff);
  padding: 1px 28px;
}

.add-line .link-button {
  min-height: 22px;
  height: auto;
  padding: 2px 0;
  font-size: 12.5px;
}

/* Barra de variantes compacta. */
.method-bar {
  min-height: 28px;
  padding: 2px 28px;
}

.method-bar .tabs {
  gap: 4px;
}

.method-bar .tab-button {
  min-height: 22px;
  height: auto;
  padding: 2px 9px;
  font-size: 12px;
}

.method-bar .icon-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
}

.section-bar {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-bar span,
.link-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.section-bar strong {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.stage-config {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.4fr) minmax(170px, 0.5fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--table-subtle);
  padding: 10px 28px;
}

.field,
.compact-field {
  display: grid;
  gap: 5px;
}

.field label,
.compact-field label,
.edit-row > *::before {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.field input,
.field textarea,
.field select,
.stage-config input,
.stage-config select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 8px;
  font-size: var(--text-sm);
}

.field textarea {
  min-height: 116px;
  resize: vertical;
}

.edit-row {
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 2px 28px;
}

.edit-row:hover {
  background: var(--surface-subtle);
}

.edit-row input,
.edit-row select,
.edit-row textarea {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  padding: 5px 6px;
  font-size: var(--text-sm);
}

.edit-row textarea {
  resize: vertical;
}

.edit-row input:focus,
.edit-row select:focus,
.edit-row textarea:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.stage-config input:focus,
.stage-config select:focus,
.money-input:focus-within,
.square-meter-input:focus-within,
.inline-number:focus-within {
  border-color: rgba(16, 163, 127, 0.58);
  outline: 0;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.money-cell {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 680;
  white-space: nowrap;
}

.toggle {
  position: relative;
  display: inline-flex;
  width: 34px;
  height: 20px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e5e2d9;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  width: 16px;
  height: 16px;
  margin-left: 1px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 31, 29, 0.16);
  transition:
    margin-left var(--dur-1) var(--ease-out),
    background-color var(--dur-1) var(--ease-out);
}

.toggle:has(input:checked) {
  border-color: rgba(16, 163, 127, 0.4);
  background: var(--accent);
}

.toggle input:checked + span {
  margin-left: 15px;
}

.add-line {
  justify-content: flex-start;
  min-height: 26px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 650;
  cursor: pointer;
}

.link-button:hover {
  color: var(--ink);
}

.media-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 14px;
}

.data-panel {
  max-width: 1220px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: none;
}

.data-panel-head {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 11px 14px;
}

.data-panel-head span,
.data-panel-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.data-panel-head strong {
  display: block;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 680;
}

.data-table-wrap {
  overflow-x: auto;
}

.application-role-filter {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.application-role-filter select {
  width: 320px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 10px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.application-role-filter select:focus-visible,
.application-attachment a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.application-role-col { width: 220px; }

.data-detail-item.application-answers-item { grid-column: 1 / -1; }
.application-answers { margin: 0; display: grid; gap: 20px; }
.application-answers dt { font-size: 13px; font-weight: 600; line-height: 1.5; }
.application-answers dd { margin: 6px 0 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.application-attachment { display: grid; align-content: start; gap: 6px; min-width: 0; }
.application-attachment a { color: var(--ink); font-size: 12px; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; }
.application-link-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.application-link-list a { color: var(--ink); font-size: 12px; text-underline-offset: 3px; }
.lightbox-file { display: block; max-width: 80vw; padding: 24px; background: white; color: #171717; border-radius: 10px; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .data-panel-head:has(.application-role-filter) { flex-wrap: wrap; }
  .application-role-filter { width: 100%; }
  .application-role-filter select { width: 100%; font-size: 16px; }
}

.data-table {
  width: 100%;
  min-width: 1216px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--text-sm);
}

.whatsapp-status-col {
  width: 44px;
}

.rating-col {
  width: 74px;
}

.origin-col {
  width: 96px;
}

.status-col {
  width: 132px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 680;
}

.whatsapp-status-head {
  width: 44px;
  color: #128c7e !important;
  text-align: center !important;
}

.whatsapp-status-head svg {
  margin: 0 auto;
}

.data-table td {
  max-width: 260px;
  color: var(--ink-soft);
  line-height: 1.3;
}

.whatsapp-status-cell {
  width: 44px;
  max-width: 44px !important;
  padding-inline: 8px !important;
  text-align: center !important;
}

.rating-cell {
  width: 74px;
  max-width: 74px !important;
  padding-inline: 8px !important;
}

.origin-cell {
  width: 96px;
  max-width: 96px !important;
  padding-inline: 8px !important;
}

.status-cell {
  width: 132px;
  max-width: 132px !important;
  padding-inline: 8px !important;
}

.rating-select {
  width: 56px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 650;
  outline: none;
  padding: 0 6px;
}

.origin-select {
  width: 80px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 650;
  outline: none;
  padding: 0 6px;
}

.status-select {
  width: 116px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 650;
  outline: none;
  padding: 0 6px;
}

.rating-select:hover {
  border-color: #c8c8c8;
  background: #fafafa;
}

.origin-select:hover {
  border-color: #c8c8c8;
  background: #fafafa;
}

.status-select:hover {
  border-color: #c8c8c8;
  background: #fafafa;
}

.rating-select:focus {
  border-color: rgba(16, 163, 127, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

.origin-select:focus {
  border-color: rgba(16, 163, 127, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

.status-select:focus {
  border-color: rgba(16, 163, 127, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
}

.detail-rating-select {
  width: 82px;
}

.detail-origin-select {
  width: 112px;
}

.detail-status-select {
  width: 148px;
}

.whatsapp-contact-toggle {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: transparent;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--dur-1) var(--ease-out),
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.data-row:hover .whatsapp-contact-toggle,
.data-row:focus-visible .whatsapp-contact-toggle,
.data-row:focus-within .whatsapp-contact-toggle,
.whatsapp-contact-toggle.is-active {
  opacity: 1;
  pointer-events: auto;
}

.whatsapp-contact-toggle:hover {
  border-color: rgba(18, 140, 126, 0.45);
  background: rgba(18, 140, 126, 0.08);
}

.whatsapp-contact-toggle.is-active {
  border-color: #128c7e;
  background: #128c7e;
  color: #fff;
}

.data-row:hover .whatsapp-contact-toggle,
.data-row:focus-visible .whatsapp-contact-toggle,
.data-row:focus-within .whatsapp-contact-toggle {
  pointer-events: auto;
}

.data-row {
  cursor: pointer;
}

.data-row.is-discarded td {
  background: #fff1f1;
  color: #7f1d1d;
}

.data-row.is-discarded .cell-clip {
  color: #7f1d1d;
}

.data-row.is-not-discarded td {
  background: rgba(255, 244, 196, 0.62);
  color: #5f4a10;
}

.data-row.is-not-discarded .cell-clip {
  color: #5f4a10;
}

.data-row.is-no-response td {
  background: #3f3f3b;
  color: #f7f6f2;
}

.data-row.is-no-response .cell-clip {
  color: #f7f6f2;
}

.data-row.is-no-response .status-select,
.data-row.is-no-response .origin-select,
.data-row.is-no-response .rating-select {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.data-row.is-schedule-meeting td {
  background: rgba(219, 240, 255, 0.58);
  color: #1f4b63;
}

.data-row.is-schedule-meeting .cell-clip {
  color: #1f4b63;
}

.data-row.is-meeting-scheduled td {
  background: rgba(222, 245, 231, 0.66);
  color: #1f5132;
}

.data-row.is-meeting-scheduled .cell-clip {
  color: #1f5132;
}

.data-row.is-meeting-finished td {
  background: rgba(147, 197, 253, 0.54);
  color: #123f70;
}

.data-row.is-meeting-finished .cell-clip {
  color: #123f70;
}

.data-row.is-meeting-finished-off td {
  background: rgba(166, 124, 82, 0.45);
  color: #4d2f14;
}

.data-row.is-meeting-finished-off .cell-clip {
  color: #4d2f14;
}

.manual-order .data-row {
  cursor: grab;
}

.manual-order .data-row:active {
  cursor: grabbing;
}

.data-row.is-dragging td {
  opacity: 0.42;
}

.data-row.is-drag-over td {
  background: var(--accent-soft);
  box-shadow: inset 0 2px 0 var(--accent);
}

.row-actions-anchor {
  position: relative;
  overflow: visible !important;
}

.row-actions-panel {
  position: absolute;
  top: 50%;
  right: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(227, 227, 227, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 2px 10px rgba(32, 33, 35, 0.06);
  opacity: 0;
  padding: 3px;
  pointer-events: none;
  transform: translate(8px, -50%);
  transition:
    opacity var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}

@supports (backdrop-filter: blur(10px)) {
  .row-actions-panel {
    backdrop-filter: blur(10px);
  }
}

.data-row:hover .row-actions-panel,
.data-row:focus-visible .row-actions-panel,
.data-row:focus-within .row-actions-panel,
.data-row.is-expanded .row-actions-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.row-action-button {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.row-action-button:hover {
  background: #ededed;
  color: var(--ink);
}

.row-action-button.whatsapp {
  color: #128c7e;
}

.row-action-button.whatsapp:hover {
  background: rgba(18, 140, 126, 0.1);
  color: #075e54;
}

.row-action-button.danger {
  background: var(--danger);
  color: #fff;
}

.row-action-button.danger:hover {
  background: #b42318;
}

.data-row:hover td,
.data-row:focus-visible td,
.data-row.is-expanded td {
  background: var(--surface-hover);
}

.data-row.is-discarded:hover td,
.data-row.is-discarded:focus-visible td,
.data-row.is-discarded.is-expanded td {
  background: #ffe7e7;
}

.data-row.is-not-discarded:hover td,
.data-row.is-not-discarded:focus-visible td,
.data-row.is-not-discarded.is-expanded td {
  background: rgba(255, 236, 153, 0.78);
}

.data-row.is-no-response:hover td,
.data-row.is-no-response:focus-visible td,
.data-row.is-no-response.is-expanded td {
  background: #343431;
}

.data-row.is-schedule-meeting:hover td,
.data-row.is-schedule-meeting:focus-visible td,
.data-row.is-schedule-meeting.is-expanded td {
  background: rgba(203, 232, 252, 0.76);
}

.data-row.is-meeting-scheduled:hover td,
.data-row.is-meeting-scheduled:focus-visible td,
.data-row.is-meeting-scheduled.is-expanded td {
  background: rgba(199, 235, 213, 0.82);
}

.data-row.is-meeting-finished:hover td,
.data-row.is-meeting-finished:focus-visible td,
.data-row.is-meeting-finished.is-expanded td {
  background: rgba(96, 165, 250, 0.62);
}

.data-row.is-meeting-finished-off:hover td,
.data-row.is-meeting-finished-off:focus-visible td,
.data-row.is-meeting-finished-off.is-expanded td {
  background: rgba(150, 108, 66, 0.6);
}

.data-row:focus-visible {
  outline: 2px solid rgba(16, 163, 127, 0.7);
  outline-offset: -2px;
}

.cell-clip {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-detail-row td {
  background: #fafafa;
  padding: 0;
  white-space: normal;
}

.data-detail {
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 16px;
}

.data-detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.data-detail-head span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 680;
  text-transform: uppercase;
}

.data-detail-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.data-detail-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px;
}

.opinion-item {
  display: grid;
  min-height: 146px;
  grid-template-rows: auto minmax(92px, 1fr);
  border-color: var(--blue-line);
  background: var(--blue-soft);
}

.data-detail-item span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.data-detail-item p {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.data-detail-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: var(--text-sm);
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.data-detail-input.long {
  min-height: 120px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.data-detail-input::placeholder {
  color: var(--muted-light);
}

.opinion-item span {
  color: var(--blue-ink);
}

.opinion-item textarea {
  width: 100%;
  min-height: 92px;
  height: 100%;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: var(--text-sm);
  line-height: 1.42;
}

.opinion-item textarea::placeholder {
  color: rgba(23, 100, 137, 0.62);
}

/* Galeria de archivos (miniaturas) */
.archivos-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.archivos-thumb {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.archivos-thumb:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.archivos-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-empty {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Lightbox */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  background: rgba(18, 16, 14, 0.82);
  backdrop-filter: blur(2px);
}

.lightbox-figure {
  margin: 0;
  max-width: min(88vw, 1100px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-figure img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  background: var(--surface);
}

.lightbox-figure figcaption {
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

.lightbox-nav,
.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lightbox-nav {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  flex-shrink: 0;
}

.lightbox-nav:hover,
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
}

.table-state {
  display: grid;
  gap: 12px;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.error-state {
  color: var(--danger);
}

.table-state-hint {
  color: var(--muted);
  font-size: 13px;
  max-width: 420px;
}

.media-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.media-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 690;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.media-card,
.empty-state {
  overflow: hidden;
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.media-card img,
.map-preview {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: var(--surface-soft);
}

.map-preview {
  position: relative;
  background:
    linear-gradient(90deg, rgba(31, 31, 29, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(31, 31, 29, 0.045) 1px, transparent 1px),
    linear-gradient(135deg, #f5f4ee, #ffffff);
  background-size: 34px 34px, 34px 34px, 100% 100%;
}

.map-preview::before,
.map-preview::after {
  content: "";
  position: absolute;
}

.map-preview::before {
  width: 13px;
  height: 13px;
  left: 48%;
  top: 54%;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(217, 45, 32, 0.12);
}

.map-preview::after {
  width: 68%;
  height: 2px;
  left: 16%;
  top: 38%;
  background: rgba(16, 163, 127, 0.38);
  transform: rotate(-12deg);
}

.media-empty,
.empty-state {
  display: grid;
  min-height: 170px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 640;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(31, 31, 29, 0.22);
  padding: 20px;
}

.modal {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.modal header {
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  background: var(--bg-subtle);
}

.modal h2 {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 690;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.modal-copy {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.save-alert {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 9999;
  display: grid;
  gap: 4px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 14px;
  background: #b42318;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  animation: save-alert-in .18s ease-out;
}
.save-alert strong { font-size: 14px; }
.save-alert span { font-size: 12.5px; line-height: 1.5; opacity: .95; }
@keyframes save-alert-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

.move-options {
  display: grid;
  gap: 8px;
}
.move-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .05s;
}
.move-option:hover {
  border-color: var(--ink);
  background: var(--hover, rgba(0,0,0,0.03));
}
.move-option:active { transform: scale(0.99); }
.move-option svg { color: var(--muted); flex: 0 0 auto; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 44px));
  border: 1px solid rgba(31, 31, 29, 0.1);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: 620;
}

.desktop-only {
  display: block;
}

@media (max-width: 1180px) {
  .openai-app {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  .openai-main {
    padding: 26px 24px 48px;
  }

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

  .primary-summary-row,
  .secondary-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .financial-card {
    border-width: 0 1px 1px 0;
  }
}

@media (max-width: 860px) {
  .openai-app {
    display: block;
  }

  .side-rail {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-stats,
  .rail-sync {
    display: none;
  }

  .rail-projects {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .openai-main {
    padding: 22px 14px 40px;
  }

  .page-head,
  .workspace-page-head,
  .finance-panel-head,
  .media-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-head-actions {
    flex-wrap: wrap;
  }

  .page-head h1,
  .title-input {
    font-size: 24px;
  }

  .overview-strip,
  .project-grid,
  .summary-grid,
  .primary-summary-row,
  .secondary-summary-row,
  .finance-grid {
    grid-template-columns: 1fr;
  }

  .financial-card {
    border-width: 0 0 1px;
  }

  .financial-card:last-child {
    border-bottom: 0;
  }

  .project-card {
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }

  .project-meta {
    display: none;
  }
}

@media (max-width: 700px) {
  .table-header {
    display: none;
  }

  /* En celular las filas se apilan como tarjetas: no hace falta scroll lateral
     y la manija de arrastre no aplica. */
  .budget-scroll {
    margin: 0;
    overflow-x: visible;
  }

  .drag-handle {
    display: none;
  }

  .item-cell {
    display: block;
  }

  .budget-table {
    min-width: 0;
  }

  .stages {
    min-width: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg);
  }

  .stage-row,
  .edit-row {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    padding: 12px;
  }

  .stage-desc {
    grid-column: auto;
    white-space: normal;
  }

  .stage-row > span:empty {
    display: none;
  }

  .total-pill {
    justify-self: start;
  }

  /* En celular la fila se apila: cada hijo vuelve a tener su propia fila. */
  .stage-row > * {
    grid-row: auto;
  }

  .stage-config {
    grid-template-columns: 1fr;
  }

  .edit-row > *::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
  }

  /* Pagos es una grilla: la etiqueta ocupa su propia fila entera. */
  .pagos-cell::before {
    grid-column: 1 / -1;
  }

  .edit-row > button::before {
    content: "";
    display: none;
  }

  .money-cell {
    padding: 5px 6px;
  }

  .project-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 520px) {
  .top-actions,
  .tabs {
    width: 100%;
  }

  .tab-button,
  .view-button,
  .ghost-button,
  .danger-button,
  .button {
    flex: 1 1 auto;
  }

  .overview-strip strong {
    font-size: var(--text-xl);
  }
}

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

/* ===== Chat IA (playground) ===== */
.chat-main { display: flex; flex-direction: column; min-height: 0; }

.chat-provider-switch { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.chat-provider-switch button {
  display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-provider-switch button small { font-size: 10px; font-weight: 500; opacity: 0.7; }
.chat-provider-switch button.active { background: var(--ink); color: var(--surface); }

.chat-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 18px;
  flex: 1; min-height: 0; margin-top: 18px;
}
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }

.chat-panel {
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); padding: 16px; align-self: start;
}
.chat-panel-head { display: flex; align-items: center; justify-content: space-between; }
.chat-panel-head strong { font-size: 14px; }

.chat-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.chat-field > span { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.03em; }
.chat-field > span em { font-style: normal; color: var(--muted-light); text-transform: none; letter-spacing: 0; }
.chat-field input[type="text"], .chat-field input[type="number"], .chat-field input[type="password"], .chat-field input:not([type]), .chat-field textarea, .chat-field select {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); padding: 8px 10px; font-size: 13px; outline: 0;
  font-family: inherit;
}
.chat-field textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
.chat-field input:focus, .chat-field textarea:focus, .chat-field select:focus { border-color: var(--accent); }
.chat-field input[type="range"] { padding: 0; accent-color: var(--accent); }
.chat-toggle { flex-direction: row; align-items: center; justify-content: space-between; }
.chat-toggle input { width: auto; }
.chat-caps-note { margin: 0; font-size: 11px; color: var(--muted-light); }
.ghost-button.small, .button.small { padding: 5px 10px; font-size: 12px; }

.chat-conversation {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  overflow: hidden;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 340px; }
.chat-empty { margin: auto; color: var(--muted); font-size: 14px; text-align: center; max-width: 320px; }
.chat-msg { display: flex; flex-direction: column; gap: 4px; max-width: 82%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg-role { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; }
.chat-msg-body {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 13px;
  font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--surface);
  overflow-wrap: anywhere;
}
.chat-msg.user .chat-msg-body { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chat-typing { color: var(--muted); font-style: italic; }
.chat-cursor { display: inline-block; width: 7px; color: var(--muted); animation: chat-blink 1s steps(2, start) infinite; }
@keyframes chat-blink { to { opacity: 0; } }

.chat-error { padding: 10px 16px; font-size: 13px; color: #b42318; background: rgba(180, 35, 24, 0.06); border-top: 1px solid var(--line); }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.chat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px 3px 10px; color: var(--muted); }
.chat-chip button { border: 0; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted); }

.chat-composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-composer textarea {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  font-size: 14px; font-family: inherit; resize: none; outline: 0; max-height: 160px; line-height: 1.4;
}
.chat-composer textarea:focus { border-color: var(--accent); }
.chat-composer .button.primary { padding: 9px 12px; }
.chat-attach-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); cursor: pointer; }
.chat-attach-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Sidebar colapsable ===== */
.rail-collapse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.rail-collapse:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.rail-open-floating {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 150ms ease, border-color 150ms ease;
}
.rail-open-floating:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.openai-app.rail-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.openai-app.rail-collapsed .side-rail {
  display: none;
}
.openai-app.rail-collapsed .rail-open-floating {
  display: inline-flex;
}
.openai-app.rail-collapsed .openai-main {
  padding-left: 60px;
}

/* ===== Rail fino de iconos (estilo Claude) ===== */
.openai-app {
  grid-template-columns: 56px minmax(0, 1fr);
}
.side-rail {
  align-items: center;
  gap: 4px;
  padding: 14px 0;
}
.rail-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.rail-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.rail-icon:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.rail-icon.active {
  background: var(--surface-subtle);
  color: var(--ink);
}
.rail-tip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  white-space: nowrap;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 7px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 60;
  transition: opacity 130ms ease, transform 130ms ease;
}
.rail-tip::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--ink);
}
.rail-icon:hover .rail-tip,
.rail-icon:focus-visible .rail-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}
.rail-foot {
  margin-top: auto;
  display: flex;
  justify-content: center;
}
.rail-foot .sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--positive);
}

/* En celular los iconos van en fila: apilados se comian la primera pantalla. El
   presupuesto queda afuera porque tiene su propio rail angosto (budget-design.css). */
@media (max-width: 860px) {
  .openai-app:not(.budget-workspace) .side-rail {
    flex-direction: row;
    padding: 8px 14px;
  }
  .openai-app:not(.budget-workspace) .rail-mark {
    margin: 0 6px 0 0;
  }
  .openai-app:not(.budget-workspace) .rail-nav {
    flex: 0 1 auto;
    flex-direction: row;
    gap: 2px;
    min-width: 0;
    width: auto;
  }
  /* Con ocho iconos mas el de cerrar sesion no entran a 36 px en un telefono: se achican
     (a 26 px entran en 320 px de ancho). */
  .openai-app:not(.budget-workspace) .rail-icon {
    flex: 0 1 36px;
    width: 36px;
    min-width: 26px;
    height: 36px;
  }
  .openai-app:not(.budget-workspace) .rail-tip {
    display: none;
  }
  .openai-app:not(.budget-workspace) .rail-foot {
    align-items: center;
    gap: 6px;
    margin: 0 0 0 auto;
  }
}

/* Pestanas para cambiar de tabla dentro de Personal */
.table-tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.table-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: background 150ms ease, color 150ms ease;
}
.table-tabs button:hover {
  color: var(--ink);
}
.table-tabs button.active {
  background: var(--ink);
  color: var(--surface);
}

/* Etapas sobre la tabla (Leads): un numero grande por etapa; tocar una filtra. */
.etapas-resumen {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.etapas-resumen button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 92px;
  padding: 8px 14px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}
.etapas-resumen button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.etapas-resumen button strong {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.etapas-resumen button:hover {
  border-color: var(--line-strong);
}
.etapas-resumen button.vacia strong {
  color: var(--muted-light);
}
.etapas-resumen button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}
.etapas-resumen button.active span {
  color: rgba(255, 255, 255, 0.72);
}
.etapas-resumen button.active strong {
  color: var(--surface);
}
@media (max-width: 560px) {
  .etapas-resumen {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .etapas-resumen button {
    min-width: 0;
    padding: 6px 8px 7px;
    border-radius: 10px;
  }
  .etapas-resumen button span {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .etapas-resumen button strong {
    font-size: 18px;
  }
}

/* ===== Chat IA v2 (estilo ChatGPT) ===== */
.openai-main.chat-main {
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.chat-main.is-empty .chat-thread {
  align-items: center;
  justify-content: center;
}
.chat-stream {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 40px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-hero { text-align: center; padding: 0 20px; }
.chat-hero h1 { margin: 0 0 6px; font-size: 27px; color: var(--ink); }
.chat-hero p { margin: 0; font-size: 14px; color: var(--muted); }

.chat-msg { display: flex; width: 100%; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.user .chat-msg-body {
  max-width: 80%;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 11px 16px;
}
.chat-msg.assistant .chat-msg-body { max-width: 100%; padding: 2px 0; }
.chat-msg-body {
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.chat-typing { color: var(--muted); font-style: italic; }

.chat-dock {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 20px 22px;
}
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  padding: 7px;
  box-shadow: var(--shadow-sm);
}
.chat-attach-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.chat-attach-btn:hover { background: var(--surface-subtle); color: var(--ink); }
.chat-attach-btn.is-disabled { opacity: 0.35; cursor: not-allowed; }
.chat-composer textarea {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  padding: 9px 4px;
  max-height: 200px;
}
.chat-send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease;
}
.chat-send:hover { background: #2a2925; }
.chat-send:disabled { opacity: 0.35; cursor: default; }

.chat-dock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 0;
}
.chat-dock-left { display: flex; align-items: center; gap: 6px; }
.chat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px 6px 12px;
  cursor: pointer;
  transition: background 150ms ease;
}
.chat-pill:hover { background: var(--surface-subtle); }
.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.chat-icon-btn:hover { background: var(--surface-subtle); color: var(--ink); }
.chat-clear-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.chat-clear-link:hover { color: var(--danger); }

.chat-menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.chat-menu {
  position: absolute;
  bottom: 64px;
  left: 20px;
  z-index: 50;
  width: min(320px, calc(100% - 40px));
  max-height: 58vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 8px;
}
.chat-menu-group { padding: 2px 0; }
.chat-menu-group + .chat-menu-group { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.chat-menu-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 6px 10px 4px;
}
.chat-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
}
.chat-menu-item:hover { background: var(--surface-subtle); }
.chat-menu-item.active { color: var(--accent); font-weight: 600; }
.chat-settings-menu { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-menu-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.chat-error { padding: 8px 12px; margin-bottom: 8px; font-size: 13px; color: #b42318; background: rgba(180, 35, 24, 0.06); border-radius: 10px; }

/* Ajustes chat: subir composer y slider de tokens */
.chat-dock {
  padding: 0 20px 46px;
}
.chat-menu {
  bottom: 88px;
}
.chat-range-hint {
  font-size: 10px;
  color: var(--muted-light);
  font-weight: 500;
}
.chat-field input[type="range"] {
  accent-color: var(--accent);
}

/* ===== Historial de chats ===== */
.openai-main.chat-main { flex-direction: row; }
.chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-area.is-empty .chat-thread { align-items: center; justify-content: center; }

.chat-history {
  flex: 0 0 236px;
  width: 236px;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 10px;
  overflow: hidden;
}
.chat-newchat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 9px;
  cursor: pointer;
  transition: background 150ms ease;
}
.chat-newchat:hover { background: var(--surface-subtle); }
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-hitem {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 150ms ease;
}
.chat-hitem:hover { background: var(--surface-subtle); }
.chat-hitem.active { background: var(--surface-subtle); }
.chat-hitem-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-hitem-title {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-hitem-model { font-size: 10px; color: var(--muted); }
.chat-hitem-del {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted-light);
  cursor: pointer;
  opacity: 0;
  padding: 3px;
  border-radius: 6px;
  transition: opacity 150ms ease, color 150ms ease, background 150ms ease;
}
.chat-hitem:hover .chat-hitem-del { opacity: 1; }
.chat-hitem-del:hover { color: var(--danger); background: var(--danger-soft); }

@media (max-width: 720px) {
  .chat-history { flex-basis: 150px; width: 150px; }
}

/* Tokens y costo por respuesta / contexto */
.chat-usage {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted-light);
  font-variant-numeric: tabular-nums;
}
.chat-context-tokens {
  margin-left: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Fix definitivo estilo de mensajes (anula reglas viejas de la 1ra version) */
.chat-msg-body {
  border: 0;
  background: transparent;
  color: var(--ink);
}
.chat-msg.user { justify-content: flex-end; }
.chat-msg.user .chat-msg-body {
  max-width: 78%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 11px 16px;
  box-shadow: var(--shadow-sm);
}
.chat-msg.assistant .chat-msg-body {
  max-width: 100%;
  background: transparent;
  border: 0;
  padding: 2px 0;
  color: var(--ink);
}

/* ===== Comparación multi-modelo ===== */
.chat-msg.assistant.multi { display: block; }
.chat-answers { display: grid; gap: 22px; width: 100%; }
.chat-answer { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chat-answer-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.chat-answer .chat-msg-body { padding: 0; }
.chat-answer-error { color: var(--danger); }

.chat-menu-note { font-size: 11px; color: var(--muted); padding: 2px 10px 8px; line-height: 1.4; }

.chat-settings-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-settings-nav > span {
  flex: 1;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}
.chat-settings-nav > span em { font-style: normal; color: var(--muted); font-weight: 500; }
.chat-nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}
.chat-nav-arrow:hover { color: var(--ink); background: var(--surface-subtle); }

/* Formato de las respuestas (markdown básico) */
.chat-msg-body .md-line { margin: 0; }
.chat-msg-body .md-sp { height: 10px; }
.chat-msg-body .md-h { font-weight: 700; margin: 10px 0 4px; }
.chat-msg-body .md-ul { margin: 6px 0; padding-left: 20px; }
.chat-msg-body .md-ul li { margin: 3px 0; }
.chat-msg-body strong { font-weight: 700; }
.chat-msg-body em { font-style: italic; }
.chat-msg-body code {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}

/* Imágenes adjuntas en el mensaje del usuario */
.chat-msg.user .chat-user-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 6px;
  max-width: 78%;
}
.chat-msg.user .chat-user-imgs img {
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  object-fit: cover;
}

/* Apilar imagen + texto del usuario, alineados a la derecha */
.chat-msg.user { flex-direction: column; align-items: flex-end; }

/* Multi-modelo: cada columna del ancho de una respuesta sola, lado a lado */
.chat-stream.multi, .chat-dock.multi {
  width: 100%;
  max-width: 1680px;
}
.chat-answers {
  display: flex;
  gap: 32px;
  width: 100%;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 6px;
}
.chat-answer {
  flex: 1 0 660px;
  min-width: 0;
}

/* Ajuste final multi: composer y mensaje del usuario como en single; columnas comparten ancho, sin scroll */
.chat-stream.multi { width: 100%; max-width: 1080px; }
.chat-dock.multi { width: min(100%, 760px); max-width: 760px; }
.chat-answers { display: flex; gap: 32px; width: 100%; overflow-x: visible; align-items: flex-start; }
.chat-answer { flex: 1 1 0; min-width: 0; }
.chat-stream.multi > .chat-msg.user { max-width: 760px; margin-left: auto; margin-right: auto; }

/* Destrabar el ancho del bloque multi (habia un max-width:82% viejo en .chat-msg) */
.chat-msg.assistant.multi { max-width: 100%; }

/* Chips de archivos adjuntos (composer y burbuja del usuario) */
.chat-chip-thumb { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }
.chat-chip.chat-chip-file { padding: 5px 8px 5px 10px; color: var(--ink); }
.chat-chip-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-user-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 6px;
  max-width: 78%;
}
.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.chat-file-chip span { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Separador en ajustes: system prompt compartido arriba, ajustes por modelo abajo */
.chat-settings-divider { height: 1px; background: var(--line); margin: 4px 0 2px; }

/* --- Vista de la obra: presupuesto o cronograma --------------------------- */
/* El par de botones va arriba del encabezado de la tabla. Es solo un cambio de
   vista: los dos leen los mismos datos guardados, ninguno los altera. */
.vista-switch {
  display: flex;
  gap: 4px;
  /* Aire con las tarjetas del escenario comercial, que quedan justo arriba. */
  margin-top: 30px;
  margin-bottom: 10px;
  padding: 0 28px;
}

.vista-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface, #fff);
  padding: 7px 14px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--dur-1, 150ms) ease,
    border-color var(--dur-1, 150ms) ease,
    color var(--dur-1, 150ms) ease;
}

.vista-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.vista-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* --- Tabla del cronograma ------------------------------------------------- */
.crono-table {
  min-width: 900px;
}

.crono-header,
.crono-row {
  display: grid;
  /* Nueve columnas: se achicaron los minimos para que entren sin cortarse. */
  grid-template-columns:
    minmax(58px, 0.3fr)
    minmax(140px, 1.15fr)
    minmax(120px, 0.9fr)
    minmax(66px, 0.34fr)
    minmax(66px, 0.34fr)
    minmax(96px, 0.48fr)
    minmax(120px, 0.9fr)
    minmax(64px, 0.32fr)
    44px;
  align-items: center;
  column-gap: 8px;
}

.crono-header {
  border-bottom: 1px solid var(--line);
  padding: 0 16px 8px;
}

.crono-header span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crono-row {
  border-bottom: 1px solid var(--line);
  padding: 3px 16px;
}

.crono-row:hover {
  background: var(--table-subtle);
}

.crono-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  padding: 5px 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
}

.crono-row input:hover {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.crono-row input:focus {
  border-color: var(--accent);
  background: var(--surface, #fff);
  outline: none;
}

/* Dia: a la izquierda el numero calculado, a la derecha la duracion editable. */
.crono-dia {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crono-rango {
  flex: 0 0 auto;
  min-width: 40px;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.crono-dur {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  padding: 0 7px 0 2px;
}

.crono-dur input {
  width: 40px;
  padding: 4px 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-dur span {
  color: var(--muted-light);
  font-size: 10.5px;
  font-weight: 600;
}

/* Jornales: el que se escribe y, al lado, el acumulado hasta esa fila. */
.crono-jorn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crono-jorn input {
  flex: 1 1 auto;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-acum {
  flex: 0 0 auto;
  min-width: 26px;
  color: var(--muted-light);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-total {
  border-top: 2px solid var(--ink);
  border-bottom: 0;
  background: var(--surface-subtle);
  padding-top: 11px;
  padding-bottom: 11px;
  color: var(--ink);
  font-size: 13px;
}

.crono-total:hover {
  background: var(--surface-subtle);
}

.crono-total .n {
  text-align: left;
}

.crono-empty {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 22px 28px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .crono-table {
    min-width: 0;
  }

  .crono-header {
    display: none;
  }

  .crono-row {
    grid-template-columns: 1fr;
    row-gap: 4px;
    padding: 10px 18px;
  }

  .crono-row > *::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted-light);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .vista-switch {
    padding: 0 18px;
  }
}

/* El dia se escribe a mano ("7" o "2-4"): las tareas se solapan y no hay forma de
   deducirlo acumulando duraciones. */
.crono-dia-input {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Banda de etapa: separa los bloques cuando el cronograma tiene varias etapas. */
.crono-band {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 7px 28px;
}


@media (max-width: 860px) {
  .crono-band {
    padding: 7px 18px;
  }
}

/* Barra de arriba del cronograma: el precio del jornal manda sobre toda la columna
   de costo, asi que va afuera de la tabla y no dentro de una fila. */
.crono-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 0 16px;
}

.crono-precio {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.crono-precio > span:first-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crono-precio-input {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface, #fff);
  padding: 0 12px;
}

.crono-precio-input:focus-within {
  border-color: var(--accent);
}

.crono-precio-input em {
  color: var(--muted-light);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 600;
}

.crono-precio-input input {
  width: 108px;
  border: 0;
  background: transparent;
  padding: 7px 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.crono-precio-input input:focus {
  outline: none;
}

.crono-bar-total {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
}

.crono-bar-total span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crono-bar-total strong {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Costo de la fila: sale de jornales x precio, no se escribe. */
.crono-costo {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-header span:nth-child(4) {
  text-align: right;
}

@media (max-width: 860px) {
  .crono-bar {
    padding: 0 18px;
  }

  .crono-costo {
    text-align: left;
  }
}

/* --- Etapas del cronograma con versiones --------------------------------- */
/* Cada etapa es un bloque con sus versiones. Solo la activa se dibuja y solo ella
   entra en los totales, igual que las variantes del presupuesto. */
.crono-bloque {
  margin-bottom: 6px;
}

.crono-band {
  display: grid;
  /* Sin esto la columna se dimensiona al contenido y la banda queda apretada
     contra el borde izquierdo, con media tabla vacia al lado. */
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 9px 16px;
}

.crono-band-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.crono-band-name {
  min-width: 0;
  flex: 1 1 220px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 3px 7px;
  color: var(--ink);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.crono-band-name:hover {
  border-color: var(--line-strong);
  background: var(--surface, #fff);
}

.crono-band-name:focus {
  border-color: var(--accent);
  background: var(--surface, #fff);
  outline: none;
}

.crono-band-datos {
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.crono-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.crono-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface, #fff);
  padding: 4px 11px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.crono-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.crono-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* La version activa se edita en el lugar, sin abrir nada. */
.crono-tab-input {
  width: 128px;
  cursor: text;
}

.crono-tab-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface, #fff);
}


.crono-header span:nth-child(5),
.crono-header span:nth-child(6) {
  text-align: right;
}


/* Eliminar la etapa entera: lleva texto, asi que no puede ser un .icon-button
   (esos son cuadrados de 30px y el texto se desbordaba). */
.crono-del-bloque {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface, #fff);
  padding: 4px 11px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
}

.crono-del-bloque:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Todo lo de la fila de versiones a la misma altura: los .icon-button son cuadrados
   de 30px y las pastillas median 27, y se veia la linea despareja. */
.crono-tabs .icon-button {
  width: 28px;
  height: 28px;
}

.crono-tab,
.crono-del-bloque {
  min-height: 28px;
}

/* Jornales que no se pagan (los tuyos, el inge, el maestro): se restan del costo
   pero siguen contando como trabajo hecho. */
.crono-libres {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-libres input {
  width: 100%;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-total .crono-libres {
  font-weight: 600;
}

/* --- Contratistas y alquileres de la etapa -------------------------------- */
/* Lo que se paga por trabajo o por equipo, no por jornal. Va arriba de las tareas
   porque se contrata antes de empezar, y su total suma al de la etapa. */
.crono-extras {
  border-bottom: 1px solid var(--line);
  background: #fcfbf9;
  padding: 8px 16px 2px;
}

.crono-extras-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
}

.crono-extras-head span {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crono-extras-head strong {
  color: var(--ink);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.crono-extras-header,
.crono-extra-row {
  display: grid;
  grid-template-columns:
    minmax(150px, 1.3fr)
    minmax(72px, 0.42fr)
    minmax(96px, 0.5fr)
    minmax(100px, 0.52fr)
    minmax(160px, 1.4fr)
    46px;
  align-items: center;
  column-gap: 8px;
}

.crono-extras-header {
  padding-bottom: 4px;
}

.crono-extras-header span {
  color: var(--muted-light);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.crono-extras-header span:nth-child(2),
.crono-extras-header span:nth-child(3),
.crono-extras-header span:nth-child(4) {
  text-align: right;
}

.crono-extra-row {
  border-top: 1px solid #f2efe9;
  padding: 2px 0;
}

.crono-extra-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  padding: 5px 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
}

.crono-extra-row input:hover {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.crono-extra-row input:focus {
  border-color: var(--accent);
  background: var(--surface, #fff);
  outline: none;
}

.crono-extra-row [data-label="Cantidad"] input,
.crono-extra-row [data-label="Precio"] input {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-extra-total {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-extras .add-line {
  padding: 2px 0 6px;
}

/* Los tres totales de la barra de arriba. */
.crono-bar-totales {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 18px;
}

.crono-bar-suma strong {
  color: var(--accent);
}

@media (max-width: 860px) {
  .crono-extras-header {
    display: none;
  }

  .crono-extra-row {
    grid-template-columns: 1fr;
    row-gap: 3px;
    padding: 8px 0;
  }

  .crono-extra-row > *::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted-light);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
}

/* Gente del frente paralelo. Se muestra y se suma, pero no cuesta en esta etapa. */
.crono-jornaleros {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-jornaleros input {
  width: 100%;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-header span:nth-child(8) {
  text-align: right;
}

/* --- Plegar la etapa del cronograma -------------------------------------- */
/* Igual que en el presupuesto: se hace clic en la banda y el cuerpo se guarda,
   para que con varias etapas cargadas la pantalla siga siendo legible. */
.crono-band {
  cursor: pointer;
}

.crono-band:hover {
  background: var(--table-subtle);
}

.crono-chevron {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--muted-light);
  transform: rotate(90deg);
  transition: transform 150ms ease;
}

.crono-bloque.cerrado .crono-chevron {
  transform: rotate(0deg);
}

.crono-bloque.cerrado .crono-cuerpo {
  display: none;
}

/* Cerrada, la fila de versiones sobra: lo que importa es el resumen de la banda. */
.crono-bloque.cerrado .crono-tabs {
  display: none;
}

.crono-band-head {
  align-items: center;
}

/* --- Cierre de cada etapa ------------------------------------------------ */
/* Los jornaleros contados de las dos formas y el total, con cada numero al lado
   de su etiqueta en vez de caer en las columnas de las tareas. */
.crono-cierre {
  border-top: 1px solid var(--line);
  background: #fcfbf9;
  padding: 10px 16px 12px;
}

.crono-cierre-fila {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 70px 96px 140px;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
}

.crono-cierre-fila > span:first-child {
  color: var(--muted);
}

.crono-cierre-fila em {
  color: var(--muted-light);
  font-size: 10.5px;
  font-style: normal;
}

.crono-cierre-cant,
.crono-cierre-precio {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-cierre-precio {
  color: var(--muted-light);
  font-size: 11px;
}

.crono-cierre-fila strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-cierre-total {
  margin-top: 4px;
  border-top: 1px solid var(--line-strong);
  padding-top: 8px;
  font-size: 13px;
}

.crono-cierre-total > span:first-child,
.crono-cierre-total strong {
  color: var(--ink);
  font-weight: 700;
}

/* --- Resumen de toda la obra --------------------------------------------- */
.crono-resumen {
  border-top: 2px solid var(--ink);
  background: var(--surface, #fff);
  padding: 14px 16px 16px;
}

.crono-res-titulo {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crono-res-fila {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1.4fr) 160px;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  font-size: 12.5px;
}

.crono-res-que {
  color: var(--ink);
}

.crono-res-det {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.crono-res-fila strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.crono-res-total {
  margin-top: 6px;
  border-top: 1px solid var(--ink);
  padding-top: 10px;
  font-size: 15px;
}

.crono-res-total .crono-res-que,
.crono-res-total strong {
  font-weight: 700;
}

@media (max-width: 860px) {
  .crono-cierre-fila,
  .crono-res-fila {
    grid-template-columns: 1fr auto;
  }

  .crono-cierre-precio,
  .crono-res-det {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* --- Pagos por item ------------------------------------------------------- */
/* Ocupa el lugar de las viejas columnas de planificacion: una grilla chica con la
   cantidad de pagos y, por cada pago, su fecha y su monto. Medido en pantalla, no
   calculado: en los 156px de la columna entran "28/12/26" y hasta "125.000.000".
   No hay margen para ensanchar: a 1280 de ancho la tabla ya va justa. */
.col-pagos,
.pagos-cell {
  display: grid;
  grid-template-columns: 20px 58px minmax(0, 1fr);
  column-gap: 2px;
  row-gap: 2px;
  align-items: center;
}

.col-pagos b {
  grid-column: 1 / -1;
  font-weight: inherit;
}

.col-pagos em {
  font-size: 9px;
  font-style: normal;
  opacity: 0.8;
}

.pagos-cell input {
  min-width: 0;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 3px 1px;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
}

.pagos-cell input:hover {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.pagos-cell input:focus {
  border-color: var(--accent);
  background: var(--surface, #fff);
  outline: none;
}

.pagos-cantidad {
  grid-column: 1;
  text-align: center;
}

.pago-fecha {
  grid-column: 2;
}

.pago-monto {
  grid-column: 3;
}

/* Estados sin pago: una raya, como las demas celdas vacias. */
.pagos-vacio {
  display: block;
  color: var(--muted-light);
}

/* Con varios pagos la fila no crece: el ultimo pago y el total pagado van en un
   boton que ocupa fecha y monto, y el detalle se abre en el panel flotante. Las
   columnas internas repiten las de los campos para que todo quede alineado. */
.pagos-resumen {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: 57px minmax(0, 1fr);
  column-gap: 2px;
  min-height: 24px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-subtle);
  padding: 3px 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.pagos-resumen span {
  overflow: hidden;
  padding: 0 1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagos-resumen:hover,
.pagos-resumen.abierto {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.pagos-panel {
  position: fixed;
  z-index: 61;
  max-height: 420px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.16);
}

.pagos-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pagos-panel-head strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagos-panel-grid {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.25fr);
  column-gap: 6px;
  row-gap: 4px;
  align-items: center;
}

.pagos-panel-titulo {
  color: var(--muted-light);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pagos-panel-n {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.pagos-panel input {
  min-width: 0;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface, #fff);
  padding: 4px 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
}

.pagos-panel input:focus {
  border-color: var(--accent);
  outline: none;
}

.pagos-panel-pie {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pagos-panel-pie strong {
  color: var(--ink);
  font-weight: 600;
}

/* --- Estado de la compra -------------------------------------------------- */
.estado-menu {
  position: relative;
  flex: 0 0 auto;
}

.estado-boton {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface, #fff);
  padding: 0 9px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}

.estado-boton:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.estado-punto {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-subtle);
}

.estado-punto.estado-confirmado,
.estado-boton.estado-confirmado .estado-punto { border-color: #c97a2c; background: #e8942f; }
.estado-punto.estado-senado,
.estado-boton.estado-senado .estado-punto { border-color: #3d8fb0; background: #63b6d6; }
.estado-punto.estado-parcial,
.estado-boton.estado-parcial .estado-punto { border-color: #c2a021; background: #e5c53c; }
.estado-punto.estado-pagado,
.estado-boton.estado-pagado .estado-punto { border-color: #3f8455; background: #57a86f; }
.estado-punto.estado-pagadosf,
.estado-boton.estado-pagadosf .estado-punto { border-color: #154d29; background: #1f6b3a; }
.estado-punto.estado-presupuesto,
.estado-boton.estado-presupuesto .estado-punto { border-color: var(--muted); background: var(--muted-light); }
.estado-punto.estado-duda,
.estado-boton.estado-duda .estado-punto { border-color: #b0392c; background: #cf4536; }

/* El menu se abre al pasar por encima y tambien con el teclado. */
.estado-opciones {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  display: none;
  min-width: 200px;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface, #fff);
  padding: 4px;
  box-shadow: 0 10px 28px -10px rgba(20, 18, 15, 0.28);
}

.estado-menu:hover .estado-opciones,
.estado-menu:focus-within .estado-opciones {
  display: flex;
}

/* Puente invisible: sin esto el menu se cierra al cruzar el hueco con el mouse. */
.estado-menu:hover .estado-opciones::before,
.estado-menu:focus-within .estado-opciones::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 0;
  left: 0;
  height: 6px;
}

.estado-opcion {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 7px 9px;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.estado-opcion:hover,
.estado-opcion:focus-visible {
  background: var(--surface-subtle);
}

.estado-opcion.activa {
  color: var(--accent);
  font-weight: 600;
}

/* --- Color de la fila segun el estado ------------------------------------ */
/* "Presupuesto solicitado" no pinta: pedir precio todavia no es comprar. */
.stage.estado-fila-confirmado > .stage-row { background: rgba(232, 148, 47, 0.14); }
.stage.estado-fila-senado > .stage-row { background: rgba(99, 182, 214, 0.16); }
.stage.estado-fila-parcial > .stage-row { background: rgba(229, 197, 60, 0.18); }
.stage.estado-fila-pagado > .stage-row { background: rgba(87, 168, 111, 0.16); }

.stage.estado-fila-confirmado > .stage-row:hover { background: rgba(232, 148, 47, 0.2); }
.stage.estado-fila-senado > .stage-row:hover { background: rgba(99, 182, 214, 0.22); }
.stage.estado-fila-parcial > .stage-row:hover { background: rgba(229, 197, 60, 0.24); }
.stage.estado-fila-pagado > .stage-row:hover { background: rgba(87, 168, 111, 0.22); }

/* Abierta, la etapa se pone blanca; el estado tiene que seguir ganando. */
.stage.open.estado-fila-confirmado > .stage-row { background: rgba(232, 148, 47, 0.14); }
.stage.open.estado-fila-senado > .stage-row { background: rgba(99, 182, 214, 0.16); }
.stage.open.estado-fila-parcial > .stage-row { background: rgba(229, 197, 60, 0.18); }
.stage.open.estado-fila-pagado > .stage-row { background: rgba(87, 168, 111, 0.16); }

@media (max-width: 860px) {
  .stage-row .plan-compra {
    grid-column: auto;
    justify-self: start;
  }

  .estado-opciones {
    right: auto;
    left: 0;
  }
}

/* Con la etapa abierta, el cuerpo (variantes, notas, items) se pinta despues en el
   DOM y taparia el menu de estado que se abre hacia abajo. Al abrirlo (hover o foco)
   se sube la fila entera por encima de todo con :has, y el menu queda visible. */
.stage-row { position: relative; }

.stage:has(.estado-menu:hover) > .stage-row,
.stage:has(.estado-menu:focus-within) > .stage-row {
  z-index: 60;
}

/* Titulos de columna: en columnas angostas se acomodan en dos lineas en vez de
   cortarse. Sin esto, "Pedir antes" o "Verificacion" quedaban tapados. */
.table-header span {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.12;
  overflow: visible;
  font-size: 10px;
  letter-spacing: 0.015em;
}

/* --- Estado de compra por item ------------------------------------------- */
/* Boton compacto (solo un punto de color) en la celda de acciones del item. */
.estado-boton-punto {
  padding: 0;
  width: 24px;
  min-height: 24px;
  justify-content: center;
  border-radius: 999px;
}

.estado-boton-punto .estado-punto {
  width: 9px;
  height: 9px;
}

/* La fila del item se tiñe segun su estado de compra. "Presupuesto solicitado" no
   pinta a proposito: pedir precio todavia no es comprar. */
.edit-row.estado-fila-duda { background: rgba(207, 69, 54, 0.14); }
.edit-row.estado-fila-confirmado { background: rgba(232, 148, 47, 0.13); }
.edit-row.estado-fila-senado { background: rgba(99, 182, 214, 0.15); }
.edit-row.estado-fila-parcial { background: rgba(229, 197, 60, 0.17); }
.edit-row.estado-fila-pagado { background: rgba(87, 168, 111, 0.15); }
/* Pago completo sin factura: el mismo verde, mas oscuro, para que se distinga de un vistazo. */
.edit-row.estado-fila-pagadosf { background: rgba(30, 110, 60, 0.42); }

/* El menu del item se abre hacia arriba (la mayoria de las filas tienen mas espacio
   arriba que abajo dentro de la etapa) y la fila sube por encima de las vecinas. */
.estado-menu-item .estado-opciones {
  top: auto;
  bottom: calc(100% + 4px);
}

.estado-menu-item:hover .estado-opciones::before,
.estado-menu-item:focus-within .estado-opciones::before {
  top: auto;
  bottom: -6px;
}

.edit-row { position: relative; }

.edit-row:has(.estado-menu:hover),
.edit-row:has(.estado-menu:focus-within) {
  z-index: 60;
}

/* --- Reordenar etapas arrastrando --------------------------------------- */
/* Misma manija que los items, pero en la cabecera de la etapa. Aparece al pasar
   el mouse por encima para no ensuciar la fila. */
.stage-drag-handle {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  color: var(--muted);
  cursor: grab;
  opacity: 0;
  transition: opacity 120ms ease;
}

.stage-row:hover .stage-drag-handle {
  opacity: 0.5;
}

.stage-drag-handle:hover {
  opacity: 1;
}

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

.stage.is-dragging {
  opacity: 0.4;
}

/* La linea marca donde va a quedar la etapa al soltar. */
.stage.is-drag-over > .stage-row {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

/* --- Cronograma embebido dentro de una etapa del presupuesto ------------- */
/* Es el mismo bloque que la vista Cronograma, metido en el cuerpo de la etapa.
   Se le saca el margen propio y se le deja scroll lateral: sus columnas son mas
   anchas que la etapa y no deben empujar la tabla del presupuesto. */
.stage-crono {
  overflow-x: auto;
  padding: 0;
}

.stage-crono .crono-bloque {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  min-width: 900px;
}

/* El nombre del bloque no se edita aca: lo pone la etapa. */
.crono-band-name-fijo {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Fotos del item ------------------------------------------------------- */
/* La miniatura mide lo mismo que el switch de verificado (34x20) para que la fila
   no cambie de alto y las dos columnas se lean como un par. */
.foto-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.foto-boton,
.foto-thumb {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
}

.foto-boton:hover,
.foto-thumb:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.foto-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Cuando hay mas de una foto: el contador avisa que abajo hay otras. */
.foto-mas {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 0 2px;
  border-radius: 3px 0 0 0;
  background: rgba(20, 20, 20, 0.72);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  line-height: 12px;
}

.foto-cargando {
  display: flex;
  opacity: 0.5;
}

/* Visor de todas las fotos del item. */
.fotos-modal {
  width: min(760px, 92vw);
}

.fotos-grid {
  display: grid;
  max-height: 60vh;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  overflow-y: auto;
  padding: 4px 0;
}

.fotos-item {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fotos-item img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.fotos-borrar {
  position: absolute;
  top: 6px;
  right: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.fotos-vacio {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

/* El encabezado repetido dentro de una subetapa: no es el de la pantalla, asi que
   no se pega arriba ni lleva el borde superior. Solo rotula las columnas de abajo. */
.table-header-interno {
  position: static;
  z-index: auto;
  min-height: 30px;
  border-top: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  margin: 0;
  opacity: 0.75;
}

/* La foto del visor es un boton: al tocarla se abre en grande. */
.fotos-abrir {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.fotos-abrir:hover img {
  opacity: 0.88;
}

.fotos-abrir img {
  transition: opacity 120ms ease;
}

/* Las subetapas van sangradas debajo de su etapa, para que se lea que cuelgan de
   ella y no se confundan con otra etapa mas. */
.move-option-sub {
  margin-left: 14px;
  padding-top: 9px;
  padding-bottom: 9px;
  border-style: dashed;
  font-size: 13px;
  font-weight: 500;
}


/* --- Inversores del desarrollo ------------------------------------------ */
.inversores-panel {
  display: grid;
  gap: 12px;
}

.inversores-panel .media-heading {
  margin-bottom: 0;
}

.inversores-resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.inversores-resumen > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.inversores-resumen span {
  color: var(--muted-light);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inversores-resumen strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
}

.inversor-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.5fr) minmax(104px, 1fr) minmax(84px, 0.7fr) minmax(84px, 0.6fr) minmax(72px, 0.5fr) minmax(104px, 0.6fr) 52px 32px;
  align-items: center;
  column-gap: 10px;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
}

.inversor-header {
  min-height: 26px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted-light);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* El monto va alineado a la derecha, como todas las columnas de plata. */
.inversor-header span:nth-child(2) {
  padding-right: 9px;
  text-align: right;
}

/* Los dos porcentajes tambien: el titulo termina donde termina el numero, antes del "%". */
.inversor-header span:nth-child(5),
.inversor-header span:nth-child(6) {
  padding-right: 24px;
  text-align: right;
}

/* "% de retorno" es el titulo mas largo: con menos sangria entra en un renglon
   tambien cuando la columna esta en su ancho minimo. */
.inversor-header span:nth-child(6) {
  padding-right: 16px;
  white-space: nowrap;
}

.inversor-header span:nth-child(7) {
  text-align: center;
}

.inversor-pct {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inversor-pct input {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inversor-pct span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.inversor-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
}

.inversor-row input[data-inversor-field="monto"] {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inversor-row input:hover {
  border-color: var(--line);
}

.inversor-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface, #fff);
}

.inversor-row .row-actions-cell {
  display: flex;
  justify-content: flex-end;
}

.inversor-row .icon-button {
  width: 26px;
  height: 26px;
}

/* Check de "ya pago": cuadrado, no switch, porque es un hecho y no una preferencia. */
.inversor-pagado {
  display: flex;
  justify-content: center;
}

.inversor-check {
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.inversor-check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

/* El cuadrito es el span y no el label, igual que el .toggle de los items: el
   input va invisible encima y el marcado se pinta con el hermano adyacente. */
.inversor-check span {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
  transition:
    border-color var(--dur-1) var(--ease-out),
    background-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.inversor-check:hover span {
  border-color: var(--positive);
}

.inversor-check input:checked + span {
  border-color: var(--positive);
  background: var(--positive);
  color: #fff;
}

.inversor-check input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* La plata que ya entro se lee de un vistazo sin tener que mirar el check. */
.inversor-row.is-pagado input[data-inversor-field="monto"] {
  color: var(--positive);
  font-weight: 650;
}

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

.inversores-total {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.inversores-total span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted-light);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inversores-total strong {
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
}

.inversores-total small {
  color: var(--muted);
  font-size: var(--text-sm);
}

.inversores-total.is-pagado {
  border-color: rgba(79, 125, 94, 0.35);
  background: rgba(79, 125, 94, 0.07);
}

.inversores-total.is-pagado span,
.inversores-total.is-pagado strong {
  color: var(--positive);
}

.inversores-desembolsos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inversores-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.inversores-chip strong {
  color: var(--ink);
  font-weight: 650;
}

/* En celular las filas se apilan y cada campo muestra su etiqueta. */
@media (max-width: 780px) {
  .inversor-header {
    display: none;
  }

  .inversor-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 0;
  }

  .inversor-row > div[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted-light);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
  }

  .inversor-row input[data-inversor-field="monto"] {
    text-align: left;
  }

  .inversor-pct {
    flex-wrap: wrap;
  }

  .inversor-pct::before {
    flex-basis: 100%;
  }

  .inversor-pct input {
    flex: 1 1 0;
    text-align: left;
  }

  .inversor-pagado {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .inversor-pagado::before {
    flex-basis: 100%;
  }
}


/* --- Gastos posventa ------------------------------------------------------- */
/* Etapa aparte, en amarillo: lo que se paga despues de vender (impuestos, tramites).
   Se ve con las demas pero no entra en el total de la obra. */
.stage.posventa > .stage-row {
  background: rgba(229, 197, 60, 0.2);
}

.stage.posventa .stage-body {
  background: rgba(229, 197, 60, 0.08);
}

/* Las filas dejan ver el amarillo de la etapa, salvo las que tienen estado de compra. */
.stage.posventa .edit-row:not([class*="estado-fila-"]) {
  background: transparent;
}

.posventa-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 10px;
  border: 1px solid rgba(194, 160, 33, 0.5);
  border-radius: 999px;
  background: rgba(229, 197, 60, 0.28);
  color: #6f5500;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* Precio que sale solo del escenario comercial: se lee, no se escribe. */
.edit-row input.precio-auto {
  color: var(--muted);
  cursor: default;
}


/* Total base del escenario: el costo de la obra arriba, y abajo cuanto ponen los
   inversores. Lo que falta lo muestra el cuadro del prestamo. */
.total-base-costo {
  display: grid;
  gap: 2px;
}

.total-base-costo strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-tight);
}

.total-base-costo span {
  color: var(--muted);
  font-size: 12px;
}

.total-base-aporte {
  margin-top: 4px;
  color: #637083;
  font-size: 11px;
  font-weight: 600;
}


/* Prestamo personal: el monto arriba, y la tasa y los meses en una fila. */
.prestamo-condiciones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.prestamo-condiciones + .prestamo-condiciones {
  margin-top: 6px;
}

.prestamo-devolucion {
  color: var(--muted);
  font-size: 12px;
}


/* Métricas web: misma escala y tarjetas que el resumen del workspace. */
.site-metrics-main .page-head {
  width: 100%;
}

.site-metrics-status,
.site-metrics-note {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.site-metrics-status.is-error {
  color: #a4262c;
}

.site-metrics-note p {
  max-width: 78ch;
  margin: 0 0 8px;
}


.site-metrics-main .overview-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .site-metrics-main .overview-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .site-metrics-main .overview-strip {
    grid-template-columns: 1fr;
  }
}


/* Tablas de Personal en solo lectura (admin): se leen igual, sin subir ni quitar imagenes. */
.solo-lectura .archivos-quitar,
.solo-lectura .archivos-subir {
  display: none;
}

.solo-lectura select:disabled,
.solo-lectura .whatsapp-contact-toggle:disabled {
  opacity: 1;
  color: var(--ink);
  cursor: default;
}

/* Calculo de desarrollo: los datos a la izquierda, lo que se gana a la derecha y abajo
   el detalle. */
.calculo-main .page-head,
.calculo-proyectos,
.calculo {
  width: 100%;
  max-width: 1380px;
}

/* Los proyectos guardados, como pestañas, y a la derecha lo que se hace con el abierto. */
.calculo-proyectos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: -8px auto 14px;
}

.calculo-proyectos-lista,
.calculo-proyectos-acciones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.calculo-proyectos-acciones small {
  margin-right: 6px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.calculo-proyecto {
  min-height: 34px;
  max-width: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 14px;
  font-size: var(--text-md);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.calculo-proyecto:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.calculo-proyecto.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.calculo-proyectos .button.is-danger {
  border-color: #c0392b;
  background: #c0392b;
  color: #fff;
}

.calculo-nombre {
  margin-bottom: 12px;
}

.calculo .calculo-nombre input {
  font-size: 15px;
  text-align: left;
}

.calculo {
  display: grid;
  grid-template-areas:
    "entradas arriba"
    "entradas numeros"
    "detalle detalle";
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  margin: 0 auto;
}

.calculo-caja {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 18px;
}

.calculo-caja h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 650;
}

.calculo-arriba {
  grid-area: arriba;
}

.calculo-numeros {
  grid-area: numeros;
}

.calculo-entradas {
  display: grid;
  grid-area: entradas;
  align-content: start;
  gap: 14px;
}

.calculo-detalle {
  display: grid;
  grid-area: detalle;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.calculo-por-tipo {
  grid-column: 1 / -1;
}

.calculo input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.calculo input:focus {
  border-color: rgba(189, 123, 79, 0.48);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(189, 123, 79, 0.09);
}

.calculo input.calculo-tipo-nombre {
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

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

.calculo-campo {
  display: grid;
  align-content: start;
  gap: 4px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 610;
}

.calculo-campo small {
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: right;
}

.calculo-tipo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px 58px 58px 56px 56px 104px 112px 64px 96px 80px 30px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* El precio con sus dos flechas: suben y bajan de a mil. */
.calculo-precio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 4px;
}

.calculo-pasos {
  display: grid;
  gap: 2px;
}

.calculo-pasos button {
  display: grid;
  width: 20px;
  height: 19px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  cursor: pointer;
}

.calculo-pasos button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink);
}

.calculo-pasos .es-arriba {
  display: grid;
  transform: rotate(180deg);
}

/* Otros gastos: nombre, valor, sobre que se calcula, lo que da en US$ y el tacho. */
.calculo-gasto {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 156px 96px 30px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Los numeros tienen ancho fijo y el nombre usa lo que sobra; a 16px "134.000" no entra. */
.calculo-tipo input,
.calculo-gasto input {
  padding: 0 8px;
  font-size: 14px;
}

.calculo select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 6px;
  font-size: 14px;
  font-weight: 500;
}

.calculo select:focus {
  border-color: rgba(189, 123, 79, 0.48);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(189, 123, 79, 0.09);
}

.calculo-tipo label span,
.calculo-tipo-dato span {
  display: none;
}

/* Precio Gs y US$/m2: salen de lo cargado, van sin casillero. */
.calculo-tipo-datos {
  display: contents;
}

.calculo-tipo-dato {
  min-width: 0;
  color: var(--muted);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.calculo-tipo-dato strong {
  font-weight: 500;
}

.calculo-tipo-total {
  margin: 2px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--ink);
  font-size: var(--text-md);
}

.calculo-tipo-total strong,
.calculo-tipo-total .calculo-tipo-dato {
  color: var(--ink);
  font-weight: 650;
}

/* Bajo los casilleros, el numero se alinea con el texto de adentro (borde + relleno). */
.calculo-tipo-total > .calculo-tipo-dato {
  padding-right: 9px;
}

.calculo-tipo-titulos {
  align-items: end;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 610;
  text-align: right;
}

.calculo-tipo-titulos span:first-child {
  text-align: left;
}

.calculo-tipos-pie {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.calculo-ganancia span {
  color: var(--muted);
  font-size: var(--text-lg);
  font-weight: 610;
}

.calculo-ganancia strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 34px;
  font-weight: 690;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  overflow-wrap: anywhere;
}

.calculo-ganancia small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

.calculo-ganancia.is-ganancia strong {
  color: var(--positive);
}

.calculo-ganancia.is-perdida strong {
  color: var(--danger);
}

.calculo-filas {
  margin: 0;
}

.calculo-filas div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 9px 0;
  font-size: var(--text-md);
}

.calculo-filas div:first-child {
  border-top: 0;
  padding-top: 0;
}

.calculo-filas div:last-child {
  padding-bottom: 0;
}

.calculo-filas dt {
  min-width: 0;
  color: var(--muted);
}

.calculo-filas dd {
  margin: 0;
  color: var(--ink);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.calculo-filas dd small {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.calculo-filas .es-total dt {
  color: var(--ink);
  font-weight: 620;
}

/* Inversores y preventas: pegados al costo total, que es lo que pagan. */
.calculo-filas .es-parte {
  border-top: 0;
  padding-top: 0;
}

.calculo-filas .es-parte dt {
  padding-left: 14px;
}

.calculo-filas .es-parte dd {
  font-weight: 500;
}

.calculo-uso dd {
  display: flex;
  gap: 14px;
}

.calculo-uso dd small {
  min-width: 46px;
  font-size: var(--text-md);
}

/* Barra del uso del terreno: un tramo por tipo, en proporcion a sus m2; el area comun
   va hueca. */
.calculo-barra {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-bottom: 14px;
  border-radius: 4px;
  overflow: hidden;
}

.calculo-barra-uso {
  flex: 0 1 0;
  min-width: 2px;
}

.calculo-marca {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: -1px;
}

.calculo-barra-uso.es-libre,
.calculo-marca.es-libre {
  background: var(--surface-subtle);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.calculo-barra-uso.es-libre {
  border-radius: 0 4px 4px 0;
}

.calculo-aviso {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: var(--text-md);
}

.calculo-por-tipo table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

.calculo-por-tipo th,
.calculo-por-tipo td {
  border-top: 1px solid var(--line);
  padding: 9px 0 9px 14px;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.calculo-por-tipo th:first-child {
  padding-left: 0;
  text-align: left;
  white-space: normal;
}

.calculo-por-tipo thead th {
  border-top: 0;
  padding-top: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 610;
}

.calculo-por-tipo tfoot th,
.calculo-por-tipo tfoot td {
  padding-bottom: 0;
  font-weight: 650;
}

/* En una columna la ganancia queda fija arriba, a la vista mientras se cargan los datos.
   Va en flex porque sticky no sale de la celda de un grid. Desde 1400px, porque mas angosto
   las doce columnas de Unidades no entran al lado de la ganancia. */
@media (max-width: 1400px) {
  .calculo {
    display: flex;
    flex-direction: column;
  }

  .calculo-arriba {
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: var(--shadow-sm);
    padding: 12px 18px;
  }

  .calculo-ganancia {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    column-gap: 12px;
    text-align: right;
  }

  .calculo-ganancia span {
    text-align: left;
  }

  .calculo-ganancia strong {
    margin: 0;
    font-size: 26px;
  }

  .calculo-ganancia small {
    grid-column: 1 / -1;
    margin-top: 2px;
  }
}

/* Desde 1120px: con las doce columnas de Unidades, mas angosto el nombre no entra. */
@media (max-width: 1120px) {
  .calculo-costos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calculo-detalle {
    grid-template-columns: minmax(0, 1fr);
  }

  .calculo-proyectos {
    margin-top: 0;
  }

  .calculo-tipo-hueco {
    display: none;
  }

  /* Cada gasto: el nombre y el tacho arriba, el valor y sobre que se calcula abajo. */
  .calculo-gasto {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 30px;
    gap: 6px;
    margin-bottom: 14px;
  }

  .calculo-gasto > :first-child {
    grid-column: 1 / 3;
  }

  .calculo-gasto > :last-child {
    grid-row: 1;
    grid-column: 3;
  }

  .calculo-gasto input,
  .calculo select {
    font-size: 16px;
  }

  .calculo-gasto .calculo-tipo-dato {
    grid-column: 1 / -1;
  }

  /* Cada tipo: el nombre y el tacho arriba, los cuatro numeros abajo con su etiqueta. */
  .calculo-tipo {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.4fr);
    align-items: end;
    gap: 6px;
    margin-bottom: 14px;
  }

  .calculo-tipo-titulos {
    display: none;
  }

  /* 16px para que el iPhone no agrande la pagina al tocar el casillero. */
  .calculo-tipo input {
    padding: 0 10px;
    font-size: 16px;
  }

  .calculo-tipo > :first-child {
    grid-row: 1;
    grid-column: 1 / 4;
  }

  .calculo-tipo > :last-child {
    grid-row: 1;
    grid-column: 4;
    justify-self: end;
    align-self: center;
  }

  .calculo-tipo label {
    display: grid;
    gap: 2px;
  }

  /* Baño y cocina, el precio con sus flechas y el US$/m2: media fila cada uno. */
  .calculo-tipo > label:nth-of-type(n + 6),
  .calculo-tipo > .calculo-precio {
    grid-column: span 2;
  }

  .calculo-precio {
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: end;
  }

  .calculo-pasos button {
    width: 28px;
    height: 20px;
  }

  .calculo-tipo label span,
  .calculo-tipo-dato span {
    display: block;
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 610;
    text-align: left;
    white-space: nowrap;
  }

  /* Precio Gs y US$/m2 van en una tercera fila, a media fila cada uno. */
  .calculo-tipo-dato {
    display: grid;
    gap: 2px;
    text-align: left;
  }

  .calculo-tipo-datos .calculo-tipo-dato {
    grid-column: span 2;
  }

  .calculo-tipo-total > .calculo-tipo-dato {
    padding-right: 0;
  }

  /* La tabla por tipo se apila: cada tipo es un bloque con sus numeros en grilla. */
  .calculo-por-tipo thead {
    display: none;
  }

  .calculo-por-tipo tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 6px;
    border-top: 1px solid var(--line);
    padding: 10px 0;
  }

  .calculo-por-tipo tbody tr:first-child {
    border-top: 0;
    padding-top: 0;
  }

  .calculo-por-tipo tfoot tr {
    padding-bottom: 0;
  }

  .calculo-por-tipo th,
  .calculo-por-tipo td {
    border: 0;
    padding: 0;
    text-align: left;
  }

  .calculo-por-tipo tbody th,
  .calculo-por-tipo tfoot th {
    grid-column: 1 / -1;
    font-weight: 620;
  }

  .calculo-por-tipo td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 610;
  }
}


/* Campos con tipo en las tablas de Personal (Terrenos): numeros alineados, link del
   mapa y las imagenes del plano, mas grandes y con boton para quitarlas. */
.data-table td.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.celda-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

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

.detalle-ayuda {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.archivos-gallery.grande {
  align-items: flex-start;
}

.archivos-gallery.grande .application-attachment {
  position: relative;
}

.archivos-gallery.grande .archivos-thumb {
  width: 220px;
  height: 150px;
  background: #fff;
}

.archivos-gallery.grande .archivos-thumb img {
  object-fit: contain;
}

.archivos-quitar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
}

.archivos-quitar:hover {
  border-color: #b0544a;
  color: #b0544a;
}

.archivos-subir {
  align-self: center;
  cursor: pointer;
}


/* Inicio de sesion */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
  background: var(--bg);
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(100%, 340px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 28px 24px;
  box-shadow: 0 2px 5px rgba(20, 18, 15, 0.055);
}

.login-card h1 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.login-aviso {
  color: var(--muted);
  font-size: 14px;
}

/* ===== Tablero por etapas (Leads) =====
   Una columna por etapa, tarjetas que se arrastran y una ficha que se abre al costado.
   El tablero ocupa el alto de la pantalla y cada columna tiene su propio scroll. */
.openai-main.pipeline-main {
  --pipeline-lado: clamp(18px, 2.4vw, 40px);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: 28px 0 0;
}
.pipeline-main > .table-state {
  margin: 0 var(--pipeline-lado);
}
.page-head.pipeline-head {
  flex: 0 0 auto;
  align-items: flex-end;
  max-width: none;
  margin: 0 0 18px;
  padding: 0 var(--pipeline-lado);
}
.pipeline-board {
  display: flex;
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 var(--pipeline-lado) 18px;
  scrollbar-width: thin;
}
.pipeline-col {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 208px;
  max-width: 340px;
  min-height: 0;
  border: 1px solid transparent;
  border-radius: 14px;
  background: #eff1f4;
  transition: background var(--dur-2) ease, border-color var(--dur-2) ease;
}
.pipeline-col-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 13px 14px 9px;
  text-align: left;
}
.pipeline-col-head strong {
  font-size: 13px;
  font-weight: 600;
}
.pipeline-punto {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--etapa, var(--muted-light));
}
.pipeline-cuenta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pipeline-plegar {
  margin-left: auto;
  color: var(--muted-light);
  font-size: 11px;
  font-weight: 500;
}
button.pipeline-col-head {
  border-radius: 13px 13px 0 0;
  cursor: pointer;
}
button.pipeline-col-head:hover .pipeline-plegar {
  color: var(--ink);
}
.pipeline-cards {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 10px;
  scrollbar-color: rgba(20, 18, 15, 0.16) transparent;
  scrollbar-width: thin;
}
.pipeline-vacia {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted-light);
  font-size: 12px;
  padding: 20px 8px;
  text-align: center;
}

/* Tarjeta de un lead */
.lead-card {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  padding: 11px 12px 7px;
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-2) ease, transform var(--dur-2) var(--ease-out), opacity var(--dur-1) ease;
  user-select: none;
  -webkit-user-select: none;
}
.solo-lectura .lead-card {
  cursor: pointer;
}
.lead-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 6px 18px rgba(20, 18, 15, 0.08);
  transform: translateY(-1px);
}
.lead-card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.lead-card.abierta {
  border-color: var(--ink);
}
.lead-card.arrastrando {
  box-shadow: none;
  opacity: 0.35;
  transform: none;
}
.lead-card.recien-movida {
  animation: lead-llega 900ms ease both;
}
@keyframes lead-llega {
  0%, 25% {
    background: color-mix(in srgb, var(--etapa, #9d9a92) 10%, #ffffff);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--etapa, #9d9a92) 60%, transparent);
  }
  100% {
    background: var(--surface);
    box-shadow: 0 0 0 2px transparent;
  }
}
.lead-nombre {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.lead-datos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}
.lead-datos span {
  border-radius: 999px;
  background: #f3f2ef;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  padding: 2px 8px;
  white-space: nowrap;
}
.lead-nota {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}
.lead-pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-top: 5px;
  color: var(--muted-light);
  font-size: 11.5px;
}
.lead-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: -5px;
  border-radius: 999px;
  color: var(--muted-light);
  transition: background var(--dur-1) ease, color var(--dur-1) ease;
}
.lead-wa:hover {
  background: rgba(37, 150, 84, 0.12);
  color: #1b7f45;
}

/* Columna de destino mientras se arrastra una tarjeta */
.pipeline-col.destino {
  border-color: color-mix(in srgb, var(--etapa, #9d9a92) 55%, transparent);
  background: color-mix(in srgb, var(--etapa, #9d9a92) 11%, #eff1f4);
}

/* Descartados: en pantalla ancha es una tira angosta al final; se abre al tocarla y
   recibe tarjetas igual que las demas. */
@media (min-width: 861px) {
  .pipeline-col.colapsada {
    flex: 0 0 46px;
    min-width: 46px;
    border: 1px dashed var(--line-strong);
    background: transparent;
  }
  .pipeline-col.colapsada:hover {
    background: #eff1f4;
  }
  .pipeline-col.colapsada .pipeline-col-head {
    flex: 1 1 auto;
    align-items: center;
    border-radius: 13px;
    padding: 14px 0;
    writing-mode: vertical-rl;
  }
  .pipeline-col.colapsada .pipeline-cards,
  .pipeline-col.colapsada .pipeline-plegar {
    display: none;
  }
  .pipeline-board.arrastrando .pipeline-col.colapsada {
    border-color: color-mix(in srgb, var(--etapa, #9d9a92) 55%, transparent);
  }
  .pipeline-col.colapsada.destino {
    border-style: solid;
    background: color-mix(in srgb, var(--etapa, #9d9a92) 14%, #eff1f4);
  }
}

/* Ficha del lead */
.lead-ficha-fondo {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  background: rgba(31, 31, 29, 0.2);
}
.lead-ficha {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: 100%;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -24px 0 60px rgba(20, 18, 15, 0.12);
}
.lead-ficha-fondo.entrando {
  animation: ficha-fondo 280ms ease both;
  animation-delay: var(--ya, 0ms);
}
.lead-ficha-fondo.entrando .lead-ficha {
  animation: ficha-entra 280ms var(--ease-out) both;
  animation-delay: var(--ya, 0ms);
}
@keyframes ficha-fondo {
  from { background: rgba(31, 31, 29, 0); }
}
@keyframes ficha-entra {
  from { opacity: 0; transform: translateX(32px); }
}
.lead-ficha-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 10px;
  padding: 20px 16px 4px 22px;
}
.lead-ficha-titulo {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.lead-ficha-nombre,
.lead-ficha-tel {
  width: calc(100% + 9px);
  margin-left: -9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 4px 8px;
  transition: background var(--dur-1) ease, border-color var(--dur-1) ease;
}
.lead-ficha-nombre {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.lead-ficha-tel {
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.lead-ficha-nombre:hover,
.lead-ficha-tel:hover {
  background: var(--surface-subtle);
}
.lead-ficha-nombre:focus,
.lead-ficha-tel:focus {
  border-color: var(--line-strong);
  background: var(--surface);
}
.lead-ficha-cuerpo {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 22px 26px;
}
.lead-ficha-wa {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(37, 150, 84, 0.3);
  border-radius: 999px;
  background: rgba(37, 150, 84, 0.07);
  color: #1b7f45;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px 8px 12px;
  text-decoration: none;
  transition: background var(--dur-1) ease;
}
.lead-ficha-wa:hover {
  background: rgba(37, 150, 84, 0.14);
}
.lead-ficha-bloque {
  margin-top: 22px;
}
.lead-ficha-bloque h3 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.lead-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lead-pills button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 13px;
  transition: background var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease;
}
.lead-pills button:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}
.lead-pills button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}
.lead-pills button:disabled {
  cursor: default;
}
.lead-ficha-notas {
  display: block;
  width: 100%;
  min-height: 120px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  outline: none;
  padding: 11px 13px;
  resize: none;
  transition: border-color var(--dur-1) ease;
}
.lead-ficha-notas:focus {
  border-color: var(--ink-soft);
}
.lead-ficha-pie {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-light);
  font-size: 12px;
  padding: 10px 14px 10px 22px;
}
.lead-ficha-borrar {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 9px;
}
.lead-ficha-borrar:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Telefono: las columnas se pasan con el dedo, de a una, y la ficha ocupa la pantalla. */
@media (max-width: 860px) {
  .openai-app.pipeline-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }
  .openai-main.pipeline-main {
    --pipeline-lado: 14px;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding-top: 16px;
  }
  .page-head.pipeline-head {
    flex-direction: row;
    align-items: center;
    margin-bottom: 12px;
  }
  .pipeline-board {
    gap: 10px;
    padding-bottom: 14px;
    scroll-padding-inline: 14px;
    scroll-snap-type: x mandatory;
  }
  .pipeline-col {
    flex: 0 0 min(80vw, 320px);
    min-width: 0;
    max-width: none;
    scroll-snap-align: start;
  }
  /* Una etapa sin nadie no se lleva toda la pantalla: queda angosta al lado de la siguiente. */
  .pipeline-col.vacia {
    flex-basis: 132px;
  }
  .pipeline-plegar {
    display: none;
  }
  .lead-ficha {
    border-left: 0;
  }
  /* Con letra de menos de 16 px el iPhone agranda la pantalla al tocar un casillero. */
  .lead-ficha-tel,
  .lead-ficha-notas {
    font-size: 16px;
  }
}
