/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Status Colors */
    --status-pending: #f59e0b;
    --status-scheduled: #3b82f6;
    --status-assigned: #6366f1;
    --status-in-progress: #8b5cf6;
    --status-completed: #22c55e;
    --status-rejected: #ef4444;
    --status-cancelled: #64748b;

    /* Background */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.8);

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Border */
    --border-color: rgba(148, 163, 184, 0.2);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Glass Effect */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(10px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

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

/* Layout */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xs);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.1));
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.online {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Sidebar user block ──────────────────────────────────── */

.sidebar-user-block {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

.sidebar-user-block:empty { display: none; }

#sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: fadeInUser 0.4s ease forwards;
}

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

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.sidebar-logout-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
    font-size: 0.85rem;
}

.sidebar-logout-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: var(--spacing-xl);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    gap: var(--spacing-md);
    min-width: 0;
}

.page-title {
    font-size: clamp(1.1rem, 2.5vw, 1.875rem);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ── Dashboard mode: full-viewport layout, zero outer scroll ── */
.main-content.dashboard-mode {
    overflow-y: hidden;  /* lock outer scroll */
    display: flex;
    flex-direction: column;
}

.main-content.dashboard-mode .content-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: fadeIn 0.3s ease;
}

.main-content.dashboard-mode .stats-grid {
    flex-shrink: 0;
}

/* 2-column panel grid filling remaining height */
.dashboard-panels {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--spacing-lg);
}

.dashboard-panels .section-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.dashboard-panels .table-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Dashboard panel tables: no horizontal scroll — fit the panel width */
.dashboard-panels .data-table {
    min-width: 0;       /* override global 600px */
    width: 100%;
    table-layout: auto;
}

/* Left panel: recent OTs — 3 cols, title wraps */
.db-recent-table th,
.db-recent-table td {
    font-size: 0.82rem;
    padding: .45rem .75rem;
}
.db-recent-table td:first-child {
    white-space: nowrap;
    width: 60px;
}
.db-recent-table td:last-child {
    white-space: nowrap;
    width: 110px;
}
.db-recent-table .col-title {
    white-space: normal;
    word-break: break-word;
    max-width: 0;        /* lets flex/grid give remaining space */
}

