/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ── Header / Topbar ──────────────────────────────────────────── */
.topbar {
    background: #1e2a3a;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 52px;
    gap: 0;
}

.topbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    margin-right: 2.5rem;
    letter-spacing: -0.01em;
}

.topbar-brand span {
    font-weight: 400;
    color: #94a3b8;
}

.topbar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    gap: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 1.25rem;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
    border-bottom: 3px solid transparent;
    user-select: none;
}

.nav-link:hover {
    color: #e2e8f0;
}

.nav-link.active {
    color: #ffffff;
    border-bottom-color: #3b82f6;
}

.badge {
    display: inline-block;
    background: #3b82f6;
    color: white;
    font-size: 0.65rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    margin-left: 0.35rem;
    font-weight: 600;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


/* ── User Menu (EmAdmin style) ──────────────────────────── */
.user-menu { position: relative; }
.user-menu-trigger {
    background: transparent; color: rgba(255,255,255,0.7);
    border: none; padding: 6px 0; cursor: pointer;
    font-size: 0.85rem; display: flex; align-items: center; gap: 6px;
    font-family: inherit;
}
.user-menu-trigger:hover { color: #fff; }
.user-menu-caret { font-size: 0.65rem; opacity: 0.5; }
.user-menu-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    background: #1e293b; border: 1px solid #475569; border-radius: 8px;
    padding: 16px 20px; min-width: 240px; max-width: 280px; z-index: 10000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4); text-align: left;
}
.user-menu-dropdown.open { display: block; }
.user-menu-name { font-weight: 600; color: #f8fafc; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-email { color: #64748b; font-size: 0.8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-role { color: #94a3b8; font-size: 0.85rem; margin-top: 4px; }
.user-menu-divider { height: 1px; background: #334155; margin: 12px 0; }
.user-menu-profile {
    display: block; color: #cbd5e1; font-size: 0.85rem;
    padding: 4px 0; text-decoration: none; transition: color 0.15s;
}
.user-menu-profile:hover { color: #fbbf24; }
.user-menu-tenant-label {
    color: #64748b; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 6px;
}
.user-menu-tenant-list { display: flex; flex-direction: column; gap: 2px; }
.user-menu-tenant-item {
    background: none; border: none; color: #94a3b8; cursor: pointer;
    padding: 4px 0; font-size: 0.85rem; text-align: left;
    display: flex; align-items: center; gap: 6px; font-family: inherit;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.user-menu-tenant-item:hover { color: #f8fafc; }
.user-menu-tenant-item.active { color: #f8fafc; font-weight: 500; cursor: default; }
.tenant-check { color: #fbbf24; font-size: 0.75rem; }
.user-menu-single-tenant { color: #f8fafc; font-size: 0.85rem; }
.user-menu-item {
    display: block; color: #cbd5e1; font-size: 0.85rem;
    cursor: pointer; text-decoration: none; padding: 4px 0;
    transition: color 0.15s;
}
.user-menu-item:hover { color: #fbbf24; }
.user-menu-logout {
    background: none; border: none; color: #f87171; cursor: pointer;
    padding: 4px 0; font-size: 0.85rem; font-weight: 500; font-family: inherit;
}
.user-menu-logout:hover { text-decoration: underline; }

/* ── Main ─────────────────────────────────────────────────────── */
main {
    padding: 1.5rem 2rem;
}

/* ── Single Search ───────────────────────────────────────────── */
.single-search-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    max-width: 1400px;
}

.single-search-row {
    display: flex;
    gap: 0.5rem;
}

.single-search-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

.search-help {
    margin-top: 1.25rem;
}

.search-help h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.search-help-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.search-help-card {
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.search-help-icon {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.search-help-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.search-help-example {
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.search-help-example em {
    font-style: normal;
    background: #e0e7ff;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.78rem;
}

.search-help-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
}

@media (max-width: 800px) {
    .search-help-grid {
        grid-template-columns: 1fr;
    }
}

.single-search-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.single-search-error {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #dc2626;
}

.single-search-empty {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.single-search-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
}

.single-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.single-preview-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.single-result-card {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.4rem;
    background: #f8fafc;
}

.single-result-selectable {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    transition: background 0.1s;
}

.single-result-selectable:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.single-result-selectable input[type="checkbox"] {
    margin-top: 0.3rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.single-result-content {
    flex: 1;
    min-width: 0;
}

.single-result-top {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.single-result-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.single-result-addr {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.single-result-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.single-result-details a {
    color: var(--primary);
    text-decoration: none;
}

.single-result-details a:hover {
    text-decoration: underline;
}

.single-result-saved {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.single-result-saved-badge {
    font-size: 0.7rem;
    color: var(--success);
    background: #dcfce7;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
}

/* ── Search Layout ────────────────────────────────────────────── */
.search-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    max-width: 1400px;
}

@media (max-width: 900px) {
    .search-layout {
        grid-template-columns: 1fr;
    }
}

.branchen-panel,
.crawl-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* ── Branchen Tree ────────────────────────────────────────────── */
#branchen-tree {
    max-height: 65vh;
    overflow-y: auto;
}

.branchen-section {
    margin-bottom: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.branchen-section-header {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    background: #f8fafc;
    border-radius: 6px;
}

.branchen-section-header:hover {
    background: #f1f5f9;
}

.branchen-section-header .arrow {
    font-size: 0.7rem;
    transition: transform 0.15s;
    color: var(--text-muted);
}

.branchen-section-header.expanded .arrow {
    transform: rotate(90deg);
}

.branchen-section-header .count {
    margin-left: auto;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.branchen-section-body {
    padding: 0.25rem 0.75rem 0.5rem 2rem;
    display: none;
}

.branchen-section-body.open {
    display: block;
}

.branchen-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0;
    font-size: 0.8rem;
}

.branchen-category input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ── Crawl Panel ──────────────────────────────────────────────── */
.crawl-config {
    margin-bottom: 1rem;
}

.crawl-config label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.crawl-config input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

#crawl-progress {
    margin-top: 1rem;
    max-height: 50vh;
    overflow-y: auto;
}

.group-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid #f1f5f9;
}

.group-status .icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.group-status .name {
    flex: 1;
}

.group-status .count-label {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.enrich-cancel {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    margin-left: 6px;
    vertical-align: middle;
}

.enrich-cancel:hover {
    color: #dc2626;
}

.crawl-summary {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
}

.missing-info {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.btn:hover {
    background: var(--bg);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-lg {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 0.25rem;
}

/* ── Results Toolbar ──────────────────────────────────────────── */
.toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.toolbar input {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

#search-input {
    width: 100%;
    font-size: 1.1rem;
    padding: 0.6rem 1.2rem;
    text-align: center;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    box-sizing: border-box;
}

#search-input:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.toolbar-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

#origin-input {
    min-width: 200px;
}

.origin-warning {
    display: inline-block;
    margin-left: 4px;
    color: #f59e0b;
    font-size: 14px;
    cursor: help;
    vertical-align: middle;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

.count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Actions Dropdown ─────────────────────────────────────────── */
.actions-dropdown {
    position: relative;
}

.actions-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    z-index: 100;
    padding: 0.25rem 0;
}

.actions-menu.open {
    display: block;
}

.actions-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.75rem;
    border: none;
    background: none;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text);
}

.actions-menu button:hover:not(:disabled) {
    background: var(--bg);
}

.actions-menu button:disabled {
    color: #aaa;
    cursor: default;
}

.actions-menu button.actions-danger {
    color: #dc2626;
}

.actions-menu button.actions-danger:hover {
    background: #fef2f2;
}

.actions-group-label {
    padding: 0.3rem 0.75rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.actions-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* ── Export Dropdown ──────────────────────────────────────────── */
.export-dropdown {
    position: relative;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
    color: var(--text);
    background: var(--bg);
}

/* Google Autocomplete dropdown styling */
.pac-container {
    z-index: 10000 !important;
    font-size: 0.85rem;
}

/* ── Toggle Label (used in single search) ──────────────────────── */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ── Danger Button ───────────────────────────────────────────── */
.btn-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* ── AG Grid ──────────────────────────────────────────────────── */
#grid {
    height: calc(100vh - 160px);
    width: 100%;
}

.ag-theme-alpine {
    --ag-header-background-color: #f8fafc;
    --ag-row-hover-color: #f1f5f9;
}

.ag-theme-alpine .ag-row {
    cursor: pointer;
}

.ag-theme-alpine [col-id="email"] .ag-cell-value {
    text-overflow: clip;
    overflow: hidden;
}

.ag-theme-alpine .ag-selection-checkbox,
.ag-theme-alpine .ag-checkbox-input-wrapper,
.ag-theme-alpine .ag-checkbox-input-wrapper input {
    pointer-events: all;
    cursor: pointer;
}

/* Floating filter: compact spacing */
.ag-theme-alpine .ag-floating-filter-body {
    padding: 0 1px;
}


.ag-theme-alpine .ag-floating-filter-full-body {
    padding: 0 1px;
}

.ag-theme-alpine .ag-header-row-floating-filter .ag-header-cell {
    padding-left: 2px;
    padding-right: 2px;
}

/* Floating filter inputs */
.ag-theme-alpine .ag-floating-filter-input input {
    font-size: 0.8rem;
}

/* ── Unified Side Panel ───────────────────────────────────────── */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 33%;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.side-panel.open {
    transform: translateX(0);
}



/* Panel header / body / footer structure */
.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card, var(--surface));
    gap: 0.5rem;
    flex-shrink: 0;
}

.side-panel-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.side-panel-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.side-panel-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.side-panel-close:hover {
    background: var(--bg);
}

.side-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.side-panel-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-card, var(--surface));
}

/* Panel-results shrinks when side panel is open */
#panel-results.side-panel-open {
    width: 67%;
    transition: width 0.25s ease;
}

/* ── Panel Header ─────────────────────────────────────────────── */
.detail-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.detail-header-top {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.7rem 1rem 0.4rem;
}

.detail-header-name {
    flex: 1;
    min-width: 0;
}

.detail-header-name h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-header-name .detail-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(248, 250, 252, 0.4);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.detail-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    white-space: nowrap;
}

.detail-action-btn svg {
    width: 14px;
    stroke: #64748b;
    stroke-width: 2.2px;
    flex-shrink: 0;
    transition: stroke 0.2s ease;
}

.detail-action-btn span {
    line-height: 1;
}

.detail-action-btn:hover {
    transform: translateY(-1px);
    background: #334155;
    border-color: #1e293b;
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.detail-action-btn:hover svg {
    stroke: #ffffff;
}

.detail-action-btn:active {
    transform: translateY(0);
}

.detail-action-overflow {
    position: relative;
    display: inline-block;
}

.detail-action-overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 300;
    min-width: 160px;
    padding: 4px 0;
}

.detail-action-overflow-menu.open {
    display: block;
}

.detail-action-overflow-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 14px;
    font-size: 0.8rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
}

.detail-action-overflow-menu button:hover {
    background: var(--bg);
}

.detail-action-overflow-menu button.danger {
    color: #dc2626;
}

/* ── Panel Body (scrollable) ──────────────────────────────────── */
.detail-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Sections */
.detail-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.detail-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.detail-fields {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 0.15rem 0.4rem;
    align-items: baseline;
}

.detail-field {
    font-size: 0.82rem;
    display: contents;
}

.detail-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 0;
    align-self: baseline;
}

.detail-value {
    font-size: 0.82rem;
    padding: 2px 0;
    min-width: 0;
}

.detail-code {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Inline editable inputs */
.detail-edit {
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.82rem;
    font-family: inherit;
    padding: 1px 4px;
    border-radius: 3px;
    width: 100%;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
    min-width: 0;
}

.detail-edit:hover {
    border-color: var(--border);
    background: #fff;
}

.detail-edit:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

/* Tags row */
.detail-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* DSGVO / status badges */
.detail-dsgvo-badge {
    font-size: 0.72rem;
    letter-spacing: 1px;
    padding: 1px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.detail-dsgvo-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Screenshot section */
.detail-company-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.detail-company-row .detail-fields {
    flex: 1;
    min-width: 0;
}

.detail-screenshot-col {
    flex-shrink: 0;
    width: 120px;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-screenshot-placeholder {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screenshot-placeholder-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
}

.detail-screenshot-img {
    width: 100%;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    object-fit: cover;
    object-position: top;
    height: auto;
    display: block;
}

.detail-screenshot-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    font-size: 11px;
}

/* Lead / contact cards */
.detail-contact-card {
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.4rem;
    background: var(--bg);
}

.detail-contact-card:last-child {
    margin-bottom: 0;
}

.detail-dsgvo-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    padding: 0.3rem 0.5rem;
    border-left: 2px solid var(--border);
    line-height: 1.4;
}

.detail-contact-role {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.detail-contact-fields {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 0.1rem 0.4rem;
    align-items: baseline;
}

/* Lead action buttons */
.detail-lead-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* Expert tools */
.detail-expert-area {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.detail-expert-heading {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.detail-expert-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.detail-expert-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.expert-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.expert-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.expert-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.expert-btn-icon {
    font-size: 0.85rem;
}

.expert-result {
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.75rem;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
}

.expert-result-header {
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.expert-result-body li {
    margin-left: 1.2rem;
    list-style-type: disc;
}

/* Cached expert button state */
.expert-btn.expert-cached {
    background: #f0fdf4;
    border-color: #86efac;
}

.expert-btn.expert-cached:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.expert-cached-dot {
    color: #22c55e;
    font-size: 8px;
    margin-left: 2px;
    vertical-align: middle;
}

/* Close button (top-right of header) */
.detail-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.detail-close:hover {
    background: var(--bg);
    color: var(--text);
}

/* Trash & Download mini-icons */
.expert-trash,
.expert-download {
    font-size: 10px;
    margin-left: 2px;
    opacity: 0.4;
    cursor: pointer;
    vertical-align: middle;
    transition: opacity 0.15s;
}

.expert-trash:hover {
    opacity: 1;
}

.expert-download:hover {
    opacity: 1;
}

/* Cached/New badges in result header */
.expert-cached-badge,
.expert-new-badge {
    font-size: 10px;
    font-weight: 400;
    color: #888;
    margin-left: auto;
}

.expert-date-label {
    font-size: 10px;
    font-weight: 400;
    color: #999;
}

/* ── Markdown rendered content (tables, headings, etc) ────────── */

.md-rendered h1 {
    font-size: 1rem;
    font-weight: 700;
    margin: 10px 0 6px;
}

.md-rendered h2 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 10px 0 4px;
}

.md-rendered h3 {
    font-size: 0.82rem;
    font-weight: 600;
    margin: 8px 0 4px;
}

.md-rendered h4 {
    font-size: 0.78rem;
    font-weight: 600;
    margin: 6px 0 2px;
}

.md-rendered p {
    margin: 4px 0;
}

.md-rendered hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.md-rendered table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.7rem;
    line-height: 1.35;
    table-layout: auto;
}

.md-rendered th {
    background: #f1f5f9;
    font-weight: 600;
    text-align: left;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

.md-rendered td {
    padding: 3px 6px;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    word-break: break-word;
}

.md-rendered tr:nth-child(even) {
    background: #fafbfc;
}

.md-rendered tr:hover {
    background: #f0f4ff;
}

.md-rendered code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.7rem;
}

.md-rendered pre {
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.7rem;
}

.md-rendered blockquote {
    border-left: 3px solid var(--primary);
    margin: 6px 0;
    padding: 4px 10px;
    color: #555;
    background: #fafbfc;
}

.md-rendered ol,
.md-rendered ul {
    margin: 4px 0 4px 1.5rem;
}

.md-rendered li {
    margin-bottom: 2px;
}

.detail-edit {
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 2px 4px;
    border-radius: 3px;
    width: 100%;
    max-width: 320px;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.detail-edit:hover {
    border-color: var(--border);
    background: #fff;
}

.detail-edit:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.detail-description .detail-edit {
    max-width: 100%;
}

.detail-panel a {
    color: var(--primary);
    text-decoration: none;
}

.detail-panel a:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .detail-body {
        grid-template-columns: 1fr;
    }

    .detail-description {
        grid-column: 1 / -1;
    }
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 64px;
    right: 2rem;
    background: #1e293b;
    color: #fff;
    padding: 0.65rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: toastIn 0.2s ease-out, toastOut 0.3s ease-in forwards;
    animation-delay: 0s, 3.5s;
}

.toast.toast-error {
    background: #dc2626;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* ── Confirm Modal ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.15s ease-out;
}

.modal-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem 1.75rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.2s ease-out;
}

.modal-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.modal-card p {
    margin: 0 0 1.25rem;
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.5;
    white-space: pre-line;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-actions button {
    padding: 0.45rem 1rem;
    border-radius: 6px;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.modal-actions button:active {
    transform: scale(0.97);
}

.modal-btn-cancel {
    background: #e2e8f0;
    color: #475569;
}

.modal-btn-cancel:hover {
    background: #cbd5e1;
}

.modal-btn-confirm {
    background: #3b82f6;
    color: #fff;
}

.modal-btn-confirm:hover {
    background: #2563eb;
}

.modal-btn-danger {
    background: #dc2626;
    color: #fff;
}

.modal-btn-danger:hover {
    background: #b91c1c;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Tag Badges (AG Grid cells) ──────────────────────────── */
.tag-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
    margin: 1px 2px;
    line-height: 1.4;
}

/* ── Tag Modal Chips ────────────────────────────────────── */
.tag-modal-existing {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--tag-bg, #f1f5f9);
    color: var(--tag-text, #475569);
    border: 1.5px solid var(--tag-border, #e2e8f0);
    opacity: 0.5;
    transition: all 0.15s;
    user-select: none;
}

.tag-chip:hover {
    opacity: 0.8;
}

.tag-chip.tag-chip-active {
    opacity: 1;
    box-shadow: 0 0 0 2px var(--tag-border, #93c5fd);
}

.tag-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tag-text-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}

.tag-text-input:focus {
    outline: none;
    border-color: var(--primary);
}

.tag-badge-x {
    margin-left: 4px;
    cursor: pointer;
    font-weight: 700;
    opacity: 0.5;
    font-size: 0.85em;
}

.tag-badge-x:hover {
    opacity: 1;
}

.tag-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px dashed #94a3b8;
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}

.tag-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.tag-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 40px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    max-height: 180px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    margin-top: 4px;
}

.tag-autocomplete-dropdown.visible {
    display: block;
}

.tag-autocomplete-item {
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.1s;
}

.tag-autocomplete-item:hover {
    background: #f1f5f9;
}

/* ── Tag Set Filter (AG Grid custom filter) ─────────────── */
.tag-set-filter {
    padding: 8px;
    min-width: 180px;
    max-height: 300px;
    overflow-y: auto;
}

.tag-set-filter-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tag-set-filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.tag-set-filter-item:hover {
    background: #f1f5f9;
}

.tag-set-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.tag-set-filter-actions {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
}

.tag-set-filter-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
}

.tag-set-filter-btn:hover {
    color: #2563eb;
}

/* ── Country Header Filter ─────────────────────────────────── */
.country-header-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    height: 100%;
}

.country-header-label {
    flex: 1;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.country-header-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 1px 3px;
    font-size: 0.7rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    flex-shrink: 0;
}

.country-header-btn:hover,
.country-header-btn.active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.country-dropdown {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
}

.country-dd-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.8rem;
}

.country-dd-item:hover {
    background: #f1f5f9;
}

.country-dd-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.country-code {
    font-weight: 600;
    font-family: monospace;
    color: #1e40af;
    width: 2.2ch;
    flex-shrink: 0;
}

.country-name {
    flex: 1;
    color: #334155;
}

.country-count {
    color: #94a3b8;
    font-size: 0.72rem;
}

.country-dd-sep {
    border-top: 1px solid #e2e8f0;
    margin: 4px 0;
}

.country-dd-footer {
    border-top: 1px solid #e2e8f0;
    padding: 6px 12px 4px;
}

.country-dd-reset {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
}

.country-dd-reset:hover {
    color: #2563eb;
}

.tag-floating-filter {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.tag-floating-label {
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.tag-floating-label.active {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.floating-filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #ef4444;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}

.floating-filter-clear:hover {
    background: #fef2f2;
    color: #dc2626;
}

.floating-filter-clear svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
}

.floating-filter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}

.floating-filter-icon:hover {
    background: #f1f5f9;
    color: #64748b;
}

.floating-filter-icon svg {
    width: 12px;
    height: 12px;
    pointer-events: none;
}

.global-filter-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #ef4444;
    cursor: pointer;
    overflow: visible;
}

.global-filter-clear:hover {
    color: #dc2626;
}

.global-filter-clear svg {
    min-width: 18px;
    min-height: 18px;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* ── Email Modal ─────────────────────────────────────────── */
.email-modal-card {
    max-width: 720px !important;
}

.email-modal-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
}

.email-count-ok {
    color: #16a34a;
    font-weight: 600;
}

.email-count-skip {
    color: #f59e0b;
}

.email-modal-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0.75rem;
}

.email-tab {
    padding: 6px 14px;
    border: none;
    background: none;
    font-size: 0.78rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.email-tab:hover {
    color: #1e293b;
}

.email-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.email-editor-selectors {
    display: flex;
    gap: 12px;
    margin-bottom: 0.6rem;
}

.email-selector-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
}

.email-selector-group label {
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}

.email-selector-group select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    background: #fff;
}

.email-subject-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.5rem;
}

.email-subject-row label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.email-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}

