body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
}

html.dark body {
    background-color: #0f172a;
}

.badge-anonymous {
    background-color: #fef3c7;
    color: #92400e;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

html.dark .badge-anonymous {
    background-color: #78350f;
    color: #fbbf24;
}

.badge-known {
    background-color: #d1fae5;
    color: #065f46;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

html.dark .badge-known {
    background-color: #064e3b;
    color: #34d399;
}

.timeline-item {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.25rem;
    border-left: 2px solid #e2e8f0;
}

html.dark .timeline-item {
    border-left-color: #334155;
}

.timeline-item:last-child {
    border-left: 2px solid transparent;
}

.timeline-dot {
    position: absolute;
    left: -7px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #3b82f6;
}

.timeline-dot.identify {
    background-color: #10b981;
}

.timeline-dot.form {
    background-color: #f59e0b;
}

.timeline-dot.event {
    background-color: #ea580c;
}

.contact-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.contact-row:hover {
    background-color: #f1f5f9;
}

html.dark .contact-row:hover {
    background-color: #1e293b;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

html.dark .stat-card {
    background: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.filter-input {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    background: white;
    color: #1e293b;
}

html.dark .filter-input {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.filter-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

html.dark .filter-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background-color 0.15s;
    cursor: pointer;
    border: none;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-secondary {
    background-color: white;
    color: #374151;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: background-color 0.15s;
}

html.dark .btn-secondary {
    background-color: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

html.dark .btn-secondary:hover {
    background-color: #475569;
}

.pagination-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    background: white;
    color: #374151;
}

html.dark .pagination-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

.pagination-btn:hover {
    background-color: #f3f4f6;
}

html.dark .pagination-btn:hover {
    background-color: #475569;
}

.pagination-btn.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

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

/* Session group in timeline */
.timeline-session {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.timeline-session-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

html.dark .timeline-session-header {
    color: #64748b;
}

/* Page flow arrows */
.page-flow {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.page-flow-item {
    font-size: 0.7rem;
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.dark .page-flow-item {
    background: #334155;
    color: #94a3b8;
}

.page-flow-arrow {
    color: #cbd5e1;
    font-size: 0.6rem;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.toast {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

html.dark .toast {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.toast-success {
    border-left: 3px solid #10b981;
}

.toast-info {
    border-left: 3px solid #3b82f6;
}

.toast-icon {
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
    color: #374151;
}

html.dark .toast-text {
    color: #e2e8f0;
}

.toast-close {
    cursor: pointer;
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.toast-close:hover {
    color: #64748b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-exit {
    animation: slideOut 0.3s ease-in forwards;
}

/* Timeline filter buttons */
.timeline-filter-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

html.dark .timeline-filter-btn {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

.timeline-filter-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.timeline-filter-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Responsive filters panel */
@media (max-width: 767px) {
    .filters-collapsed #filter-panel {
        display: none;
    }
}

/* ── Sortable table headers ─────────────────────────────────── */
.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.sortable:hover {
    color: #2563eb !important;
}

html.dark .sortable:hover {
    color: #60a5fa !important;
}

.sort-indicator {
    font-size: 0.65em;
    font-weight: 700;
    margin-left: 0.25rem;
}

.sort-asc .sort-indicator,
.sort-desc .sort-indicator {
    color: #2563eb;
}

html.dark .sort-asc .sort-indicator,
html.dark .sort-desc .sort-indicator {
    color: #60a5fa;
}

/* Mobile-friendly tap targets */
@media (max-width: 767px) {
    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .filter-input {
        min-height: 44px;
    }

    .pagination-btn {
        min-height: 40px;
        min-width: 40px;
    }
}

/* ── Form Builder (admin) ───────────────────────────────────
   Scoped classes so the builder never depends on Tailwind utility
   classes that may be missing from the precompiled tailwind.css.
*/
.fb-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(15, 23, 42, 0.55);
    display: none; align-items: stretch; justify-content: center;
}
/* .is-open (two-class specificity) overrides .fb-overlay and Tailwind's .hidden,
   so the editor is hidden on load and shown only via openEditor(). */
.fb-overlay.is-open { display: flex; }
.fb-sheet {
    background: #fff; width: 100%; max-width: 1280px;
    display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
}
.dark .fb-sheet { background: #1e293b; }

.fb-topbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
}
.dark .fb-topbar { background: #0f172a; border-color: #334155; }

.fb-body {
    flex: 1; display: grid; grid-template-columns: 200px 1fr 300px;
    gap: 1px; background: #e2e8f0; overflow: hidden; min-height: 0;
}
.dark .fb-body { background: #334155; }
.fb-col { background: #fff; overflow-y: auto; padding: 16px; }
.dark .fb-col { background: #1e293b; }
@media (max-width: 900px) { .fb-body { grid-template-columns: 1fr; } }

.fb-section { font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: #94a3b8; font-weight: 600; margin: 0 0 8px; }

.fb-palette-btn {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
    border: 1px dashed #cbd5e1; border-radius: 8px; background: transparent;
    color: #334155; font-size: 13px; text-align: left;
}
.fb-palette-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.dark .fb-palette-btn { border-color: #475569; color: #cbd5e1; }
.dark .fb-palette-btn:hover { border-color: #3b82f6; color: #93c5fd; background: rgba(59,130,246,.1); }

.fb-canvas-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px;
    border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; cursor: grab;
}
.fb-canvas-item.fb-selected { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.2); }
.fb-canvas-item:hover { border-color: #93c5fd; }
.dark .fb-canvas-item { background: #0f172a; border-color: #334155; }
.fb-grip { color: #94a3b8; cursor: grab; user-select: none; font-size: 16px; }
.fb-field-meta { flex: 1; min-width: 0; }
.fb-field-meta .t { font-size: 13px; font-weight: 600; color: #1e293b; }
.dark .fb-field-meta .t { color: #e2e8f0; }
.fb-field-meta .s { font-size: 11px; color: #94a3b8; }
.fb-tag { font-size: 10px; padding: 1px 7px; border-radius: 9999px; background: #e0e7ff; color: #3730a3; }
.dark .fb-tag { background: rgba(99,102,241,.2); color: #c7d2fe; }

.fb-tabbar { display: flex; gap: 4px; border-bottom: 1px solid #e2e8f0; margin-bottom: 14px; flex-wrap: wrap; }
.dark .fb-tabbar { border-color: #334155; }
.fb-tab { padding: 7px 14px; font-size: 13px; color: #64748b; cursor: pointer; border-bottom: 2px solid transparent; }
.dark .fb-tab { color: #94a3b8; }
.fb-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.fb-row-3 { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr; gap: 8px; margin-bottom: 8px; align-items: end; }
.fb-prop-label { font-size: 11px; color: #64748b; margin-bottom: 4px; display: block; }
.dark .fb-prop-label { color: #94a3b8; }
.fb-card { border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.dark .fb-card { border-color: #334155; }
.fb-mini-btn { font-size: 12px; padding: 5px 10px; border-radius: 7px; border: 1px solid #cbd5e1;
    background: #fff; color: #334155; cursor: pointer; }
.dark .fb-mini-btn { background: #0f172a; color: #cbd5e1; border-color: #475569; }
.fb-mini-btn:hover { border-color: #2563eb; color: #2563eb; }
.fb-mini-btn.danger:hover { border-color: #dc2626; color: #dc2626; }
.fb-code { background: #0f172a; color: #4ade80; padding: 10px; border-radius: 8px; font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.fb-device-toggle { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.fb-device-toggle button { padding: 6px 14px; font-size: 12px; background: transparent; border: 0; cursor: pointer; color: #64748b; }
.dark .fb-device-toggle button { color: #cbd5e1; }
.fb-device-toggle button.active { background: #2563eb; color: #fff; }
.fb-preview-wrap { display: flex; justify-content: center; padding: 24px; background: #f1f5f9; border-radius: 10px; }
.dark .fb-preview-wrap { background: #0b1220; }
.fb-preview-device { width: 100%; max-width: 640px; transition: max-width .25s ease; }
.fb-preview-device.mobile { max-width: 380px; }
.fb-empty { text-align: center; color: #94a3b8; font-size: 13px; padding: 24px; border: 1px dashed #cbd5e1; border-radius: 10px; }
.dark .fb-empty { border-color: #334155; }
.fb-when-builder { border-left: 3px solid #93c5fd; padding-left: 10px; margin-top: 8px; }