/* Right panel: compact store stats — fixed layout to prevent overflow */
.dashboard-panels .db-calls-table {
    table-layout: fixed;
    width: 100%;
}
.dashboard-panels .db-calls-table th,
.dashboard-panels .db-calls-table td {
    font-size: 0.78rem;
    padding: .4rem .5rem;
    white-space: nowrap;
    overflow: hidden;
}
/* Tienda column: truncates to fill remaining space */
.dashboard-panels .db-calls-table th:first-child,
.dashboard-panels .db-calls-table td.col-title {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
/* Numeric cols: fixed narrow widths */
.dashboard-panels .db-calls-table th:nth-child(2),
.dashboard-panels .db-calls-table td:nth-child(2) { width: 52px; text-align: center; }
.dashboard-panels .db-calls-table th:nth-child(3),
.dashboard-panels .db-calls-table td:nth-child(3) { width: 72px; text-align: center; }
.dashboard-panels .db-calls-table th:nth-child(4),
.dashboard-panels .db-calls-table td:nth-child(4) { width: 72px; text-align: center; }

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.pending { background: rgba(245, 158, 11, 0.2); color: var(--status-pending); }
.stat-icon.scheduled { background: rgba(59, 130, 246, 0.2); color: var(--status-scheduled); }
.stat-icon.completed { background: rgba(34, 197, 94, 0.2); color: var(--status-completed); }
.stat-icon.calls { background: rgba(99, 102, 241, 0.2); color: var(--primary-light); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Section Cards */
.section-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    margin-bottom: var(--spacing-xl);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.view-all {
    color: var(--primary-light);
    text-decoration: none;
    font-size: 0.875rem;
}

.view-all:hover {
    text-decoration: underline;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-pending { background: rgba(245, 158, 11, 0.2); color: var(--status-pending); }
.badge-scheduled { background: rgba(59, 130, 246, 0.2); color: var(--status-scheduled); }
.badge-assigned { background: rgba(99, 102, 241, 0.2); color: var(--status-assigned); }
.badge-in-progress { background: rgba(139, 92, 246, 0.2); color: var(--status-in-progress); }
.badge-completed { background: rgba(34, 197, 94, 0.2); color: var(--status-completed); }
.badge-rejected { background: rgba(239, 68, 68, 0.2); color: var(--status-rejected); }
.badge-cancelled { background: rgba(100, 116, 139, 0.2); color: var(--status-cancelled); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
}

.btn-action {
    background: transparent;
    color: var(--text-muted);
    padding: var(--spacing-xs);
}

.btn-action:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

/* Transcription Styles */
.transcription-message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.transcription-message.transcription-nora {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.transcription-message.transcription-technician {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex-direction: row-reverse;
}

.transcription-speaker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.transcription-speaker-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.transcription-message.transcription-nora .transcription-speaker-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

.transcription-message.transcription-technician .transcription-speaker-avatar {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    box-shadow: 0 0 16px rgba(14, 165, 233, 0.35);
}

.transcription-speaker-name {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 10px;
    border-radius: 12px;
}

.transcription-message.transcription-nora .transcription-speaker-name {
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: white;
}

.transcription-message.transcription-technician .transcription-speaker-name {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
}

.transcription-text {
    flex: 1;
    padding: 14px 18px;
    line-height: 1.7;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.transcription-message.transcription-nora .transcription-text {
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px 18px 18px 18px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--text-primary);
}

.transcription-message.transcription-technician .transcription-text {
    background: rgba(51, 65, 85, 0.7);
    border-radius: 18px 4px 18px 18px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

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

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* Modal header extras */
.modal-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    font-size: 1rem;
    flex-shrink: 0;
}

.modal-header-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.modal-header-meta i {
    font-size: 0.7rem;
}

/* Calls Stats Bar */
.calls-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.calls-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s;
}

.calls-stat-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.calls-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    flex-shrink: 0;
}

.calls-stat-icon.cs-completed { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.calls-stat-icon.cs-rejected  { background: rgba(239, 68, 68, 0.15);  color: #f87171; }
.calls-stat-icon.cs-avg       { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

.calls-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.calls-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Filters */
.filters {
    display: flex;
    gap: var(--spacing-md);
}

.filters select {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Checklist Template */
.checklist-template {
    padding: var(--spacing-lg);
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
}

.checklist-item-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.checklist-item-text {
    flex: 1;
    font-size: 0.875rem;
}

.checklist-item-required {
    font-size: 0.75rem;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

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

.toast-icon {
    font-size: 1.25rem;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
}

/* Visit Detail Styles */
.visit-detail-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.visit-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.visit-detail-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.visit-detail-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.visit-detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.visit-detail-value {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.audio-player-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-player-progress {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.audio-player-progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — full system
   ═══════════════════════════════════════════════════════════════ */

/* ── Hamburger button ─────────────────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px; height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background .2s;
    flex-shrink: 0;
}
.hamburger:hover { background: rgba(255,255,255,.06); }
.hamburger span {
    display: block; height: 2px; width: 100%;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: transform .25s ease, opacity .25s ease;
    transform-origin: center;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ── Header left group ────────────────────────────────────── */
.header-left {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

/* ── Fluid typography (applies always) ───────────────────── */
.page-title      { font-size: clamp(1.1rem, 2.5vw, 1.875rem); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-header h2 { font-size: clamp(.9rem, 1.8vw, 1.125rem); }
.stat-value      { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
.stat-label      { font-size: clamp(.75rem, 1.4vw, .875rem); }
.data-table th   { font-size: clamp(.7rem, 1.2vw, .875rem); }
.data-table td   { font-size: clamp(.78rem, 1.3vw, .9rem); }

/* ── Table: always scroll horizontally, never wrap columns ── */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table {
    min-width: 600px;        /* table never collapses below this */
}
.data-table th,
.data-table td {
    white-space: nowrap;
    padding: var(--spacing-sm) var(--spacing-md);
}
/* Title/description columns allowed to break */
.data-table td.col-title,
.data-table td.col-desc {
    white-space: normal;
    max-width: 220px;
    word-break: break-word;
}

/* ── ≤1280px: tighten main padding ───────────────────────── */
@media (max-width: 1280px) {
    .main-content { padding: var(--spacing-lg); }
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
}

/* ── ≤1024px: collapse sidebar to drawer ─────────────────── */
@media (max-width: 1024px) {
    .hamburger { display: flex; }

    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 100;
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
    }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--spacing-md); }
    .stat-card  { padding: var(--spacing-md); }
    .stat-icon  { width: 42px; height: 42px; font-size: 1.1rem; }

    .header { margin-bottom: var(--spacing-lg); }
}

/* ── ≤1280px: dashboard panels still 2-col but proportional ─ */
@media (max-width: 1280px) {
    .dashboard-panels { grid-template-columns: 1.3fr 1fr; }
}

/* ── ≤768px: further tighten ─────────────────────────────── */
@media (max-width: 768px) {
    .main-content { padding: var(--spacing-md); }

    .header { margin-bottom: var(--spacing-md); }

    /* Button label hidden — icon only */
    .btn-label { display: none; }
    .btn-primary#btn-new-wo { padding: var(--spacing-sm); }

    .stats-grid { gap: .625rem; }
    .stat-card  { padding: .75rem; gap: .75rem; }
    .stat-icon  { width: 36px; height: 36px; font-size: 1rem; flex-shrink: 0; }

    .section-header {
        padding: var(--spacing-md);
        flex-direction: column;
        align-items: stretch;
        gap: .625rem;
    }
    .section-header h2 { font-size: 1rem; }
    .data-table th, .data-table td { padding: .5rem .75rem; }

    /* Modals: full width on mobile */
    .modal-content { margin: .5rem; max-width: calc(100vw - 1rem); width: 100% !important; }
    .modal-body    { padding: var(--spacing-md); }
    .modal-header  { padding: var(--spacing-md); }
    .modal-footer  { padding: var(--spacing-sm) var(--spacing-md); flex-wrap: wrap; gap: .5rem; }
    .modal-footer .btn { flex: 1 1 auto; justify-content: center; }

    /* Filters full-width column */
    .filters { flex-direction: column; gap: .5rem; width: 100%; }
    .filter-input, .filter-select { width: 100% !important; }
}

/* ── ≤768px: dashboard panels stack, allow scroll ───────── */
@media (max-width: 768px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
        flex: none;
        min-height: auto;
    }
    .dashboard-panels .section-card {
        min-height: 220px;
        max-height: 320px;
    }
    .main-content.dashboard-mode {
        overflow-y: auto;   /* allow scroll on mobile (stack = taller than viewport) */
    }
}

/* ── ≤480px: phone ───────────────────────────────────────── */
@media (max-width: 480px) {
    .main-content { padding: .625rem; }
    .stats-grid   { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
    .stat-card    { padding: .625rem .5rem; gap: .5rem; }
    .stat-icon    { width: 32px; height: 32px; font-size: .875rem; }
    .form-row     { grid-template-columns: 1fr; }
    .section-header { flex-wrap: wrap; gap: .5rem; }
}

/* ── ≤360px: tiny phone ──────────────────────────────────── */
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS — ENGINEERING ARCHITECTURE LAYOUT
   ═══════════════════════════════════════════════════════════════ */

:root {
    --border: rgba(148, 163, 184, 0.2);
    --accent: #6366f1;
    --node-online: #22c55e;
    --node-offline: #ef4444;
    --node-warning: #f59e0b;
    --node-unknown: #64748b;
}

/* ── Architecture Topology ────────────────────────────────────── */
.arch-topology {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.75rem 1.5rem 1rem;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.arch-side-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.arch-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-width: 110px;
    position: relative;
    transition: border-color 0.2s;
}

.arch-node.node-ok { border-color: rgba(34, 197, 94, 0.35); }
.arch-node.node-warn { border-color: rgba(245, 158, 11, 0.35); }
.arch-node.node-err { border-color: rgba(239, 68, 68, 0.35); }

.arch-node-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.arch-node-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.arch-node-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 100px;
    word-break: break-all;
}

.arch-node-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--node-unknown);
}

.arch-node-dot.online  { background: var(--node-online);  box-shadow: 0 0 6px var(--node-online); }
.arch-node-dot.offline { background: var(--node-offline); box-shadow: 0 0 6px var(--node-offline); }
.arch-node-dot.warning { background: var(--node-warning); box-shadow: 0 0 6px var(--node-warning); }

/* NORA Core */
.arch-core {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 1.75rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(99,102,241,0.08));
    border: 1.5px solid rgba(99, 102, 241, 0.45);
    border-radius: var(--radius-xl);
    min-width: 210px;
    position: relative;
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.15);
}

.arch-core-pulse {
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: calc(var(--radius-xl) + 2px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    animation: corePulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes corePulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.1; transform: scale(1.01); }
}

.arch-core-icon {
    font-size: 2rem;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.arch-core-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.arch-core-stack {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-align: center;
}

.arch-core-deps {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(99, 102, 241, 0.25);
    width: 100%;
}

.arch-dep {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 6px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    position: relative;
}

.arch-dep-icon { font-size: 1rem; color: var(--text-secondary); }
.arch-dep-label { font-size: 0.72rem; font-weight: 600; color: var(--text-primary); }
.arch-dep-meta { font-size: 0.65rem; color: var(--text-muted); text-align: center; }

.arch-dep-dot {
    position: absolute;
    top: 5px; right: 5px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--node-unknown);
}
.arch-dep-dot.online  { background: var(--node-online);  box-shadow: 0 0 5px var(--node-online); }
.arch-dep-dot.offline { background: var(--node-offline); }
.arch-dep-dot.warning { background: var(--node-warning); }

/* Connectors */
.arch-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.5rem;
    min-width: 70px;
    gap: 4px;
}

.arch-connector-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
}

.arch-connector-line {
    width: 48px;
    height: 1px;
    background: linear-gradient(90deg, var(--border-color), rgba(99,102,241,0.5), var(--border-color));
    position: relative;
    overflow: visible;
}

.arch-connector-line::after {
    content: '';
    position: absolute;
    right: -4px;
    top: -4px;
    border: 4px solid transparent;
    border-left-color: rgba(99,102,241,0.6);
}

/* ── Config Tabs ──────────────────────────────────────────────── */
.config-tab-nav {
    display: flex;
    gap: 2px;
    padding: 0.75rem 1rem 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
}

.config-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.config-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }

.config-tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
    background: rgba(99, 102, 241, 0.07);
}

