.fdc-contact-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fdc-contact-notice {
    display: none;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-sec);
    font-size: 12px;
}

.fdc-contact-notice.show {
    display: block;
}

.fdc-contact-notice.error {
    color: var(--danger);
}

.fdc-contact-notice.success {
    color: var(--success);
}

/* Keep active navigation understated in dark mode instead of switching to white. */
[data-theme="dark"] .nav-item.active {
    background-color: rgba(255, 255, 255, 0.085);
    color: #F5F5F5;
}

[data-theme="dark"] .nav-item.active:hover {
    background-color: rgba(255, 255, 255, 0.105);
    color: #FFFFFF;
}

[data-theme="dark"] .nav-item.active span,
[data-theme="dark"] .nav-item.active .icon-wrapper,
[data-theme="dark"] .nav-item.active .icon-wrapper i {
    color: #F5F5F5;
    stroke: #F5F5F5;
}

/* Department Contacts is a data-heavy admin surface: use the available workspace. */
.content-container:has(#contacts-page.active) {
    max-width: none;
}

#contacts-page {
    width: 100%;
}

#contacts-page .table-container {
    width: calc(100% - 48px);
    margin-inline: auto;
    max-height: calc(100vh - 196px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

#contacts-page table {
    width: 100%;
    min-width: 1280px;
    table-layout: auto;
}

#contacts-page thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: var(--bg-surface-2);
    box-shadow: 0 1px 0 var(--border-color);
}

#contacts-page th:nth-child(2),
#contacts-page td:nth-child(2) {
    width: 105px;
    min-width: 105px;
    white-space: nowrap;
}

#contacts-page th:nth-child(3),
#contacts-page td:nth-child(3) {
    min-width: 155px;
}

#contacts-page th:nth-child(7),
#contacts-page td:nth-child(7) {
    width: 92px;
    min-width: 92px;
    white-space: nowrap;
}

#contacts-page th:nth-child(8),
#contacts-page td:nth-child(8) {
    width: 78px;
    min-width: 78px;
    white-space: nowrap;
}

#contacts-page td.fdc-contact-area {
    min-width: 235px;
    white-space: normal;
    font-weight: 500;
}

#contacts-page td.fdc-contact-email {
    min-width: 195px;
}

#contacts-page .fdc-contact-email-link {
    color: var(--text-main);
    text-decoration: none;
}

#contacts-page .fdc-contact-email-link:hover {
    text-decoration: underline;
}

/* FDC contact editor: full-height right drawer using the existing Admin Center tokens. */
.fdc-contact-dialog {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(560px, 100vw);
    height: 100dvh;
    max-width: 100vw;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    background: var(--bg-main);
    color: var(--text-main);
    box-shadow: -24px 0 64px rgba(0, 0, 0, 0.28);
    opacity: 1;
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fdc-contact-dialog[open] {
    display: flex;
    flex-direction: column;
}

.fdc-contact-dialog.is-open {
    transform: translateX(0);
}

.fdc-contact-dialog.is-closing {
    transform: translateX(100%);
}

.fdc-contact-dialog::backdrop {
    background: rgba(0, 0, 0, 0.58);
    opacity: 0;
    transition: opacity 180ms ease;
    backdrop-filter: blur(1px);
}

.fdc-contact-dialog.is-open::backdrop {
    opacity: 1;
}

.fdc-contact-dialog-header {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-main);
}

.fdc-contact-dialog-heading {
    min-width: 0;
}

.fdc-contact-dialog-kicker {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.fdc-contact-dialog-title {
    margin: 0;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}

.fdc-contact-dialog-subtitle {
    margin: 4px 0 0;
    color: var(--text-sec);
    font-size: 12px;
    line-height: 1.5;
}

.fdc-contact-icon-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 1px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-sec);
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.fdc-contact-icon-button:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}

.fdc-contact-icon-button:focus-visible,
.fdc-contact-field input:focus-visible {
    outline: 2px solid var(--text-muted);
    outline-offset: 2px;
}

.fdc-contact-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.fdc-contact-form-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
    scrollbar-gutter: stable;
}

.fdc-contact-field-full {
    grid-column: 1 / -1;
}

.fdc-contact-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-sec);
    font-size: 12px;
    font-weight: 500;
}

.fdc-contact-field input {
    width: 100%;
    height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-main);
    font: inherit;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.fdc-contact-field input:hover {
    border-color: var(--text-muted);
}

.fdc-contact-field input::placeholder {
    color: var(--text-muted);
}

.fdc-contact-numeric {
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.fdc-contact-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 13px;
}

.fdc-contact-checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--success);
}

.fdc-contact-dialog-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: 64px;
    margin: 0;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
}

.fdc-contact-dialog-actions .btn {
    min-width: 104px;
}

.fdc-contact-dialog-actions .btn-primary {
    min-width: 136px;
}

@media (max-width: 768px) {
    .fdc-contact-toolbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    #contacts-page .table-container {
        width: 100%;
        max-height: calc(100vh - 220px);
    }

    .fdc-contact-dialog {
        width: 100vw;
        border-left: 0;
    }
}

@media (max-width: 560px) {
    .fdc-contact-form-grid {
        grid-template-columns: 1fr;
    }

    .fdc-contact-field-full {
        grid-column: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fdc-contact-dialog,
    .fdc-contact-dialog::backdrop {
        transition-duration: 1ms;
    }
}


/* Production alignment: controls and table share the same content edges. */
#contacts-page > .toolbar {
    width: calc(100% - 48px);
    margin-inline: auto;
}

#contacts-page > .toolbar .input-group {
    min-width: 0;
}

#contacts-page > .toolbar .input-control {
    max-width: 100%;
}

@media (max-width: 768px) {
    #contacts-page > .toolbar {
        width: 100%;
        flex-wrap: wrap;
    }
}
