:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --text: #0f172a;
    --muted: #55627a;
    --line: #d4dde9;
    --line-soft: #e7edf5;
    --sidebar: #0f1828;
    --sidebar-hover: #1b2940;
    --accent: #1663c7;
    --accent-strong: #0f4e9e;
    --green: #0f766e;
    --yellow: #9a6700;
    --red: #b42318;
    --radius: 12px;
    --radius-soft: 16px;
    --shadow-soft: 0 22px 46px -38px rgba(15, 28, 48, 0.75);
    --shadow-card: 0 12px 26px -24px rgba(17, 24, 39, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Aptos", "Segoe UI", "Trebuchet MS", Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 4% -8%, #d9e7ff 0, rgba(217, 231, 255, 0) 40%),
        radial-gradient(circle at 100% 0%, #e3ecfb 0, rgba(227, 236, 251, 0) 30%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 38%, var(--bg) 100%);
    font-size: 14px;
    overflow-x: hidden;
}

a {
    color: #006a8e;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(190deg, #0e1624 0%, #101d31 50%, #162842 100%);
    color: #f5f7fa;
    padding: 16px 12px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 10px 0 30px -20px rgba(10, 16, 29, 0.8);
}

.sidebar-brand {
    padding: 10px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    display: grid;
    gap: 4px;
}

.sidebar-brand strong {
    font-size: 16px;
    letter-spacing: 0.01em;
}

.sidebar-brand span {
    color: #c1c9d6;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
    margin-top: 14px;
}

.sidebar-nav a {
    color: #e8edf6;
    border-radius: var(--radius);
    padding: 10px 11px;
    font-size: 13px;
    font-weight: 600;
    transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
    transform: translateX(2px);
}

.sidebar-nav a.active {
    background: linear-gradient(180deg, #f6f8fc 0%, #e9eef8 100%);
    color: #121b2b;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

.app-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
    min-height: 58px;
    background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.topbar .muted {
    margin: 3px 0 0;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.page {
    min-width: 0;
    padding: 18px 20px;
    display: grid;
    gap: 16px;
}

.contacts-screen .page {
    padding: 0;
    overflow: hidden;
}

h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

.muted {
    color: var(--muted);
    font-size: 12px;
}

.panel,
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-soft);
    padding: 15px;
    box-shadow: var(--shadow-soft);
    min-width: 0;
}

.stats-grid,
.split-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-card);
}

.stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.stat-value {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 700;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin: 8px 0 4px;
}

