:root {
    --primary: #2dd4bf;
    --secondary: #a78bfa;
    --background: #0a0f1e;
    --surface: #111827;
    --on-surface: #dee1f7;
    --on-surface-muted: #8899bb;
    --input-bg: #1a2235;
    --border: #1e2d45;
    --muted: #64748b;
}

* { box-sizing: border-box; }

body {
    background-color: var(--background);
    color: var(--on-surface);
    font-family: 'Manrope', sans-serif;
    margin: 0;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'Playfair Display', serif;
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #f5f0e8, #2dd4bf, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Starfield — three parallax layers ───────────── */
.star-layer {
    position: fixed;
    inset: -80px;           /* oversized: stars stay in-frame during parallax shift */
    pointer-events: none;
    z-index: -1;
    will-change: transform;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0.2;
    animation: twinkle var(--duration) infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.12; }
    50%       { opacity: 0.50; }
}

/* ── Ambient glow ────────────────────────────────── */
.ambient-glow {
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 140%;
    height: 65vh;
    background: radial-gradient(ellipse at center,
        rgba(45, 212, 191, 0.12) 0%,
        rgba(167, 139, 250, 0.06) 45%,
        transparent 70%);
    filter: blur(90px);
    pointer-events: none;
    z-index: -1;
}

/* ── Combined sticky top bar ─────────────────────── */
.site-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    height: 50px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(16px);
    background: rgba(10, 15, 30, 0.80);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.health-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 4px 11px;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 7px #22c55e88;
    flex-shrink: 0;
    transition: background 0.4s, box-shadow 0.4s;
}

.status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 7px #ef444488;
}

/* ── Tab Navigation (inside site-header) ─────────── */
.tab-nav {
    display: flex;
    gap: 2px;
    align-items: center;
    flex: 1;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
    height: 100%;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-family: 'Manrope', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    height: 34px;
}

.tab-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tab-btn:hover {
    color: var(--on-surface);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn:hover svg { opacity: 1; }

.tab-btn.active {
    color: var(--primary);
    background: rgba(45, 212, 191, 0.09);
    border-color: rgba(45, 212, 191, 0.28);
}

.tab-btn.active svg { opacity: 1; color: var(--primary); }

/* ── Tab panels ──────────────────────────────────── */
.tab-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: tabFadeIn 0.2s ease-out;
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── LED border card ─────────────────────────────── */
.led-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    padding: 1px;
    overflow: hidden;
    border-radius: 14px;
}

.led-border {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    aspect-ratio: 1 / 1;
    pointer-events: none;
    z-index: 2;
    background: conic-gradient(from 0deg,
        transparent 0%,
        transparent 28%,
        rgba(45, 212, 191, 0.18) 37%,
        #2dd4bf 46%,
        #a78bfa 54%,
        rgba(167, 139, 250, 0.18) 63%,
        transparent 72%,
        transparent 100%
    );
    animation: rotate-led 8s linear infinite;
}

@keyframes rotate-led {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.led-content {
    position: relative;
    z-index: 3;
    background: rgba(10, 15, 30, 0.92);
    border-radius: 13px;
    padding: 26px 28px;
    height: 100%;
}

/* ── Panel helpers ───────────────────────────────── */
.panel-centered {
    max-width: 560px;
    margin: 0 auto;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--on-surface);
    margin: 0 0 22px;
}

.icon-title {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

/* ── Toggle switch ───────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
    background: rgba(45, 212, 191, 0.18);
    border-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translate(20px, -50%);
    background: var(--primary);
}

/* ── Inputs / selects / textareas ────────────────── */
input, select, textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--on-surface);
    padding: 10px 12px;
    border-radius: 8px;
    outline: none;
    font-family: 'Manrope', sans-serif;
    font-size: 0.9rem;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.18);
}

select option { background: var(--surface); }