.config-panel { display: none; padding: 1.5rem; }
.config-panel.active { display: block; animation: fadeIn 0.2s ease; }

/* ── Config Sections ──────────────────────────────────────────── */
.config-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.config-section {
    margin-bottom: 1.5rem;
}

.config-section:last-child { margin-bottom: 0; }

.config-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.config-section-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.55;
}

.config-section-desc code {
    background: rgba(99,102,241,0.12);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    color: var(--primary-light);
}

.config-notice {
    margin-top: 0.75rem;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.config-notice i { color: var(--info); margin-top: 2px; flex-shrink: 0; }

.config-notice code {
    background: rgba(99,102,241,0.12);
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--primary-light);
}

/* ── Input + Secret fields ────────────────────────────────────── */
.config-input {
    padding: 7px 11px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.config-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

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

.secret-field-row .config-input { flex: 1; }

.config-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-field-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Info rows (label + value) ────────────────────────────────── */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(148,163,184,0.1);
    gap: 1rem;
}

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

.info-row-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.info-row-value {
    font-size: 0.82rem;
    font-weight: 500;
    text-align: right;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}

.info-badge.ok { background: rgba(34,197,94,0.12); color: var(--success); }
.info-badge.warn { background: rgba(245,158,11,0.12); color: var(--warning); }
.info-badge.err { background: rgba(239,68,68,0.12); color: var(--danger); }

