:root {
    color-scheme: light;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #5f6b7a;
    --line: #d9e1ea;
    --primary: #1769aa;
    --primary-dark: #10517f;
    --success-bg: #e7f7ee;
    --success-text: #146c43;
    --error-bg: #fdeaea;
    --error-text: #a32020;
    --warning-bg: #fff6db;
    --warning-text: #7a5600;
}

/* Společné ovládání skutečně širokých tabulek. Aktivuje se pouze atributem
   data-wide-table-scroll na existujícím vodorovně posuvném obalu. */
.wide-table-top-scroll {
    width: 100%;
    max-width: 100%;
    height: 20px;
    margin: 0 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f4f7fa;
    scrollbar-gutter: stable;
    overscroll-behavior-inline: contain;
}

.wide-table-top-scroll[hidden] {
    display: none;
}

.wide-table-top-scroll:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .2);
    outline-offset: 2px;
}

.wide-table-top-scroll-inner {
    height: 1px;
    pointer-events: none;
}

[data-wide-table-scroll] .wide-table-sticky-cell {
    position: sticky;
    z-index: 3;
    background: #fff;
    background-clip: border-box;
    box-shadow: inset -1px 0 0 #000;
}

[data-wide-table-scroll] thead .wide-table-sticky-cell {
    z-index: 5;
    background: #eef4f9;
}

[data-wide-table-scroll] .wide-table-sticky-last {
    box-shadow: inset -1px 0 0 #000, 5px 0 7px -6px rgba(20, 48, 70, .75);
}

/* Řádkový přehled má černou mřížku. Sticky buňky proto musí samy překrýt
   posouvaný obsah včetně zlomkových hranic a vykreslit vlastní pravou příčku. */
.contacts-row-admin [data-wide-table-scroll] .wide-table-sticky-cell {
    z-index: 6;
    background-color: #fff;
    background-clip: border-box;
}

.contacts-row-admin [data-wide-table-scroll] thead .wide-table-sticky-cell {
    z-index: 8;
    background-color: #eef4f9;
}

.contacts-row-admin [data-wide-table-scroll] tbody tr.contacts-row-data-row.is-even .wide-table-sticky-cell {
    background-color: #f9fbfd;
}

.contacts-row-table-scroll[data-wide-table-scroll] tbody tr.contacts-row-data-row.is-even .wide-table-sticky-cell {
    background: #f9fbfd;
}

[data-wide-table-scroll] .state-reviewed .wide-table-sticky-cell {
    background: #e3f3e8;
}

[data-wide-table-scroll] .state-pending .wide-table-sticky-cell {
    background: #fff7d9;
}

[data-wide-table-scroll] .state-duplicate .wide-table-sticky-cell {
    background: #ffead3;
}

[data-wide-table-scroll] .state-skipped .wide-table-sticky-cell {
    background: #eceff2;
}

[data-wide-table-scroll] .state-error .wide-table-sticky-cell {
    background: #fde1e4;
}

[data-wide-table-scroll] .state-merged .wide-table-sticky-cell {
    background: #e4ebf4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

:focus-visible {
    outline: 3px solid rgba(23, 105, 170, 0.35);
    outline-offset: 3px;
}

.site-navigation {
    border-bottom: 1px solid #cbd8e5;
    background: #ffffff;
    box-shadow: 0 3px 14px rgba(31, 41, 51, 0.06);
}

.site-navigation-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
}

.site-brand {
    color: var(--text);
    font-size: 1.12rem;
    font-weight: 800;
    text-decoration: none;
}

.site-navigation-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-navigation-links a {
    padding: 18px 12px 15px;
    border-bottom: 3px solid transparent;
    color: #405264;
    font-weight: 700;
    text-decoration: none;
}

.site-navigation-links a:hover,
.site-navigation-links a.active {
    border-bottom-color: var(--primary);
    color: var(--primary-dark);
    background: #f3f8fc;
}

.site-navigation-links a:last-child {
    margin-left: 12px;
}

.active-database-bar {
    padding: 6px 16px;
    border-bottom: 1px solid #d8e4ee;
    background: #eef5fa;
    color: #405264;
    font-size: .86rem;
    text-align: center;
}

a {
    color: var(--primary);
}

.page {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.page.page-wide {
    width: min(1720px, calc(100% - 32px));
    max-width: none;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 16px 40px rgba(31, 41, 51, 0.08);
}

.panel-narrow {
    max-width: 480px;
    margin: 8vh auto 0;
}

h1,
h2 {
    margin: 0 0 16px;
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.35rem;
}

p {
    margin: 0 0 14px;
}

.form {
    display: grid;
    gap: 18px;
}

.grid-form {
    gap: 24px;
}

fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

legend {
    padding: 0 8px;
    font-weight: 700;
}

.form-wide {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #b8c4d2;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(23, 105, 170, 0.16);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.button.secondary {
    background: #fff;
    color: var(--primary);
}

.button.secondary:hover {
    background: #eef6fc;
    color: var(--primary-dark);
}

.button.danger {
    border-color: var(--error-text);
    background: #fff;
    color: var(--error-text);
}

.button.danger:hover {
    border-color: var(--error-text);
    background: var(--error-bg);
    color: var(--error-text);
}

.contact-card-copy {
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    min-height: 34px;
    padding: 6px;
}

.contact-card-copy svg {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.contact-card-copy:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .24);
    outline-offset: 2px;
}

.contact-card-copy.is-copied {
    border-color: var(--success-text);
    background: var(--success-bg);
    color: var(--success-text);
}

.contact-card-notice {
    position: fixed;
    z-index: 1000;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 11px 14px;
    border: 1px solid #8cc49c;
    border-radius: 7px;
    background: var(--success-bg);
    color: var(--success-text);
    box-shadow: 0 8px 24px rgba(22, 42, 58, .18);
    font-weight: 700;
}

.contact-card-notice.is-error {
    border-color: #d7a0a0;
    background: var(--error-bg);
    color: var(--error-text);
}

.contact-card-notice[hidden] {
    display: none;
}

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

.inline-form {
    display: inline;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.message {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 700;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #b8e3c9;
}

.message.error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #f2b8b8;
}

.message.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: #f3dc91;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar p {
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.dashboard {
    display: grid;
    gap: 20px;
}

.dashboard-intro {
    padding: 14px 2px 4px;
}

.dashboard-intro h1 {
    margin-bottom: 10px;
    font-size: clamp(2rem, 4vw, 3rem);
}

.dashboard-intro > p:last-child {
    max-width: 680px;
    color: var(--muted);
    font-size: 1.08rem;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.dashboard-stats a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(31, 41, 51, .05);
}

.dashboard-stats a:hover {
    border-color: #94b8d2;
}

.dashboard-stats span {
    color: var(--muted);
    font-weight: 700;
}

.dashboard-stats strong {
    color: var(--primary-dark);
    font-size: 1.65rem;
}

.section-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.section-card {
    --accent: var(--primary);
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 360px;
    flex-direction: column;
    padding: 26px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 9px 25px rgba(31, 41, 51, .07);
}

.section-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: var(--accent);
    content: "";
}