textarea { resize: vertical; }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, #2dd4bf, #34d399);
    color: #0a0f1e;
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    padding: 11px 24px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(45, 212, 191, 0.35);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn-secondary:hover {
    background: rgba(45, 212, 191, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(45, 212, 191, 0.2);
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-danger {
    background: transparent;
    color: #f87171;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.32);
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.75);
    transform: translateY(-2px);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.45), 0 4px 18px rgba(239, 68, 68, 0.22);
}

.btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Conversations filter/sort bar ───────────────── */
.convo-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.convo-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--on-surface-muted);
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.convo-sort-btn:hover {
    color: var(--on-surface);
    border-color: var(--primary);
    background: rgba(0,210,200,0.07);
}

.convo-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.convo-preset {
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--on-surface-muted);
    font-size: 0.72rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.convo-preset:hover {
    color: var(--on-surface);
    border-color: var(--primary);
}
.convo-preset.active {
    background: rgba(0,210,200,0.13);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.convo-custom-range {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}

.convo-date-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--on-surface-muted);
}

.convo-date-input {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--on-surface);
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}
.convo-date-input:focus { border-color: var(--primary); }

/* ── Knowledge tab — two-column ingestion grid ───── */
.knowledge-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.knowledge-right-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Drop zone ───────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 4px;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: rgba(45, 212, 191, 0.04);
}

/* ── Schedule tab layout ─────────────────────────── */
.schedule-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: start;
}

.next-run-box {
    background: rgba(45, 212, 191, 0.06);
    border: 1px solid rgba(45, 212, 191, 0.2);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 210px;
}

/* ── Collapsible section ─────────────────────────── */
.collapsible-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    color: var(--on-surface);
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    margin: 0;
    text-align: left;
    transition: color 0.2s;
}

.collapsible-trigger:hover { color: var(--primary); }

.chevron-icon {
    width: 17px;
    height: 17px;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.28s ease, color 0.2s;
}

.collapsible-trigger[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

.collapsible-body {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    transition: max-height 0.32s ease, opacity 0.26s ease, margin-top 0.26s ease;
}

.collapsible-body.open {
    max-height: 600px;
    opacity: 1;
    margin-top: 22px;
}

/* ── Chat & Theme tab ────────────────────────────── */
.color-picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.color-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input-group input[type="color"] {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 0;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}

.color-input-group input[type="text"] {
    width: 92px;
    font-size: 0.82rem;
    font-family: 'Manrope', monospace;
    padding: 9px 10px;
}

.color-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-self: flex-end;
    flex-wrap: wrap;
}

/* ── Chat messages ───────────────────────────────── */
.chat-messages-box {
    height: 336px;
    overflow-y: auto;
    padding: 20px 16px;
    background:
        linear-gradient(180deg,
            rgba(8, 13, 26, 0.92) 0%,
            rgba(12, 8, 28, 0.96) 100%);
    border: 1px solid rgba(45, 212, 191, 0.14);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

/* Themed scrollbar */
.chat-messages-box::-webkit-scrollbar {
    width: 4px;
}
.chat-messages-box::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages-box::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 10px;
}
.chat-messages-box::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-row input {
    flex: 1;
    background: rgba(10, 15, 30, 0.8);
    border-color: rgba(45, 212, 191, 0.2);
}

.chat-input-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.15);
}

/* ── Chat image attachment ────────────────────────── */
.btn-attach {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-attach:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(45, 212, 191, 0.07);
}

.btn-attach.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(45, 212, 191, 0.12);
}

.chat-image-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(45, 212, 191, 0.06);
    border: 1px solid rgba(45, 212, 191, 0.2);
    border-radius: 10px;
    animation: fadeIn 0.2s ease-out;
}

.chat-image-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(45, 212, 191, 0.25);
}

.chat-image-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-image-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-image-hint {
    font-size: 0.72rem;
    color: var(--muted);
}