.copy-inline-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.copy-inline-btn:hover { color: var(--text-primary); border-color: var(--primary); }

/* ── Code blocks ──────────────────────────────────────────────── */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.code-copy-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    padding: 2px 8px;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.code-copy-btn:hover { color: var(--primary-light); border-color: var(--primary); }

.code-block {
    width: 100%;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    color: #a5f3fc;
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    line-height: 1.5;
    resize: none;
    min-height: 68px;
    white-space: pre;
    overflow: auto;
}

textarea.code-block { resize: vertical; }

/* ── JWT Generator ────────────────────────────────────────────── */
.jwt-input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.jwt-output-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Pipeline Flow ────────────────────────────────────────────── */
.pipeline-flow {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.75rem 0;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-width: 110px;
    text-align: center;
}

.pipeline-step-icon {
    font-size: 1.1rem;
    color: var(--primary-light);
}

.pipeline-step-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pipeline-step-detail {
    font-size: 0.67rem;
    color: var(--text-muted);
}

.pipeline-arrow {
    font-size: 1.1rem;
    color: rgba(99,102,241,0.5);
    padding: 0 6px;
    flex-shrink: 0;
}

/* ── Integration Flow ─────────────────────────────────────────── */
.integration-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 700px;
}

.int-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.int-arrow {
    text-align: center;
    color: rgba(99,102,241,0.4);
    font-size: 1.2rem;
    line-height: 1;
    padding: 3px 0;
    margin-left: 18px;
}

