﻿@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    --primary: #a855f7;
    --primary-dark: #9333ea;
    --primary-light: #c084fc;
    --bg-dark: #0a1628;
    --bg-card: #0f1f3a;
    --bg-input: #162544;
    --bg-hover: #1e3a5f;
    --text-primary: #ffffff;
    --text-secondary: #8ba3c7;
    --border-color: #1e3a5f;
    --border-focus: #a855f7;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
}

[data-theme="light"] {
    --bg-dark: #f0f4f8;
    --bg-card: #ffffff;
    --bg-input: #e8eef4;
    --bg-hover: #dce4ec;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --border-color: #cbd5e0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100%;
    font-size: 16px;
    overflow: hidden;
}

.history-section {
    margin: 1rem 1.5rem 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.history-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.history-clear-btn {
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
}

.history-clear-btn:hover {
    background: var(--bg-hover);
}

.history-table-wrapper {
    overflow: auto;
    max-height: 42vh;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th,
.history-table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.history-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.history-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
}

.history-table tbody tr:hover {
    background: rgba(168, 85, 247, 0.08);
}

.history-detail-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.3rem 0.55rem;
    font-size: 0.78rem;
    cursor: pointer;
}

.history-detail-btn:hover {
    background: var(--bg-hover);
}

.history-record-detail {
    margin-top: 0.85rem;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-input);
}

.history-record-detail h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.history-detail-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
}

.history-detail-tools,
.history-detail-transcript {
    margin-top: 0.55rem;
}

.history-detail-tools ul,
.history-detail-transcript ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.history-detail-transcript li {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    background: var(--bg-card);
}

.history-role-label {
    color: var(--primary-light);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 0.15rem;
}

#app { 
    display: flex; 
    flex-direction: column; 
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-icon {
    flex-shrink: 0;
    border-radius: 6px;
}

.header-controls { display: flex; align-items: center; gap: 0.75rem; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.icon-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.settings-btn:hover { transform: rotate(45deg); }

.theme-toggle {
    width: 50px; height: 26px;
    background: var(--bg-input);
    border-radius: 13px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    position: relative;
}

.theme-toggle::before {
    content: 'ðŸŒ™';
    position: absolute;
    left: 4px; top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    right: 4px; top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    transition: all 0.3s ease;
}

[data-theme="light"] .theme-toggle::before { content: 'â˜€ï¸'; left: auto; right: 4px; }
[data-theme="light"] .theme-toggle::after { right: auto; left: 4px; }

/* Settings overlay (dimmed background) */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: fixed;
    top: 0; right: 0;
    width: 520px; max-width: 100%; height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.settings-panel.open { transform: translateX(0); }

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.settings-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.close-btn:hover { background: var(--bg-input); color: var(--error); }

.settings-section { margin-bottom: 1rem; }

.settings-label {
    display: block;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.settings-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.settings-input:focus {
    outline: none;
    border-color: var(--primary);
}

.setting-checkbox-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.setting-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.custom-select { 
    position: relative; 
    width: 100%; 
    user-select: none; 
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.custom-select-trigger:hover { border-color: var(--primary-light); background: var(--bg-hover); }

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    z-index: 1001;
}

.custom-select-value { flex: 1; }
.custom-select-arrow { color: var(--text-secondary); transition: transform 0.3s ease; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); color: var(--primary); }

.custom-select-options {
    position: absolute;
    top: 100%; 
    left: 0; 
    right: 0;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.custom-select.open .custom-select-options { 
    max-height: 300px; 
    overflow-y: auto; 
    opacity: 1; 
    visibility: visible;
}

.custom-select-option {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    background: var(--bg-card);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.custom-select-option:hover { background: var(--bg-hover); border-left-color: var(--primary-light); }
.custom-select-option.selected { background: var(--bg-hover); border-left-color: var(--primary); color: var(--primary-light); }

/* Options with descriptions */
.custom-select.has-description .custom-select-option {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.75rem;
}

.option-label {
    font-weight: 500;
    font-size: 0.95rem;
}

.option-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.custom-select-option.selected .option-description {
    color: var(--text-secondary);
}

/* Disabled state for settings during conversation */
.settings-disabled {
    position: relative;
}

.settings-disabled::before {
    display: none;
}

.custom-select.disabled .custom-select-trigger {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.settings-textarea:disabled,
.settings-slider:disabled,
.slider-value-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gender-icon { width: 16px; height: 16px; vertical-align: middle; margin-right: 8px; }
.gender-icon.male { color: #60a5fa; }
.gender-icon.female { color: #f472b6; }
.custom-select-value .gender-icon { margin-right: 6px; }

.settings-textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
}

.settings-textarea:focus { outline: none; border-color: var(--primary); }

.settings-accordion {
    margin-bottom: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: visible;
}

.settings-accordion summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--bg-input);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-accordion summary::before {
    content: '';
    width: 8px; height: 8px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(-45deg);
    transition: transform 0.3s ease;
}

.settings-accordion[open] summary::before { transform: rotate(45deg); }
.settings-accordion[open] summary { border-bottom: 1px solid var(--border-color); }
.settings-accordion summary::-webkit-details-marker { display: none; }

.accordion-content { padding: 0.5rem; overflow: visible; }
.setting-item { 
    margin-bottom: 0.5rem; 
    position: relative;
    z-index: 1;
}

.setting-item:last-child { margin-bottom: 0; }

/* Ensure open dropdowns stack above siblings */
.setting-item:has(.custom-select.open) {
    z-index: 100;
}

.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }

.slider-value-input {
    width: 80px;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
}

.slider-value-input:focus { outline: none; border-color: var(--primary); }

.settings-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-input);
    border-radius: 4px;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}


.section-header {
    width: 100%;
    margin-bottom: 0.5rem;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.transcription-section {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}


.voice-container {
    position: relative;
    width: 100%;
    flex: 0 0 auto;
    min-height: 180px;
    max-height: 40vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.waveform-canvas { 
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.button-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
}

.ring-canvas {
    position: absolute;
    width: 200px;
    height: 200px;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 9;
}

.voice-btn {
    width: 100px; height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a1628 0%, #162544 50%, #1e3a5f 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3), inset 0 0 40px rgba(168, 85, 247, 0.2);
    z-index: 10;
}

.voice-btn:hover { transform: scale(1.05); box-shadow: 0 0 50px rgba(168, 85, 247, 0.5), inset 0 0 50px rgba(168, 85, 247, 0.3); }
.voice-btn.active { animation: pulse-btn 2s infinite; }

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 30px rgba(168, 85, 247, 0.3), inset 0 0 40px rgba(168, 85, 247, 0.2); }
    50% { box-shadow: 0 0 50px rgba(168, 85, 247, 0.5), inset 0 0 60px rgba(168, 85, 247, 0.3); }
}

.voice-btn svg { width: 40px; height: 40px; color: white; }
.voice-btn .hidden { display: none; }
.voice-hint { color: var(--text-secondary); font-size: 1rem; }

.chat-container {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    min-height: 0;
    scroll-behavior: smooth;
}

.current-conversation-section {
    width: 100%;
    flex: 0 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem;
}

.concurrency-dashboard-section {
    width: 100%;
    flex: 0 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem;
}

.concurrency-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.concurrency-table-wrapper {
    max-height: 32vh;
    overflow: auto;
}

.concurrency-table td:nth-child(2),
.concurrency-table td:nth-child(3),
.concurrency-table td:nth-child(4),
.concurrency-table th:nth-child(2),
.concurrency-table th:nth-child(3),
.concurrency-table th:nth-child(4) {
    text-align: center;
}

.concurrency-updated-at {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.calls-explorer-block {
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
}

.calls-explorer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.calls-explorer-header h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.calls-client-filter {
    max-width: 280px;
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
}

.calls-explorer-table th,
.calls-explorer-table td {
    font-size: 0.82rem;
}

.call-detail-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.28rem 0.48rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.call-detail-btn:hover {
    background: var(--bg-hover);
}

.call-detail-panel {
    margin-top: 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-input);
    padding: 0.7rem;
}

.call-detail-panel h5 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.call-detail-panel pre {
    margin: 0;
    max-height: 220px;
    overflow: auto;
    font-size: 0.76rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

.current-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.summary-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.summary-value {
    margin-top: 0.2rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.summary-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.current-tools-block h4 {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}

.current-tools-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.current-tools-list li {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: var(--primary-light);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
}

.history-panel {
    width: 100%;
    flex: 0 0 auto;
    background: transparent;
}

.history-panel > summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 0.1rem;
}

.history-panel[open] > summary {
    margin-bottom: 0.5rem;
}

.message {
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0.25rem 0;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn { 
    from { opacity: 0; transform: translateY(12px); } 
    to { opacity: 1; transform: translateY(0); } 
}

.message.user { background: var(--accent-gradient); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.message.assistant { background: var(--bg-input); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px; }
.message.system { background: transparent; color: var(--text-secondary); align-self: center; text-align: center; }

/* Session timeout indicators */
.session-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--warning);
    animation: warningPulse 2s ease-in-out infinite;
}

.session-renew {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary-light);
    animation: renewSpin 1s ease-in-out;
    transition: opacity 0.5s ease-out;
}

.session-renew.success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.1) 100%);
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--success);
}

