:root {
    --sidebar-expanded-width: 244px;
    --sidebar-collapsed-width: 76px;
    --sidebar-width: var(--sidebar-expanded-width);
    --dashboard-content-gutter: 24px;
}
html.sidebar-collapsed {
    --sidebar-width: var(--sidebar-collapsed-width);
}

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

.dashboard-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 16px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    transition: width 0.2s ease, padding 0.2s ease;
    overflow: visible;
}
.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: -24px;
    transform: translateY(-50%);
    z-index: 25;
    width: 36px;
    height: 132px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.sidebar-toggle-line {
    display: block;
    width: 2px;
    height: 52px;
    border-radius: 999px;
    background: var(--text-muted);
    transition: width 0.15s ease, height 0.15s ease, background 0.15s ease;
}
.sidebar-toggle:hover .sidebar-toggle-line,
.sidebar-toggle:focus-visible .sidebar-toggle-line {
    width: 3px;
    height: 58px;
    background: var(--text);
}
.sidebar-organization-switcher {
    position: relative;
    flex: 0 0 auto;
    min-width: 0;
    margin: -4px -16px 0;
    padding: 0 16px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-organization-switcher summary {
    list-style: none;
}
.sidebar-organization-switcher summary::-webkit-details-marker {
    display: none;
}
.sidebar-organization-trigger {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 54px;
    padding: 4px 8px;
    color: var(--text);
    cursor: pointer;
}
.sidebar-organization-trigger:hover {
    color: var(--primary);
}
.sidebar-organization-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}
.sidebar-organization-copy span {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}
.sidebar-organization-copy strong {
    min-width: 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-organization-collapsed-icon {
    display: none;
}
.sidebar-organization-chevrons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
    transition: color 0.15s ease;
}
.sidebar-organization-trigger:hover .sidebar-organization-chevrons,
.sidebar-organization-switcher[open] .sidebar-organization-chevrons {
    color: var(--primary);
}
.organization-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 16px;
    z-index: 40;
    width: min(320px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    transform-origin: top left;
    animation: popupFadeIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.organization-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    margin: -10px -10px 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}
.organization-search input {
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}
.organization-dropdown-title {
    margin: 12px 3px 6px;
    color: var(--text-muted);
    font-size: 12px;
}
.organization-list {
    display: grid;
    gap: 4px;
    max-height: 280px;
    overflow-y: auto;
}
.organization-switch-form {
    margin: 0;
}
.organization-option {
    appearance: none;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 18px;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 52px;
    padding: 8px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.organization-option:hover,
.organization-option.active {
    background: var(--bg-hover);
}
.organization-option:disabled {
    cursor: default;
}
.organization-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--bg-hover) 72%, transparent);
    color: var(--text-muted);
}
.organization-option-text {
    display: grid;
    min-width: 0;
}
.organization-option-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.organization-option-text strong {
    font-size: 14px;
}
.organization-option-check {
    color: var(--primary);
    font-size: 12px;
}
.organization-create {
    margin: 8px -10px 0;
    padding: 8px 10px 0;
    border-top: 1px solid var(--border);
}
.organization-create summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
}
.organization-create summary:hover {
    background: var(--bg-hover);
    color: var(--primary);
}
.organization-create[open] summary {
    display: none;
}
.organization-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
}
.organization-create-form input {
    height: 38px;
    padding: 8px 10px;
    font-size: 14px;
}
.organization-create-submit {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--border));
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.organization-create-submit:hover,
.organization-create-submit:focus-visible {
    border-color: color-mix(in srgb, var(--primary) 78%, var(--border));
    background: color-mix(in srgb, var(--primary) 84%, #fff);
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    padding-right: 4px;
}
.sidebar-nav-main {
    flex: 1 1 auto;
    overflow-y: auto;
}
.sidebar-nav-secondary {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    overflow: visible;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-hover);
    color: var(--primary);
    text-decoration: none;
}
.sidebar-nav i { width: 18px; flex: 0 0 18px; text-align: center; }

