/* Empresas: lista primero, ficha al abrir, alta debajo. */
#organizations .companies-toolbar { display: flex; align-items: end; gap: 8px; margin: 4px 0 12px; }
#organizations .companies-toolbar label { display: grid; flex: 1; gap: 4px; min-width: 0; font-weight: 700; }
#organizations .companies-toolbar input { width: 100%; min-width: 0; min-height: 44px; }
#organizations .companies-jump { width: auto; min-height: 44px; white-space: nowrap; }
#organizations .companies-workspace { display: grid; gap: 16px; min-width: 0; }
#organizations .companies-workspace:has(#company-ficha:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
#organizations:has(#company-ficha:not([hidden])) .companies-toolbar,
#organizations .companies-workspace:has(#company-ficha:not([hidden])) .companies-list-pane { display: none; }
#organizations .companies-list-pane, #company-ficha, #company-panel-resumen, #company-panel-tarifas, #company-panel-estructura { min-width: 0; }
#organizations .companies-empty { margin: 8px 0; color: var(--czn-muted, #5b625f); }
#company-state-help{margin:-4px 0 8px;color:var(--czn-muted,#5b625f);font-size:.82rem}
#organization-cards > article.companies-org { align-items: center; }
#organization-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:start}
#organization-cards > article.companies-org{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;min-height:48px;margin:0;padding:4px 10px;border:1px solid var(--czn-line,#d9d5ce);border-radius:10px;background:#fff}
#organization-cards > article.companies-org h3{margin:0;font-size:.94rem;line-height:1.3}
#organization-cards > article.companies-org .status-badge{width:max-content;max-width:100%;background:#f0eeea;color:#4d5652}
#organization-cards > article.companies-org .status-badge[hidden]{display:none}
#organizations #company-context{display:none}
body:has(#organizations:not([hidden])) .workspace-sidebar>.workspace-context{display:none}
#organization-cards .companies-open { width: auto; min-height: 44px; white-space: nowrap; }
#company-ficha { padding: 16px; border: 1px solid var(--czn-line, #d9d5ce); border-radius: 12px; background: #fff; }
#company-ficha .company-back { width: fit-content; min-height: 44px; margin-bottom: 14px; padding-inline: 0; border: 0; background: transparent; color: var(--czn-brand, #79342b); font-weight: 700; text-align: left; }
#company-ficha .company-back:hover { text-decoration: underline; }
#company-ficha .company-ficha-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
#company-ficha .company-ficha-head h3 { margin: 0; font-size: 1.35rem; }
#company-ficha .company-ficha-head p { margin: 4px 0 0; color: var(--czn-muted, #5b625f); }
#company-ficha .company-ficha-head .button-secondary, #company-ficha-edit { width: auto; min-height: 44px; }
.company-ficha-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.company-ficha-tabs button { width: auto; min-height: 44px; border: 1px solid var(--czn-line, #d9d5ce); background: #fff; color: var(--czn-brand, #79342b); }
.company-ficha-tabs button:hover { background: #f8f1ed; }
.company-ficha-tabs button[aria-selected="true"] { border-color: var(--czn-brand, #79342b); background: #f5eae6; color: var(--czn-brand, #79342b); box-shadow: inset 0 -3px var(--czn-brand, #79342b); }
.company-record { display: grid; gap: 4px; margin: 8px 0; padding: 12px; border: 1px solid var(--czn-line, #d9d5ce); border-radius: 12px; background: #fff; }
.company-record h4, .company-record p { margin: 0; }
.company-record p { color: var(--czn-muted, #5b625f); }
.companies-phase { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.companies-phase[data-phase="vigente"] { background: #e9f3ee; color: #17633f; }
.companies-phase[data-phase="pendiente"] { background: #fff2df; color: #8d510d; }
.companies-phase[data-phase="historico"] { background: #f3f0eb; color: #5b625f; }
.company-context, #company-context, #commercial-company-context { margin: 0 0 12px; color: var(--czn-muted, #5b625f); }
#commercial-current-tariff { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--czn-line, #d9d5ce); border-left: 4px solid var(--czn-brand, #79342b); border-radius: 12px; background: var(--czn-background, #f7f5f0); }
#commercial-version-effect { margin-top: 0; }
#organizations .companies-forms { margin-top: 20px; }
#organizations .companies-forms > h3 { margin: 0 0 8px; }
#company-panel-estructura .companies-structure-forms { margin-top: 12px; }
#company-panel-estructura .companies-structure-forms h4 { margin: 16px 0 8px; }
#company-panel-estructura #unit-form { max-width: 760px; }
#company-panel-estructura #unit-form [data-organization-scope] { display: none; }
#company-panel-estructura .company-structure-intro { max-width: 68ch; margin: 0 0 12px; color: var(--czn-muted, #5b625f); }
#company-panel-estructura .company-structure-access { margin-top: 22px; border-top: 1px solid var(--czn-line, #d9d5ce); }
#company-panel-estructura .company-structure-access > summary { padding: 14px 0; color: var(--czn-brand, #79342b); font-weight: 700; cursor: pointer; }
#company-panel-estructura .company-structure-access > p { margin: 0 0 12px; color: var(--czn-muted, #5b625f); }
#company-panel-estructura #unit-form [data-combobox="unit-organization"] { display: none; }
.company-ficha-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.company-ficha-actions button { width: auto; min-height: 44px; }

@media (max-width: 700px) {
  #organization-cards { grid-template-columns:minmax(0,1fr);gap:0;overflow:hidden;border:1px solid var(--czn-line,#d9d5ce);border-radius:10px;background:#fff }
  #organization-cards > article.companies-org { border:0;border-bottom:1px solid #e9e5df;border-radius:0 }
  #organization-cards > article.companies-org:last-child { border-bottom:0 }
  #organizations .companies-toolbar { flex-direction: column; align-items: stretch; }
  #organizations .companies-jump, #company-ficha-edit { width: 100%; }
  #organization-cards > article.companies-org { grid-template-columns:minmax(0,1fr) auto;gap:2px 8px;padding:7px 10px; }
  #organization-cards > article.companies-org .status-badge{grid-column:1;grid-row:2}
  #organization-cards .companies-open { grid-column:2;grid-row:1 / span 2;min-width:44px }
  #company-ficha .company-ficha-head { display: grid; }
  .company-ficha-tabs button { flex: 1 1 auto; }
}
