/* Proyectos (#proyectos): hoja propia del módulo. Movida desde styles.css sin
   cambios (UX-F3-03 fase A); index.html la carga desde el bloque modules:auto. */

#proyectos {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.project-workspace {
  --ac-index-min: 320px;
  --ac-index-max: 520px;
  --ac-work-height: 100%;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.project-directory,
.project-workbench {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.project-directory {
  display: flex;
  flex-direction: column;
}

.project-directory-heading,
.project-workbench-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

/* Un nombre de proyecto sin espacios reventaba la cabecera y se salía de su
   contenedor hasta 39.000 px a la derecha en PC y tablet. */
.project-directory-heading > div,
.project-workbench-heading > div {
  min-width: 0;
}

.project-directory-heading h3,
.project-workbench-heading h3 {
  margin: 1px 0 0;
  color: var(--ink-strong);
  font-size: var(--font-lg);
  overflow-wrap: anywhere;
}

.project-workbench-heading p,
.project-directory-hint {
  overflow-wrap: anywhere;
}

.project-directory-heading output {
  align-self: center;
  color: var(--ink-strong);
  font: 700 var(--font-sm) var(--font-mono);
  white-space: nowrap;
}

.project-directory-hint,
.project-workbench-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--font-sm);
}

.project-directory-hint {
  min-height: 36px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}

.project-workbench-heading p:not(.eyebrow) {
  margin-top: 4px;
}

.project-directory-list {
  flex: 1;
  min-height: 0;
  max-height: none !important;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: auto;
  background: var(--bg);
  contain: content;
}

.project-directory-row {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(190px, .8fr) minmax(88px, auto);
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-directory-row:hover,
.project-directory-row:focus-visible {
  position: relative;
  z-index: 1;
  background: var(--surface-2);
  outline: 2px solid color-mix(in srgb, var(--signal) 45%, transparent);
  outline-offset: -2px;
}

.project-directory-row.active {
  background: color-mix(in srgb, var(--signal) 10%, var(--surface));
  box-shadow: inset 3px 0 0 var(--signal);
}

.project-directory-row.is-archived:not(.active) {
  opacity: .68;
}

.project-row-copy,
.project-row-context {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.project-row-copy strong,
.project-row-copy small,
.project-row-context span,
.project-row-context small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row-copy strong {
  color: var(--ink-strong);
  font-size: var(--font-sm);
}

.project-row-context span {
  color: var(--ink-muted);
  font-size: var(--font-sm);
}

.project-row-copy small,
.project-row-context small {
  color: var(--ink-faint);
  font-size: var(--font-xs);
}

.project-row-status {
  justify-self: end;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-deep);
  color: var(--ink-muted);
  font: 600 var(--font-xs) var(--font-mono);
  white-space: nowrap;
}

.project-workbench {
  overflow: auto;
  background: var(--bg);
}

.project-date-feedback {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-index-query {
  flex: 0 0 auto;
}

.project-date-feedback[data-tone="danger"] {
  color: var(--danger);
  font-weight: 700;
}

@media (pointer: coarse) and (max-height: 900px) {
  .project-directory-hint {
    display: none;
  }
}

.project-editor {
  width: min(840px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
  margin: 16px auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.project-field > span {
  color: var(--ink-faint);
  font: 600 var(--font-xs) var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.project-field-wide {
  grid-column: 1 / -1;
}

/* Lote 3a: ficha completa de Proyectos (fechas anunciadas, transición y equipo). */
.project-dates-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.project-dates-hint[data-state="error"] {
  color: var(--danger);
  font-weight: 600;
}

.project-transition-field > span {
  color: var(--ink-faint);
  font: 600 var(--font-xs) var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.project-transition-field .form-hint {
  margin: 0;
}

.project-team-field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  margin: 0;
}

.project-team-field > legend {
  color: var(--ink-faint);
  font: 600 var(--font-xs) var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 0 4px;
}

.project-team-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.project-team-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2, var(--surface));
  cursor: pointer;
}

.project-team-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--accent);
}

@media (pointer: coarse) {
  .project-team-option { min-height: 48px; }

  .project-team-option input[type="checkbox"] {
    width: 44px;
    height: 44px;
  }

  /* Objetivos táctiles de 44 px en toda la ficha (UI-008 aplicado a Proyectos). */
  #proyectos .project-editor :is(input:not([type="checkbox"]), select),
  #proyectos .project-transition-field .btn {
    height: auto;
    min-height: 44px;
  }
}