.dashboard-topbar {
    position: relative;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 86px;
    margin-left: var(--sidebar-width);
    padding: 16px var(--dashboard-content-gutter) 0;
    transition: margin-left 0.2s ease, padding 0.2s ease;
}
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}
.topbar-brand:hover { text-decoration: none; color: var(--text); }
.topbar-brand i { color: var(--primary); font-size: 1.45rem; }
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar-menu {
    position: relative;
}
.topbar-menu summary {
    list-style: none;
}
.topbar-menu summary::-webkit-details-marker {
    display: none;
}
.topbar-control,
.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
}
.topbar-control {
    appearance: none;
    gap: 9px;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 600;
    font: inherit;
}
.topbar-control:hover,
.user-menu-trigger:hover {
    border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
    background: var(--bg-hover);
}
.theme-toggle {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
    border-color: transparent;
    background: var(--bg-hover);
    box-shadow: none;
}
.user-menu-trigger {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-weight: 800;
}
.user-menu-trigger span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.topbar-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 35;
    min-width: 210px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    transform-origin: top right;
    animation: popupFadeIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.user-theme-grid {
    display: grid;
    gap: 6px;
}
.user-theme-grid button,
.user-dropdown-action,
.user-logout-form button {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.user-theme-grid button:hover,
.user-theme-grid button.active,
.user-dropdown-action:hover,
.user-logout-form button:hover {
    border-color: var(--border);
    background: var(--bg-hover);
    color: var(--primary);
}
.user-dropdown {
    width: min(320px, calc(100vw - 32px));
    padding: 12px;
}
.user-dropdown-header {
    display: grid;
    gap: 4px;
    margin: 0 -12px 8px;
    padding: 4px 14px 12px;
    border-bottom: 1px solid var(--border);
}
.user-dropdown-header span,
.user-menu-section-title {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.user-dropdown-header strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-dropdown-header small {
    color: var(--primary);
    font-weight: 700;
}
.user-menu-alert {
    margin: 8px 0;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
}
.user-menu-alert-success {
    border: 1px solid rgba(39, 174, 96, 0.35);
    background: rgba(39, 174, 96, 0.12);
    color: #81c784;
}
.user-menu-alert-error {
    border: 1px solid rgba(231, 76, 60, 0.35);
    background: rgba(231, 76, 60, 0.12);
    color: #f28b82;
}
.user-password-form {
    display: grid;
    gap: 8px;
    margin: 8px 0 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg-hover) 45%, transparent);
}
.user-password-form[hidden] {
    display: none;
}
.user-password-form label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
.user-password-form input {
    height: 38px;
    padding: 8px 10px;
    font-size: 14px;
}
.user-menu-section-title {
    margin: 12px 2px 8px;
}
.user-theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.user-theme-grid button {
    justify-content: center;
    min-height: 34px;
    padding: 7px 8px;
    font-size: 12px;
    text-align: center;
}
.user-logout-form {
    margin: 10px -12px 0;
    padding: 10px 12px 0;
    border-top: 1px solid var(--border);
}

html.sidebar-collapsed .dashboard-sidebar {
    padding: 20px 10px;
}
html.sidebar-collapsed .sidebar-organization-switcher {
    align-items: center;
    margin: -4px -10px 0;
    padding: 0 10px 16px;
}
html.sidebar-collapsed .sidebar-organization-trigger {
    display: flex;
    justify-content: center;
    padding: 6px 0;
}
html.sidebar-collapsed .sidebar-organization-copy,
html.sidebar-collapsed .sidebar-organization-chevrons {
    display: none;
}
html.sidebar-collapsed .sidebar-organization-collapsed-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--primary) 16%, var(--bg-hover));
    border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--border));
    color: var(--primary);
}
html.sidebar-collapsed .organization-dropdown {
    left: calc(100% + 8px);
    top: 0;
}
html.sidebar-collapsed .sidebar-nav {
    padding-right: 0;
}
html.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    gap: 0;
    padding: 9px;
}
html.sidebar-collapsed .sidebar-nav a {
    font-size: 0;
}
html.sidebar-collapsed .sidebar-nav i {
    font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
    .organization-dropdown,
    .topbar-dropdown {
        animation: none;
    }
}

.dashboard-main {
    width: calc(100% - var(--sidebar-width));
    max-width: none;
    margin-left: var(--sidebar-width);
    padding: 24px var(--dashboard-content-gutter);
    transition: margin-left 0.2s ease, width 0.2s ease;
}
.card-body.p-0 { padding: 0; }
.empty-msg { padding: 24px; text-align: center; color: var(--text-muted); }