.email-input:focus {
    outline: none;
    border-color: var(--primary);
}

.email-input-sm {
    font-size: 0.78rem;
    padding: 4px 8px;
}

.email-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.etb {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #475569;
}

.etb:hover {
    background: #e2e8f0;
}

.etb-sep {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
    margin: 0 2px;
}

.etb-field-select {
    padding: 3px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.72rem;
    color: #64748b;
    background: #fff;
    cursor: pointer;
    margin-left: auto;
}

.email-editor-area {
    min-height: 180px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    font-size: 0.82rem;
    line-height: 1.6;
    background: #fff;
    white-space: pre-wrap;
    outline: none;
}

.email-editor-area:focus {
    border-color: var(--primary);
}

.email-dirty-hint {
    font-size: 0.78rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.email-save-tpl-row {
    display: flex;
    gap: 6px;
    margin-top: 0.5rem;
    align-items: center;
}

.email-save-tpl-row .email-input-sm {
    flex: 1;
}

#email-save-scope {
    flex: 0 0 auto;
    max-width: 160px;
    font-size: 0.78rem;
}

.btn-outline {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-danger-outline {
    border-color: #fca5a5;
    color: #dc2626;
}

.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #f87171;
}

/* ── Template Manager ──────────────────────────────── */
.email-tpl-manager {
    max-height: 320px;
    overflow-y: auto;
}

