:root {
    --contacts-border: #e6ebf3;
    --contacts-muted: #64748b;
    --contacts-soft: #f8fafc;
    --contacts-ink: #0f172a;
}

.contacts-workspace[hidden] {
    display: none !important;
}

.app-main.contacts-workspace-open > .app-header,
.app-main.contacts-workspace-open > .calendar-panel,
.app-main.contacts-workspace-open > #availabilityWorkspace,
.app-main.contacts-workspace-open > .settings-workspace {
    display: none !important;
}

.contacts-workspace {
    min-height: calc(100vh - 36px);
    width: 100%;
}

.contacts-screen {
    display: grid;
    gap: 14px;
}

.contacts-toolbar {
    background: #fff;
    border: 1px solid var(--contacts-border);
    border-radius: 24px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .035);
}

.contacts-kicker {
    display: inline-flex;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .115em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.contacts-kicker.danger {
    color: #dc2626;
}

.contacts-toolbar h1 {
    margin: 0;
    color: var(--contacts-ink);
    font-size: clamp(28px, 2.7vw, 38px);
    line-height: 1;
    letter-spacing: -.05em;
    font-weight: 930;
}

.contacts-toolbar p {
    margin: 7px 0 0;
    color: var(--contacts-muted);
    font-size: 13px;
    line-height: 1.35;
    font-weight: 650;
    max-width: 680px;
}

.contacts-search-card {
    border: 1px solid var(--contacts-border);
    background: #fff;
    border-radius: 20px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .03);
}

.contacts-search-box {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    min-width: 0;
}

.contacts-search-box span {
    color: #94a3b8;
    font-size: 18px;
    text-align: center;
}

.contacts-search-box input {
    border: 0;
    outline: 0;
    width: 100%;
    min-width: 0;
    color: var(--contacts-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 650;
}

.contacts-count-pill {
    border: 1px solid #eef2f7;
    background: var(--contacts-soft);
    color: var(--contacts-muted);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.contacts-list-card-full {
    width: 100%;
    min-height: 250px;
    background: #fff;
    border: 1px solid var(--contacts-border);
    border-radius: 22px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .035);
    overflow: hidden;
}

.contacts-table {
    display: grid;
    width: 100%;
}

.contacts-table-head,
.contacts-row {
    display: grid;
    grid-template-columns:
        minmax(220px, 1.15fr)
        minmax(210px, 1fr)
        minmax(150px, .65fr)
        minmax(170px, .75fr)
        minmax(120px, .55fr)
        210px;
    align-items: center;
    gap: 12px;
}

.contacts-table-head {
    padding: 11px 14px;
    background: #f8fafc;
    color: #94a3b8;
    border-bottom: 1px solid #eef2f7;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.contacts-row {
    min-width: 0;
    border-bottom: 1px solid #eef2f7;
    background: #fff;
    padding: 12px 14px;
    text-align: left;
    transition: background .16s ease, box-shadow .16s ease;
}

.contacts-row:last-child {
    border-bottom: 0;
}

.contacts-row:hover {
    background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
}

.contacts-row-person {
    min-width: 0;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.contacts-avatar,
.contacts-detail-avatar {
    border-radius: 15px;
    background: #fff7ed;
    color: #c2410c;
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: -.02em;
}

.contacts-avatar {
    width: 40px;
    height: 40px;
    font-size: 13px;
}

.contacts-row-person strong,
.contacts-row-person span,
.contacts-row-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contacts-row-person strong {
    display: block;
    color: var(--contacts-ink);
    font-size: 14px;
    font-weight: 900;
}

.contacts-row-person span,
.contacts-row-meta {
    display: block;
    color: var(--contacts-muted);
    font-size: 12px;
    font-weight: 700;
}

.contacts-row-actions {
    display: grid;
    grid-template-columns: repeat(3, 32px);
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.contact-icon-action.booking-icon-action {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    display: inline-grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
    transition: transform .14s ease, background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}

.contact-icon-action.booking-icon-action svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.contact-icon-action.booking-icon-action:hover:not(:disabled) {
    transform: translateY(-1px);
    background: #fff;
    border-color: rgba(249, 115, 22, .36);
    color: #c2410c;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}

.contact-icon-action.contact-action-delete {
    background: #fff7ed;
    color: #c2410c;
    border-color: #ffedd5;
}

.contact-icon-action.contact-action-delete:hover:not(:disabled) {
    background: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.contacts-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.contacts-empty-state,
.contacts-error-card {
    min-height: 230px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    gap: 8px;
    padding: 24px;
}

.contacts-empty-state strong,
.contacts-error-card strong {
    color: var(--contacts-ink);
    font-size: 17px;
    font-weight: 900;
}

.contacts-empty-state p,
.contacts-error-card p {
    color: var(--contacts-muted);
    margin: 0;
    max-width: 380px;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 650;
}

#contextContacts .contacts-context-block {
    display: grid;
    gap: 10px;
}

#contextContacts .contacts-section-card {
    width: 100%;
    border: 1px solid var(--contacts-border);
    background: #fff;
    color: var(--contacts-ink);
    border-radius: 18px;
    padding: 12px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    text-align: left;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .04);
    transition: border-color .16s ease, background .16s ease;
}

#contextContacts .contacts-section-card:hover,
#contextContacts .contacts-section-card.is-active {
    border-color: rgba(249, 115, 22, .42);
    background: linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
}

#contextContacts .contacts-section-icon {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #fff7ed;
    color: #c2410c;
    font-size: 17px;
}