.session-renew.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--error);
}

.session-renew.fade-out {
    opacity: 0;
}

.warning-icon, .renew-icon {
    font-size: 0.875rem;
}

@keyframes warningPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes renewSpin {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Nova icon for assistant messages */
.message-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin-right: 0.5rem;
}

.nova-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.message.assistant {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.message-content {
    flex: 1;
}

.interrupted-indicator {
    display: block;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.message.thinking { display: flex; align-items: center; gap: 0.5rem; }
.thinking-text { font-style: italic; opacity: 0.8; }
.thinking-dots { display: flex; gap: 3px; }
.thinking-dots .dot { 
    width: 5px; 
    height: 5px; 
    background: currentColor; 
    border-radius: 50%; 
    animation: bounce 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite; 
}
.thinking-dots .dot:nth-child(1) { animation-delay: 0s; }
.thinking-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce { 
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 
    30% { transform: translateY(-4px); opacity: 1; } 
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

@media (max-width: 768px) {
    .settings-panel { width: 100%; }
    .button-wrapper { width: 160px; height: 160px; }
    .ring-canvas { width: 160px; height: 160px; }
    .voice-btn { width: 80px; height: 80px; }
    .voice-btn svg { width: 32px; height: 32px; }
    .message { max-width: 90%; }
    .voice-container { min-height: 140px; }
    .main-content { padding: 0.75rem; gap: 0.75rem; }
    .chat-container { padding: 0.75rem; border-radius: 12px; }
    .current-summary-grid { grid-template-columns: 1fr; }
    .concurrency-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calls-explorer-header { flex-direction: column; align-items: stretch; }
    .calls-client-filter { max-width: 100%; }
}

@media (max-height: 600px) {
    .voice-container { min-height: 120px; }
    .button-wrapper { width: 140px; height: 140px; }
    .ring-canvas { width: 140px; height: 140px; }
    .voice-btn { width: 70px; height: 70px; }
    .voice-btn svg { width: 28px; height: 28px; }
    .status { padding: 0.4rem 1rem; font-size: 0.875rem; }
}

.hidden { display: none !important; }

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Tool Usage Card Styles */
.tool-card {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 0;
    max-width: 70%;
    width: fit-content;
    min-width: 200px;
    align-self: flex-start;
    margin: 0.25rem 0 0.25rem 2rem;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-radius: 8px;
}

.tool-card.expanded .tool-header {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.tool-header:hover {
    background: rgba(168, 85, 247, 0.15);
}

.tool-icon {
    width: 14px;
    height: 14px;
    color: var(--primary-light);
    flex-shrink: 0;
    opacity: 0.8;
}

.tool-name {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--primary-light);
    flex: 1;
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.tool-status.running {
    color: var(--warning);
}

.tool-status.completed {
    color: var(--success);
}

.tool-status.error {
    color: var(--error, #ef4444);
}

.tool-elapsed {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.tool-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(168, 85, 247, 0.3);
    border-top-color: var(--warning);
    border-radius: 50%;
    animation: toolSpin 0.8s linear infinite;
}

@keyframes toolSpin {
    to { transform: rotate(360deg); }
}

.tool-check {
    width: 12px;
    height: 12px;
    color: var(--success);
}

.tool-error {
    width: 12px;
    height: 12px;
    color: var(--error, #ef4444);
}

.tool-error-output .tool-section-content {
    color: var(--error, #ef4444);
}

.tool-expand-icon {
    width: 12px;
    height: 12px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

.tool-card.expanded .tool-expand-icon {
    transform: rotate(180deg);
}

.tool-details {
    display: none;
    border-top: 1px solid rgba(168, 85, 247, 0.2);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 8px 8px;
}

.tool-card.expanded .tool-details {
    display: block;
}

.tool-section {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.15);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
    opacity: 0.7;
}

.tool-section-content {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}


/* Tools List Styles */
.tools-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tools-loading {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.5rem;
    text-align: center;
}

.tool-toggle-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tool-toggle-item:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.tool-toggle-item.disabled {
    opacity: 0.5;
}

.tool-checkbox {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tool-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.tool-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tool-checkbox input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.tool-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.tool-checkbox input:checked + .checkmark::after {
    display: block;
}

.tool-checkbox input:disabled {
    cursor: not-allowed;
}

.tool-checkbox input:disabled + .checkmark {
    opacity: 0.5;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-info-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.tool-info-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}


/* Typing Window Styles */
.typing-window {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    display: block !important;
}

.typing-window.hidden {
    transform: translateY(100%) !important;
    pointer-events: none;
}

.typing-window:not(.hidden) {
    transform: translateY(0) !important;
    pointer-events: auto;
}

.typing-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    transition: border-color 0.3s ease;
}

.typing-input-wrapper:focus-within {
    border-color: var(--primary);
}

.text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    padding: 0.25rem 0.5rem;
    outline: none;
}

.text-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.send-text-btn {
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.send-text-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.send-text-btn:active {
    transform: scale(0.95);
}

.send-text-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-text-btn svg {
    color: white;
}

.hide-typing-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    color: var(--text-primary);
}

.hide-typing-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.hide-typing-btn:active {
    transform: scale(0.95);
}

/* Keyboard Toggle Button */
.keyboard-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
}

.keyboard-toggle.visible {
    opacity: 1;
    visibility: visible;
}

.keyboard-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.keyboard-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.keyboard-toggle.active:hover {
    background: var(--primary-dark);
}

/* Adjust chat container when typing window is visible */
.main-content {
    transition: padding-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.typing-active {
    padding-bottom: 100px;
}

.main-content:has(.typing-window:not(.hidden)) .chat-container {
    margin-bottom: 0;
    padding-bottom: 80px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .keyboard-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .typing-window {
        padding: 0.5rem;
    }
    
    .text-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ============ APP SHELL / SIDEBAR LAYOUT ============ */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color, rgba(255,255,255,0.08));
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.sidebar-brand-icon {
    border-radius: 10px;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-brand-title {
    font-weight: 700;
    font-size: 16px;
}

.sidebar-brand-subtitle {
    font-size: 11px;
    opacity: 0.6;
}

.sidebar-nav {
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav-item:hover {
    background: var(--bg-hover);
}

.sidebar-nav-item.active {
    background: var(--primary);
    color: #fff;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    display: flex;
    justify-content: center;
}

.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-section {
    display: none;
}

.app-section.active {
    display: block;
    width: 100%;
    max-width: 1100px;
    overflow-y: auto;
    padding-bottom: 40px;
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        width: 200px;
    }
}

@media (max-width: 640px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    }
    .sidebar-brand-text,
    .sidebar-footer {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
    }
    .sidebar-nav-item {
        white-space: nowrap;
        width: auto;
    }
}

/* ============ PROMPTS ============ */
.prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.prompt-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s ease;
}

.prompt-card:hover {
    border-color: var(--primary);
}

.prompt-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.prompt-card-header h4 {
    margin: 0 0 4px;
    font-size: 15px;
}

.prompt-card-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
}

.prompt-card-actions {
    display: flex;
    gap: 6px;
}

.prompt-card-actions button {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.15));
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.prompt-card-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.prompt-card-description {
    font-size: 13px;
    opacity: 0.7;
    margin: 0;
}

.prompt-card-preview {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow: hidden;
    margin: 0;
}

.prompt-card-footer {
    font-size: 11px;
    opacity: 0.5;
}

.prompts-empty,
.prompts-loading {
    text-align: center;
    padding: 40px;
    opacity: 0.6;
}

.prompt-editor-textarea {
    min-height: 280px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    display: flex;
    justify-content: flex-end;
}

/* ============ CREDENCIALES ============ */
.credentials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.credential-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.credential-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.credential-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
}

.credential-card-header h4 {
    margin: 0;
    font-size: 15px;
}

.credential-card-header p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.6;
}

.credential-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.credential-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.credential-field label {
    font-size: 12px;
    opacity: 0.7;
}

.credential-save-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.credential-save-btn:hover {
    filter: brightness(1.1);
}

.credential-label-with-help { display:flex; align-items:center; gap:7px; }
.help-icon-btn { width:18px; height:18px; padding:0; border:1px solid var(--primary); border-radius:50%; background:transparent; color:var(--primary); font-size:11px; font-weight:700; line-height:16px; cursor:pointer; }
.help-icon-btn:hover { background:var(--primary); color:#fff; }
.help-modal { max-width:560px; }
.help-modal p { color:var(--text-secondary); font-size:13px; line-height:1.6; }
.help-modal pre { margin:12px 0; padding:12px; overflow-x:auto; border-radius:8px; background:var(--bg-input); color:var(--text-primary); font-family:var(--font-mono); font-size:12px; line-height:1.6; }
.help-modal code { color:var(--primary); font-family:var(--font-mono); }
.help-modal-warning { padding:10px 12px; border-left:3px solid var(--primary); background:var(--surface-2); }
.cost-scope-hint { margin:0 0 12px; padding:9px 10px; border-left:2px solid var(--primary); background:var(--surface-2); }
#settings-toggle, .settings-toggle { display:none !important; }
#app .app-header .header-controls { display:none; }
#app .app-header { display:none; }
.settings-overlay { display:none !important; }
.settings-inline-panel { position:static; width:100%; max-width:none; height:auto; max-height:none; transform:none !important; border:0; box-shadow:none; display:block; margin-top:14px; }
.settings-inline-panel .settings-header { display:none; }
.settings-inline-panel .settings-content { padding:0; overflow:visible; }
section[data-section-panel="settings"] > #settings-panel.settings-inline-panel { position:static !important; inset:auto !important; width:100% !important; height:auto !important; max-width:none !important; transform:none !important; visibility:visible !important; opacity:1 !important; }
section[data-section-panel="settings"] > #settings-panel.settings-inline-panel .settings-content { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
section[data-section-panel="settings"] > #settings-panel.settings-inline-panel .settings-header { display:none !important; }
.advanced-settings-grid > details:last-child { grid-column:1 / -1; }
.advanced-settings-grid > details:last-child .rules-visual-editor { grid-template-columns:repeat(3,minmax(0,1fr)); }
.rules-visual-editor { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:10px 0 14px; }
.rules-editor-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.rule-card { padding:14px; border:1px solid var(--border-soft); border-radius:10px; background:var(--bg-card); }
.rule-card-header { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:12px; }
.rule-card-header strong { display:block; color:var(--text-primary); text-transform:capitalize; }
.rule-card-header span { display:block; margin-top:3px; color:var(--text-secondary); font-size:11px; }
.rule-add-field, .rule-remove-field { border:1px solid var(--border-color); border-radius:6px; background:transparent; color:var(--primary); cursor:pointer; }
.rule-add-field { padding:5px 8px; font-size:11px; }
.rule-remove-field { width:30px; flex:0 0 30px; color:var(--text-secondary); font-size:16px; }
.rule-fields { display:flex; flex-direction:column; gap:7px; }
.rule-field-row { display:flex; gap:7px; align-items:center; }
.rule-field-row .settings-input { min-width:0; flex:1; padding:8px; font-size:11px; }
.rules-raw-editor { margin:8px 0 12px; border:1px solid var(--border-soft); border-radius:8px; }
.rules-raw-editor summary { padding:9px 11px; color:var(--text-secondary); cursor:pointer; font-size:11px; }
.rules-raw-editor .rules-editor { margin:0; border:0; border-top:1px solid var(--border-soft); border-radius:0 0 8px 8px; }
.rules-editor-error, .rules-editor-empty { grid-column:1/-1; padding:12px; color:var(--text-secondary); border:1px dashed var(--border-color); border-radius:8px; }

@media (min-width: 901px) {
    #app.app-shell { flex-direction:column; }
    .sidebar { width:100%; height:auto; min-height:70px; flex-direction:row; align-items:center; border-right:0; border-bottom:1px solid var(--border-soft); padding:8px 20px; overflow:visible; }
    .sidebar-brand { flex:0 0 auto; padding:5px 18px 5px 0; border-bottom:0; border-right:1px solid var(--border-soft); }
    .sidebar-nav { flex-direction:row; align-items:center; justify-content:center; gap:4px; padding:0 12px; overflow-x:auto; }
    .sidebar-nav-item { width:auto; white-space:nowrap; padding:9px 11px; font-size:12px; }
    .sidebar-footer { margin-left:auto; padding:0 0 0 12px; border-top:0; border-left:1px solid var(--border-soft); }
    .main-area { height:calc(100vh - 70px); }
}

@media (max-width: 900px) { .rules-visual-editor { grid-template-columns:1fr; } }
@media (max-width: 900px) {
    section[data-section-panel="settings"] > #settings-panel.settings-inline-panel .settings-content { grid-template-columns:1fr; }
    .advanced-settings-grid > details:last-child .rules-visual-editor { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 640px) { .advanced-settings-grid > details:last-child .rules-visual-editor { grid-template-columns:1fr; } }


.credential-save-status {
    font-size: 12px;
    min-height: 16px;
}

.advanced-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .advanced-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ============ OPERATIONS UI THEME ============
   Visual language aligned with the Central de Novedades mockup. */

/* theme overrides */
:where([hidden]) { display: none !important; }

:root {
    --primary: #f5a623;
    --primary-dark: #c77e14;
    --primary-light: #ffc45c;
    --bg-dark: #0e1216;
    --bg-card: #161b22;
    --bg-input: #1d242d;
    --bg-hover: #242c37;
    --text-primary: #edf1f5;
    --text-secondary: #8c97a6;
    --border-color: #2a323d;
    --border-focus: #f5a623;
    --success: #34d399;
    --warning: #f5a623;
    --error: #f0554d;
    --accent-gradient: linear-gradient(135deg, #f5a623 0%, #c77e14 100%);
    --surface-3: #242c37;
    --border-soft: #1f2731;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

html, body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    font-size: 14px;
}

body {
    background-image: radial-gradient(circle at 8% 8%, rgba(245,166,35,.05), transparent 38%),
        radial-gradient(circle at 92% 85%, rgba(78,161,245,.035), transparent 42%);
}

.app-shell {
    display: flex;
    flex-direction: row;
}

#app.app-shell {
    flex-direction: row;
}

/* Operations tables and integration cards */
.calls-explorer-block,
.history-panel {
    padding: 20px;
    margin-top: 0;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}
.queue-panel { padding:20px; margin-bottom:14px; border:1px solid var(--border-soft); border-radius:10px; }
.queue-panel h3 { margin-top:5px; font-family:var(--font-display); font-size:18px; }
.queue-count { padding:5px 9px; border-radius:999px; background:rgba(245,166,35,.14); color:var(--primary); font-family:var(--font-mono); font-size:11px; }
.queue-position { color:var(--primary); font-family:var(--font-mono); font-weight:600; }
.queue-table { min-width:850px; }

.calls-explorer-header,
.history-header {
    margin-bottom: 16px;
}

.table-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.table-search { min-width: 220px; }
.table-filter { width: auto; min-width: 135px; padding: 8px 10px; font-size: 12px; }
.history-filters { max-width: 760px; }

.calls-explorer-header h3,
.history-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
}

.concurrency-table-wrapper,
.history-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.calls-explorer-table,
.history-panel .history-table {
    min-width: 980px;
    font-size: 12.5px;
}

.calls-explorer-table th,
.history-panel .history-table th {
    height: 40px;
    padding: 10px 14px;
    background: #1d242d;
    color: #5c6673;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .65px;
    text-transform: uppercase;
}

.calls-explorer-table td,
.history-panel .history-table td {
    height: 54px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-secondary);
    vertical-align: middle;
}

.calls-explorer-table tbody tr:last-child td,
.history-panel .history-table tbody tr:last-child td { border-bottom: 0; }

.calls-explorer-table tbody tr:hover,
.history-panel .history-table tbody tr:hover { background: #1d242d; }

.call-id,
.mono-cell { font-family: var(--font-mono); font-size: 11.5px; }
.call-id { color: #9da8b7; }

.novelty-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(245,166,35,.14);
    color: var(--primary-light);
    font-size: 11px;
    font-weight: 600;
}

.novelty-badge::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    content: '';
}

.call-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.call-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8994a2;
}