.tpl-mgr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid #f1f5f9;
}

.tpl-mgr-row:last-child {
    border-bottom: none;
}

.tpl-mgr-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.tpl-mgr-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
}

.tpl-mgr-subject {
    font-size: 0.75rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpl-mgr-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tpl-mgr-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 10px 4px 4px;
    border-top: 1px solid #e2e8f0;
    margin-top: 4px;
}

.tpl-mgr-group-label:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 4px;
}

.email-recipient-list {
    max-height: 250px;
    overflow-y: auto;
}

.email-recipient-row,
.email-result-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.78rem;
    border-bottom: 1px solid #f1f5f9;
}

.email-recipient-name {
    font-weight: 600;
    min-width: 150px;
}

.email-recipient-email {
    color: #2563eb;
}

.email-recipient-contact {
    color: #64748b;
    margin-left: auto;
}

.email-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.email-progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

/* ── Pipeline Toolbar ────────────────────────────────────────────── */
.pipeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 0.5rem;
}

.pipeline-toolbar-left,
.pipeline-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pipeline-select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface);
}

.pipeline-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Kanban Board ────────────────────────────────────────────────── */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 0 0.5rem 1rem;
    min-height: 400px;
    align-items: flex-start;
}

.kanban-column {
    min-width: 220px;
    max-width: 300px;
    flex: 1;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s;
}