.stats-table {
    min-width: 980px;
}
.stats-table th,
.stats-table td {
    text-align: center;
}
.stats-table th:first-child,
.stats-table td:first-child {
    text-align: left;
}
.stats-table .account-col {
    vertical-align: top;
    background: rgba(255, 255, 255, 0.02);
}
.stats-table .item-id-muted {
    color: var(--text-muted);
}
.stats-table .total-row td {
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    font-weight: 700;
}
.stats-table .global-total-row td {
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    font-weight: 800;
}
.stats-table .empty-account-row td {
    color: var(--text-muted);
}
.table-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 90px;
}
.item-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.item-summary strong {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

table.data-table td.active-items-cell {
    text-align: center;
}

.account-id-note {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.3;
}

.account-tags-panel .card-header { justify-content: space-between; flex-wrap: wrap; }
.account-tags-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}
.tag-create-toggle { flex: 0 0 auto; }
.tag-manage-panel {
    margin-top: 16px;
}
.tag-manage-panel[hidden] { display: none !important; }
.tag-filter-row,
.account-tag-list,
.tag-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag-filter-chip,
.tag-admin-chip,
.account-tag,
.tag-checkbox span {
    --tag-color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--tag-color) 55%, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--tag-color) 14%, transparent);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}
.tag-delete-form {
    display: none;
    margin: 0;
}
.account-tags-panel.is-managing .tag-filter-chip-view {
    display: none;
}
.account-tags-panel.is-managing .tag-delete-form {
    display: inline-flex;
}
.tag-admin-chip {
    appearance: none;
    font-family: inherit;
    cursor: pointer;
}
.tag-filter-chip:hover,
.tag-filter-chip.active {
    background: color-mix(in srgb, var(--tag-color) 24%, transparent);
    color: #fff;
    text-decoration: none;
}
.tag-create-form { margin: 0; }
.tag-create-form input[type="text"],
.tag-create-form .btn {
    height: 44px;
}
.tag-color-field { flex: 0 0 92px !important; }
.tag-color-field input[type="color"] {
    position: relative;
    top: 2px;
    width: 100%;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    overflow: hidden;
}
.tag-color-field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.tag-color-field input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: calc(var(--radius) - 1px);
}
.tag-color-field input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: calc(var(--radius) - 1px);
}
.tag-create-action { flex: 0 0 auto !important; }
.tag-checkbox { display: inline-flex; cursor: pointer; }
.tag-checkbox input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.tag-checkbox input:checked + span {
    background: color-mix(in srgb, var(--tag-color) 30%, transparent);
    color: #fff;
}
.tag-checkbox input:focus + span {
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.15);
}

div.table-wrap.accounts-table-wrap {
    overflow: visible;
}

.card.accounts-list-card {
    overflow: visible;
}

table.data-table.accounts-table {
    border-collapse: separate;
    border-spacing: 0;
}

table.data-table.accounts-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-hover);
}