#contextContacts .contacts-section-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

#contextContacts .contacts-section-copy strong {
    color: #0f172a;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.05;
}

#contextContacts .contacts-section-copy small {
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
}

#contextContacts .contacts-section-count {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    border: 1px solid #eef2f7;
    color: #64748b;
    font-size: 12px;
    font-weight: 900;
}

#contextContacts .contacts-context-summary {
    margin-top: auto;
}

#contextContacts .contacts-context-note {
    border: 1px dashed #e2e8f0;
    background: #fff;
    border-radius: 16px;
    padding: 10px 12px;
    color: var(--contacts-muted);
    font-size: 11px;
    line-height: 1.2;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contacts-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(15, 23, 42, .38);
    display: grid;
    place-items: center;
    padding: 24px;
}

.contacts-modal {
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #fff;
    border-radius: 28px;
    border: 1px solid var(--contacts-border);
    box-shadow: 0 30px 90px rgba(15, 23, 42, .24);
    padding: 22px;
}

.contacts-view-modal,
.contacts-delete-modal {
    width: min(620px, 100%);
}

.contacts-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.contacts-modal-head h2 {
    margin: 0;
    color: var(--contacts-ink);
    font-size: 26px;
    font-weight: 930;
    letter-spacing: -.04em;
}

.contacts-modal-head p {
    margin: 6px 0 0;
    color: var(--contacts-muted);
    font-size: 14px;
    font-weight: 650;
}

.contacts-modal-close {
    width: 38px;
    height: 38px;
    border: 1px solid #eef2f7;
    background: #fff;
    border-radius: 14px;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
}

.contacts-detail-head {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    margin-bottom: 16px;
}

.contacts-detail-avatar {
    width: 58px;
    height: 58px;
    font-size: 17px;
}

.contacts-detail-head h2 {
    margin: 0;
    color: var(--contacts-ink);
    font-size: 22px;
    font-weight: 930;
    letter-spacing: -.04em;
    line-height: 1.05;
}

.contacts-detail-head p {
    margin: 5px 0 0;
    color: var(--contacts-muted);
    font-size: 13px;
    font-weight: 700;
}

.contacts-detail-fields {
    display: grid;
    gap: 8px;
}

.contacts-detail-field {
    border: 1px solid #eef2f7;
    background: var(--contacts-soft);
    border-radius: 16px;
    padding: 11px 12px;
    display: grid;
    gap: 3px;
}

.contacts-detail-field span,
.contacts-notes span {
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 10px;
    font-weight: 850;
}

.contacts-detail-field strong {
    color: #1e293b;
    font-size: 13px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.contacts-notes {
    border: 1px solid #eef2f7;
    border-radius: 16px;
    padding: 12px;
    margin-top: 10px;
}

.contacts-notes p {
    margin: 5px 0 0;
    color: #475569;
    line-height: 1.45;
    font-size: 13px;
    font-weight: 650;
    white-space: pre-wrap;
}

.contacts-form {
    display: grid;
    gap: 14px;
}

.contacts-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.contacts-form label {
    display: grid;
    gap: 6px;
    color: #475569;
    font-size: 12px;
    font-weight: 850;
}

.contacts-form input,
.contacts-form textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 14px;
    padding: 11px 12px;
    color: var(--contacts-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    outline: 0;
}

.contacts-form input:focus,
.contacts-form textarea:focus {
    border-color: rgba(233, 145, 56, .48);
    box-shadow: 0 0 0 4px rgba(233, 145, 56, .10);
}

.contacts-form-full {
    grid-column: 1 / -1;
}

.contacts-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.contacts-inline-error,
.contacts-inline-success {
    border-radius: 16px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 12px;
}

.contacts-inline-error {
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #991b1b;
}

.contacts-inline-success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.contacts-delete-summary {
    border: 1px solid #fee2e2;
    background: #fff7f7;
    border-radius: 18px;
    padding: 16px;
    display: grid;
    gap: 4px;
    margin-bottom: 16px;
}

.contacts-delete-summary strong {
    color: var(--contacts-ink);
    font-weight: 900;
}

.contacts-delete-summary span {
    color: #7f1d1d;
    font-size: 13px;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.btn-danger {
    border-color: #ef4444 !important;
    background: #dc2626 !important;
    color: #fff !important;
}

.danger-soft {
    color: #b91c1c !important;
}

@media (max-width: 1240px) {
    .contacts-table-head,
    .contacts-row {
        grid-template-columns:
            minmax(220px, 1.2fr)
            minmax(190px, 1fr)
            minmax(130px, .7fr)
            minmax(150px, .8fr)
            190px;
    }

    .contacts-table-head span:nth-child(5),
    .contacts-row > .contacts-row-meta:nth-child(5) {
        display: none;
    }
}

@media (max-width: 920px) {
    .contacts-table-head {
        display: none;
    }

    .contacts-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .contacts-row-actions {
        justify-content: flex-start;
    }

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



/* Contacts Phase 2L: use native sidebar section classes, no custom separator.
   The separator comes from .sidebar-section and its top offset from .calendar-list-section in app.css. */
#contextContacts > .sidebar-section.contacts-context-block {
    display: grid;
    gap: 10px;
}

#contextContacts > .sidebar-section.contacts-context-summary {
    margin-top: auto;
}

/* Keep cards compact inside the native sidebar-section wrapper. */
#contextContacts .contacts-section-card {
    min-height: 0;
}