.kanban-column-dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.kanban-column-header {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-step-label {
    font-weight: 600;
    font-size: 0.82rem;
}

.kanban-step-meta {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.kanban-cards {
    padding: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 60px;
}

/* ── Kanban Card ─────────────────────────────────────────────────── */
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    cursor: grab;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.kanban-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card-dragging {
    opacity: 0.4;
}

.kanban-card-name {
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 2px;
}

.kanban-card-company {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kanban-card-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.72rem;
}

.kanban-card-value {
    font-weight: 600;
    color: var(--success);
}

.kanban-card-owner {
    color: var(--text-muted);
}

/* ── Won/Lost Columns Row ────────────────────────────────────────── */
.kanban-summary-row {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
    padding: 0 0.5rem 1rem;
    overflow-x: auto;
    align-items: flex-start;
}

/* Inbox-Spalte (Step 0) */
.kanban-column-inbox {
    border-color: #e0e7ff;
    background: #f5f7ff;
    opacity: 0.92;
}

.kanban-column-inbox .kanban-column-header {
    background: #e0e7ff;
}

.kanban-column-inbox .kanban-step-label {
    color: #3730a3;
}

/* Lead-Detail-Modal Erweiterungen */
.lead-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin: 12px 0 4px;
    border-top: 1px solid #f3f4f6;
    padding-top: 10px;
}

.lead-gdpr-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    color: #166534;
    margin-bottom: 10px;
}