.chat-image-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.chat-image-remove:hover { color: #ef4444; }

/* Image thumbnail inside a sent message bubble */
.chat-msg-image {
    display: block;
    max-width: 200px;
    max-height: 160px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.message {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.6;
    animation: fadeIn 0.25s ease-out;
    font-size: 0.88rem;
}

.message.user {
    margin-left: auto;
    background: linear-gradient(135deg, #2dd4bf 0%, #34d399 100%);
    color: #06111f;
    font-weight: 500;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 14px rgba(45, 212, 191, 0.28);
}

.message.assistant {
    margin-right: auto;
    background: linear-gradient(135deg,
        rgba(167, 139, 250, 0.11) 0%,
        rgba(59, 130, 246, 0.07) 100%);
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-bottom-left-radius: 4px;
    color: var(--on-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: linear-gradient(135deg,
        rgba(167, 139, 250, 0.11) 0%,
        rgba(59, 130, 246, 0.07) 100%);
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40%           { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Color swatch polish ─────────────────────────── */
input[type="color"] {
    -webkit-appearance: none;
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* ── Leads card grid ─────────────────────────────── */
.leads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.lead-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, background 0.2s;
}
.lead-card:hover {
    border-color: rgba(0,210,200,0.30);
    background: rgba(255,255,255,0.05);
}

.lead-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lead-time {
    font-size: 0.71rem;
    color: var(--on-surface-muted);
    white-space: nowrap;
}

.lead-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-surface);
    margin-bottom: 4px;
}

.lead-contact {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.81rem;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.lead-message {
    font-size: 0.82rem;
    color: var(--on-surface-muted);
    line-height: 1.55;
    margin: 0;
}

.lead-card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 2px;
}

/* ── Missed questions list ──────────────────────── */
.missed-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.missed-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, background 0.2s;
}
.missed-card:hover {
    border-color: rgba(0,210,200,0.25);
    background: rgba(255,255,255,0.05);
}

.missed-q-text {
    font-size: 0.9rem;
    color: var(--on-surface);
    line-height: 1.55;
    margin: 0;
}

.missed-q-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

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

/* ── Conversation cards ─────────────────────────── */
.convo-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.convo-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s, background 0.2s;
}
.convo-card:hover {
    border-color: rgba(0,210,200,0.25);
    background: rgba(255,255,255,0.05);
}

.convo-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.convo-session-id {
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--on-surface-muted);
}

.convo-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.convo-turns-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 20px;
    background: rgba(0,210,200,0.12);
    color: var(--primary);
}

.convo-time {
    font-size: 0.71rem;
    color: var(--on-surface-muted);
    white-space: nowrap;
}

.convo-preview {
    font-size: 0.88rem;
    color: var(--on-surface);
    line-height: 1.5;
    margin: 0;
}

.convo-card-footer {
    display: flex;
    justify-content: flex-end;
}

/* ── Inbox: lead type badges ─────────────────────── */
.inbox-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
}
.inbox-badge-teal   { background: rgba(45,212,191,0.15); color: #2dd4bf; }
.inbox-badge-orange { background: rgba(251,146,60,0.15);  color: #fb923c; }

/* ── Transcript slide-in panel ───────────────────── */
.transcript-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity 0.25s;
}
.transcript-overlay.open  { opacity: 1; }
.transcript-overlay.hidden { display: none !important; }

.transcript-panel {
    width: 460px;
    max-width: 95vw;
    height: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.transcript-overlay.open .transcript-panel { transform: translateX(0); }

.transcript-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.transcript-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--on-surface);
}
.transcript-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 3px;
}
.transcript-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.transcript-close:hover { color: var(--on-surface); background: rgba(255,255,255,0.06); }

.transcript-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.transcript-body::-webkit-scrollbar { width: 4px; }
.transcript-body::-webkit-scrollbar-track { background: transparent; }
.transcript-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 4px;
}

.transcript-msg { display: flex; flex-direction: column; max-width: 85%; }
.transcript-user      { align-self: flex-end;  align-items: flex-end; }
.transcript-assistant { align-self: flex-start; align-items: flex-start; }