input,
select,
textarea,
button {
    width: 100%;
    border: 1px solid #c7d4e5;
    border-radius: 8px;
    padding: 8px 9px;
    font: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease, transform 120ms ease;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn-light:focus-visible,
.icon-link:focus-visible,
.mini-action:focus-visible,
.mini-danger:focus-visible {
    outline: none;
    border-color: #8ab8ef;
    box-shadow: 0 0 0 3px rgba(13, 119, 229, 0.16);
}

input[type="checkbox"] {
    width: 14px;
    height: 14px;
    padding: 0;
}

textarea {
    resize: vertical;
    min-height: 112px;
}

button {
    background: linear-gradient(180deg, #2790ff 0%, var(--accent) 100%);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 9px 16px -12px rgba(9, 91, 178, 0.7);
}

button:hover {
    background: linear-gradient(180deg, #1982f2 0%, var(--accent-strong) 100%);
    border-color: var(--accent-strong);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(180deg, #ffffff 0%, #f4f8fe 100%);
    border-color: #c3d4ea;
    color: #20324b;
    box-shadow: none;
}

.btn-secondary:hover {
    background: #eef4fd;
    border-color: #adc4e1;
}

.btn-warning {
    background: linear-gradient(180deg, #ffb35c 0%, #f59f35 100%);
    border-color: #e08f2a;
    color: #3d2707;
    box-shadow: 0 8px 16px -12px rgba(224, 143, 42, 0.65);
}

.btn-warning:hover {
    background: linear-gradient(180deg, #f8a84c 0%, #e68f24 100%);
    border-color: #cf7f1b;
}

.btn-light,
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c3d4ea;
    background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.btn-light:hover,
.icon-link:hover {
    background: #edf4fe;
    border-color: #a8bfde;
    text-decoration: none;
    transform: translateY(-1px);
}

.row,
.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.operations-screen .table-wrap {
    max-width: 100%;
    overflow: auto;
}

.operations-screen .table-wrap > table {
    min-width: 0;
    width: 100%;
}

.operations-screen .table-wrap th,
.operations-screen .table-wrap td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.operations-screen .log-view {
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.operations-screen code {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

th,
td {
    border-bottom: 1px solid var(--line-soft);
    padding: 8px;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

th {
    background: #f0f6ff;
    color: #475467;
    font-weight: 700;
}

.flash {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 10px 12px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.flash.success {
    background: #ecfdf3;
    color: #05603a;
    border-color: #abefc6;
}

.flash.error {
    background: #fef3f2;
    color: #912018;
    border-color: #fecdca;
}

.flash[data-flash="1"] {
    display: none;
}

.crm-toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    width: min(420px, calc(100vw - 24px));
    z-index: 1200;
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.crm-toast {
    pointer-events: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 24px 46px -34px rgba(15, 22, 40, 0.85);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 10px 10px 12px;
    animation: crmToastIn 160ms ease-out;
}

.crm-toast.success {
    border-color: #a8e6c2;
    background: linear-gradient(180deg, #f7fff9 0%, #f0fdf4 100%);
}

.crm-toast.error {
    border-color: #f8c4bf;
    background: linear-gradient(180deg, #fff9f9 0%, #fef3f2 100%);
}

.crm-toast.warning {
    border-color: #f0d2a2;
    background: linear-gradient(180deg, #fffaf2 0%, #fff7e9 100%);
}

.crm-toast.info {
    border-color: #c7daf2;
    background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
}

.crm-toast.closing {
    animation: crmToastOut 180ms ease-in forwards;
}

.crm-toast-body {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.crm-toast-body strong {
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #334156;
}

.crm-toast-body div {
    color: #1f2f48;
    font-size: 13px;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

.crm-toast-close {
    width: 28px;
    min-height: 28px;
    max-width: 28px;
    border-radius: 8px;
    border: 1px solid #d7e1ef;
    background: #ffffff;
    color: #4a607c;
    box-shadow: none;
    padding: 0;
}

.crm-toast-close:hover {
    border-color: #b8cbe5;
    background: #f5f9ff;
    transform: none;
}

.crm-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(10, 16, 27, 0.45);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 18px;
}

.crm-modal {
    width: min(520px, calc(100vw - 24px));
    border-radius: 14px;
    border: 1px solid #cfdbeb;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 34px 64px -42px rgba(8, 20, 38, 0.95);
    padding: 14px;
    animation: crmModalIn 160ms ease-out;
}

.crm-modal h3 {
    margin: 0 0 8px;
    font-size: 17px;
}

.crm-modal p {
    margin: 0;
    color: #344054;
    line-height: 1.45;
}

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

.crm-modal-actions .btn-light,
.crm-modal-actions button {
    width: auto;
    min-width: 120px;
}

.btn-danger {
    background: linear-gradient(180deg, #ff8a7a 0%, #e84f3c 100%);
    border-color: #d94532;
    color: #fff;
    box-shadow: 0 8px 16px -12px rgba(217, 69, 50, 0.8);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #f37968 0%, #cf3e2d 100%);
    border-color: #be3525;
}

@keyframes crmToastIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes crmToastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
}

@keyframes crmModalIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.setup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.hint-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: #344054;
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    padding: 10px;
}

.hint-card p {
    margin: 0;
    font-size: 12px;
}

.hint-card code {
    background: #eef4ff;
    border: 1px solid #d6e4ff;
    border-radius: 4px;
    color: #1849a9;
    padding: 1px 4px;
}

.contacts-console {
    height: calc(100vh - 62px);
    min-height: 640px;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    background: transparent;
}

.contacts-command {
    border-bottom: 1px solid var(--line-soft);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-top: 1px solid var(--line-soft);
}

.view-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.view-tabs a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    color: #304560;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.view-tabs a:hover {
    text-decoration: none;
    background: #edf4fe;
    border-color: #bed1ea;
    transform: translateY(-1px);
}

.view-tabs a.active {
    background: linear-gradient(180deg, #e9f2ff 0%, #dcecff 100%);
    border-color: #a1bce0;
    color: #0f4e9e;
}

.metric-strip {
    display: flex;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    flex-wrap: wrap;
}

.filterbar {
    border-bottom: 1px solid var(--line-soft);
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: linear-gradient(180deg, #fcfdff 0%, #f7faff 100%);
}

.filterbar > * {
    flex: 1 1 140px;
}

.filterbar input[name="q"] {
    flex: 2 1 320px;
}

.filterbar input[name="include_domain"],
.filterbar input[name="exclude_domains"] {
    flex: 1.2 1 200px;
}

.filterbar input[name="limit"] {
    flex: 0 0 86px;
}

.filterbar .compact-check {
    flex: 0 0 auto;
}

.filterbar button,
.filterbar .icon-link {
    flex: 0 0 auto;
    min-width: 90px;
}

.compact-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-weight: 600;
    font-size: 12px;
    color: #344054;
}

.contacts-workbench {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 336px);
    gap: 12px;
    padding: 12px;
}

.table-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border: 1px solid var(--line);
    border-radius: var(--radius-soft);
    background: #fff;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

#contacts-selection-form {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.table-toolbar {
    min-height: 46px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.table-toolbar strong {
    margin-right: 8px;
    font-size: 14px;
}

.table-toolbar span {
    color: var(--muted);
    font-size: 12px;
}

.selection-shortcuts-hint {
    display: block;
    margin-top: 4px;
    color: #61748e;
    font-size: 11px;
    font-weight: 600;
}

.selection-shortcuts-hint kbd {
    border: 1px solid #bfd0e7;
    border-radius: 6px;
    background: #f4f8ff;
    color: #1d3f66;
    font-size: 10px;
    padding: 1px 5px;
}

.crm-table-wrap {
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    overflow: auto;
}

.crm-table {
    width: max-content;
    min-width: 1260px;
}

.crm-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--line);
}

.crm-table th:first-child,
.crm-table td:first-child {
    width: 36px;
    text-align: center;
}

.crm-table tbody tr:hover {
    background: #f2f7ff;
}

.crm-table tbody tr.js-contact-row {
    cursor: pointer;
}

.crm-table tbody tr:nth-child(even):not(.timeline-row) {
    background: #f9fbff;
}

.crm-table tbody tr.js-contact-row.is-selected,
.crm-table tbody tr.js-contact-row.is-selected:hover {
    background: #deecff;
    box-shadow: inset 3px 0 0 #2c79cf;
}

.crm-table tbody tr.timeline-row:hover {
    background: transparent;
}

.crm-table td small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.name-inline-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}

.mini-google-action {
    min-width: 26px;
    min-height: 24px;
    padding: 2px 7px;
    font-size: 11px;
    line-height: 1;
}

.mini-mail-action {
    min-width: 26px;
    min-height: 24px;
    padding: 2px 7px;
    font-size: 11px;
    line-height: 1;
}

.mini-mail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 19, 39, 0.45);
    z-index: 1200;
    display: none;
    place-items: center;
    padding: 16px;
}

.mini-mail-modal {
    width: min(620px, 96vw);
    max-height: 88vh;
    overflow: auto;
    background: #ffffff;
    border: 1px solid #d5e0ee;
    border-radius: 12px;
    box-shadow: 0 20px 44px rgba(10, 24, 46, 0.25);
    padding: 14px;
}

.mini-mail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mini-mail-header h3 {
    margin: 0;
    font-size: 17px;
}

.mini-mail-close {
    min-width: 90px;
}

.mini-mail-email-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #d8e3f1;
    border-radius: 10px;
    padding: 8px;
    background: #fbfdff;
}

.mini-mail-email-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e2ebf7;
    border-radius: 8px;
    padding: 6px 8px;
    background: #ffffff;
}

.mini-mail-actions {
    justify-content: flex-end;
}

.mini-mail-log-wrap {
    margin: 8px 0 10px;
    border: 1px dashed #ccd8e9;
    border-radius: 8px;
    padding: 6px 8px;
    background: #f8fbff;
}

.mini-mail-log-wrap summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
}

.mini-mail-log {
    margin: 8px 0 0;
    padding: 8px;
    border: 1px solid #d8e3f1;
    border-radius: 8px;
    background: #ffffff;
    max-height: 160px;
    overflow: auto;
    font-size: 11px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
}

.row-actions form {
    margin: 0;
}

.mini-action,
.mini-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 28px;
    border-radius: 8px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.mini-action {
    border: 1px solid #c3d1e5;
    color: #243850;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.mini-action:hover {
    background: #edf4ff;
    border-color: #a7bedf;
    transform: translateY(-1px);
    text-decoration: none;
}

.mini-web-action {
    margin-left: 6px;
    border-color: #8bc4ff;
    background: linear-gradient(180deg, #f0f7ff 0%, #e6f1ff 100%);
    color: #12467a;
}

.mini-web-action:hover {
    border-color: #66a6eb;
    background: linear-gradient(180deg, #e9f4ff 0%, #dcebff 100%);
}

.mini-danger {
    border: 1px solid #f8cfc9;
    background: linear-gradient(180deg, #ffffff 0%, #fff7f6 100%);
    color: var(--red);
}

.mini-danger:hover {
    background: #feecea;
    border-color: #fecdca;
    transform: translateY(-1px);
}

.mailbox-test-actions {
    display: grid;
    gap: 8px;
    min-width: 260px;
}

.mailbox-test-actions form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 100px;
    gap: 6px;
    align-items: center;
}

.mailbox-test-actions form:last-child {
    grid-template-columns: 1fr;
}

.mailbox-form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.mailbox-form-actions .btn-light {
    min-height: 38px;
}

.mailbox-active-check {
    min-height: 38px;
    align-items: center;
}

.bulk-panel {
    min-width: 0;
    background: linear-gradient(180deg, #fafcff 0%, #f3f7fd 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-soft);
    box-shadow: var(--shadow-soft);
    padding: 12px;
    overflow: auto;
}

.selected-summary {
    background: linear-gradient(135deg, #0f2342 0%, #143058 100%);
    color: #fff;
    border-radius: var(--radius-soft);
    padding: 12px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.quick-imap-form {
    margin-bottom: 10px;
}

.selected-summary span {
    font-size: 26px;
    font-weight: 800;
}

.bulk-panel details {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.bulk-panel summary {
    cursor: pointer;
    padding: 11px 12px;
    font-weight: 800;
    border-bottom: 1px solid transparent;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.bulk-panel details[open] summary {
    border-bottom-color: var(--line-soft);
}

.bulk-panel form {
    display: grid;
    gap: 8px;
    padding: 11px;
}

.quick-edit-hint {
    margin: 0;
    padding: 8px;
    border-radius: 8px;
    background: #edf5ff;
    border: 1px solid #c8dbf6;
    color: #24466d;
    font-size: 12px;
}

.quick-edit-note {
    display: block;
    margin-top: 4px;
    color: #5b6f89;
    font-size: 11px;
}

.quick-edit-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.quick-edit-actions .btn-light {
    width: auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
}

.blocked-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 10px 10px;
}

.blocked-domains form {
    padding: 0;
}

.blocked-domains button {
    width: auto;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #344054;
    border-color: var(--line);
    font-size: 12px;
    padding: 5px 9px;
}

.tag,
.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 800;
    margin: 2px 4px 2px 0;
    white-space: nowrap;
}

.tag-list {
    background: #f2f4f7;
    color: #344054;
}

.timeline-panel {
    background: linear-gradient(180deg, #fcfdff 0%, #f7fbff 100%);
    border: 1px solid #cfddee;
    border-radius: var(--radius-soft);
    padding: 12px;
    box-shadow: 0 14px 28px -30px rgba(6, 24, 49, 0.95);
}

.timeline-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.timeline-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

.timeline-card {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: #fff;
    padding: 8px;
}

.timeline-card h4 {
    margin: 0 0 8px;
    font-size: 13px;
}

.live-monitor {
    border: 1px solid #cbd9ea;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f4f9ff 100%);
    padding: 11px;
    display: grid;
    gap: 10px;
    box-shadow: var(--shadow-card);
}

.live-monitor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.live-monitor-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 800;
    color: #1e324d;
}

.live-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #2f9d69;
    box-shadow: 0 0 0 0 rgba(47, 157, 105, 0.7);
    animation: livePulse 1.4s infinite;
}

.live-monitor-tools {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
    gap: 8px;
    align-items: center;
}

.live-monitor-tools select {
    flex: 1 1 170px;
    min-width: 0;
}

.live-monitor-tools .inline-form {
    margin: 0;
}

.live-monitor-tools .btn-secondary,
.live-monitor-tools .inline-form button {
    width: auto;
}

.live-monitor-tools .compact-check {
    justify-content: flex-start;
}

.live-monitor-refresh {
    width: auto;
    min-width: 120px;
}

@media (max-width: 980px) {
    .live-monitor-tools .btn-secondary {
        width: 100%;
    }
}

.live-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.live-metric {
    border: 1px solid #dce6f3;
    background: #ffffff;
    border-radius: 9px;
    padding: 8px;
}

.live-metric small {
    display: block;
    color: #607085;
    font-size: 11px;
}

.live-metric strong {
    display: block;
    margin-top: 2px;
    font-size: 15px;
}

.live-last-update {
    color: #667085;
    font-size: 11px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.live-progress {
    border: 1px solid #dbe6f4;
    border-radius: 10px;
    background: #ffffff;
    padding: 8px 9px;
    display: grid;
    gap: 6px;
}

.live-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.live-progress-head strong {
    font-size: 12px;
    color: #233650;
}

.live-progress-head span {
    font-size: 13px;
    font-weight: 800;
    color: #0d4f93;
}

.live-progress-track,
.live-campaign-progress-track {
    height: 8px;
    border-radius: 999px;
    background: #edf3fb;
    overflow: hidden;
}

.live-progress-track span,
.live-campaign-progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #56b486 0%, #2f9d69 55%, #1f8a57 100%);
}

.live-progress-meta {
    color: #607085;
    font-size: 11px;
    margin: 0;
}

.live-campaign-progress-list {
    display: grid;
    gap: 6px;
}

.live-campaign-progress-card {
    border: 1px solid #dbe6f4;
    background: #ffffff;
    border-radius: 10px;
    padding: 8px;
    display: grid;
    gap: 5px;
}

.web-outreach-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

.web-assistant-data {
    display: grid;
    gap: 8px;
}

.web-assistant-data textarea,
#web-bookmarklet-code {
    min-height: 160px;
    resize: vertical;
}

.web-open-url-form {
    margin-bottom: 12px;
}

.web-assistant-actions {
    margin-bottom: 10px;
}

.web-manual-sent-form {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.web-links-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.web-outreach-send-card {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
}

.web-scan-form,
.web-send-form {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #d8e4f3;
    border-radius: 10px;
    background: #fbfdff;
}

.web-scan-report {
    border: 1px solid #d8e4f3;
    border-radius: 10px;
    background: #fff;
    padding: 9px 10px;
}

.web-scan-report ul {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.web-scan-report li {
    display: grid;
    gap: 2px;
    border-bottom: 1px solid #edf3fb;
    padding-bottom: 6px;
}

.web-scan-report li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.web-scan-report .web-ok {
    color: #1f7a4f;
    font-weight: 700;
}

.web-scan-report .web-warn {
    color: #9a5b14;
    font-weight: 700;
}

.web-detected-email-list {
    max-height: 280px;
    overflow: auto;
    border: 1px solid #d8e4f3;
    border-radius: 10px;
    background: #fff;
    padding: 8px;
    display: grid;
    gap: 7px;
}

.web-detected-email-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 8px;
    align-items: center;
    border-bottom: 1px solid #edf3fb;
    padding-bottom: 6px;
}

.web-detected-email-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.web-detected-email-item small {
    grid-column: 2;
    color: #5f738b;
    font-size: 11px;
}

.live-campaign-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.live-campaign-progress-head strong {
    font-size: 12px;
    color: #233650;
}

.live-campaign-progress-head span {
    font-size: 12px;
    font-weight: 800;
    color: #0d4f93;
}

.live-campaign-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #607085;
    font-size: 11px;
}

.live-recent {
    border: 1px solid #dde8f6;
    border-radius: 10px;
    background: #fff;
    max-height: 220px;
    overflow: auto;
}

.live-recent ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.live-recent li {
    border-bottom: 1px solid #edf3fb;
    padding: 7px 9px;
    display: grid;
    gap: 3px;
}

.live-recent li:last-child {
    border-bottom: 0;
}

.live-recent-meta {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    color: #607085;
    font-size: 11px;
}

.live-empty {
    color: #607085;
    font-size: 12px;
    padding: 10px;
}

@keyframes livePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(47, 157, 105, 0.65);
    }
    100% {
        box-shadow: 0 0 0 12px rgba(47, 157, 105, 0);
    }
}

.tag-smart {
    background: #ecfdf3;
    color: var(--green);
}

.status-pill {
    background: #f2f4f7;
    color: #344054;
}

.status-active {
    background: #ecfdf3;
    color: var(--green);
}

.status-not_sent {
    background: #f2f4f7;
    color: #475467;
}

.status-pending {
    background: #edf4ff;
    color: #1e4f89;
}

.status-processing {
    background: #efe9ff;
    color: #4a2ca8;
}

.status-sent {
    background: #ecfdf3;
    color: #0f766e;
}

.status-manual_sent {
    background: #eaf2ff;
    color: #1849a9;
}

.status-form_sent {
    background: #e9f8ff;
    color: #0f5f8e;
}

.status-failed {
    background: #fef3f2;
    color: #b42318;
}

.status-cancelled {
    background: #f2f4f7;
    color: #344054;
}

.status-replied {
    background: #fff7e6;
    color: var(--yellow);
}

.status-unsubscribed,
.status-suppressed,
.status-bounced {
    background: #fef3f2;
    color: var(--red);
}

.status-no_interesado,
.status-no_contactar {
    background: #fef3f2;
    color: #b42318;
}

.status-note-negative {
    color: #b42318;
    font-weight: 700;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.status-note-review {
    color: #9a5b08;
    font-weight: 700;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: static;
        height: auto;
    }

    .sidebar-nav {
        grid-template-columns: repeat(6, minmax(120px, 1fr));
        overflow: auto;
    }

    .contacts-console {
        height: auto;
    }

    .filterbar {
        padding: 10px;
    }

    .contacts-workbench {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .bulk-panel {
        border-top: 0;
    }

    .live-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        padding: 12px;
    }

    .contacts-screen .page {
        padding: 0;
    }

    .contacts-command,
    .metric-strip {
        align-items: flex-start;
        flex-direction: column;
    }

    .row,
    .two-cols {
        grid-template-columns: 1fr;
    }

    .quick-edit-actions {
        grid-template-columns: 1fr;
    }

    .quick-edit-actions .btn-light {
        width: 100%;
    }

    .filterbar > * {
        flex: 1 1 100%;
    }

    .filterbar button,
    .filterbar .icon-link,
    .filterbar .compact-check {
        width: 100%;
    }

    .live-metrics {
        grid-template-columns: 1fr;
    }
}