.project-team-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-team-option span > :is(strong, small) {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-team-option span > small {
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-active-hermes,
.project-active-tasks,
.project-active-calendar {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.project-active-hermes h4,
.project-active-tasks h4,
.project-active-calendar h4 {
  margin: 2px 0 0;
  color: var(--ink-strong);
}

.project-active-calendar > header,
.project-active-tasks > header,
.project-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.project-active-hermes .project-crm-assist-result {
  width: 100%;
  margin: 0;
}

.project-active-detail-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.project-active-detail-tabs button {
  min-height: 40px;
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
  cursor: pointer;
}

.project-active-detail-tabs button.active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: var(--shadow);
}

.project-active-detail-panel {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.project-active-detail-panel[hidden] { display: none; }

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

.project-finance-heading,
.project-finance-block > header,
.project-billing-item-editor > header,
.project-billing-item-editor > footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.project-finance-panel :is(h4, h5, h6) {
  margin: 2px 0 0;
  color: var(--ink-strong);
}

.project-finance-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.project-finance-summary article {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.project-finance-summary span {
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-finance-summary strong {
  overflow: hidden;
  color: var(--ink-strong);
  font: 700 var(--font-sm) var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-finance-block {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-billing-items-list,
.project-finance-expenses-list,
.project-expense-budget-list {
  display: grid;
  gap: 7px;
}

.project-billing-item-row,
.project-finance-expenses-list article,
.project-expense-budget-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

.project-billing-item-row > div:first-child,
.project-finance-expenses-list article > div:first-child,
.project-expense-budget-row > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.project-billing-item-row small,
.project-finance-expenses-list article small,
.project-expense-budget-row small {
  overflow: hidden;
  color: var(--ink-muted);
  font-size: var(--font-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-billing-item-editor {
  display: grid;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-billing-item-editor[hidden] { display: none; }

.project-expense-budget-editor {
  display: grid;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-expense-budget-editor[hidden] { display: none; }

.project-expense-budget-editor > header,
.project-expense-budget-editor > footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

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

.project-expense-budget-grid label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-expense-budget-grid .wide { grid-column: 1 / -1; }

#projectFinanceExpenseVariance[data-state="over"] { color: var(--danger); }

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

.project-billing-item-grid label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-billing-item-grid .wide { grid-column: 1 / -1; }

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

.project-finance-sources-grid fieldset {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.project-finance-sources-grid legend {
  padding: 0 4px;
  color: var(--ink-faint);
  font: 600 var(--font-xs) var(--font-mono);
  text-transform: uppercase;
}

.project-finance-source-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.project-finance-source-list label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.project-finance-source-list label > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.project-finance-source-list label small {
  overflow: hidden;
  color: var(--ink-muted);
  font-size: var(--font-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .project-finance-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-billing-item-row,
  .project-finance-expenses-list article,
  .project-expense-budget-row { grid-template-columns: minmax(0, 1fr) auto; }
  .project-billing-item-row .project-inline-actions { grid-column: 1 / -1; }
  .project-expense-budget-row .project-inline-actions { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .project-billing-item-grid,
  .project-expense-budget-grid,
  .project-finance-sources-grid { grid-template-columns: minmax(0, 1fr); }
  .project-finance-heading,
  .project-finance-block > header,
  .project-billing-item-editor > header,
  .project-billing-item-editor > footer,
  .project-expense-budget-editor > header,
  .project-expense-budget-editor > footer { flex-direction: column; align-items: stretch; }
}

.project-active-tasks {
  display: grid;
  gap: 12px;
}

.project-active-tasks > header > div:first-child {
  min-width: 0;
}

.project-active-tasks > header .form-hint {
  margin: 3px 0 0;
}

.project-task-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.project-task-list > .form-hint {
  margin: 0;
  padding: 14px;
}

.project-task-tree {
  min-width: 0;
  border-bottom: 1px solid var(--line);
}

.project-task-tree:last-child { border-bottom: 0; }

.project-task-tree > .project-task-row { border-bottom: 0; }

.project-task-row {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(190px, .85fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-task-row:hover,
.project-task-row:focus-visible { background: var(--surface-2); outline: 2px solid color-mix(in srgb, var(--signal) 40%, transparent); outline-offset: -2px; }
.project-task-row.active { background: color-mix(in srgb, var(--signal) 9%, var(--surface)); box-shadow: inset 3px 0 0 var(--signal); }

.project-task-row-main,
.project-task-row-plan {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.project-task-row :is(strong, span, small) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-task-row small { color: var(--ink-muted); font-size: var(--font-xs); }

.project-task-budget-children {
  display: grid;
  gap: 5px;
  margin: 0 12px 10px 28px;
  padding-left: 12px;
  border-left: 2px solid color-mix(in srgb, var(--signal) 32%, var(--line));
}

.project-task-budget-children-heading,
.project-task-budget-child {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-task-budget-children-heading {
  color: var(--ink-muted);
  font-size: var(--font-xs);
}

.project-task-budget-child {
  min-height: 44px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
}

button.project-task-budget-child { cursor: pointer; }

.project-task-budget-child.is-cancelled {
  opacity: .68;
}

.project-task-budget-child.is-cancelled :is(strong, b) {
  text-decoration: line-through;
}

.project-task-budget-child span { min-width: 0; display: grid; gap: 2px; }
.project-task-budget-child small { color: var(--ink-muted); font-size: var(--font-xs); }

.project-task-editor {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-task-editor[hidden] { display: none; }

.project-task-editor > header,
.project-task-editor-actions,
.project-task-tracking section > header,
.project-task-hermes-proposal > header,
.project-task-hermes-proposal > footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.project-task-editor h5,
.project-task-editor h6 {
  margin: 2px 0 0;
  color: var(--ink-strong);
  font-size: var(--font-md);
}

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

.project-task-color-field {
  min-width: 0;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.project-task-color-field > legend {
  padding: 0 4px;
  color: var(--ink-faint);
  font: 600 var(--font-xs) var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.project-task-color-control {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
}

.project-task-color-control input[type="color"] {
  width: 52px;
  min-width: 52px;
  height: var(--row-h);
  padding: 3px;
  cursor: pointer;
}

.project-task-color-control .btn { width: 100%; }

.project-task-color-field > small {
  color: var(--ink-muted);
  font-size: var(--font-xs);
  line-height: 1.35;
}

.project-task-summary-actions { margin-top: -5px; }
.project-task-summary-actions small { flex: 1; color: var(--ink-muted); }

.project-task-hermes-suggestion output,
.project-task-hours-balance output {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--ink-muted);
  font-size: var(--font-sm);
}

.project-task-hours-balance output[data-state="over"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
  font-weight: 700;
}

.project-task-hermes-proposal {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.project-task-hermes-proposal[hidden] { display: none; }
.project-task-hermes-proposal p { margin: 0; white-space: pre-wrap; }

.project-task-editor-actions {
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

.project-task-tracking[hidden] { display: none; }

.project-task-tracking > section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.project-task-tracking > .project-task-expense-budget { grid-column: 1 / -1; }

.project-task-compose {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.project-task-compose label { min-width: 0; display: grid; gap: 4px; color: var(--ink-muted); font-size: var(--font-xs); }
.project-task-compose .wide,
.project-task-compose > button { grid-column: 1 / -1; }

.project-task-compact-list,
.project-task-timeline {
  display: grid;
  gap: 7px;
  max-height: 280px;
  overflow: auto;
}

.project-task-compact-list article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.project-task-compact-list article span { min-width: 0; display: grid; gap: 2px; }
.project-task-compact-list article small { color: var(--ink-muted); overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .project-task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .project-task-row-plan { grid-column: 1 / -1; grid-row: 2; }
  .project-task-row > .status-pill { grid-column: 2; grid-row: 1; }
  .project-task-tracking { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .project-task-editor-grid,
  .project-task-compose { grid-template-columns: minmax(0, 1fr); }
  .project-task-color-control { grid-template-columns: minmax(0, 1fr); }
  .project-task-color-control input[type="color"] { width: 100%; }
  .project-task-editor > header,
  .project-task-editor-actions { align-items: stretch; flex-direction: column; }
  .project-task-editor-actions .project-inline-actions { width: 100%; }
  .project-task-editor-actions .btn { flex: 1; }
}

@media (pointer: coarse) {
  .project-task-row,
  .project-task-editor .btn,
  .project-task-editor :is(input, select) { min-height: 44px; }
}

.project-contact-create {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-contact-create[hidden] {
  display: none;
}

.project-contact-create h4 {
  margin: 2px 0 0;
  color: var(--ink-strong);
}

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

.project-contact-create-grid label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

@media (max-width: 900px) {
  .project-contact-create-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.project-directory-query {
  margin: 0 14px 10px;
}

.project-crm-subnav {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow-x: auto;
}

.project-crm-subnav button {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font: 700 var(--font-sm) var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
}

.project-crm-subnav button:hover,
.project-crm-subnav button:focus-visible {
  color: var(--ink-strong);
  background: var(--surface-2);
}

.project-crm-subnav button.active,
.project-crm-subnav button[aria-current="page"] {
  border-color: color-mix(in srgb, var(--signal) 35%, var(--line));
  background: color-mix(in srgb, var(--signal) 12%, var(--surface));
  color: var(--ink-strong);
}

.project-crm-workspace .project-directory-list > .ac-state-surface {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
  justify-items: center;
}

.project-crm-directory-row {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, .8fr);
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-crm-directory-row:hover,
.project-crm-directory-row:focus-visible {
  position: relative;
  z-index: 1;
  background: var(--surface-2);
  outline: 2px solid color-mix(in srgb, var(--signal) 45%, transparent);
  outline-offset: -2px;
}

.project-crm-directory-row.active {
  background: color-mix(in srgb, var(--signal) 10%, var(--surface));
  box-shadow: inset 3px 0 0 var(--signal);
}

.project-crm-directory-main,
.project-crm-directory-side {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.project-crm-directory-main :is(strong, small),
.project-crm-directory-side small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-crm-directory-main strong { color: var(--ink-strong); }
.project-crm-directory-main small,
.project-crm-directory-side small { color: var(--ink-muted); }
.project-crm-directory-side { justify-items: end; text-align: right; }

.project-crm-load-more {
  flex: 0 0 auto;
  margin: 8px 14px 12px;
}

.project-crm-editor {
  margin-bottom: 12px;
}

.project-crm-formalization {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--signal) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--signal) 5%, var(--surface));
}

.project-crm-formalization[hidden] { display: none; }

.project-crm-formalization legend {
  padding: 0 5px;
  color: var(--ink-strong);
  font-weight: 700;
}

.project-crm-formalization > label:not(.ac-checkbox-row) {
  display: grid;
  gap: 6px;
}

.project-crm-detail-block,
.project-crm-assist-result {
  width: min(840px, calc(100% - 32px));
  margin: 0 auto 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.project-crm-detail-block > header,
.project-crm-assist-result > header,
.project-crm-assist-result > footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.project-crm-detail-block h4,
.project-crm-assist-result h4 {
  margin: 2px 0 0;
  color: var(--ink-strong);
}

.project-crm-assist-result {
  border-color: color-mix(in srgb, var(--signal) 45%, var(--line));
  background: color-mix(in srgb, var(--signal) 6%, var(--surface));
}

.project-crm-assist-result pre {
  max-height: 360px;
  margin: 14px 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-deep);
  color: var(--ink);
  font: 400 var(--font-sm)/1.55 var(--font-sans);
  white-space: pre-wrap;
}

.project-crm-activity-compose {
  display: grid;
  grid-template-columns: minmax(120px, .25fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin: 14px 0;
}

.project-crm-activity-compose textarea { resize: vertical; }

.project-crm-timeline {
  display: grid;
  gap: 0;
}

.project-crm-timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
}

.project-crm-timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 24px;
  bottom: -8px;
  width: 1px;
  background: var(--line-strong);
}

.project-crm-timeline-marker {
  width: 9px;
  height: 9px;
  margin: 6px 0 0 4px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 18%, var(--surface));
}

.project-crm-timeline-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.project-crm-timeline-item header span,
.project-crm-timeline-item small { color: var(--ink-faint); font-size: var(--font-xs); }
.project-crm-timeline-item p { margin: 5px 0; color: var(--ink); white-space: pre-wrap; }

.project-crm-attachments,
.project-crm-quotes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.project-crm-attachment,
.project-crm-quote {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.project-crm-attachment-open,
.project-crm-quote-row {
  min-width: 0;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-crm-attachment-open {
  display: grid;
  flex: 1;
  gap: 3px;
  padding: 0;
  border: 0;
  background: transparent;
}

.project-crm-attachment-open span,
.project-crm-quote-row small { color: var(--ink-muted); font-size: var(--font-xs); }

.project-crm-quote-row {
  flex: 1;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.project-crm-quote-row > span:first-child { display: grid; gap: 3px; }
.project-crm-quote.is-primary {
  border-color: color-mix(in srgb, var(--success) 42%, var(--line));
  background: color-mix(in srgb, var(--success) 7%, var(--surface));
}

@media (pointer: coarse) {
  .project-crm-detail-block :is(button, select, textarea),
  .project-crm-assist-result button,
  .project-crm-attachment-open,
  .project-crm-quote-row {
    min-height: 44px;
  }
}

@media (max-width: 900px) {
  .project-crm-directory-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .project-crm-directory-side { justify-items: start; text-align: left; }
  .project-crm-activity-compose { grid-template-columns: minmax(0, 1fr); }
  .project-crm-detail-block,
  .project-crm-assist-result { width: calc(100% - 20px); padding: 14px; }
}

@media (max-width: 1200px) {
  .project-directory-row {
    grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  }

  .project-row-copy { grid-column: 1; grid-row: 1; }
  .project-row-context { grid-column: 1; grid-row: 2; }
  .project-row-status { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 900px) {
  .project-directory-hint { display: none; }
  .project-workbench-heading { padding: 10px; }
  .project-editor { width: calc(100% - 20px); margin: 10px auto; }
}

/* F3-03: una cola y fichas exclusivas con un nivel de pestañas. */
.project-unified-directory { display:flex; flex-direction:column; min-height:0; flex:1; width:100%; }
.project-unified-directory > .ac-index-query { display:flex; gap:var(--space-3); padding:var(--space-3); }
.project-unified-directory > .ac-index-query > label { flex:1; }
.project-unified-directory input { width:100%; }
.project-unified-rows { overflow:auto; min-height:0; flex:1; }
.project-unified-directory > footer { display:flex; justify-content:space-between; align-items:center; padding:var(--space-3); }
.project-record-tabs { flex:none; }
#projectDataPanel, #projectCrmDataPanel { grid-column:1/-1; }
.project-more-data { grid-column:1/-1; }
.project-more-data > summary { min-height:var(--row-h); padding:var(--space-2); cursor:pointer; }
.project-context-links { display:flex; gap:var(--space-3); padding:var(--space-3); }
.project-context-links a { min-height:var(--row-h); display:inline-flex; align-items:center; gap:var(--space-2); }
#projectForm > [role=tabpanel] { grid-column:1/-1; }

.project-unified-rows .project-directory-row { grid-template-columns:minmax(0,1fr) auto var(--space-4); gap:var(--space-3); }

.project-read-summary {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-4);padding:var(--space-4);margin:0;}
.project-read-summary dt {color:var(--ink-muted);font-size:var(--font-sm);}
.project-read-summary dd {margin:var(--space-1) 0 0;overflow-wrap:anywhere;}
.project-editable-content.project-editor {grid-column:1/-1;width:100%;margin:0;padding:0;border:0;}