.section-card:hover {
    border-color: color-mix(in srgb, var(--accent) 55%, #ffffff);
    box-shadow: 0 14px 30px rgba(31, 41, 51, .1);
}

.section-card > img,
.section-card-heading img {
    display: block;
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
    flex: 0 0 auto;
    margin-bottom: 20px;
    object-fit: contain;
}

.section-card h2 {
    margin-bottom: 12px;
    font-size: 1.28rem;
}

.section-card > p {
    color: var(--muted);
}

.section-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.coming-soon {
    padding: 5px 9px;
    border-radius: 999px;
    background: #f2edff;
    color: #65429a;
    font-size: .76rem;
    font-weight: 800;
}

.section-card-actions {
    display: grid;
    gap: 13px;
    margin-top: auto;
    padding-top: 18px;
}

.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.quick-links a {
    font-size: .9rem;
    font-weight: 700;
}

.contacts-card-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.accent-import { --accent: #157aa3; }
.accent-contacts { --accent: #2e7d5b; }
.accent-export { --accent: #a56622; }
.accent-ai { --accent: #7652a5; }
.accent-help { --accent: #3b6fb6; }
.accent-settings { --accent: #5f6f7d; }

.dashboard-meta {
    color: var(--muted);
    font-size: .9rem;
    text-align: right;
}

.placeholder-page {
    max-width: 720px;
    margin: 8vh auto 0;
    padding: 42px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: center;
    box-shadow: 0 16px 40px rgba(31, 41, 51, .08);
}

.login-page {
    width: min(100% - 28px, 620px);
}

.login-shell {
    display: grid;
    gap: 20px;
    padding-top: clamp(18px, 5vh, 58px);
}

.login-heading {
    text-align: center;
}

.login-heading h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 5vw, 2.7rem);
}

.login-heading p:last-child {
    margin-bottom: 0;
    color: var(--muted);
}

.login-panel {
    padding: clamp(22px, 5vw, 34px);
}

.login-form {
    gap: 16px;
}

.login-database-choice {
    grid-template-columns: 1fr;
    margin-bottom: 4px;
    padding: 16px;
    background: #f7fafc;
}

.login-meta {
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}

.login-meta p {
    margin: 4px 0;
}

.placeholder-icon {
    display: grid;
    width: 112px;
    height: 112px;
    margin: 0 auto 22px;
    place-items: center;
    border-radius: 50%;
    background: #eef5fb;
}

.placeholder-icon img {
    display: block;
    width: 88px;
    height: 88px;
    max-width: 88px;
    max-height: 88px;
    object-fit: contain;
}

.placeholder-lead {
    color: var(--text);
    font-size: 1.14rem;
    font-weight: 700;
}

.placeholder-page > p:not(.placeholder-lead) {
    max-width: 580px;
    margin: 0 auto 26px;
    color: var(--muted);
}

.import-workspace,
.import-workspace > *,
.import-table-panel {
    min-width: 0;
    max-width: 100%;
}

.import-workspace .topbar > div:first-child { min-width: 0; }
.import-workspace .topbar p { overflow-wrap: anywhere; }

.import-admin .topbar {
    align-items: center;
}

.import-admin .topbar-actions {
    align-items: center;
}

.import-admin .topbar-actions .button {
    min-height: 44px;
}

.import-admin .panel {
    padding: 22px;
    min-width: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.stats div {
    min-height: 100px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfd;
}

.stats span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.stats strong {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
}

.import-form {
    width: min(100%, 780px);
    max-width: none;
}

.import-upload-panel > p {
    max-width: 900px;
}

.import-upload-panel .actions {
    justify-content: flex-start;
}

.import-preview {
    display: grid;
    gap: 18px;
}

.import-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.import-summary div,
.import-facts span {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f9fbfd;
}

.import-summary dt {
    margin: 0 0 4px;
    color: var(--muted);
    font-weight: 700;
}

.import-summary dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.import-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #eef4f9;
}

.data-table th.sortable-header,
.contacts-row-table th.sortable-header {
    padding: 0;
}

.sort-header-link,
.sort-header-link:visited {
    display: flex;
    width: 100%;
    min-height: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: .35rem;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    line-height: inherit;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.sort-header-link:hover {
    background: rgba(23, 105, 170, .08);
    color: var(--primary-dark);
    text-decoration: none;
}

.sort-header-link:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid rgba(23, 105, 170, .28);
    outline-offset: -3px;
}

.sortable-header.is-active {
    box-shadow: inset 0 -3px 0 var(--primary);
}

.sort-indicator {
    flex: 0 0 1em;
    color: var(--primary-dark);
    font-size: .78em;
    line-height: 1;
    text-align: center;
}

.sort-indicator.is-inactive {
    color: var(--muted);
    opacity: .7;
}

.data-table td {
    background: #fff;
    overflow-wrap: break-word;
}

.data-table .cell-filename {
    min-width: 260px;
    overflow-wrap: normal;
    word-break: normal;
}

.data-table .cell-type,
.data-table .cell-status,
.data-table .cell-number {
    width: 1%;
    white-space: nowrap;
}

.data-table .cell-date {
    min-width: 118px;
}

.data-table .cell-note {
    min-width: 220px;
    max-width: 380px;
}

.data-table .cell-actions {
    min-width: 190px;
    white-space: nowrap;
}

.import-history-table,
.import-files-table {
    min-width: 1120px;
    table-layout: fixed;
}

.import-files-table th:nth-child(1) { width: 35%; }
.import-files-table th:nth-child(2) { width: 7%; }
.import-files-table th:nth-child(3) { width: 9%; }
.import-files-table th:nth-child(4) { width: 13%; }
.import-files-table th:nth-child(5) { width: 36%; }

.import-history-table th:nth-child(1) { width: 10%; }
.import-history-table th:nth-child(2) { width: 20%; }
.import-history-table th:nth-child(3) { width: 6%; }
.import-history-table th:nth-child(4) { width: 9%; }
.import-history-table th:nth-child(5),
.import-history-table th:nth-child(6) { width: 5%; }
.import-history-table th:nth-child(7) { width: 20%; }
.import-history-table th:nth-child(8) { width: 25%; }

.import-history-table .cell-filename,
.import-files-table .cell-filename {
    min-width: 0;
    overflow-wrap: anywhere;
}

.contacts-table {
    min-width: 1250px;
}

.contacts-table .cell-name {
    min-width: 190px;
    font-weight: 700;
    overflow-wrap: normal;
    word-break: normal;
}

.contacts-table .cell-company {
    min-width: 160px;
}

.contacts-table .cell-lines {
    min-width: 170px;
    white-space: pre-line;
    overflow-wrap: break-word;
}

.import-files-table .cell-actions {
    min-width: 380px;
}

.import-action-info {
    display: grid;
    gap: 2px;
    max-width: 190px;
    margin-top: 8px;
    color: #3d5f78;
    line-height: 1.35;
    white-space: normal;
}

.import-file-actions,
.import-history-actions {
    align-items: flex-start;
}

.import-file-actions > .button,
.import-file-actions > .inline-form .button {
    min-width: 150px;
}

.linked-import-action {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.linked-import-action .import-action-info {
    flex: 1 1 210px;
    max-width: none;
    margin-top: 0;
}

.linked-import-action .button {
    flex: 0 0 150px;
}

.import-history-actions .import-action-info {
    flex: 1 1 100%;
    max-width: none;
    margin-top: 0;
}

.import-action-info strong {
    font-size: .9rem;
}

.import-action-info small {
    color: var(--muted);
    font-size: .8rem;
}

.contacts-table .cell-actions {
    min-width: 330px;
}

.contact-form {
    max-width: 900px;
}

.contact-edit-form {
    width: 100%;
    margin-inline: auto;
}

.contacts-full-controls {
    display: grid;
    gap: 18px;
}

.search-highlight {
    padding: 0 .08em;
    border-radius: 3px;
    background: #f7df91;
    color: inherit;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.groups-admin {
    display: grid;
    gap: 22px;
}

.groups-admin > .topbar {
    margin-bottom: 0;
}

.groups-search-form {
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr) minmax(150px, auto) auto auto;
    align-items: end;
    gap: 10px;
}

.groups-search-form > label {
    align-self: center;
}

.groups-form {
    max-width: 760px;
}

.groups-result-count {
    margin: 14px 0 0;
    color: var(--muted);
}

.groups-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 340px !important;
    white-space: normal !important;
}

.group-buttons-page .group-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.group-detail-admin .cell-actions .group-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    white-space: normal;
}

.groups-actions .button,
.group-contacts-table .button {
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    font-size: .88rem;
}

.groups-summary dl,
.groups-merge-summary dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.groups-summary dl div,
.groups-merge-summary dl div {
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f7fafc;
}

.groups-summary dt,
.groups-merge-summary dt {
    color: var(--muted);
    font-weight: 700;
}

.groups-summary dd,
.groups-merge-summary dd {
    margin: 5px 0 0;
    font-weight: 700;
}

.group-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.group-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 9px;
    border: 1px solid #b9d3e7;
    border-radius: 999px;
    background: #eef6fc;
    color: var(--primary-dark);
    font-size: .86rem;
    font-weight: 700;
    text-decoration: none;
}

.group-contacts-table {
    min-width: 1120px;
}

.group-contacts-table input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
    margin: 2px;
    padding: 0;
}

.groups-selection-actions,
.groups-bulk-form,
.contact-group-add-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-top: 14px;
}

.groups-selection-actions {
    margin-bottom: 12px;
}

.groups-selection-actions .button {
    width: auto;
}

.muted {
    color: var(--muted);
}

.contact-groups-panel {
    margin-top: 22px;
}

.contact-group-memberships {
    display: grid;
    gap: 10px;
}

.contact-group-memberships > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.contact-group-add-form label {
    min-width: min(360px, 100%);
}

.contacts-overview-actions {
    display: grid;
    gap: 8px;
}

.contacts-row-controls {
    display: grid;
    gap: 18px;
}

.contacts-row-controls .filter-tabs {
    margin-bottom: 0;
}

.contacts-row-search {
    display: grid;
    grid-template-columns: auto minmax(260px, 620px) auto auto;
    align-items: center;
    gap: 10px;
}

.contacts-row-search label {
    font-weight: 700;
}

.contacts-row-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.contacts-row-summary div {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfd;
}

.contacts-row-summary dt {
    color: var(--muted);
    font-size: .88rem;
    font-weight: 700;
}

.contacts-row-summary dd {
    margin: 5px 0 0;
    color: var(--primary-dark);
    font-size: 1.45rem;
    font-weight: 700;
}

.contacts-row-panel {
    min-width: 0;
    padding: 18px;
}

.contacts-row-table-scroll-frame {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
    background: #f4f7fa;
}

.contacts-row-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 0;
    border-radius: 0;
    background: #f4f7fa;
    scrollbar-gutter: stable;
    overscroll-behavior-inline: contain;
}