.transcript-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.transcript-user .transcript-bubble {
    background: linear-gradient(135deg, #2dd4bf, #34d399);
    color: #0a0f1e;
    font-weight: 500;
    border-bottom-right-radius: 4px;
}
.transcript-assistant .transcript-bubble {
    background: linear-gradient(135deg, #1e1b4b, #1e3a5f);
    color: var(--on-surface);
    border: 1px solid rgba(167,139,250,0.15);
    border-bottom-left-radius: 4px;
}

/* ── Analytics: stat card grid ───────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
}
.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: 6px 0 3px;
    line-height: 1;
}
.stat-sub {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── Analytics: bar chart + missed row ───────────── */
.analytics-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.analytics-chart-card { flex: 1; }
.analytics-missed-card { width: 340px; flex-shrink: 0; }

/* ── CSS bar chart ───────────────────────────────── */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 130px;
    margin-top: 12px;
}
.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}
.bar-fill {
    width: 100%;
    min-height: 3px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(to top, #2dd4bf, #34d399);
    transition: height 0.4s ease;
}
.bar-label {
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
}
.bar-count {
    font-size: 0.7rem;
    color: var(--on-surface);
    font-weight: 600;
    min-height: 14px;
}

/* ── Analytics: top missed questions list ────────── */
.analytics-missed-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.analytics-missed-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
}
.analytics-missed-q {
    font-size: 0.82rem;
    color: var(--on-surface);
    line-height: 1.4;
    flex: 1;
}
.analytics-missed-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}
.analytics-missed-empty {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
    padding: 8px 0;
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   RESPONSIVE — 3 breakpoints
   ════════════════════════════════════════════════════ */

/* ── 1100px: stat grid collapses to 3 columns ─── */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── 768px: tablet + small laptop ───────────────── */
@media (max-width: 768px) {
    .site-header     { padding: 0 14px; gap: 6px; height: 48px; }
    .brand-name      { font-size: 0.95rem; }
    .tab-nav         { justify-content: flex-start; }
    .tab-btn         { padding: 5px 10px; font-size: 0.74rem; gap: 4px; }
    .health-pill     { padding: 3px 10px; }
    .health-pill .text-sm { display: none; }

    .tab-content     { padding: 22px 16px 64px; }
    .led-content     { padding: 22px 20px; }
    .panel-title     { font-size: 1rem; }

    .knowledge-top   { grid-template-columns: 1fr; gap: 16px; }
    .schedule-layout { grid-template-columns: 1fr; }
    .color-picker-row{ gap: 14px; }
    .color-actions   { margin-left: 0; width: 100%; }

    .stat-grid        { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .analytics-row    { flex-direction: column; }
    .analytics-missed-card { width: 100%; }

    .leads-grid       { grid-template-columns: 1fr 1fr; }
}

/* ── 480px: phones (375×812 target) ─────────────── */
@media (max-width: 480px) {

    /* Header: 2-row layout so tabs get full width */
    .site-header {
        flex-wrap: wrap;
        height: auto;
        padding: 0 14px;
        gap: 0;
        row-gap: 0;
    }
    .brand-name {
        height: 46px;
        display: flex;
        align-items: center;
        font-size: 0.95rem;
    }
    .header-right {
        height: 46px;
        align-items: center;
        margin-left: auto;
        gap: 8px;
    }
    .health-pill {
        padding: 4px 8px;
        gap: 0;
    }
    #status-text { display: none; }  /* hide label, keep dot only */
    .tab-nav {
        order: 10;           /* push tabs below brand row */
        flex-basis: 100%;
        height: 38px;
        min-height: 38px;
        justify-content: flex-start;
        border-top: 1px solid rgba(255,255,255,0.06);
        padding: 3px 0 3px;
        gap: 2px;
        overflow-x: auto;
        touch-action: pan-x;  /* smooth horizontal swipe on touch */
        -webkit-overflow-scrolling: touch;
    }
    .tab-btn {
        padding: 4px 10px;
        font-size: 0.7rem;
        height: 30px;
        flex-shrink: 0;
        gap: 4px;
    }
    .tab-btn svg { width: 13px; height: 13px; }

    /* Main content */
    .tab-content  { padding: 14px 12px 70px; }
    .led-content  { padding: 16px 14px; }
    .panel-title  { font-size: 0.93rem; gap: 7px; margin-bottom: 14px; }
    .icon-title   { width: 16px; height: 16px; }

    /* Leads — single column */
    .leads-grid   { grid-template-columns: 1fr; gap: 10px; }
    .lead-card    { padding: 13px 14px; gap: 8px; }
    .lead-card-top{ flex-wrap: wrap; gap: 4px; }
    .lead-name    { font-size: 0.93rem; }
    .lead-contact { font-size: 0.78rem; gap: 5px; }
    .lead-message { font-size: 0.79rem; }

    /* Missed questions */
    .missed-card     { padding: 12px 13px; gap: 8px; }
    .missed-q-text   { font-size: 0.86rem; }
    .missed-q-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .missed-q-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Conversation cards */
    .convo-card        { padding: 11px 13px; gap: 7px; }
    .convo-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .convo-card-meta   { width: 100%; justify-content: space-between; }
    .convo-preview     { font-size: 0.84rem; }
    .convo-session-id  { font-size: 0.69rem; }

    /* Conversations filter toolbar */
    .convo-filter-bar { gap: 6px; }
    .convo-sort-btn   { padding: 4px 9px; font-size: 0.7rem; }
    .convo-presets    { gap: 4px; }
    .convo-preset     { font-size: 0.67rem; padding: 3px 8px; }
    .convo-custom-range {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .convo-date-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .convo-date-input { width: 100%; }

    /* Pagination buttons */
    #btn-convo-prev,
    #btn-convo-next { font-size: 0.75rem; padding: 6px 12px; }

    /* Analytics stat cards — 2 columns */
    .stat-grid  { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card  { padding: 13px 13px; }
    .stat-value { font-size: 1.5rem; }
    .stat-sub   { font-size: 0.68rem; }
    .stat-label { font-size: 0.65rem; }

    /* Analytics bar chart */
    .bar-chart  { height: 110px; gap: 5px; }
    .bar-label  { font-size: 0.6rem; }
    .analytics-row      { gap: 14px; }
    .analytics-missed-card { width: 100%; }

    /* Chat messages */
    .chat-messages-box  { height: 240px; padding: 14px 12px; }
    .message            { max-width: 86%; font-size: 0.85rem; }
    .chat-input-row     { gap: 7px; }

    /* Knowledge upload drop zone */
    .drop-zone          { padding: 9px 12px; }

    /* Color picker — stacked on mobile */
    .color-picker-row   { flex-direction: column; gap: 12px; }
    .color-actions      { margin-left: 0; width: 100%; justify-content: flex-start; }

    /* Schedule next-run box */
    .next-run-box       { min-width: 0; width: 100%; }

    /* Collapsible — more room to expand on narrow screen */
    .collapsible-body.open { max-height: 1000px; }

    /* Transcript panel — full-screen on mobile */
    .transcript-panel {
        width: 100%;
        max-width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .transcript-header  { padding: 14px 16px 11px; }
    .transcript-body    { padding: 14px 16px; }
    .transcript-bubble  { font-size: 0.83rem; }
    .transcript-msg     { max-width: 90%; }

    /* Forms */
    input, select, textarea { font-size: 0.88rem; }
    .btn-primary   { padding: 10px 18px; font-size: 0.77rem; }
    .btn-secondary { font-size: 0.8rem; }
    .btn-danger    { font-size: 0.8rem; }

    /* iPhone notch / home bar safe areas */
    .tab-content { padding-bottom: max(70px, calc(70px + env(safe-area-inset-bottom))); }
}