.lead-gdpr-bar.lead-gdpr-warn {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.kanban-column-won {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.kanban-column-won .kanban-column-header {
    background: #dcfce7;
}

.kanban-column-won .kanban-step-label {
    color: #166534;
}

.kanban-column-lost {
    border-color: #fecaca;
    background: #fef2f2;
}

.kanban-column-lost .kanban-column-header {
    background: #fee2e2;
}

.kanban-column-lost .kanban-step-label {
    color: #991b1b;
}

.kanban-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
    font-size: 0.9rem;
    width: 100%;
}

/* ── Lead Form / Inputs ──────────────────────────────────────────── */
.lead-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lead-input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
}

.lead-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.lead-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
    margin-top: 0.5rem;
}

.lead-detail-field {
    font-size: 0.82rem;
}

.lead-detail-desc {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ── Pipeline Steps Editor ───────────────────────────────────────── */
.pl-steps-editor {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.pl-step-row,
.wh-row,
.action-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    align-items: center;
}

.actions-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.pl-step-remove {
    cursor: pointer;
    color: #dc2626;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
}

.pl-step-remove:hover {
    color: #b91c1c;
}

.btn-danger-outline {
    color: #dc2626;
    border: 1px solid #fca5a5;
    background: transparent;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-danger-outline:hover {
    background: #fef2f2;
}

/* ── Drop Comment Modal ─────────────────────────────────────────── */
.drop-modal-row {
    display: flex;
    gap: 12px;
}

.drop-modal-row .drop-modal-field {
    flex: 1;
}

.drop-modal-field {
    margin-bottom: 0.5rem;
}

.drop-modal-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Settings Layout ────────────────────────────────────────────── */
.settings-layout {
    display: flex;
    min-height: calc(100vh - 100px);
}

.settings-sidebar {
    width: 220px;
    background: #f8fafc;
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.settings-nav-link {
    display: block;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: all 0.12s;
}

.settings-nav-link:hover {
    color: var(--text);
    background: #f1f5f9;
}

.settings-nav-link.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: #eff6ff;
    font-weight: 600;
}

.settings-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.settings-content h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: #1e293b;
}

.settings-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

/* ── Tag Settings ─────────────────────────────────────────────── */
.tag-settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.tag-settings-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.tag-settings-row td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.tag-settings-row--hidden td {
    opacity: 0.5;
}

.tag-settings-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.tag-settings-divider td {
    padding: 0.6rem 0.75rem 0.3rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

/* Toggle switch */
.tag-visibility-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.tag-visibility-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tag-toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: #94a3b8;
    cursor: pointer;
    transition: background 0.2s;
}

.tag-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tag-visibility-toggle input:checked+.tag-toggle-slider {
    background: #22c55e;
}

.tag-visibility-toggle input:checked+.tag-toggle-slider::before {
    transform: translateX(16px);
}

.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.settings-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.settings-table tbody tr:hover {
    background: #f8fafc;
}

.settings-source-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.settings-source-global {
    background: #dbeafe;
    color: #1e40af;
}

.settings-source-tenant {
    background: #e0e7ff;
    color: #3730a3;
}

.settings-item-disabled {
    opacity: 0.5;
}

.topbar-logout {
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 0.3rem;
    margin-left: 0.3rem;
    color: #94a3b8;
}

.topbar-logout:hover {
    color: #fff;
}

/* ── Queue Grid ─────────────────────────────────────────────────── */
.queue-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 120px);
}