.contacts-row-table-scroll-content {
    display: inline-block;
    width: max-content;
    min-width: 100%;
    vertical-align: top;
}

.contacts-row-scroll-jump {
    position: fixed;
    z-index: 30;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid #263746;
    border-radius: 7px;
    background: #fff;
    color: #172431;
    box-shadow: 0 8px 24px rgba(22, 42, 58, .2);
    font-size: .82rem;
    font-weight: 700;
}

.contacts-row-scroll-jump:hover {
    border-color: #000;
    background: #eef3f7;
    color: #000;
}

.contacts-row-scroll-jump:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.contacts-row-scroll-jump:disabled:hover {
    border-color: #172431;
    background: #fff;
    color: #172431;
}

.contacts-row-scroll-jump:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .24);
    outline-offset: 2px;
}

.contacts-row-scroll-jump[hidden] {
    display: none;
}

.contacts-row-scroll-jump-icon {
    color: #000;
    font-size: 1.2rem;
    line-height: 1;
}

.contacts-row-scrollbar-band-row > td {
    padding: 0 !important;
    border: 0 !important;
    background: #f4f7fa !important;
    line-height: 0;
}

.contacts-row-scrollbar-band {
    display: block;
    box-sizing: border-box;
    height: 38px;
    padding: 7px 0 8px;
    border-top: 1px solid #d7e0e8;
    border-bottom: 1px solid #d7e0e8;
    background: #f4f7fa;
}

.wide-table-intermediate-scroll {
    position: sticky;
    left: 0;
    height: 21px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 0;
    background: #f4f7fa;
    scrollbar-gutter: stable;
    overscroll-behavior-inline: contain;
}

.wide-table-intermediate-scroll:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .2);
    outline-offset: -3px;
}

.wide-table-intermediate-scroll-inner {
    height: 1px;
    pointer-events: none;
}

.contacts-row-table-bottom-band {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 15px;
    border-top: 1px solid #d7e0e8;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    background: #f4f7fa;
}

.contacts-row-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    line-height: 1.35;
}

.contacts-row-table th,
.contacts-row-table td {
    min-width: 105px;
    max-width: 280px;
    padding: 8px 9px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

.contacts-row-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef3f7;
    color: #31465a;
    white-space: nowrap;
}

.contacts-row-table th.sortable-header .sort-header-link {
    padding: 8px 9px;
}

.contacts-row-table th:last-child,
.contacts-row-table td:last-child {
    border-right: 0;
}

.contacts-row-table tbody tr.contacts-row-data-row:last-child td {
    border-bottom: 1px solid #000;
}

.contacts-row-table tbody tr.contacts-row-scrollbar-band-row + tr.contacts-row-data-row > td {
    border-top: 1px solid #000;
}

.contacts-row-table tbody tr.contacts-row-data-row.is-even td {
    background: #f9fbfd;
}

.contacts-row-admin .contacts-row-table-scroll-frame {
    border-color: #000;
}

.contacts-row-admin .contacts-row-table th,
.contacts-row-admin .contacts-row-table td {
    border-color: #000;
}

.contacts-row-cell-id,
.contacts-row-cell-is-active,
.contacts-row-cell-actions {
    min-width: 82px !important;
    max-width: 115px !important;
    white-space: nowrap !important;
}

.contacts-row-cell-display-name,
.contacts-row-cell-first-name,
.contacts-row-cell-last-name,
.contacts-row-cell-company {
    min-width: 145px !important;
}

.contacts-row-cell-note {
    min-width: 240px !important;
    max-width: 360px !important;
}

.contacts-row-cell-values {
    min-width: 220px !important;
    max-width: 360px !important;
}

.contacts-row-cell-addresses,
.contacts-row-cell-websites {
    min-width: 280px !important;
    max-width: 420px !important;
}

.contacts-row-value {
    display: inline;
}

.contacts-row-value:not(:last-child)::after {
    content: " | ";
    color: #8a99a8;
    font-weight: 700;
}

.contacts-row-empty {
    color: var(--muted);
}

.contacts-row-cell-actions .button {
    width: auto;
    min-height: 34px;
    padding: 6px 10px;
    font-size: .8rem;
}

.contacts-full-controls .filter-tabs {
    margin-bottom: 0;
}

.contacts-full-search {
    display: grid;
    grid-template-columns: auto minmax(260px, 620px) auto auto;
    align-items: center;
    gap: 10px;
}

.contacts-full-search label {
    font-weight: 700;
}

.contacts-full-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.contacts-full-summary div {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfd;
}

.contacts-full-summary dt {
    color: var(--muted);
    font-weight: 700;
}

.contacts-full-summary dd {
    margin: 6px 0 0;
    color: var(--primary-dark);
    font-size: 1.6rem;
    font-weight: 700;
}

.contacts-full-list {
    display: grid;
    gap: 22px;
}

.contacts-full-admin .contacts-full-list > .contacts-full-card {
    min-width: 0;
    overflow: hidden;
    border: 2px solid #222;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(31, 41, 51, 0.07);
}

.contacts-full-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid #bfd2e2;
    background: #eef6fc;
}

.contacts-full-card-header p,
.contacts-full-card-header h2 {
    margin: 0;
}

.contacts-full-card-header p {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 700;
}

.contacts-full-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.contacts-full-status,
.contacts-full-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 700;
}

.contacts-full-status.is-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.contacts-full-status.is-archived {
    background: #e9edf1;
    color: #4f5b66;
}

.contacts-full-main,
.contacts-full-related {
    padding: 20px 22px;
}

.contacts-full-related {
    border-top: 1px solid var(--line);
}

.contacts-full-main h3,
.contacts-full-related h3 {
    margin: 0 0 14px;
}

.contacts-full-section-count {
    min-width: 30px;
    min-height: 26px;
    margin-left: 5px;
    padding: 2px 8px;
    background: #e7eef6;
    color: #38536a;
    vertical-align: middle;
}