.int-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.int-step-body { flex: 1; }

.int-step-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.int-step-code {
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', monospace;
    color: #a5f3fc;
    background: rgba(15,23,42,0.7);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    line-height: 1.5;
    word-break: break-all;
}

/* ── DB Stats Grid ────────────────────────────────────────────── */
.db-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.db-stat-card {
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.db-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.db-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.db-stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Paginación ──────────────────────────────────────────────── */
.pagination-info {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}

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

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── LIVE MONITOR MODAL ─────────────────────────────────── */
.modal-monitor {
    max-width: 1060px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.monitor-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.monitor-live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #f87171;
    letter-spacing: 0.12em;
    flex-shrink: 0;
}

.monitor-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    animation: monitor-pulse 1s infinite;
}

@keyframes monitor-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.75); }
}

.monitor-call-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.monitor-call-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Body: two columns */
.monitor-body {
    display: grid;
    grid-template-columns: 270px 1fr;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Left: AI context */
.monitor-context {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
}

.monitor-context::-webkit-scrollbar { width: 3px; }
.monitor-context::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.monitor-context-header {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.monitor-context-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.monitor-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: monitor-spin 0.65s linear infinite;
}

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

.monitor-ctx-item { margin-bottom: 14px; }

.monitor-ctx-label {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.monitor-ctx-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.monitor-ctx-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.monitor-ctx-badge.priority-alta    { background: rgba(239,68,68,0.15); color: #f87171; }
.monitor-ctx-badge.priority-normal  { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.monitor-ctx-badge.priority-baja    { background: rgba(34,197,94,0.15); color: #4ade80; }
.monitor-ctx-badge.priority-urgente { background: rgba(239,68,68,0.22); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }

.monitor-ctx-divider { height: 1px; background: var(--border-color); margin: 12px 0; }

/* Right: transcript */
.monitor-transcript {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.monitor-transcript-header {
    padding: 11px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.monitor-turn-count {
    margin-left: auto;
    background: rgba(99,102,241,0.15);
    color: var(--primary-light);
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
}

.monitor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.monitor-messages::-webkit-scrollbar { width: 4px; }
.monitor-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.monitor-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.monitor-empty i { font-size: 2rem; opacity: 0.25; display: block; margin-bottom: 4px; }

/* Message bubbles */
.monitor-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: monitor-slide 0.22s ease;
}

@keyframes monitor-slide {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.monitor-msg.msg-user { flex-direction: row-reverse; }

.monitor-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.monitor-msg.msg-nora .monitor-msg-avatar {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    box-shadow: 0 0 10px rgba(99,102,241,0.3);
}

.monitor-msg.msg-user .monitor-msg-avatar {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    box-shadow: 0 0 10px rgba(14,165,233,0.3);
}

.monitor-msg-content { flex: 1; min-width: 0; }

.monitor-msg-label {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    padding: 0 2px;
}

.monitor-msg.msg-nora .monitor-msg-label { color: var(--primary-light); }
.monitor-msg.msg-user .monitor-msg-label { color: #38bdf8; text-align: right; }

.monitor-msg-bubble {
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.monitor-msg.msg-nora .monitor-msg-bubble {
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 4px 14px 14px 14px;
    color: var(--text-primary);
}

.monitor-msg.msg-user .monitor-msg-bubble {
    background: rgba(51,65,85,0.7);
    border: 1px solid rgba(148,163,184,0.15);
    border-radius: 14px 4px 14px 14px;
    color: var(--text-secondary);
}

.monitor-msg-ts {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 2px;
}

.monitor-msg.msg-user .monitor-msg-ts { text-align: right; }

/* Typing indicator */
.monitor-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: rgba(99,102,241,0.04);
}

.monitor-typing-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.monitor-typing-dots { display: flex; gap: 4px; align-items: center; }

.monitor-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: monitor-bounce 1.3s infinite;
}

.monitor-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.monitor-typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes monitor-bounce {
    0%, 80%, 100% { transform: scale(0.75); opacity: 0.4; }
    40%           { transform: scale(1.2);  opacity: 1; }
}

/* Footer */
.monitor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(15,23,42,0.4);
    flex-shrink: 0;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.monitor-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.monitor-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.monitor-status-dot.active {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74,222,128,0.5);
    animation: monitor-pulse 1.5s infinite;
}

.monitor-counters {
    display: flex;
    gap: 18px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.monitor-counters strong { color: var(--text-secondary); }

/* Floating live badge (bottom-right when call active) */
#live-call-badge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 24px;
    padding: 8px 18px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #f87171;
    letter-spacing: 0.1em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    transition: background 0.2s, transform 0.15s;
    animation: monitor-slide 0.3s ease;
}

#live-call-badge:hover { background: rgba(239,68,68,0.22); transform: translateY(-1px); }

.live-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    animation: monitor-pulse 1s infinite;
}

/* ── UI COMPONENTS ──────────────────────────────────────── */

/* Generic Confirm Modal */
.conf-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    background: rgba(99,102,241,0.15);
    color: var(--primary-light);
    flex-shrink: 0;
}
.conf-icon.danger  { background: rgba(239,68,68,0.15);  color: #f87171; }
.conf-icon.warning { background: rgba(245,158,11,0.15); color: #fbbf24; }

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-danger:hover { background: #b91c1c; }

/* Call Initiation Modal */
.call-init-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: rgba(34,197,94,0.15);
    display: flex; align-items: center; justify-content: center;
    color: var(--success);
    font-size: 1.1rem;
    flex-shrink: 0;
    animation: call-init-glow 2s ease-in-out infinite;
}

@keyframes call-init-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
    50%       { box-shadow: 0 0 0 8px rgba(34,197,94,0.12); }
}

.call-init-card {
    background: rgba(15,23,42,0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-top: 16px;
}

.call-init-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.call-init-ot-id {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.03em;
    margin-bottom: 3px;
}

.call-init-title {
    font-size: 0.975rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.call-init-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

.call-init-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.call-init-row i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.call-init-hint {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    background: rgba(99,102,241,0.06);
    border-radius: var(--radius-md);
    border: 1px solid rgba(99,102,241,0.12);
    line-height: 1.5;
}

.btn-call {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 9px 22px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}
.btn-call:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-call:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