.queue-grid-area {
    flex: 1;
    min-width: 0;
}

/* queue-preview content styles (rendered inside side-panel-body) */

.queue-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    flex-shrink: 0;
}

.queue-preview-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #0f172a;
}

.queue-preview-body {
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
}

.queue-preview-field {
    margin-bottom: 0.75rem;
}

.queue-preview-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.queue-preview-subject {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.queue-preview-html {
    font-size: 0.88rem;
    line-height: 1.7;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    background: #fafbfc;
    color: #334155;
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
}

.queue-preview-html p {
    margin: 0.5em 0;
}

.queue-preview-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.queue-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
    display: inline-block;
}

.queue-expand-arrow {
    display: inline-block;
    font-size: 0.7rem;
    width: 1rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s;
    color: var(--text-muted);
}

.queue-expand-arrow.expanded {
    transform: rotate(90deg);
}

.queue-count-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 8px;
    margin-right: 3px;
}

.queue-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.qact-approve {
    color: #166534 !important;
    background: #dcfce7 !important;
    border-color: #bbf7d0 !important;
}

.qact-approve:hover {
    background: #bbf7d0 !important;
}

.qact-reject {
    color: #991b1b !important;
    background: #fee2e2 !important;
    border-color: #fecaca !important;
}

.qact-reject:hover {
    background: #fecaca !important;
}