.call-status.status-active i,
.call-status.status-en-curso i { background: var(--success); box-shadow: 0 0 0 3px rgba(52,211,153,.14); }
.call-status.status-failed i,
.call-status.status-fallida i,
.call-status.status-error i { background: var(--error); }

.cost-stack { font-family: var(--font-mono); white-space: nowrap; }
.cost-stack strong { display: block; color: var(--text-primary); font-size: 12px; }
.cost-stack small { color: var(--text-faint, #5c6673); font-size: 10px; }

.call-detail-btn,
.history-detail-btn {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.call-detail-btn:hover,
.history-detail-btn:hover { background: var(--amber-dim, rgba(245,166,35,.14)); color: var(--primary-light); }

.history-record-detail,
.call-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1200;
    width: min(520px, 92vw);
    height: 100vh;
    margin-top: 0;
    padding: 16px;
    background: #1d242d;
    border: 1px solid var(--border-color);
    border-radius: 0;
    overflow-y: auto;
    box-shadow: -18px 0 45px rgba(0,0,0,.35);
}

.history-record-detail h4,
.call-detail-panel h5 { font-family: var(--font-display); color: var(--text-primary); }

.detail-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin: -16px -16px 20px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border-soft);
}

.detail-panel-heading h4,
.detail-panel-heading h5 { margin: 0; font-size: 18px; }
.detail-close-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.detail-close-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.detail-section { margin-bottom: 22px; }
.detail-section-last { margin-bottom: 4px; }
.detail-section-title {
    margin-bottom: 10px;
    color: #5c7a99;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .7px;
    text-transform: uppercase;
}
.detail-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.detail-meta-grid > div {
    min-width: 0;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 61px;
}
.detail-meta-card { box-shadow: inset 0 1px 0 rgba(255,255,255,.015); }
.detail-meta-grid span {
    display: block;
    margin-bottom: 5px;
    color: #687789;
    font-family: var(--font-mono);
    font-size: 10px;
}
.detail-meta-grid strong { display: block; color: var(--text-primary); font-size: 13px; }
.detail-result {
    padding: 12px 14px;
    border: 1px solid rgba(52,211,153,.3);
    border-radius: 8px;
    background: rgba(23,50,41,.9);
    color: #b7f0da;
    font-size: 12.5px;
    line-height: 1.55;
}
.detail-result.is-error { border-color: rgba(240,85,77,.35); background: rgba(58,30,28,.9); color: #f8c4c0; }
.detail-cost-bar { display: flex; height: 8px; margin: 12px 0 9px; overflow: hidden; border-radius: 5px; }
.detail-cost-bar span { min-width: 0; }
.detail-cost-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-secondary); font-size: 11.5px; }
.detail-cost-legend span { display: inline-flex; align-items: center; gap: 6px; }
.detail-cost-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--primary); }
.detail-cost-legend i.twilio { background: #4ea1f5; }
.detail-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); color: var(--text-secondary); font-size: 13px; }
.detail-total strong { color: var(--text-primary); font-family: var(--font-mono); font-size: 18px; text-align: right; }
.detail-answers { padding: 11px 13px; background: var(--bg-input); border-radius: 8px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.detail-answers ul { margin: 0; padding-left: 17px; }
.detail-transcript { max-height: 280px; padding: 13px 15px; overflow-y: auto; background: var(--bg-input); border-radius: 8px; }
.detail-transcript ul { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.detail-transcript li { color: var(--text-secondary); font-size: 12.5px; line-height: 1.55; }
.detail-transcript .history-role-label { margin-bottom: 3px; color: var(--primary); font-family: var(--font-mono); font-size: 10px; }

@media (max-width: 560px) {
    .detail-meta-grid { grid-template-columns: 1fr; }
    .detail-total { align-items: flex-start; flex-direction: column; }
    .detail-total strong { text-align: left; }
}

.credentials-grid { gap: 14px; }
.credential-card {
    border-color: var(--border-soft);
    box-shadow: none;
}
.credential-card:hover { border-color: var(--border-color); }
.credential-card-header { padding-bottom: 4px; border-bottom: 1px solid var(--border-soft); }
.credential-card-header h4 { font-size: 15px; }
.credential-card-icon { color: var(--primary); background: var(--surface-3); }
.credential-save-status { color: var(--success); }

.prompts-header {
    padding: 20px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}

.prompts-header .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.prompts-grid { gap: 14px; }

.prompt-card {
    min-height: 246px;
    padding: 18px 18px 16px 21px;
    border-color: var(--border-soft);
    border-radius: 10px;
    background: var(--bg-card);
}

.prompt-card::before { width: 4px; background: var(--primary); }
.prompt-card.prompt-color-amber::before { background: #f5a623; }
.prompt-card.prompt-color-red::before { background: #f0554d; }
.prompt-card.prompt-color-blue::before { background: #4ea1f5; }
.prompt-card.prompt-color-purple::before { background: #a78bfa; }
.prompt-card.prompt-color-teal::before { background: #2dd4bf; }
.prompt-card-header h4 { color: var(--text-primary); font-size: 15.5px; }
.prompt-card-badge {
    margin-top: 2px;
    background: rgba(245,166,35,.14);
    color: var(--primary-light);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.prompt-card-description { color: var(--text-secondary); opacity: 1; line-height: 1.5; }
.prompt-card-preview {
    flex: 1;
    max-height: 92px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    color: #7f8b9b;
    font-family: var(--font-mono);
    font-size: 10.5px;
    line-height: 1.55;
}
.prompt-card-footer { color: #5c6673; opacity: 1; font-family: var(--font-mono); }
.prompt-card-actions button { color: var(--text-secondary); }
.prompt-card-actions button:hover { color: var(--primary); }

.add-prompt-card {
    min-height: 246px;
    border: 1.5px dashed var(--border-color);
    border-radius: 10px;
    background: rgba(14,18,22,.35);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 600;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.add-prompt-card:hover { border-color: var(--primary); color: var(--primary); background: rgba(245,166,35,.04); }
.add-prompt-icon { display: block; font-size: 25px; font-weight: 400; margin-bottom: 8px; }


.integration-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 20px;
}

.integration-status-card {
    min-width: 0;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.integration-status-label {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .35px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.integration-status-card strong {
    display: block;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.integration-status-card span {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.4;
}

.clients-page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.clients-page-header h2 { margin: 5px 0 6px; font-family: var(--font-display); font-size: 25px; }
.clients-page-header p { max-width: 560px; color: var(--text-secondary); line-height: 1.5; }
.page-eyebrow { color: var(--primary); font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.clients-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border-soft); margin-bottom: 20px; }
.clients-tabs button { padding: 0 2px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-secondary); cursor: pointer; }
.clients-tabs button.active { border-color: var(--primary); color: var(--text-primary); }
.clients-table-toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.clients-table-toolbar .table-search { flex:1; max-width:520px; }
.required-mark { color:var(--primary); }
.optional-label { color:var(--text-secondary); font-weight:400; }
.clients-table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--bg-card); }
.clients-table { min-width: 760px; }
.client-code { display:block; margin-top:3px; color:#5c6673; font-family:var(--font-mono); font-size:10px; }
.plan-badge { display:inline-block; padding:4px 9px; border-radius:999px; background:var(--surface-3); color:var(--text-secondary); font-size:11px; }
.client-progress { width:240px; height:6px; margin-top:7px; border-radius:5px; background:var(--surface-3); overflow:hidden; }
.client-progress span { display:block; height:100%; border-radius:inherit; background:var(--primary); }
.client-queue { display:block; margin-top:3px; color:var(--primary); font-family:var(--font-mono); font-size:10px; }
.client-state { display:inline-flex; align-items:center; gap:7px; color:var(--text-secondary); }
.client-state i { width:7px; height:7px; border-radius:50%; background:#5c6673; }
.client-state.active { color:var(--success); }
.client-state.active i { background:var(--success); }
.plans-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; }
.plan-card { min-height:170px; display:flex; flex-direction:column; justify-content:space-between; padding:20px; border:1px solid var(--border-soft); border-radius:10px; background:var(--bg-card); }
.plan-card-top { display:flex; justify-content:space-between; gap:14px; }
.plan-card h3 { margin:0 0 8px; font-family:var(--font-display); font-size:16px; }
.plan-card p { max-width:210px; color:var(--text-secondary); font-size:12px; line-height:1.5; }
.plan-card-top > strong { flex-shrink:0; color:var(--primary); font-family:var(--font-mono); font-size:30px; line-height:1; text-align:right; white-space:nowrap; }
.plan-card-top > strong small { display:block; color:#5c6673; font-size:9px; letter-spacing:.8px; text-align:right; }
.plan-card footer { display:flex; justify-content:space-between; align-items:center; gap:12px; padding-top:14px; border-top:1px solid var(--border-soft); color:var(--text-secondary); font-size:11px; }
.add-plan-card { min-height:170px; border:1.5px dashed var(--border-color); border-radius:10px; background:transparent; color:var(--text-secondary); cursor:pointer; font-weight:600; }
.add-plan-card span { display:block; margin-bottom:7px; color:var(--text-secondary); font-size:25px; font-weight:400; }
.add-plan-card:hover { border-color:var(--primary); color:var(--primary); }
.api-page-header { margin-bottom:26px; }
.api-page-header h2 { margin:5px 0 6px; font-family:var(--font-display); font-size:25px; }
.api-page-header p { max-width:620px; color:var(--text-secondary); line-height:1.5; }
.api-docs-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.api-doc-card, .api-intake-card { padding:18px; border:1px solid var(--border-soft); border-radius:10px; background:var(--bg-card); }
.api-doc-top { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.api-doc-top code, .api-intake-card code { color:var(--text-primary); font-family:var(--font-mono); font-size:12px; }
.api-method { padding:3px 7px; border-radius:5px; font-family:var(--font-mono); font-size:10px; font-weight:600; }
.api-method.get { background:rgba(52,211,153,.14); color:var(--success); }
.api-doc-card p, .api-intake-card p { color:var(--text-secondary); font-size:12px; line-height:1.5; }
.api-doc-card pre, .api-intake-card pre { margin-top:14px; padding:12px; overflow:auto; border:1px solid var(--border-soft); border-radius:7px; background:var(--bg-input); color:#9da8b7; font-family:var(--font-mono); font-size:11px; line-height:1.5; }
.api-intake-card { display:grid; grid-template-columns:1fr 1.2fr; gap:20px; margin-top:14px; }
.api-intake-card h3 { margin:5px 0; font-family:var(--font-display); }

.sidebar {
    width: 248px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-soft);
    padding: 22px 16px;
}

.sidebar-brand {
    padding: 4px 8px 26px;
    border-bottom: 0;
}

.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(245,166,35,.14);
}

.sidebar-brand-title, .app-title, .section-header h3, .prompt-card-header h4,
.credential-card-header h4, .settings-header h2, .modal-header h3 {
    font-family: var(--font-display);
}

.sidebar-brand-title { font-size: 15.5px; font-weight: 600; }
.sidebar-brand-subtitle { font-family: var(--font-mono); font-size: 10px; letter-spacing: .5px; }

.sidebar-nav { padding: 12px 0; gap: 2px; }

.sidebar-nav-item {
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13.5px;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.sidebar-nav-item:hover { background: var(--surface-3); color: var(--text-primary); }
.sidebar-nav-item.active {
    background: var(--surface-3);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.sidebar-nav-item.active svg { color: var(--primary); }

.sidebar-footer {
    padding: 14px 8px 0;
    border-top: 1px solid var(--border-soft);
}

.main-area { background: transparent; }

.app-header {
    min-height: 74px;
    padding: 20px 36px;
    background: rgba(14,18,22,.72);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(12px);
}

.app-title { font-size: 20px; letter-spacing: -.2px; }
.header-icon { width: 30px; height: 30px; border-radius: 7px; }
.header-controls { gap: 14px; }

.header-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .35px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(52,211,153,.12);
}
.user-profile { display:flex; align-items:center; gap:8px; color:var(--text-secondary); font-size:12px; }
.user-avatar { display:inline-flex; align-items:center; justify-content:center; width:25px; height:25px; border-radius:50%; background:var(--primary); color:#221806; font-weight:700; }
.user-profile button { border:0; background:transparent; color:var(--text-secondary); cursor:pointer; font-size:11px; }
.user-profile button:hover { color:var(--primary); }
.profile-menu { position:relative; }
.sidebar-footer { display:flex; align-items:center; gap:10px; }
.profile-avatar { display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; border:2px solid var(--primary); border-radius:50%; background:var(--surface-3); color:var(--text-primary); font-family:var(--font-display); font-size:13px; font-weight:700; cursor:pointer; transition:transform .15s ease, box-shadow .15s ease; }
.profile-avatar:hover, .profile-avatar:focus-visible { transform:translateY(-1px); outline:none; box-shadow:0 0 0 4px rgba(245,166,35,.15); }
.profile-dropdown { position:fixed; top:82px; right:18px; z-index:9999; width:230px; padding:14px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-card); box-shadow:0 18px 45px rgba(0,0,0,.28); }
.profile-dropdown-heading { display:flex; flex-direction:column; gap:3px; padding-bottom:10px; border-bottom:1px solid var(--border-soft); }
.profile-dropdown-label { color:var(--text-secondary); font-family:var(--font-mono); font-size:9px; letter-spacing:.7px; text-transform:uppercase; }
.profile-dropdown-heading strong { color:var(--text-primary); font-size:13px; }
.profile-dropdown-email { padding:10px 0; overflow:hidden; color:var(--text-secondary); font-family:var(--font-mono); font-size:10px; text-overflow:ellipsis; white-space:nowrap; }
.profile-logout { width:100%; padding:9px 10px; border:1px solid var(--border-color); border-radius:8px; background:transparent; color:var(--text-secondary); cursor:pointer; font-size:11px; text-align:left; }
.profile-logout:hover { border-color:var(--primary); color:var(--primary); }
#app.app-shell > .sidebar { overflow:visible; z-index:100; }
#app.app-shell .sidebar-footer, #app.app-shell .profile-menu { overflow:visible; z-index:120; }
.auth-overlay { position:fixed; inset:0; z-index:2000; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(6,8,10,.86); backdrop-filter:blur(8px); }
.auth-card { width:min(430px,100%); padding:28px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-card); box-shadow:0 24px 80px rgba(0,0,0,.4); }
.auth-brand { display:flex; align-items:center; gap:10px; margin-bottom:28px; }
.auth-brand img { width:36px; height:36px; border-radius:8px; }
.auth-brand strong, .auth-brand span { display:block; }
.auth-brand strong { font-family:var(--font-display); font-size:16px; }
.auth-brand span { color:var(--text-secondary); font-size:11px; }
.auth-card h2 { margin:7px 0; font-family:var(--font-display); font-size:24px; }
.auth-card p { color:var(--text-secondary); font-size:12px; line-height:1.5; }
.auth-card form { display:flex; flex-direction:column; gap:13px; margin-top:20px; }
.auth-card label { display:flex; flex-direction:column; gap:6px; color:var(--text-secondary); font-size:11px; }
.auth-card input { padding:11px 12px; border:1px solid var(--border-color); border-radius:8px; background:var(--bg-input); color:var(--text-primary); }
.auth-card input:focus { outline:none; border-color:var(--primary); }
.auth-status { min-height:18px; margin-top:10px; color:var(--error) !important; }
.auth-link { margin-top:12px; padding:0; border:0; background:transparent; color:var(--primary); cursor:pointer; font-size:12px; }

.main-content {
    align-items: stretch;
    padding: 28px 36px 60px;
    gap: 18px;
}

.app-section.active { max-width: 1180px; margin: 0 auto; }
.panel-card, .history-section {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    box-shadow: none;
}

.section-header { margin-bottom: 12px; }
.section-header h3 { font-size: 15px; font-weight: 600; }
.setting-hint, .summary-label, .history-detail-meta { color: var(--text-secondary); }

.voice-container {
    min-height: 230px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(29,36,45,.65), rgba(22,27,34,.9));
    overflow: hidden;
}

.voice-btn {
    background: linear-gradient(145deg, #242c37, #161b22);
    box-shadow: 0 0 32px rgba(245,166,35,.16), inset 0 0 32px rgba(245,166,35,.08);
}
.voice-btn:hover { box-shadow: 0 0 45px rgba(245,166,35,.3), inset 0 0 42px rgba(245,166,35,.13); }
.voice-btn.active { box-shadow: 0 0 45px rgba(245,166,35,.32), inset 0 0 42px rgba(245,166,35,.14); }
.voice-btn svg { color: var(--primary); }
.voice-hint { font-family: var(--font-mono); font-size: 11px; }

.chat-container {
    background: var(--bg-input);
    border-color: var(--border-soft);
    border-radius: 8px;
}
.message { border-radius: 9px; font-size: 13px; }
.message.user { background: var(--accent-gradient); color: #221806; }
.message.assistant { background: var(--surface-3); }

.summary-item, .credential-card, .prompt-card, .history-record-detail, .call-detail-panel {
    background: var(--bg-input);
    border-color: var(--border-soft);
    border-radius: 8px;
}
.summary-value { font-family: var(--font-mono); font-size: 12px; }

.history-table th, .history-table td { border-color: var(--border-soft); }
.history-table th {
    background: var(--bg-input);
    color: #5c6673;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.history-table tbody tr:hover { background: var(--bg-input); }
.history-detail-btn, .call-detail-btn, .prompt-card-actions button {
    border-color: var(--border-color);
    background: transparent;
    color: var(--primary);
}

.prompt-card { position: relative; overflow: hidden; }
.prompt-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); }
.prompt-card-preview { background: var(--bg-card); border: 1px solid var(--border-soft); font-family: var(--font-mono); }
.prompt-card-badge { background: rgba(245,166,35,.15); color: var(--primary-light); }

.credential-card-icon { background: var(--surface-3); color: var(--primary); border: 1px solid var(--border-color); }
.credential-save-btn { background: var(--primary); color: #221806; border-radius: 8px; }
.settings-input, .settings-textarea, .custom-select-trigger, .slider-value-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.settings-input:focus, .settings-textarea:focus, .custom-select-trigger:hover { border-color: var(--primary); }
.settings-accordion { border: 1px solid var(--border-color); border-radius: 8px; }
.settings-accordion summary { background: var(--bg-input); }
.settings-accordion summary::before { border-color: var(--primary); }

.modal-overlay, .settings-overlay { background: rgba(6,8,10,.68); backdrop-filter: blur(3px); }
.modal, .settings-panel { background: var(--bg-card); border-color: var(--border-color); }
.modal-header, .modal-footer, .settings-header { border-color: var(--border-soft); }

.theme-toggle::before { content: 'M'; font-family: var(--font-mono); color: var(--text-faint, #5c6673); }
[data-theme="light"] .theme-toggle::before { content: 'L'; }

@media (max-width: 900px) {
    .app-header { padding: 16px 20px; }
    .main-content { padding: 20px; }
}

@media (max-width: 640px) {
    #app.app-shell { flex-direction: column; }
    .sidebar { padding: 8px; }
    .sidebar-brand { padding: 6px 8px; }
    .app-header { min-height: 62px; }
    .header-status { display: none; }
    .main-content { padding: 14px; }
    .voice-container { min-height: 180px; }
    .integration-status-grid { grid-template-columns: 1fr; }
    .clients-page-header { align-items: stretch; flex-direction: column; }
    .plans-grid, .api-docs-grid, .api-intake-card { grid-template-columns:1fr; }
    .table-filters { justify-content: stretch; width: 100%; }
    .table-search, .table-filter { min-width: 0; width: 100%; }
}

/* ============ SINGLE HORIZONTAL NAVIGATION ============ */
.app-shell#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-shell#app > .sidebar {
    width: 100%;
    height: auto;
    min-height: 70px;
    flex: 0 0 auto;
    position: relative;
    top: auto;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    padding: 8px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
}

.app-shell#app .sidebar-brand {
    flex: 0 0 auto;
    padding: 5px 18px 5px 0;
    border: 0;
    border-right: 1px solid var(--border-soft);
}

.app-shell#app .sidebar-nav {
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

.app-shell#app .sidebar-nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 11px;
}

.app-shell#app .sidebar-footer {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0 0 0 12px;
    border: 0;
    border-left: 1px solid var(--border-soft);
}

.app-shell#app .main-area {
    width: 100%;
    height: 100vh;
    min-height: 0;
}

.app-shell#app .app-section {
    display: block;
    width: 100%;
}

.app-shell#app .app-section[hidden] {
    display: none !important;
}

@media (min-width: 1200px) {
    .app-shell#app > .sidebar { padding-inline: 32px; }
    .app-shell#app .sidebar-nav { justify-content: center; }
}

@media (max-width: 900px) {
    .app-shell#app > .sidebar { padding-inline: 16px; }
    .app-shell#app .sidebar-nav { justify-content: flex-start; }
}

@media (max-width: 768px) {
    .app-shell#app > .sidebar { min-height: 64px; padding: 8px 12px; }
    .app-shell#app .sidebar-brand { padding-right: 12px; }
    .app-shell#app .sidebar-nav { padding-inline: 8px; }
    .app-shell#app .main-area { height: 100vh; }
    .profile-dropdown { top:58px; right:10px; }
}

@media (max-width: 640px) {
    .app-shell#app > .sidebar { min-height: 56px; padding: 6px 8px; }
    .app-shell#app .sidebar-brand-icon { width: 30px; height: 30px; }
    .app-shell#app .sidebar-brand-text { display: none; }
    .app-shell#app .sidebar-brand { padding: 0 8px 0 0; }
    .app-shell#app .sidebar-nav { gap: 2px; padding-inline: 6px; }
    .app-shell#app .sidebar-nav-item { padding: 8px 10px; }
    .app-shell#app .sidebar-nav-item svg { display: none; }
    .app-shell#app .sidebar-footer { display:flex; gap:8px; }
    .app-shell#app .main-area { height: 100vh; }
}