.badge-danger { background: rgba(231, 76, 60, 0.2); color: #f28b82; }
.badge-info { background: rgba(0, 170, 255, 0.18); color: #7dd3fc; }
.nowrap { white-space: nowrap; }
.leads-table-wrap { overflow-x: auto; }
.leads-table { min-width: 1380px; }
.leads-table th,
.leads-table td { vertical-align: top; }
.leads-table .lead-client-cell { min-width: 180px; }
.leads-table .lead-phone-cell { min-width: 150px; }
.leads-table .lead-item-cell { min-width: 260px; max-width: 340px; white-space: normal; overflow-wrap: anywhere; }
.leads-table .lead-error-cell { min-width: 220px; max-width: 320px; white-space: normal; overflow-wrap: anywhere; color: var(--text-muted); }
.leads-table .selected-row td { background: rgba(0, 170, 255, 0.07); }
.lead-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.lead-error-message { margin-top: 4px; }
.lead-phone-blacklisted { margin-left: 6px; vertical-align: middle; }
.amo-working-card { margin-bottom: 20px; }
.amo-working-list { display: flex; flex-wrap: wrap; gap: 10px; }
.amo-working-user { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.015); }
.amo-working-user .text-muted { overflow-wrap: anywhere; }
.conversation { border-top: 1px solid var(--border); padding-top: 18px; }
.conversation-title { margin-bottom: 14px; font-weight: 600; color: var(--text); }
.message-row { display: flex; margin-bottom: 12px; }
.message-row-in { justify-content: flex-start; }
.message-row-out { justify-content: flex-end; }
.message-bubble { max-width: min(720px, 82%); padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-hover); }
.message-row-out .message-bubble { background: rgba(0, 170, 255, 0.12); border-color: rgba(0, 170, 255, 0.28); }
.message-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 6px; color: var(--text-muted); font-size: 12px; }
.message-text { white-space: normal; word-break: break-word; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.message-image-link { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.message-image-link:hover { border-color: var(--primary); text-decoration: none; }
.message-image-thumb { width: 160px; height: 120px; object-fit: cover; display: block; }
@media (max-width: 720px) {
    .sidebar-toggle {
        display: none;
    }
    .dashboard-sidebar {
        position: static;
        width: auto;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }
    .sidebar-organization-switcher {
        margin: 0 0 2px;
        padding: 0 0 12px;
    }
    .sidebar-organization-trigger {
        padding: 4px 8px;
    }
    .organization-dropdown {
        left: 0;
        width: min(320px, calc(100vw - 24px));
    }
    .sidebar-nav {
        margin-top: 12px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
        padding-right: 0;
    }
    .sidebar-nav a {
        white-space: nowrap;
        width: auto;
    }
    .sidebar-nav-main,
    .sidebar-nav-secondary {
        flex: 0 0 auto;
    }
    .sidebar-nav-secondary {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
    .dashboard-topbar {
        margin-left: 0;
        padding: 14px 16px 0;
    }
    .topbar-brand {
        font-size: 1.2rem;
    }
    .topbar-control span {
        display: none;
    }
    .topbar-control {
        width: 42px;
        padding: 0;
    }
    html.sidebar-collapsed .sidebar-organization-switcher {
        margin: 0 0 2px;
        padding: 0 0 12px;
    }
    html.sidebar-collapsed .sidebar-organization-trigger {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 18px;
        justify-content: stretch;
        padding: 4px 8px;
    }
    html.sidebar-collapsed .sidebar-organization-copy,
    html.sidebar-collapsed .sidebar-organization-chevrons {
        display: flex;
    }
    html.sidebar-collapsed .sidebar-organization-collapsed-icon {
        display: none;
    }
    html.sidebar-collapsed .organization-dropdown {
        left: 0;
        top: calc(100% + 10px);
    }
    html.sidebar-collapsed .sidebar-nav i {
        font-size: inherit;
    }
    html.sidebar-collapsed .sidebar-nav a {
        justify-content: flex-start;
        gap: 10px;
        padding: 9px 11px;
        font-size: inherit;
    }
    .dashboard-main {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }
    .message-bubble { max-width: 100%; }
    .message-row-out, .message-row-in { justify-content: stretch; }
}


.system-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.system-summary-item { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); box-shadow: var(--shadow); min-width: 0; }
.system-summary-label { color: var(--text-muted); font-size: 13px; }
.system-summary-item strong { font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.system-summary-item-danger { border-color: rgba(231, 76, 60, 0.45); background: rgba(231, 76, 60, 0.08); }
.system-summary-item-danger strong { color: #f28b82; }
.page-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.card-header-note { margin-left: auto; color: var(--text-muted); font-size: 13px; font-weight: 400; }
.dashboard-filter-card {
    border-color: var(--border);
    background: var(--bg-card);
}
.dashboard-filter-card .card-body { padding: 14px 18px; }
.dashboard-filter-grid {
    display: grid;
    grid-template-columns: minmax(150px, 0.6fr) minmax(150px, 0.6fr) minmax(260px, 1.2fr) minmax(220px, 0.9fr) auto;
    gap: 12px;
    align-items: end;
}
.dashboard-filter-grid .form-group { margin-bottom: 0; }
.dashboard-filter-grid label {
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 600;
}
.dashboard-filter-grid input[type="date"],
.dashboard-filter-grid select,
.dashboard-filter-actions .btn {
    height: 44px;
}
.dashboard-filter-grid input[type="date"],
.dashboard-filter-grid select {
    border-color: color-mix(in srgb, var(--border) 78%, transparent);
    background: color-mix(in srgb, var(--bg-card) 82%, var(--bg-hover));
}
.dashboard-filter-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: end;
}
.dashboard-filter-actions .btn-primary {
    min-width: 116px;
    justify-content: center;
    padding-left: 16px;
    padding-right: 16px;
}
.dashboard-filter-actions .btn-secondary { min-width: 42px; justify-content: center; padding-left: 12px; padding-right: 12px; }
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.dashboard-kpi-item {
    display: grid;
    gap: 8px;
    min-width: 0;
    min-height: 128px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow);
}
.dashboard-kpi-primary { border-color: var(--border); background: var(--bg-card); }
.dashboard-kpi-label { color: var(--text-muted); font-size: 13px; }
.dashboard-kpi-item strong { align-self: end; font-size: 26px; line-height: 1.1; overflow-wrap: anywhere; }
.dashboard-kpi-item small { color: var(--text-muted); font-size: 12px; }
.dashboard-layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
    gap: 24px;
    align-items: stretch;
}
.dashboard-chart-card,
.dashboard-attention-card { min-width: 0; }
.dashboard-chart-wrap { min-height: 340px; height: 42vh; max-height: 460px; }
.dashboard-chart-wrap canvas { width: 100%; height: 100%; }
.dashboard-attention-list { display: grid; gap: 12px; }
.dashboard-attention-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.02);
}
.dashboard-attention-item > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
}
.dashboard-attention-item strong { display: block; margin-bottom: 3px; }
.dashboard-attention-item span { display: block; color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.dashboard-attention-warning > i { color: var(--warning); background: rgba(243, 156, 18, 0.13); }
.dashboard-attention-danger > i { color: #f28b82; background: rgba(231, 76, 60, 0.14); }
.dashboard-attention-muted > i { color: var(--primary); background: rgba(0, 170, 255, 0.12); }
.dashboard-attention-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    color: var(--text-muted);
}
.dashboard-attention-empty i { color: var(--success); }
.dashboard-performance-table th,
.dashboard-performance-table td { white-space: nowrap; }
.dashboard-account-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
}
.dashboard-account-name a,
.dashboard-account-name span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.empty-state,
.empty-cell {
    padding: 24px;
    color: var(--text-muted);
    text-align: center;
}
@media (max-width: 1080px) {
    .dashboard-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard-filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
    .dashboard-layout-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 720px) {
    .dashboard-filter-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-filter-actions {
        flex-wrap: wrap;
    }
    .dashboard-kpi-item {
        min-height: 112px;
    }
    .dashboard-kpi-item strong {
        font-size: 22px;
    }
    .dashboard-chart-wrap {
        min-height: 280px;
        height: 340px;
    }
    .card-header-note {
        width: 100%;
        margin-left: 0;
    }
}
.system-log-form .system-lines-select { flex: 0 0 180px; }
.system-log-files-table .system-log-file-current td { background: rgba(0, 170, 255, 0.08); }
.system-log-viewer-header { justify-content: space-between; flex-wrap: wrap; }
.system-log-meta { margin-left: auto; color: var(--text-muted); font-size: 13px; font-weight: 400; }
.system-log-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.system-log-legend span { display: inline-flex; align-items: center; gap: 7px; }
.system-log-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.system-log-dot-error { background: var(--danger); }
.system-log-dot-warning { background: var(--warning); }
.system-log-dot-info { background: var(--primary); }
.system-log-lines { max-height: 68vh; overflow: auto; background: #0b0d10; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 1.55; }
.system-log-line { display: grid; grid-template-columns: 72px minmax(0, 1fr); border-bottom: 1px solid rgba(255,255,255,0.04); }
.system-log-line-number { padding: 6px 12px; color: #6b7280; text-align: right; user-select: none; border-right: 1px solid rgba(255,255,255,0.06); }
.system-log-line-text { padding: 6px 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: #d6dae1; }
.system-log-line-critical { background: rgba(231, 76, 60, 0.18); box-shadow: inset 4px 0 0 var(--danger); }
.system-log-line-error { background: rgba(231, 76, 60, 0.13); box-shadow: inset 4px 0 0 rgba(231, 76, 60, 0.85); }
.system-log-line-warning { background: rgba(243, 156, 18, 0.12); box-shadow: inset 4px 0 0 rgba(243, 156, 18, 0.9); }
.system-log-line-info { background: rgba(0, 170, 255, 0.03); }
@media (max-width: 720px) {
    .system-log-line { grid-template-columns: 54px minmax(0, 1fr); }
    .system-log-line-number { padding: 6px 8px; }
    .system-log-line-text { padding: 6px 8px; }
    .system-log-viewer-header { align-items: flex-start; }
    .system-log-meta { width: 100%; margin-left: 0; }
}


.label-with-help,
.table-header-with-help { display: inline-flex; align-items: center; gap: 6px; }
.info-tooltip { position: relative; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: help; line-height: 1; outline: none; }
.info-tooltip i { margin: 0; width: auto; }
.info-tooltip:hover,
.info-tooltip:focus { color: var(--primary); }
.info-tooltip::after { content: attr(data-tooltip); position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px); width: max-content; max-width: min(320px, calc(100vw - 48px)); padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #11151b; color: var(--text); box-shadow: var(--shadow); font-size: 13px; font-weight: 400; line-height: 1.4; text-align: left; white-space: pre-line; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease; }
.info-tooltip:hover::after,
.info-tooltip:focus::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.info-tooltip-bottom::after { top: calc(100% + 8px); bottom: auto; transform: translateX(-50%) translateY(-4px); }
.info-tooltip-bottom:hover::after,
.info-tooltip-bottom:focus::after { transform: translateX(-50%) translateY(0); }
.info-tooltip-align-right::after { left: auto; right: 0; transform: translateY(-4px); }
.info-tooltip-align-right:hover::after,
.info-tooltip-align-right:focus::after { transform: translateY(0); }


.lead-settings-table { min-width: 920px; }
.google-source-settings-table { min-width: 1320px; }
.amo-schedule-table { min-width: 1280px; }
.amo-schedule-table th,
.amo-schedule-table td,
.lead-settings-table th,
.lead-settings-table td,
.google-source-settings-table th,
.google-source-settings-table td { vertical-align: middle; }
.amo-schedule-table td:first-child,
.lead-settings-table td:first-child { min-width: 220px; }
.amo-schedule-table td:nth-child(2) { min-width: 250px; }
.google-source-settings-table td:first-child { min-width: 260px; }
.google-source-settings-table td:nth-child(2) { min-width: 420px; }
.amo-schedule-table td:nth-child(3) { min-width: 760px; }
.amo-schedule-table select,
.lead-settings-table select,
.google-source-settings-table select { min-width: 220px; }
.google-source-settings-table input[type="text"],
.google-source-settings-table input[type="url"] { width: 100%; min-width: 0; }
.lead-settings-status-select { min-width: 180px; }
.lead-settings-delay-input { width: 88px; min-width: 88px; }
.lead-settings-global-row .form-group { min-width: 180px; }
.lead-settings-table-section { border-top: 1px solid var(--border); }
.lead-settings-blacklist { margin-top: 0; }
.lead-settings-blacklist .text-muted { margin-top: 6px; font-size: 13px; }
.source-settings-error { margin-top: 6px; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.text-danger { color: #f28b82; }
.lead-attention-card .card-header { color: var(--text); }
.lead-attention-list { display: grid; gap: 12px; }
.lead-attention-item { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid rgba(255, 167, 38, 0.35); border-radius: var(--radius); background: rgba(255, 167, 38, 0.08); }
.lead-attention-item span { color: var(--text-muted); line-height: 1.45; }
.toggle-checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); cursor: pointer; }
.toggle-checkbox input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.amo-assignment-options { display: grid; gap: 10px; }
.amo-assignment-options .toggle-checkbox { line-height: 1.35; }
.work-day-toggle { display: inline-flex; align-items: center; cursor: pointer; }
.work-day-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.work-day-toggle span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.01); color: var(--text-muted); font-size: 12px; font-weight: 600; }
.work-day-toggle input:checked + span { border-color: var(--primary); background: rgba(0, 170, 255, 0.14); color: var(--primary); }
.work-day-toggle input:focus + span { box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.15); }
.amo-day-schedule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 10px; }
.amo-day-schedule-row { display: grid; grid-template-columns: 46px minmax(250px, 1fr); align-items: center; gap: 10px; min-height: 44px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.015); }
.amo-day-schedule-row .work-day-toggle span { min-width: 40px; }
.amo-schedule-time-range { display: grid; grid-template-columns: minmax(112px, 1fr) auto minmax(112px, 1fr); align-items: center; gap: 8px; min-width: 0; }
.amo-schedule-time-range input[type="time"] { width: 100%; min-width: 112px; padding: 8px 10px; }
.lead-settings-actions { display: flex; justify-content: flex-end; }
@media (max-width: 720px) {
    .amo-schedule-table,
    .lead-settings-table { min-width: 760px; }
    .google-source-settings-table { min-width: 1100px; }
    .amo-schedule-table { min-width: 920px; }
    .amo-schedule-table td:nth-child(3) { min-width: 620px; }
    .lead-settings-table select { min-width: 180px; }
}

.lead-amo-create-form { margin: 8px 0 0; }
.lead-amo-create-form .btn { white-space: nowrap; }

.item-link-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}
.item-meta-grid .system-summary-item strong {
    word-break: break-word;
}
.item-description {
    white-space: pre-wrap;
    line-height: 1.55;
}
.item-description-table {
    min-width: 320px;
    max-width: 620px;
    font-size: 13px;
}
.item-detail-table {
    min-width: 1120px;
}
.item-detail-table .item-text-cell {
    vertical-align: top;
}
.item-current-row td {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}