.qact-undo {
    color: #64748b !important;
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
}

.qact-undo:hover {
    background: #e2e8f0 !important;
}

.qact-delete {
    color: #dc2626 !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    padding: 0.15rem 0.4rem !important;
    opacity: 0.4;
}

.qact-delete:hover {
    opacity: 1;
}

.queue-dispatch-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.queue-dispatch-badge.auto {
    background: #dcfce7;
    color: #166534;
}

.queue-dispatch-badge.delay {
    background: #fff7ed;
    color: #c2410c;
}

.queue-countdown {
    font-size: 0.78rem;
    font-weight: 600;
    color: #c2410c;
    margin-left: 6px;
}

.qact-cancel {
    border-color: #f97316 !important;
    color: #f97316 !important;
    font-size: 0.78rem !important;
}

.qact-cancel:hover {
    background: #fff7ed !important;
}

@media (max-width: 900px) {
    .queue-layout {
        flex-direction: column;
    }
}

/* ── KI-Assistent Chat (inside unified side-panel) ───────────────── */

.assistant-web-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary, var(--text-muted));
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-hover, var(--bg));
}

.assistant-web-toggle input {
    margin: 0;
}

.assistant-web-toggle:has(input:checked) {
    background: var(--accent, var(--primary));
    color: #fff;
}