/* Contacts Phase 2M: native option cards inside native sidebar section.
   Uses the same option classes as Disponibilidad:
   .sidebar-section.calendar-list-section + .settings-option.availability-open-card
   This only corrects card geometry/count pill; the separator remains native. */
#contextContacts > .sidebar-section.calendar-list-section.contacts-context-block {
    display: block !important;
}

#contextContacts > .sidebar-section.contacts-context-block {
    gap: 0 !important;
}

#contextContacts .contacts-section-card.settings-option.availability-open-card {
    width: 100% !important;
    min-height: 64px !important;
    height: auto !important;
    padding: 12px !important;
    margin: 0 0 8px !important;
    border-radius: 18px !important;
    display: grid !important;
    grid-template-columns: 38px minmax(0, 1fr) 28px !important;
    align-items: center !important;
    gap: 10px !important;
    text-align: left !important;
}

#contextContacts .contacts-section-card.settings-option.availability-open-card:last-child {
    margin-bottom: 0 !important;
}

#contextContacts .contacts-section-card .settings-option-icon.contacts-section-icon {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 14px !important;
    display: grid !important;
    place-items: center !important;
}

#contextContacts .contacts-section-card .settings-option-copy.contacts-section-copy {
    min-width: 0 !important;
    display: grid !important;
    gap: 3px !important;
}

#contextContacts .contacts-section-card .settings-option-copy.contacts-section-copy strong,
#contextContacts .contacts-section-card .settings-option-copy.contacts-section-copy small {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

#contextContacts .contacts-section-card .settings-option-arrow.contacts-section-count {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 999px !important;
    display: grid !important;
    place-items: center !important;
    border: 1px solid #eef2f7 !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
}

#contextContacts .contacts-section-card.is-active .settings-option-arrow.contacts-section-count,
#contextContacts .contacts-section-card.active .settings-option-arrow.contacts-section-count {
    border-color: rgba(249, 115, 22, .30) !important;
    background: #fff7ed !important;
    color: #c2410c !important;
}



/* Phase 7I: custom SVG icons for Contactos context sections. */
#contextContacts .contacts-section-svg {
    width: 22px;
    height: 22px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    overflow: visible;
}

#contextContacts .contacts-section-card.is-active .contacts-section-svg,
#contextContacts .contacts-section-card:hover .contacts-section-svg {
    color: var(--pc-orange-dark, #c2410c);
}

/* Phase 7I2 — iconos de subsecciones neutros cuando no están activos. */
#contextContacts .contacts-section-card:not(.is-active):not(.active) .contacts-section-svg,
#contextContacts .contacts-section-card:not(.is-active):not(.active):hover .contacts-section-svg {
    color: #111827;
}

#contextContacts .contacts-section-card.is-active .contacts-section-svg,
#contextContacts .contacts-section-card.active .contacts-section-svg {
    color: var(--pc-orange-dark, #c2410c);
}


/* Phase 7J — semantic colors for contacts icon actions. */
.contact-icon-action.contact-action-view {
    background: #eff6ff;
    color: #2563eb;
    border-color: #dbeafe;
}

.contact-icon-action.contact-action-edit {
    background: #f8fafc;
    color: #334155;
    border-color: #e2e8f0;
}

.contact-icon-action.contact-action-delete {
    background: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.contact-icon-action.contact-action-view:hover:not(:disabled) {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.contact-icon-action.contact-action-edit:hover:not(:disabled) {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

/* Phase 7K — títulos de módulo normalizados al tamaño de Disponibilidad. */
.contacts-toolbar h1 {
    font-size: 22px !important;
    line-height: 1.08;
    letter-spacing: -.04em;
}