.contacts-full-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.contacts-full-fields div {
    display: grid;
    grid-template-columns: minmax(140px, 36%) minmax(0, 1fr);
    min-width: 0;
    border-bottom: 1px solid var(--line);
}

.contacts-full-fields div:nth-child(odd) {
    border-right: 1px solid var(--line);
}

.contacts-full-fields div.is-wide {
    grid-column: 1 / -1;
    border-right: 0;
}

.contacts-full-fields dt,
.contacts-full-fields dd {
    min-width: 0;
    margin: 0;
    padding: 10px 12px;
    overflow-wrap: anywhere;
}

.contacts-full-fields dt {
    background: #f4f7fa;
    font-weight: 700;
}

.contacts-full-fields dd {
    white-space: normal;
}

.contacts-full-empty {
    margin: 0;
    color: var(--muted);
}

.contacts-full-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 7px;
    scrollbar-gutter: stable;
}

.contacts-full-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: .92rem;
}

.contacts-full-table th,
.contacts-full-table td {
    padding: 9px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

.contacts-full-table th {
    background: #f4f7fa;
    white-space: nowrap;
}

.contacts-full-table th:last-child,
.contacts-full-table td:last-child {
    border-right: 0;
}

.contacts-full-table tbody tr:last-child td {
    border-bottom: 0;
}

.contacts-bulk-admin .contacts-bulk-controls {
    display: grid;
    gap: 18px;
}

.contacts-bulk-admin .contacts-bulk-controls .filter-tabs {
    margin-bottom: 0;
}

.contacts-bulk-admin .contacts-bulk-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.contacts-bulk-admin .contacts-bulk-form {
    display: grid;
    gap: 18px;
}

.contacts-bulk-admin .contacts-bulk-selection-panel,
.contacts-bulk-admin .contacts-bulk-operations-panel,
.contacts-bulk-admin .contacts-bulk-table-panel {
    margin: 0;
}

.contacts-bulk-admin .contacts-bulk-selection-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.contacts-bulk-admin .contacts-bulk-selection-panel p {
    margin: 0;
    color: var(--muted);
}

.contacts-bulk-admin .contacts-bulk-selection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.contacts-bulk-admin .contacts-bulk-operation-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.contacts-bulk-admin .contacts-bulk-operation-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    max-width: 100%;
    border: 1px solid #9fb1c2;
    border-radius: 8px;
    background: #f9fbfd;
    box-shadow: 0 1px 3px rgba(31, 57, 78, .12);
    overflow: hidden;
}

.contacts-bulk-admin .contacts-bulk-operation {
    display: grid;
    align-content: start;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
    padding: 16px;
    background: transparent;
}

.contacts-bulk-admin .contacts-bulk-operation + .contacts-bulk-operation {
    border-left: 1px solid var(--line);
}

.contacts-bulk-admin .contacts-bulk-operation > * {
    min-width: 0;
    max-width: 100%;
}

.contacts-bulk-admin .contacts-bulk-operation h3,
.contacts-bulk-admin .contacts-bulk-operation p {
    margin: 0;
}

.contacts-bulk-admin .contacts-bulk-operation p {
    color: var(--muted);
}

.contacts-bulk-admin .contacts-bulk-operation .button,
.contacts-bulk-admin .contacts-bulk-operation button {
    width: fit-content;
}

.contacts-bulk-admin .contacts-bulk-table-panel {
    min-width: 0;
    padding: 18px;
}

.contacts-bulk-admin .contacts-bulk-cell-select {
    min-width: 82px;
    text-align: center;
}

.contacts-bulk-admin .contacts-bulk-cell-select input {
    width: 20px;
    height: 20px;
}

.contacts-bulk-admin .contacts-bulk-cell-groups {
    min-width: 220px;
    max-width: 360px;
}

.contacts-bulk-admin [data-wide-table-scroll] .wide-table-sticky-cell {
    box-shadow: inset -1px 0 0 var(--line);
}

.contacts-bulk-admin [data-wide-table-scroll] .wide-table-sticky-last {
    box-shadow: inset -1px 0 0 var(--line), 5px 0 7px -6px rgba(20, 48, 70, .28);
}

.contact-form fieldset {
    align-items: start;
}

.contact-detail-row {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfd;
}

.contact-detail-row h3 {
    margin: 0 0 14px;
}

.contact-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.contact-detail-grid .detail-field-wide {
    grid-column: span 2;
}

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

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

.table-actions .button,
.cell-actions .button {
    width: auto;
    min-height: 38px;
    padding: 8px 12px;
    white-space: nowrap;
}

.preview-table {
    font-size: 0.94rem;
}

.csv-preview-page .csv-file-preview {
    width: 100%;
    min-width: 0;
}

.csv-preview-page .csv-file-preview-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
}