/* Toggle button active state */
#assistant-toggle-btn.active {
    background: var(--accent, var(--primary));
    color: #fff;
}

/* Messages */
.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.assistant-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}

/* Chat bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    word-break: break-word;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble.ai code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.78rem;
}

.chat-bubble.error {
    border-color: var(--danger);
    color: var(--danger);
}

/* Typing animation */
.chat-bubble.typing {
    animation: typing-pulse 1.2s infinite;
    font-size: 1.1rem;
    letter-spacing: 2px;
    padding: 0.4rem 0.75rem;
}

@keyframes typing-pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* Tool call chips */
.chat-tool-chip {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.chat-tool-chip.done {
    border-color: var(--success);
    color: var(--success);
}

.chip-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: chip-spin 0.8s linear infinite;
}

@keyframes chip-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Input area */
.assistant-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.6rem 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

#assistant-input {
    flex: 1;
    resize: none;
    overflow-y: auto;
    max-height: 120px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
}

#assistant-input:focus {
    border-color: var(--accent);
}

.assistant-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.1s, opacity 0.2s;
}

.assistant-send-btn:hover {
    transform: scale(1.05);
}

.assistant-send-btn:active {
    transform: scale(0.95);
}

/* Responsive: mobile */
@media (max-width: 768px) {
    .side-panel {
        width: 100vw;
    }
}