.csv-preview-page .csv-file-preview-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.csv-preview-page .csv-file-preview-table th,
.csv-preview-page .csv-file-preview-table td {
    min-width: 150px;
    max-width: 280px;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.import-workspace .import-summary { grid-template-columns: repeat(4,minmax(0,1fr)); }
.import-workspace .import-summary > div:last-child { grid-column: span 2; }
.import-workspace .panel-actions { align-items: center; gap: 12px; }
.import-workspace .panel-actions > .button,
.import-workspace .panel-actions .control-with-help > .button,
.import-workspace .panel-actions .control-with-help > button { min-height: 44px; }
.import-workspace .inline-action-form { min-height: 44px; }
.import-table-scroll {
    position: relative;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.import-table-scroll:focus-visible { outline: 3px solid rgba(23,105,170,.2); outline-offset: 2px; }
.import-items-table { min-width: 1800px; table-layout: fixed; }
.import-items-table th,
.import-items-table td { padding: 9px 10px; font-size: .92rem; overflow-wrap: anywhere; }
.import-items-table th { position: sticky; top: 0; z-index: 2; }
.import-items-table .col-order { width: 66px; }
.import-items-table .col-name { width: 165px; }
.import-items-table .col-organization { width: 130px; }
.import-items-table .col-phones { width: 140px; }
.import-items-table .col-emails { width: 180px; }
.import-items-table .col-suggestion { width: 230px; }
.import-items-table .col-match { width: 150px; }
.import-items-table .col-reason { width: 210px; }
.import-items-table .col-unsupported { width: 160px; }
.import-items-table .col-review { width: 125px; }
.import-items-table .col-action { width: 220px; }
.import-items-table .cell-name { font-weight: 700; }
.import-items-table .cell-order,
.import-items-table .cell-action { white-space: nowrap; }
.import-items-table .cell-lines { white-space: pre-line; overflow-wrap: anywhere; }
.import-items-table .cell-action .button { width: auto; min-width: max-content; min-height: 36px; padding: 7px 10px; white-space: nowrap; }
.import-state-legend { display: grid; grid-template-columns: repeat(6,minmax(135px,1fr)); gap: 10px 14px; margin: 0 0 14px; }
.import-state-legend span { display: inline-flex; align-items: center; gap: 8px; min-height: 28px; font-size: .88rem; font-weight: 700; }
.import-state-legend span::before { content: ""; flex: 0 0 18px; width: 18px; height: 18px; border: 1px solid rgba(31,41,51,.22); border-radius: 4px; background: var(--state-color); }
.data-table tr.state-reviewed td { background: #e3f3e8; }
.data-table tr.state-pending td { background: #fff7d9; }
.data-table tr.state-duplicate td { background: #ffead3; }
.data-table tr.state-skipped td { background: #eceff2; color: #4f5b66; }
.data-table tr.state-error td { background: #fde1e4; }
.data-table tr.state-merged td { background: #e4ebf4; color: #46586a; }
.state-reviewed { --state-color: #e3f3e8; }
.state-pending { --state-color: #fff7d9; }
.state-duplicate { --state-color: #ffead3; }
.state-skipped { --state-color: #eceff2; }
.state-error { --state-color: #fde1e4; }
.state-merged { --state-color: #e4ebf4; }
.import-state-legend + .import-table-scroll { width: 100%; }
.internal-match-note,
.internal-merged-note { display: block; margin-top: 6px; padding: 5px 7px; border-radius: 5px; background: #fff0d6; color: #754500; font-size: .78rem; font-weight: 700; line-height: 1.35; }
.internal-merged-note { background: #e6f3ec; color: #225b3a; }
.duplicate-badge { display: flex; align-items: center; width: 100%; margin-top: 6px; padding: 5px 8px; border: 1px solid transparent; border-radius: 5px; font-size: .78rem; font-weight: 700; line-height: 1.35; overflow-wrap: normal; word-break: normal; hyphens: none; }
.duplicate-badge-database { border-color: #e7bd79; background: #fff3df; color: #754500; }
.duplicate-badge-internal { border-color: #d6a366; background: #ffead3; color: #6b3d00; }
.duplicate-badge-both { border-color: #c7813b; background: #ffe1bd; color: #623500; }
.duplicate-group-badge { display: block; width: max-content; max-width: 100%; margin-top: 5px; padding: 3px 8px; border: 1px solid #d6a366; border-radius: 999px; background: rgba(255,255,255,.72); color: #6b3d00; font-size: .74rem; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
.import-items-table .cell-suggestion,
.import-items-table .cell-duplicates,
.import-items-table .duplicate-badge,
.import-items-table .duplicate-group-badge { overflow-wrap: normal; word-break: normal; }
.duplicate-reason { display: block; margin-top: 5px; line-height: 1.35; }
.duplicate-reason + .duplicate-reason { padding-top: 5px; border-top: 1px solid rgba(117,69,0,.2); }
.internal-reason { color: #754500; }
.import-items-table .cell-reason .duplicate-reason { overflow-wrap: normal; word-break: normal; }
.internal-matches-table { min-width: 1120px; }
.internal-matches-table th:last-child { width: 260px; }
.internal-match-actions { display: grid; gap: 7px; }
.internal-match-actions form { margin: 0; }
.internal-match-actions .button,
.internal-match-actions button { width: 100%; min-height: 36px; padding: 7px 10px; }
.internal-merged-list { display: grid; gap: 10px; }
.internal-match-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.internal-match-card h3,
.internal-match-card p { margin: 0; }
.internal-match-card p { margin-top: 5px; }
.result-items-table { min-width: 1980px; }
.result-items-table .result-col-order { width: 70px; }
.result-items-table .result-col-name { width: 190px; }
.result-items-table .result-col-organization { width: 150px; }
.result-items-table .result-col-phones { width: 160px; }
.result-items-table .result-col-emails { width: 190px; }
.result-items-table .result-col-note { width: 220px; }
.result-items-table .result-col-decision { width: 150px; }
.result-items-table .result-col-duplicates { width: 280px; }
.result-items-table .result-col-target { width: 170px; }
.result-items-table .result-col-warning { width: 170px; }
.result-items-table .result-col-review { width: 140px; }
.result-items-table .result-col-action { width: 90px; }
.result-preview-workspace .result-preview-scroll-jump {
    position: fixed;
    z-index: 30;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 38px;
    min-width: 36px;
    min-height: 38px;
    padding: 0;
    border: 1px solid #263746;
    border-radius: 7px;
    background: #fff;
    color: #172431;
    box-shadow: 0 8px 24px rgba(22, 42, 58, .2);
    font-size: .82rem;
    font-weight: 700;
}
.result-preview-workspace .result-preview-scroll-jump:hover { border-color: #000; background: #eef3f7; color: #000; }
.result-preview-workspace .result-preview-scroll-jump:disabled { opacity: .42; cursor: not-allowed; }
.result-preview-workspace .result-preview-scroll-jump:disabled:hover { border-color: #172431; background: #fff; color: #172431; }
.result-preview-workspace .result-preview-scroll-jump:focus-visible { outline: 3px solid rgba(23, 105, 170, .24); outline-offset: 2px; }
.result-preview-workspace .result-preview-scroll-jump[hidden] { display: none; }
.result-preview-workspace .result-preview-scroll-jump-icon { color: #000; font-size: 1.2rem; line-height: 1; }
.result-preview-workspace .result-preview-scrollbar-row > td {
    padding: 0 !important;
    border: 0 !important;
    background: #f4f7fa !important;
    line-height: 0;
}
.result-preview-workspace .result-preview-scrollbar-band {
    display: block;
    position: sticky;
    left: 0;
    box-sizing: border-box;
    height: 38px;
    padding: 7px 0 8px;
    border-top: 1px solid #d7e0e8;
    border-bottom: 1px solid #d7e0e8;
    background: #f4f7fa;
}
.result-preview-workspace .result-preview-scrollbar-band .wide-table-intermediate-scroll {
    height: 21px;
    border: 0;
}
.result-preview-workspace [data-result-preview-table-scroll] .wide-table-sticky-cell {
    box-shadow: inset -1px 0 0 var(--line);
}
.result-preview-workspace [data-result-preview-table-scroll] .wide-table-sticky-last {
    box-shadow: inset -1px 0 0 var(--line), 4px 0 7px -7px rgba(31, 41, 51, .28);
}
@media (max-width: 700px) {
    .result-preview-workspace .result-items-table .result-col-order { width: 56px; }
    .result-preview-workspace .result-items-table .result-col-name { width: 135px; }
    .result-preview-workspace .result-items-table .result-col-organization { width: 110px; }
    .result-preview-workspace .result-preview-scroll-jump { width: 28px; height: 34px; min-width: 28px; min-height: 34px; }
}
.edited-badge { display: inline-flex; margin: 4px 0 0 6px; padding: 2px 6px; border-radius: 999px; background: #e8f1fb; color: #245b86; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.status-skipped { background: #e5e8eb; color: #4f5963; }
.inline-action-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.check-label { display: flex; grid: none; flex-wrap: wrap; align-items: center; gap: 7px; font-weight: 400; }
.check-label input { width: auto; min-height: 0; }
.control-with-help,
.filter-control,
.heading-with-help,
.label-with-help { display: inline-flex; align-items: center; gap: 6px; }
.filter-control { min-width: 0; }
.filter-control .button { white-space: nowrap; }
.heading-with-help { align-items: flex-start; }
.label-with-help { justify-content: flex-start; }
.help-overview {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}
.help-overview summary { width: fit-content; color: var(--primary); font-weight: 700; cursor: pointer; }
.help-overview p { max-width: 900px; margin: 12px 0 0; color: var(--muted); }
.help-tip {
    flex: 0 0 auto;
    width: 1.35rem;
    min-width: 1.35rem;
    height: 1.35rem;
    min-height: 1.35rem;
    padding: 0;
    border: 1px solid #8fa2b5;
    border-radius: 50%;
    background: #fff;
    color: #42566a;
    font-size: .78rem;
    line-height: 1;
    font-weight: 700;
    vertical-align: middle;
}
.help-tip:hover,
.help-tip:focus-visible,
.help-tip[aria-expanded="true"] { border-color: var(--primary); background: #eef6fc; color: var(--primary-dark); outline: none; }
.help-tip:focus-visible { box-shadow: 0 0 0 3px rgba(23,105,170,.18); }
.help-tooltip {
    position: fixed;
    z-index: 10000;
    width: max-content;
    max-width: min(320px, calc(100vw - 24px));
    padding: 9px 11px;
    border: 1px solid #31465a;
    border-radius: 6px;
    background: #182736;
    color: #fff;
    box-shadow: 0 8px 24px rgba(15,30,45,.24);
    font-size: .86rem;
    line-height: 1.4;
    font-weight: 400;
    pointer-events: none;
}
.help-tooltip[hidden] { display: none; }
.help-tooltip.is-left::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #182736;
}
.help-tooltip.is-right::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #182736;
}
.detail-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin-top: 20px; }
.raw-fields { display: grid; gap: 10px; margin: 0; }
.raw-fields div { padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.raw-fields dt { font-weight: 700; }
.raw-fields dd { margin: 4px 0 0; }
.raw-fields small { display: block; color: var(--muted); }
.raw-record { max-height: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
.text-error { color: var(--error-text); }

.diagnostic-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}

.diagnostic-summary div {
    min-height: 108px;
    padding: 15px;
    border: 1px solid #cbd8e6;
    border-radius: 8px;
    background: #f7fafc;
}

.diagnostic-summary dt { color: #52657a; font-size: .9rem; }
.diagnostic-summary dd { margin: 7px 0 0; font-size: 1.55rem; font-weight: 700; }
.diagnostic-badge { display: inline-block; max-width: 100%; margin: 2px 4px 2px 0; padding: 3px 7px; border-radius: 999px; background: #e7eef6; font-size: .82rem; font-weight: 700; line-height: 1.3; white-space: normal; }
.diagnostic-badge.ok { background: #dff3e6; color: #176337; }
.diagnostic-badge.warn { background: #fff0c9; color: #795400; }
.diagnostic-badge.bad { background: #fde3e3; color: #8d1c1c; }
.diagnostic-value { overflow-wrap: anywhere; word-break: break-word; }
.diagnostic-list { margin: 0; padding-left: 18px; }
.diagnostic-note { color: #52657a; font-size: .88rem; }
.diagnostic-files-table { min-width: 1240px; table-layout: fixed; }
.diagnostic-files-table th:nth-child(1) { width: 28%; }
.diagnostic-files-table th:nth-child(2) { width: 13%; }
.diagnostic-files-table th:nth-child(3) { width: 15%; }
.diagnostic-files-table th:nth-child(4),
.diagnostic-files-table th:nth-child(5) { width: 22%; }
.diagnostic-imports-table { min-width: 1380px; table-layout: fixed; }
.diagnostic-imports-table th:nth-child(1) { width: 12%; }
.diagnostic-imports-table th:nth-child(2) { width: 18%; }
.diagnostic-imports-table th:nth-child(3) { width: 12%; }
.diagnostic-imports-table th:nth-child(4) { width: 22%; }
.diagnostic-imports-table th:nth-child(5) { width: 15%; }
.diagnostic-imports-table th:nth-child(6) { width: 21%; }
.diagnostic-files-table .cell-filename,
.diagnostic-imports-table .cell-filename { min-width: 0; overflow-wrap: anywhere; }

.settings-admin .settings-tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.settings-admin .settings-tool-card {
    display: flex;
    min-width: 0;
    margin: 0;
    flex-direction: column;
    align-items: flex-start;
}

.settings-admin .settings-tool-card h2 { margin-top: 0; }
.settings-admin .settings-tool-card p { margin-bottom: 20px; }
.settings-admin .settings-tool-card .button { margin-top: auto; }

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

.contact-diagnostics-admin .contact-diagnostics-unavailable {
    display: block;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.35;
}

.contact-diagnostics-admin .contact-diagnostics-id-form {
    display: grid;
    grid-template-columns: auto minmax(180px, 320px) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.contact-diagnostics-admin .contact-diagnostics-id-form label { font-weight: 700; }

.contact-diagnostics-admin .contact-diagnostics-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.contact-diagnostics-admin .contact-diagnostics-detail-grid div {
    min-width: 0;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.contact-diagnostics-admin .contact-diagnostics-detail-grid dt {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.contact-diagnostics-admin .contact-diagnostics-detail-grid dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.contact-diagnostics-admin .contact-diagnostics-orphan-table { min-width: 820px; }
.contact-diagnostics-admin .contact-diagnostics-quality-grid,
.contact-diagnostics-admin .contact-diagnostics-duplicate-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.contact-diagnostics-admin .contact-diagnostics-quality-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
}

.contact-diagnostics-admin .contact-diagnostics-quality-card h3,
.contact-diagnostics-admin .contact-diagnostics-duplicate-grid h3 { margin-top: 0; }
.contact-diagnostics-admin .contact-diagnostics-duplicate-grid section { min-width: 0; }

.comparison-table { min-width: 900px; table-layout: fixed; }
.comparison-table th:first-child { width: 160px; }
.comparison-table th:nth-child(2),
.comparison-table th:nth-child(3) { width: 24%; }
.comparison-table td { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; }
.comparison-table select { min-width: 220px; }
.import-item-workspace,
.import-item-workspace > *,
.import-item-workspace .import-form,
.import-item-workspace .panel { min-width: 0; max-width: 100%; }
.import-item-workspace .import-form { width: 100%; }
.import-item-workspace .table-scroll {
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}
.import-item-workspace .comparison-table { min-width: 1120px; }
.import-item-workspace .comparison-table th:first-child { width: 150px; }
.import-item-workspace .comparison-table th:nth-child(2),
.import-item-workspace .comparison-table th:nth-child(3) { width: 22%; }
.import-item-workspace .comparison-table th:last-child { width: 38%; }
.import-item-workspace .comparison-table select,
.import-item-workspace .edited-value-field textarea { max-width: 100%; }
.import-item-workspace .form-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.decision-state { display: block; margin-bottom: 5px; color: var(--muted); font-size: .84rem; }
.edited-value-field { display: grid; gap: 6px; margin-top: 10px; }
.edited-value-field[hidden] { display: none; }
.edited-value-field > span { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 700; }
.edited-value-field textarea { min-width: 220px; resize: vertical; }
.empty-value { color: var(--muted); font-style: italic; }
.form-help { color: var(--muted); font-size: .92rem; }
.extra-field-list { display: grid; gap: 14px; }
.extra-field-card { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.extra-field-card > header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.extra-field-card h3 { margin: 0; }
.extra-field-card .source-value { margin-bottom: 6px; overflow-wrap: anywhere; }
.extra-field-controls { display: grid; grid-template-columns: minmax(260px,1fr) minmax(240px,1fr); gap: 14px; margin-top: 12px; }
.status-badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.status-ready { background: #e7f5ec; color: #23613a; }
.status-blocking { background: #fff0e0; color: #8a4700; }
.status-warning { background: #fff8d8; color: #735c00; }

.code-block {
    overflow-x: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #101820;
    color: #f5f7fa;
    font-size: 0.9rem;
}

@media (max-width: 760px) {
    .contacts-card-links {
        grid-template-columns: 1fr;
    }

    .groups-search-form,
    .groups-summary dl,
    .groups-merge-summary dl {
        grid-template-columns: 1fr;
    }

    .groups-search-form .button,
    .groups-search-form button,
    .groups-bulk-form button,
    .contact-group-add-form button {
        width: 100%;
    }

    .groups-actions {
        min-width: 260px !important;
    }

    .site-navigation-inner {
        align-items: stretch;
        width: calc(100% - 20px);
        flex-direction: column;
        gap: 0;
    }

    .site-brand {
        padding-top: 14px;
    }

    .site-navigation-links {
        justify-content: flex-start;
    }

    .site-navigation-links a {
        padding: 10px 9px 8px;
    }

    .site-navigation-links a:last-child {
        margin-left: 0;
    }

    .page {
        width: min(100% - 20px, 1100px);
        padding: 18px 0;
    }

    .page.page-wide { width: calc(100% - 20px); }

    .panel {
        padding: 20px;
    }

    h1 {
        font-size: 1.6rem;
    }

    fieldset,
    .detail-columns,
    .stats,
    .dashboard-stats,
    .section-cards {
        grid-template-columns: 1fr;
    }

    .section-card {
        min-height: 0;
        padding: 22px;
    }

    .placeholder-page {
        margin-top: 2vh;
        padding: 28px 20px;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .import-admin .topbar {
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: stretch;
    }

    .actions,
    .panel-actions,
    .filter-tabs {
        justify-content: stretch;
    }

    button,
    .button,
    .topbar-actions .button {
        width: 100%;
    }

    .help-tip { width: 1.35rem; min-width: 1.35rem; }
    .control-with-help,
    .filter-control { width: 100%; }
    .control-with-help > .button,
    .control-with-help > button,
    .filter-control > .button { flex: 1 1 auto; width: auto; }
    .inline-action-form { width: 100%; align-items: stretch; }
    .inline-action-form .check-label { width: 100%; }

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

    .table-actions .button,
    .cell-actions .button {
        width: auto;
    }

    .import-summary,
    .import-facts {
        grid-template-columns: 1fr;
    }

    .import-workspace .import-summary > div:last-child { grid-column: auto; }
    .import-state-legend { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .diagnostic-summary { grid-template-columns: 1fr; }
    .settings-admin .settings-tool-grid,
    .contact-diagnostics-admin .contact-diagnostics-summary,
    .contact-diagnostics-admin .contact-diagnostics-detail-grid,
    .contact-diagnostics-admin .contact-diagnostics-quality-grid,
    .contact-diagnostics-admin .contact-diagnostics-duplicate-grid {
        grid-template-columns: 1fr;
    }

    .contact-diagnostics-admin .contact-diagnostics-id-form { grid-template-columns: 1fr; }
    .contact-diagnostics-admin .contact-diagnostics-id-form button { width: 100%; }

    .extra-field-controls { grid-template-columns: 1fr; }
    .contact-detail-grid { grid-template-columns: 1fr; }
    .contact-detail-grid .detail-field-wide,
    .contact-detail-grid .detail-field-full { grid-column: auto; }

    .contacts-full-search,
    .contacts-full-summary,
    .contacts-full-fields {
        grid-template-columns: 1fr;
    }

    .contacts-row-search,
    .contacts-row-summary {
        grid-template-columns: 1fr;
    }

    .contacts-bulk-admin .contacts-bulk-operation-group {
        grid-template-columns: 1fr;
    }

    .contacts-bulk-admin .contacts-bulk-operation + .contacts-bulk-operation {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .contacts-bulk-admin .contacts-bulk-selection-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .contacts-bulk-admin .contacts-bulk-selection-actions,
    .contacts-bulk-admin .contacts-bulk-operation .button,
    .contacts-bulk-admin .contacts-bulk-operation button {
        width: 100%;
    }

    .contacts-row-search .button,
    .contacts-overview-actions .button {
        width: 100%;
    }

    .contacts-full-search .button {
        width: 100%;
    }

    .contacts-full-card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .contacts-full-card-actions {
        align-items: stretch;
        justify-content: flex-start;
        flex-direction: column;
    }

    .contacts-full-card-actions .button {
        width: 100%;
    }

    .contacts-full-card-actions .contact-card-copy {
        align-self: flex-start;
        width: 36px;
    }

    .contacts-full-fields div,
    .contacts-full-fields div:nth-child(odd),
    .contacts-full-fields div.is-wide {
        grid-column: auto;
        grid-template-columns: 1fr;
        border-right: 0;
    }

    .contacts-full-main,
    .contacts-full-related,
    .contacts-full-card-header {
        padding-right: 16px;
        padding-left: 16px;
    }
}

@media (min-width: 761px) and (max-width: 1280px) {
    .import-workspace .import-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .diagnostic-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .import-state-legend { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .settings-admin .settings-tool-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (min-width: 761px) and (max-width: 1050px) {
    .section-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (min-width: 1051px) and (min-height: 780px) {
    .page {
        padding: 6px 0 2px;
    }

    .dashboard {
        gap: 10px;
    }

    .dashboard-intro {
        padding: 2px 2px 0;
    }

    .dashboard-intro h1 {
        margin-bottom: 5px;
        font-size: clamp(2rem, 3vw, 2.4rem);
    }

    .dashboard-intro > p:last-child {
        margin-bottom: 0;
    }

    .eyebrow {
        margin-bottom: 4px;
    }

    .dashboard-stats {
        gap: 12px;
    }

    .dashboard-stats a {
        padding: 9px 16px;
    }

    .dashboard-stats strong {
        font-size: 1.45rem;
    }

    .section-cards {
        column-gap: 20px;
        row-gap: 16px;
    }

    .section-card {
        min-height: 242px;
        padding: 13px 22px;
    }

    .section-card > img,
    .section-card-heading img {
        width: 52px;
        height: 52px;
        max-width: 52px;
        max-height: 52px;
        margin-bottom: 8px;
    }

    .section-card h2 {
        margin-bottom: 6px;
    }

    .section-card > p {
        margin-bottom: 0;
        line-height: 1.4;
    }

    .section-card-actions {
        gap: 8px;
        padding-top: 8px;
    }

    .section-card-actions .button {
        min-height: 40px;
        padding: 8px 14px;
    }

    .quick-links {
        line-height: 1.3;
    }

    .dashboard-meta {
        margin: 0;
    }
}

@media (min-width: 761px) {
    .control-with-help > .button,
    .control-with-help > button { white-space: nowrap; }
}

.advanced-contact-form {
    display: grid;
    gap: 18px;
}

.databases-admin {
    min-width: 0;
}

.databases-table {
    min-width: 1120px;
}

.databases-name-form {
    display: grid;
    min-width: 250px;
    gap: 8px;
}

.databases-name-form .button {
    width: 100%;
}

.databases-manual-result .code-block {
    max-height: 360px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

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

.database-initialize-admin .database-diagnostic-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.database-initialize-admin .database-diagnostic-grid div {
    min-width: 0;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.database-initialize-admin .database-diagnostic-grid dt { color: var(--muted); font-size: .86rem; font-weight: 700; }
.database-initialize-admin .database-diagnostic-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.database-initialize-admin .database-diagnostic-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.database-initialize-admin .database-diagnostic-lists > div { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafc; }
.database-initialize-admin .database-diagnostic-lists h3 { margin-top: 0; }
.database-initialize-admin .database-diagnostic-lists ul { max-height: 260px; margin-bottom: 0; overflow: auto; }
.database-initialize-admin .database-sensitive-form { max-width: 760px; }

.contacts-advanced-list .contacts-row-search + .table-scroll {
    margin-top: 14px;
}

.export-admin {
    min-width: 0;
}

.ai-upload-admin { min-width: 0; }
.ai-upload-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}
.ai-upload-topbar h1 { margin-bottom: 0; }
.ai-upload-topbar .topbar-actions {
    flex-wrap: nowrap;
    align-self: start;
}
.ai-upload-topbar > p {
    grid-column: 1 / -1;
    margin: 0;
}
.ai-upload-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.ai-upload-summary div { padding: 12px 14px; border-right: 1px solid var(--line); }
.ai-upload-summary dt { color: var(--muted); font-size: .86rem; font-weight: 700; }
.ai-upload-summary dd { margin: 5px 0 0; font-size: 1.35rem; font-weight: 800; }
.ai-format-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ai-format-grid article { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafc; }
.ai-format-grid h3 { margin: 0 0 8px; font-size: 1rem; }
.ai-format-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.ai-format-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid #cbd9e3;
    border-radius: 999px;
    background: #fff;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.ai-format-notes { margin-top: 18px; }
.ai-format-notes p { margin: 0; }
.ai-format-notes p + p { margin-top: 10px; }
.ai-upload-confirmation fieldset { display: grid; gap: 10px; }
.ai-upload-confirmation label { display: flex; align-items: flex-start; gap: 8px; }
.ai-upload-confirmation input[type="radio"] { width: auto; margin-top: 3px; }
.ai-upload-results { min-width: 880px; }
.ai-files-admin { min-width: 0; }
.ai-files-filter-form {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr) minmax(280px, 1.5fr) auto;
    align-items: end;
    gap: 12px;
}
.ai-files-filter-form.has-user-filter {
    grid-template-columns: minmax(150px, .7fr) minmax(230px, 1.1fr) minmax(240px, 1.3fr) minmax(170px, .8fr) auto;
}
.ai-files-filter-actions { display: flex; gap: 8px; }
.ai-files-filter-actions .button,
.ai-files-filter-actions button { white-space: nowrap; }
.ai-files-list-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 18px;
    margin-bottom: 14px;
}
.ai-files-list-summary span { color: var(--muted); }
.ai-files-table { min-width: 1320px; }
.ai-files-table th,
.ai-files-table td { vertical-align: top; }
.ai-files-name {
    min-width: 240px;
    max-width: 380px;
    overflow-wrap: anywhere;
    word-break: normal;
}
.ai-files-nowrap { white-space: nowrap; }
.ai-files-status,
.ai-support-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f5f7f9;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}
.ai-support-badge.is-supported { border-color: #b8d8c3; background: #eaf6ee; color: #23613a; }
.ai-support-badge.is-unsupported { border-color: #ead8ad; background: #fff8e5; color: #735c00; }
.ai-files-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}
.ai-files-pagination span { color: var(--muted); font-weight: 700; }
.ai-files-empty { display: grid; justify-items: start; gap: 14px; }
.ai-files-empty p { margin: 0; }

.export-card-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 16px;
}

.export-card-links a:last-child {
    grid-column: 1 / -1;
}

.export-hub-links,
.export-output-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.export-hub-links a {
    display: grid;
    gap: 4px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
    color: inherit;
    text-decoration: none;
}

.export-hub-links a:hover,
.export-hub-links a:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(11, 95, 147, .12);
}

.export-hub-links strong {
    color: var(--primary);
}

.export-hub-links span {
    color: var(--muted);
}

.export-selection-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.export-selection-status > div {
    min-width: 0;
}

.export-selection-cancel-form {
    flex: 0 0 auto;
}

.export-selection-cancel-form .button {
    white-space: nowrap;
}

.export-output-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
}

.export-output-card h2 {
    margin-top: 0;
}

.export-output-card form,
.export-output-card button {
    width: 100%;
}

.export-backup-card {
    border-color: #c8a96b;
}

.export-empty-state {
    display: grid;
    justify-items: start;
    gap: 14px;
}

.export-form,
.export-step {
    display: grid;
    gap: 18px;
}

.export-step-heading {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.export-step-heading > span {
    display: inline-grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.export-step-heading h2,
.export-step-heading p {
    margin: 0;
}

.export-step-heading p {
    margin-top: 4px;
    color: var(--muted);
}

.export-choice-grid,
.export-format-grid,
.export-field-grid,
.export-group-grid,
.export-warning-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.export-choice,
.export-group-card,
.export-result-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.export-choice input,
.export-group-card input,
.export-result-card input,
.export-field-grid input {
    width: auto;
    margin-top: 3px;
}

.export-group-card span,
.export-choice span,
.export-result-card span {
    display: grid;
    gap: 4px;
}

.export-group-card small,
.export-choice small,
.export-result-card small {
    color: var(--muted);
    line-height: 1.35;
}

.export-selection-toolbar,
.export-final-actions,
.export-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.export-selection-toolbar strong {
    margin-right: auto;
}

.export-contact-filters {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) minmax(190px, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.export-contact-list {
    max-height: 540px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.export-contact-table {
    min-width: 1260px;
}

.export-contact-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.export-contact-table tr[hidden] {
    display: none;
}

.export-live-count {
    margin: 0;
    color: var(--muted);
}

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

.export-field-grid label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.export-variant {
    max-width: 620px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.export-variant[hidden] {
    display: none;
}

.export-advanced {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.export-advanced summary {
    cursor: pointer;
    font-weight: 700;
}

.export-advanced[open] summary {
    margin-bottom: 14px;
}

.export-format-note {
    margin: 12px 0 0;
    color: var(--muted);
}

.export-format-note[hidden],
[data-export-vcard-output][hidden] {
    display: none;
}

[data-export-vcard-output] {
    max-width: none;
}

.export-group-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.export-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.export-summary-grid div {
    min-width: 0;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.export-summary-grid dt {
    color: var(--muted);
    font-size: .84rem;
    font-weight: 700;
}

.export-summary-grid dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.export-warning-grid div {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #ead8ad;
    border-radius: 8px;
    background: #fff9e9;
}

.export-warning-grid strong {
    font-size: 1.35rem;
}

.export-result-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 520px;
    gap: 10px;
    overflow: auto;
}

.export-final-actions {
    justify-content: flex-end;
}

.advanced-section h2 {
    margin-top: 0;
}

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

.advanced-section-heading h2 {
    margin-bottom: 0;
}

.advanced-basic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.advanced-basic-grid label,
.advanced-row label {
    min-width: 0;
}

.advanced-wide {
    grid-column: 1 / -1;
}

.advanced-rows {
    display: grid;
    gap: 12px;
}

.advanced-row {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) auto auto;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
}

.advanced-detail-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.advanced-detail-row .advanced-value {
    grid-column: span 2;
}

.advanced-primary {
    display: inline-flex !important;
    min-height: 42px;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.advanced-primary input,
.advanced-group-grid input {
    width: auto;
}

.advanced-group-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 18px;
}

.field-error input,
.field-error select,
.field-error textarea,
[aria-invalid="true"] {
    border-color: var(--error-text);
    box-shadow: 0 0 0 2px rgba(180, 35, 24, .12);
}

.advanced-save-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
}

.active-database-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
}

.active-database-info,
.active-user-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.active-user-info {
    margin-left: auto;
    text-align: right;
}

.active-database-bar a {
    color: inherit;
    font-weight: 700;
}

.database-choice-cards {
    display: grid;
    gap: 10px;
    padding: 0;
    border: 0;
}

.database-choice-cards legend {
    margin-bottom: 10px;
    font-weight: 700;
}

.database-choice-cards label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
}

.database-choice-cards input {
    width: auto;
}

.central-user-card {
    margin-top: 18px;
}

.central-user-heading,
.central-user-fields,
.central-access-grid,
.central-user-create {
    display: grid;
    gap: 14px;
}

.central-user-fields {
    grid-template-columns: 2fr 1fr 1fr;
}

.central-access-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 18px 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.central-access-grid legend {
    padding: 0 8px;
    font-weight: 700;
}

.activation-code-form {
    margin-top: 12px;
}

@media (max-width: 900px) {
    .active-database-bar-inner {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .active-database-info,
    .active-user-info {
        text-align: center;
    }

    .active-user-info {
        margin-left: 0;
    }

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

    .central-user-fields,
    .central-access-grid {
        grid-template-columns: 1fr;
    }

    .database-initialize-admin .database-diagnostic-grid,
    .database-initialize-admin .database-diagnostic-lists {
        grid-template-columns: 1fr;
    }

    .advanced-row,
    .advanced-detail-row,
    .advanced-basic-grid,
    .advanced-group-grid {
        grid-template-columns: 1fr;
    }

    .advanced-wide,
    .advanced-detail-row .advanced-value {
        grid-column: auto;
    }

    .advanced-row .button {
        width: 100%;
    }

    .export-choice-grid,
    .export-format-grid,
    .export-field-grid,
    .export-group-grid,
    .export-warning-grid,
    .export-summary-grid,
    .export-result-list,
    .export-contact-filters,
    .export-hub-links,
    .export-output-grid,
    .export-card-links {
        grid-template-columns: 1fr;
    }

    .export-card-links a:last-child {
        grid-column: auto;
    }

    .ai-upload-summary,
    .ai-format-grid {
        grid-template-columns: 1fr;
    }

    .ai-upload-topbar {
        grid-template-columns: 1fr;
    }

    .ai-upload-topbar .topbar-actions,
    .ai-upload-topbar > p {
        grid-column: 1;
    }

    .ai-upload-topbar .topbar-actions {
        flex-wrap: wrap;
    }

    .ai-files-filter-form,
    .ai-files-filter-form.has-user-filter {
        grid-template-columns: 1fr;
    }

    .ai-files-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .ai-files-filter-actions .button,
    .ai-files-filter-actions button {
        width: 100%;
    }

    .export-selection-status {
        align-items: stretch;
        flex-direction: column;
    }

    .export-selection-cancel-form,
    .export-selection-cancel-form .button {
        width: 100%;
    }

    .export-selection-toolbar,
    .export-final-actions,
    .export-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .export-selection-toolbar strong {
        margin-right: 0;
    }
}
