/* ═══════════════════════════════════════════════════════════════
   Zammler Kazakhstan Operator Workspace — Premium Light Theme
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #007281;
    --primary-hover: #005B67;
    --primary-dim: rgba(0, 114, 129, 0.06);
    --primary-glow: rgba(0, 114, 129, 0.15);
    
    --accent: #009AB6;
    --accent-hover: #008199;
    --accent-dim: rgba(0, 154, 182, 0.08);
    
    --bg-dark: #F8FAFC;
    --bg-dark-accent: #E2E8F0;
    
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(0, 114, 129, 0.1);
    --card-border-active: rgba(0, 114, 129, 0.25);
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.2);
    
    --warning: #D97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --warning-border: rgba(217, 119, 6, 0.2);
    
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.2);

    --ai-draft: #9F7AEA;
    --ai-draft-bg: rgba(159, 122, 234, 0.1);
    --ai-draft-border: rgba(159, 122, 234, 0.35);
    
    --font-heading: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-reasoning: 'Literal', var(--font-body);
    
    --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: all 0.15s ease;
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;
}

/* ── Base Setup ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* ── Glow Spheres & Glass Background ── */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 120%, #E0F2FE 0%, var(--bg-dark) 80%);
    z-index: -10;
}

.glow-sphere {
    position: fixed;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -5;
}

.sphere-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent) 0%, rgba(0,240,255,0) 70%);
    top: -200px;
    left: -150px;
    opacity: 0.08;
}

.sphere-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary) 0%, rgba(0,91,148,0) 70%);
    bottom: -200px;
    right: -100px;
    opacity: 0.12;
}

.sphere-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, var(--accent) 0%, rgba(0,200,216,0) 70%);
    top: 30%;
    left: 45%;
    opacity: 0.05;
}

/* ── App Container & Header ── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0;
    max-width: 1920px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    filter: drop-shadow(0 0 8px var(--primary-glow));
    animation: pulseLogo 3s infinite ease-in-out;
}

@keyframes pulseLogo {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 114, 129, 0.2)); }
    50% { filter: drop-shadow(0 0 10px rgba(0, 114, 129, 0.4)); }
}

.logo-text {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    font-family: var(--font-heading);
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #485156;
}

.brand-dot {
    font-size: 1.1rem;
    font-weight: 800;
    color: #007281;
    margin: 0 6px;
}

.brand-sub {
    font-size: 1.1rem;
    font-weight: 500;
    color: #007281;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--border-radius-sm);
    background: rgba(0, 114, 129, 0.04);
    border: 1px solid rgba(0, 114, 129, 0.08);
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: rgba(0, 114, 129, 0.04);
    border: 1px solid rgba(0, 114, 129, 0.08);
    border-radius: 30px;
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Main Dashboard Layout ── */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
}

/* ── Toolbar ── */
.dashboard-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 20px rgba(0, 114, 129, 0.02);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.toolbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-top: 1px solid rgba(0, 114, 129, 0.05);
    padding-top: 8px;
    width: 100%;
    min-width: 0;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.icon-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 129, 0.12);
    background: #FFFFFF;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.filter-select {
    width: auto;
    flex: 0 1 auto;
    min-width: 108px;
    max-width: 148px;
    min-height: 28px;
    padding: 4px 8px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.72rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-overflow: ellipsis;
}

.filter-select--status {
    min-width: 128px;
    max-width: 158px;
}

.filter-select--wide {
    min-width: 118px;
    max-width: 178px;
}

.filter-select:focus {
    border-color: var(--primary);
}

.filter-select option {
    background-color: #FFFFFF;
    color: var(--text-primary);
}

.filter-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 6px;
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    background: #FAFBFC;
    flex-shrink: 0;
}

.filter-checkbox-label:hover {
    border-color: #CBD5E1;
    color: var(--text-primary);
}

.filter-checkbox-label input[type="checkbox"] {
    width: 13px;
    height: 13px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.filter-checkbox-label:has(input:checked) {
    border-color: rgba(0, 114, 129, 0.35);
    background: rgba(0, 114, 129, 0.06);
    color: var(--text-primary);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(0, 114, 129, 0.15);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 114, 129, 0.25);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(0, 114, 129, 0.05);
    border-color: rgba(0, 114, 129, 0.15);
    color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(0, 114, 129, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(0, 114, 129, 0.08);
}

.btn-outline {
    background: transparent;
    border: 1px solid #CBD5E1;
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(0, 114, 129, 0.02);
    border-color: var(--text-secondary);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none !important;
}

/* ── Custom Checkbox ── */
.checkbox-container {
    display: block;
    position: relative;
    padding-left: 20px;
    margin-bottom: 20px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    height: 18px;
    width: 18px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 114, 129, 0.2);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #FFFFFF;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ── Progress Bar ── */
.progress-bar-container {
    padding: 12px 20px;
    background: rgba(0, 114, 129, 0.02);
    border: 1px dashed rgba(0, 114, 129, 0.15);
    border-radius: var(--border-radius-sm);
    animation: pulseBorder 2s infinite ease-in-out;
}

@keyframes pulseBorder {
    0%, 100% { border-color: rgba(0, 114, 129, 0.1); }
    50% { border-color: rgba(0, 114, 129, 0.3); }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 6px;
    font-family: var(--font-heading);
    font-weight: 500;
}

.progress-track {
    height: 6px;
    background: rgba(0, 114, 129, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(0, 114, 129, 0.15);
    transition: width 0.3s ease;
}

/* ── Tasks Table Panel ── */
.table-container-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(110%);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 114, 129, 0.03);
    display: flex;
    flex-direction: column;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.tasks-table th,
.tasks-table td {
    padding: 14px 18px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(0, 114, 129, 0.06);
    vertical-align: middle;
}

.tasks-table th {
    background: rgba(0, 114, 129, 0.02);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

.tasks-table tbody tr {
    transition: var(--transition-fast);
    background: #FFFFFF;
    cursor: pointer;
}

.tasks-table tbody tr:hover {
    background: rgba(0, 114, 129, 0.02);
}

.tasks-table tbody tr.selected {
    background: rgba(0, 114, 129, 0.04);
}

.tasks-table tbody tr.active-drawer {
    background: rgba(0, 114, 129, 0.07);
}

.col-checkbox {
    padding: 14px 0 14px 18px;
}

.col-checkbox .checkbox-container {
    margin-bottom: 0;
}

/* Table elements */
.task-id-badge {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(0, 114, 129, 0.04);
    border: 1px solid rgba(0, 114, 129, 0.08);
    border-radius: 4px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--primary);
}

.task-subject {
    font-weight: 600;
    color: var(--text-primary);
}

/* SLA and Draft Badges */
.badge-sla {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 600;
}

.badge-sla.urgent {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    text-shadow: 0 0 6px rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.03);
}

.badge-sla.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
}

.badge-sla.normal {
    background: rgba(0, 114, 129, 0.04);
    border: 1px solid rgba(0, 114, 129, 0.08);
    color: var(--text-secondary);
}

.badge-sla.blink {
    animation: slaBlinkRed 1.2s ease-in-out infinite;
}

@keyframes slaBlinkRed {
    0%, 100% {
        background: var(--danger-bg);
        border-color: var(--danger-border);
        color: var(--danger);
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
    }
    50% {
        background: rgba(239, 68, 68, 0.22);
        border-color: rgba(239, 68, 68, 0.55);
        color: #B91C1C;
        box-shadow: 0 0 14px rgba(239, 68, 68, 0.35);
    }
}

.badge-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-priority.status-priority-low {
    background: rgba(148, 163, 184, 0.1);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.2);
}

.badge-priority.status-priority-normal {
    background: rgba(0, 114, 129, 0.08);
    color: var(--primary);
    border-color: rgba(0, 114, 129, 0.15);
}

.badge-priority.status-priority-high {
    background: rgba(245, 158, 11, 0.1);
    color: #B45309;
    border-color: rgba(245, 158, 11, 0.2);
}

.badge-priority.status-priority-urgent {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.chat-bubble-bar-left .badge-sla {
    font-size: 0.62rem;
    padding: 2px 7px;
    border-radius: 4px;
}

.badge-draft {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 600;
}

.badge-draft.ready {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.badge-draft.none {
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Table Task Status Badges */
.badge-task-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.badge-task-status.status-waiting {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.badge-task-status.status-progress {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: rgba(0, 114, 129, 0.2);
}

.badge-task-status.status-process {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}

.badge-task-status.status-completed {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}

.badge-task-status.status-new {
    background: rgba(148, 163, 184, 0.1);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.2);
}

/* AI Draft available badge in row */
.badge-ai-draft {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 750;
    background: rgba(0, 200, 216, 0.1);
    color: #00889A;
    border: 1px solid rgba(0, 200, 216, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(0, 200, 216, 0.05);
}

/* ── Column Comments bubbles in Table ── */
.col-comment-bubble {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.35;
    max-height: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    word-break: break-word;
}

.col-comment-bubble.problem-bubble {
    background: rgba(71, 85, 105, 0.04);
    border: 1px solid rgba(71, 85, 105, 0.08);
    color: var(--text-secondary);
    border-left: 3px solid #64748B;
}

.col-comment-bubble.ai-bubble {
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-left: 3px solid var(--success);
}

.col-comment-bubble.ai-bubble.empty-draft {
    background: rgba(0, 114, 129, 0.03);
    border: 1px solid rgba(0, 114, 129, 0.06);
    color: var(--text-muted);
    border-left: 3px solid var(--text-muted);
    font-style: italic;
}

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    gap: 12px;
}

.empty-state svg {
    color: var(--text-muted);
}

.empty-state h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
}

/* ── Sliding Side Drawer ── */
.task-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 1120px; /* Increased to 1120px for spacious 2-column layout */
    max-width: 96vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(25px) saturate(120%);
    border-left: 1px solid rgba(0, 114, 129, 0.08);
    box-shadow: -10px 0 40px rgba(0, 114, 129, 0.04);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: var(--transition-smooth);
}

.task-drawer.open {
    transform: translateX(0);
}

/* Drawer Workspace Grid (Comment left, Editor right) */
.drawer-workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.workspace-col-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.workspace-col-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Telemetry Full Width Block */
.drawer-telemetry-fullwidth {
    width: 100%;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0, 114, 129, 0.08);
}

.drawer-title-group {
    display: flex;
    flex-direction: column;
}

.drawer-title-group h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.task-num {
    font-size: 0.7rem;
    font-family: var(--font-heading);
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 4px;
    border-radius: 50%;
}

.btn-close-drawer:hover {
    color: var(--text-primary);
    background: rgba(0, 114, 129, 0.05);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Custom Drawer Components */
.drawer-sla-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 114, 129, 0.02);
    border: 1px solid rgba(0, 114, 129, 0.05);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.drawer-sla-banner.urgent {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    box-shadow: 0 0 12px rgba(239,68,68,0.08);
}

.drawer-sla-banner.urgent .sla-value {
    color: var(--danger);
    font-weight: 700;
}

.drawer-sla-banner.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.drawer-sla-banner.warning .sla-value {
    color: var(--warning);
    font-weight: 700;
}

.drawer-sla-banner.blink {
    animation: slaBlinkRed 1.2s ease-in-out infinite;
}

.drawer-sla-banner.blink .sla-value {
    color: var(--danger);
    font-weight: 700;
}

.drawer-section {
    width: 100%;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid-5col {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 114, 129, 0.05);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(0, 114, 129, 0.015);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
    border-color: rgba(0, 114, 129, 0.12);
}

.card-header {
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Metadata Items */
.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-val {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Separated Statuses inside Drawer */
.statuses-container.card {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Spanned 4 status badges horizontally across the full width */
    gap: 12px;
    padding: 12px 14px;
    background: rgba(0, 114, 129, 0.015);
    border: 1px solid rgba(0, 114, 129, 0.04);
}

.status-badge-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-badge-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.badge-status-val {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid transparent;
    transition: transform 0.2s ease;
}

/* Status badge color maps */
.badge-status-val.status-waiting {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}
.badge-status-val.status-completed {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}
.badge-status-val.status-type {
    background: rgba(0, 114, 129, 0.04);
    color: var(--primary);
    border-color: rgba(0, 114, 129, 0.1);
}
.badge-status-val.status-priority-low {
    background: rgba(148, 163, 184, 0.06);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.15);
}
.badge-status-val.status-priority-normal {
    background: rgba(0, 114, 129, 0.04);
    color: var(--primary);
    border-color: rgba(0, 114, 129, 0.1);
}
.badge-status-val.status-priority-high {
    background: rgba(245, 158, 11, 0.06);
    color: #B45309;
    border-color: rgba(245, 158, 11, 0.15);
}
.badge-status-val.status-priority-urgent {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}
.badge-status-val.status-incident {
    background: rgba(139, 92, 246, 0.06);
    color: #6D28D9;
    border-color: rgba(139, 92, 246, 0.15);
}

/* Comment text */
.comment-text {
    font-size: 0.82rem;
    line-height: 1.45;
    background: rgba(0, 114, 129, 0.015);
    border-radius: 8px;
    padding: 10px 12px;
    max-height: 120px;
    overflow-y: auto;
    border-left: 3px solid var(--accent);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

/* Telemetry Tabs inside Drawer */
.telemetry-tabs-container.card {
    padding: 0;
    overflow: visible;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid rgba(0, 114, 129, 0.05);
    box-shadow: 0 4px 20px rgba(0, 114, 129, 0.02);
}

.tabs-header {
    display: flex;
    background: rgba(0, 114, 129, 0.025);
    border-bottom: 1px solid rgba(0, 114, 129, 0.06);
    padding: 6px;
    gap: 6px;
    border-radius: 12px 12px 0 0;
}

.tab-btn {
    flex: 1;
    padding: 8px 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 114, 129, 0.02);
}

.tab-btn.active {
    color: var(--primary);
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 114, 129, 0.08);
}

.tabs-body {
    padding: 16px;
}

.tab-pane {
    display: none;
    animation: fadeInTab 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.tab-pane.active {
    display: block;
}

.pane-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Status badging */
.badge-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status.lost { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-status.delivered { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-status.transit { background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(0, 114, 129, 0.2); }
.badge-status.pending { background: rgba(0, 114, 129, 0.04); color: var(--text-secondary); }

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    padding-left: 20px;
    border-left: 1px solid rgba(0, 114, 129, 0.1);
    margin-left: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -25px;
    top: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid #FFFFFF;
}

.timeline-item.active .timeline-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.timeline-item.delivered .timeline-dot {
    background: var(--success);
}

.timeline-item.lost .timeline-dot {
    background: var(--danger);
}

.timeline-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.timeline-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Telemetry generic tables */
.telemetry-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    background: #ffffff;
}

.telemetry-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 10px 12px;
    background: rgba(0, 114, 129, 0.015);
    border-bottom: 1px solid rgba(0, 114, 129, 0.08);
}

.telemetry-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 114, 129, 0.04);
    color: var(--text-primary);
    line-height: 1.4;
}

.telemetry-table tbody tr {
    transition: background-color 0.15s ease;
}

.telemetry-table tbody tr:nth-child(even) {
    background: rgba(0, 114, 129, 0.005);
}

.telemetry-table tbody tr:hover {
    background: rgba(0, 114, 129, 0.015);
}

.table-scroll-container {
    overflow-x: auto;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(0, 114, 129, 0.06);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.01);
    background: #ffffff;
}

/* AI Editor Card */
.ai-editor-card.card {
    border: 1px solid rgba(0, 114, 129, 0.12);
    background: rgba(0, 114, 129, 0.01);
    box-shadow: 0 4px 16px rgba(0, 114, 129, 0.02);
}

.ai-status {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(0, 114, 129, 0.05);
    color: var(--primary);
    font-weight: 600;
}

.ai-status.loading {
    background: rgba(0, 114, 129, 0.1);
    color: var(--primary);
    animation: glowText 1.5s infinite ease-in-out;
}

@keyframes glowText {
    0%, 100% { text-shadow: 0 0 2px rgba(0, 114, 129, 0); }
    50% { text-shadow: 0 0 6px var(--primary); }
}

.ai-status.lost {
    background: var(--danger-bg);
    color: var(--danger);
}

.custom-prompt-container {
    margin-bottom: 12px;
}

.expand-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    transition: var(--transition-fast);
}

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

.expand-btn .chevron {
    transition: transform 0.3s ease;
}

.expand-btn.active .chevron {
    transform: rotate(180deg);
}

.prompt-expand-pane {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.prompt-expand-pane.open {
    max-height: 80px;
}

.prompt-expand-pane textarea {
    width: 100%;
    height: 70px;
    margin-top: 6px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 114, 129, 0.12);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px;
    font-size: 0.78rem;
    font-family: var(--font-body);
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-expand-pane textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 129, 0.08);
}

.editor-zone {
    margin-bottom: 16px;
}

.editor-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.3px;
}

#ai-answer-text {
    width: 100%;
    height: 120px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 114, 129, 0.12);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    line-height: 1.45;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#ai-answer-text:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 129, 0.08);
}

.action-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

/* SOP Sources */
.sources-container {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid rgba(0, 114, 129, 0.08);
    padding-top: 10px;
}

.sources-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.source-item svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* AI Reasoning / Explanation Panel */
.reasoning-container {
    margin-top: 10px;
    border-top: 1px solid rgba(0, 114, 129, 0.08);
    padding-top: 8px;
}

#ai-reasoning-text {
    width: 100%;
    height: 120px;
    background: rgba(245, 158, 11, 0.015);
    border: 1px solid rgba(245, 158, 11, 0.12);
    border-radius: 8px;
    color: #7c2d12;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-family: var(--font-reasoning);
    font-style: italic;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#ai-reasoning-text:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}

/* Spinner anims */
.loader-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 114, 129, 0.08);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
    box-shadow: 0 0 10px var(--primary-glow);
}

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

.loader-login {
    margin-top: 8px;
    width: min(320px, 90vw);
    text-align: left;
}

.loader-login-title {
    margin: 0 0 6px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-primary);
    text-align: center;
}

.loader-login-hint {
    margin: 0 0 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

.loader-login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loader-login-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #CBD5E1;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: #fff;
}

.loader-login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 129, 0.12);
}

.loader-login-btn {
    width: 100%;
    margin-top: 4px;
}

.loader-login-error {
    margin: 10px 0 0;
    font-size: 0.8rem;
    color: var(--danger);
    text-align: center;
}

.btn-loader-circle {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#loader-status {
    font-size: 0.85rem;
    font-family: var(--font-heading);
    font-weight: 500;
    color: var(--text-secondary);
}

/* Table Pagination styles */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(0, 114, 129, 0.02);
    border-top: 1px solid rgba(0, 114, 129, 0.08);
}

.pagination-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Timeline filters & toggles */
.timeline-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 0 4px;
    border-bottom: 1px solid rgba(0, 114, 129, 0.06);
    padding-bottom: 10px;
}

.filter-chip {
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid rgba(0, 114, 129, 0.1);
    background: rgba(0, 114, 129, 0.02);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-chip:hover {
    background: rgba(0, 114, 129, 0.08);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 6px var(--primary-glow);
}

/* TSD Timeline overrides */
.timeline-item.tsd-item .timeline-dot {
    background: #7C3AED;
}

/* Date Range Filter styles */
.date-range-filter {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0;
    min-height: 28px;
    flex: 1 1 240px;
    min-width: 0;
}

.date-range-filter:hover {
    border-color: transparent;
    background: transparent;
}

.date-range-filter .filter-select {
    width: auto;
    flex: 0 1 118px;
    min-width: 108px;
    max-width: 132px;
    border: 1px solid #CBD5E1;
    padding: 4px 6px;
    min-height: 28px;
    height: 28px;
    background: #FFFFFF;
    font-size: 0.72rem;
}

.date-range-filter .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 114, 129, 0.1);
}

.date-range-filter .filter-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 600;
    flex-shrink: 0;
}

/* Table scroll container for tracking tables */
.table-scroll-container {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: auto;
    margin-top: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(0, 114, 129, 0.06);
    background: #FFFFFF;
}

/* Premium telemetry table adjustments */
.table-scroll-container .telemetry-table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll-container .telemetry-table th {
    position: sticky;
    top: 0;
    background: #F8FAFC;
    z-index: 10;
    box-shadow: inset 0 -1px 0 rgba(0, 114, 129, 0.08);
    font-weight: 600;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.table-scroll-container .telemetry-table tbody tr:hover {
    background-color: rgba(0, 114, 129, 0.02);
}

.table-scroll-container .telemetry-table td {
    white-space: nowrap;
    border-bottom: 1px solid rgba(0, 114, 129, 0.04);
}

/* Wrap long comments or descriptions in tracking tables */
.table-scroll-container .telemetry-table td:last-child {
    white-space: normal;
    word-break: break-word;
    min-width: 150px;
}

/* Button style adjustments for date filter actions */
.btn-date-apply,
.btn-date-clear {
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-date-apply {
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0 8px;
    min-width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.btn-date-clear {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0;
    min-width: 28px;
    height: 28px;
    line-height: 1;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-date-clear:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

/* ── Logistics Tasks Visual Timeline ── */
.tasks-timeline-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 10px 45px 10px;
    background: rgba(0, 114, 129, 0.015);
    border: 1px solid rgba(0, 114, 129, 0.05);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    position: relative;
    gap: 8px;
}

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    min-width: 90px;
}

.timeline-node-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Node statuses */
.timeline-node.completed .timeline-node-dot {
    background: var(--success);
    color: #FFFFFF;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.timeline-node.in-progress .timeline-node-dot {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 0 12px rgba(0, 114, 129, 0.4);
    animation: pulse-node-dot 2s infinite;
}

.timeline-node.pending .timeline-node-dot {
    background: #E2E8F0;
    color: #64748B;
    border: 1.5px solid #CBD5E1;
    box-shadow: none;
}

.timeline-node-info {
    text-align: center;
    margin-top: 8px;
    position: absolute;
    top: 30px;
    width: 130px;
}

.timeline-node-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-node-route {
    font-size: 0.62rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.1;
}

.timeline-node-date {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
}

.timeline-connector {
    flex-grow: 1;
    height: 4px;
    background: #E2E8F0;
    margin-top: -55px; /* aligns with center of dot */
    position: relative;
    z-index: 1;
    border-radius: 2px;
    min-width: 20px;
}

.timeline-connector.completed {
    background: var(--success);
}

.timeline-connector.in-progress {
    background: linear-gradient(to right, var(--success), var(--primary));
}

@keyframes pulse-node-dot {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 114, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(0, 114, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 114, 129, 0);
    }
}

/* ── Layout Switcher & Segmented Controls ── */
.btn-layout-tab.active {
    background: #FFFFFF !important;
    color: var(--primary) !important;
    box-shadow: 0 2px 5px rgba(0, 114, 129, 0.1) !important;
}

.btn-layout-tab:hover {
    color: var(--primary) !important;
}

/* ── Accordion Expansion Row ── */
.expansion-row {
    background: rgba(0, 114, 129, 0.005) !important;
}

.expansion-row td {
    padding: 0 16px 16px 16px !important;
    border-bottom: 1px solid rgba(0, 114, 129, 0.08) !important;
}

.accordion-expansion-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    background: rgba(0, 114, 129, 0.02);
    border: 1px solid rgba(0, 114, 129, 0.15);
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 114, 129, 0.04), inset 0 2px 4px rgba(0, 0, 0, 0.01);
    animation: slideDownFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.expansion-card {
    background: #FFFFFF;
    border: 1px solid rgba(0, 114, 129, 0.08);
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0, 114, 129, 0.02);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-fast);
}

.expansion-card:hover {
    border-color: rgba(0, 114, 129, 0.15);
    box-shadow: 0 4px 12px rgba(0, 114, 129, 0.04);
}

.expansion-card.ai-card {
    border-color: rgba(16, 185, 129, 0.15);
    background: rgba(16, 185, 129, 0.005);
}

.expansion-card.ai-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.05);
}

.expansion-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(0, 114, 129, 0.04);
    padding-bottom: 6px;
}

.expansion-card.ai-card .expansion-card-header {
    color: var(--success);
    border-bottom-color: rgba(16, 185, 129, 0.08);
}

.expansion-card-body {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.expansion-card-body.empty-draft {
    color: var(--text-muted);
    font-style: italic;
}

.expansion-card-reasoning {
    background: rgba(180, 83, 9, 0.05);
    border: 1px dashed rgba(180, 83, 9, 0.2);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #92400E;
    margin-bottom: 8px;
    font-family: var(--font-reasoning);
    font-style: italic;
}

.expansion-card-reasoning strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-family: var(--font-heading);
    font-style: normal;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #B45309;
}

/* Accordion toggling support */
tr.task-main-row {
    position: relative;
    transition: background-color 0.2s ease;
}

tr.task-main-row.accordion-mode {
    cursor: pointer;
}

tr.task-main-row.accordion-mode:hover {
    background: rgba(0, 114, 129, 0.02) !important;
}

tr.task-main-row.accordion-mode.expanded {
    background: rgba(0, 114, 129, 0.04) !important;
}

tr.task-main-row.accordion-mode.expanded td {
    border-bottom-color: transparent !important;
}

tr.task-main-row.expanded td:first-child {
    border-left: 4px solid var(--primary) !important;
    transition: border-left 0.15s ease;
}

/* Connection Status Indicator Badges */
.connection-status-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.status-indicator-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-heading);
    background: rgba(148, 163, 184, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.status-indicator-badge.connected {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-indicator-badge.disconnected {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.indicator-dot.dot-connected {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulseGlowSuccess 2s infinite ease-in-out;
}

.indicator-dot.dot-disconnected {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    animation: pulseGlowDanger 2s infinite ease-in-out;
}

.indicator-dot.dot-unknown {
    background-color: var(--text-muted);
    box-shadow: 0 0 8px var(--text-muted);
}

@keyframes pulseGlowSuccess {
    0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 4px var(--success); }
    50% { transform: scale(1.15); opacity: 0.8; box-shadow: 0 0 10px var(--success); }
}

@keyframes pulseGlowDanger {
    0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 4px var(--danger); }
    50% { transform: scale(1.15); opacity: 0.8; box-shadow: 0 0 10px var(--danger); }
}

/* Generating badge pulsing state */
.badge-ai-draft.generating {
    background: rgba(0, 114, 129, 0.08) !important;
    color: var(--primary) !important;
    border-color: rgba(0, 114, 129, 0.2) !important;
    animation: pulseGenerating 1.5s infinite ease-in-out;
}

@keyframes pulseGenerating {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ai-answer-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.58rem;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #00889A;
    background: rgba(0, 154, 182, 0.1);
    border: 1px solid rgba(0, 154, 182, 0.22);
    vertical-align: middle;
    line-height: 1.2;
}

.ai-answer-badge svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.chat-dialog-meta .ai-answer-badge {
    margin-left: 8px;
}

.chat-bubble-bar-left .ai-answer-badge {
    font-size: 0.56rem;
    padding: 2px 6px;
}

.analyze-done-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    margin-left: 2px;
    border-radius: 50%;
    color: #7C3AED;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.24);
    vertical-align: middle;
    flex-shrink: 0;
    cursor: default;
}

.analyze-done-badge svg {
    flex-shrink: 0;
    opacity: 0.92;
}

.chat-bubble-bar-left .analyze-done-badge {
    width: 16px;
    height: 16px;
}

/* ── Analytics Navigation & Tab Styling ── */
.btn-nav {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font-body);
}
.btn-nav:hover {
    background: var(--bg-dark-accent);
    color: var(--text-primary);
}
.btn-nav.active {
    background: var(--primary-dim);
    color: var(--primary);
    border: 1px solid var(--primary-glow);
}

/* ── Analytics Layout & Presets ── */
.analytics-main {
    max-width: 1920px;
    margin: 0 auto;
    width: 100%;
}
.btn-preset {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    transition: var(--transition-fast);
    font-family: var(--font-body);
}
.btn-preset:hover {
    color: var(--text-primary);
}
.btn-preset.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ── KPI Metrics Cards (legacy) ── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 114, 129, 0.04);
    border-color: var(--card-border-active);
}
.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.4rem;
}
.kpi-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.kpi-val {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

/* ── KPI v2 Cards (redesigned analytics) ── */
.kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
@media (max-width: 1200px) {
    .kpi-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 640px) {
    .kpi-grid-4 {
        grid-template-columns: 1fr;
    }
}

.kpi-card-v2 {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    backdrop-filter: blur(12px) saturate(120%);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    animation: kpiCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kpi-card-v2:nth-child(1) { animation-delay: 0.05s; }
.kpi-card-v2:nth-child(2) { animation-delay: 0.1s; }
.kpi-card-v2:nth-child(3) { animation-delay: 0.15s; }
.kpi-card-v2:nth-child(4) { animation-delay: 0.2s; }

@keyframes kpiCardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.kpi-card-v2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 14px 14px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kpi-card-v2--ai::before { background: linear-gradient(90deg, #7C3AED, #A78BFA); }
.kpi-card-v2--gen::before { background: linear-gradient(90deg, #6366F1, #818CF8); }
.kpi-card-v2--time::before { background: linear-gradient(90deg, #0EA5E9, #38BDF8); }
.kpi-card-v2--ring::before { background: linear-gradient(90deg, #7C3AED, #06B6D4); }
.kpi-card-v2--llm::before { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
.kpi-card-v2--det::before { background: linear-gradient(90deg, #10B981, #34D399); }
.kpi-card-v2--analyze::before { background: linear-gradient(90deg, #D97706, #FBBF24); }

.kpi-card-v2__badge--blue {
    background: rgba(59, 130, 246, 0.1);
    color: #2563EB;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.kpi-card-v2:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 114, 129, 0.06);
    border-color: var(--card-border-active);
}

.kpi-card-v2:hover::before {
    opacity: 1;
}

.kpi-card-v2__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-card-v2__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.kpi-card-v2__label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.kpi-card-v2__value-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.kpi-card-v2__value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-heading);
    line-height: 1.1;
    margin: 0;
}

.kpi-card-v2__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
}

.kpi-card-v2__badge--purple {
    background: rgba(124, 58, 237, 0.1);
    color: #7C3AED;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.kpi-card-v2__badge--teal {
    background: rgba(0, 114, 129, 0.1);
    color: var(--primary);
    border: 1px solid rgba(0, 114, 129, 0.2);
}

.kpi-card-v2__badge--amber {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.kpi-card-v2__sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Ring Progress Chart */
.kpi-card-v2--ring {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 18px 20px;
}

.kpi-ring-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-ring-svg {
    filter: drop-shadow(0 2px 8px rgba(124, 58, 237, 0.12));
}

.kpi-ring-fill {
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-ring-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    fill: var(--text-primary);
}

.kpi-ring-sublabel {
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 500;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card-v2--ring .kpi-card-v2__body {
    align-items: center;
}

/* Operator leaderboard AI rate bar */
.op-ai-rate-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
}

.op-ai-rate-track {
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    overflow: hidden;
    min-width: 40px;
}

.op-ai-rate-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #7C3AED, #06B6D4);
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.op-ai-rate-label {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: #7C3AED;
    white-space: nowrap;
    min-width: 32px;
    text-align: right;
}

/* ── Analytics Leaderboard & Grid ── */
.analytics-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1024px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}
.chart-container-card, .leaderboard-card {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    background: var(--card-bg);
}

/* ═══════════════════════════════════════════════════════════════
   Case-Grouped Chat Timeline View
   ═══════════════════════════════════════════════════════════════ */

.case-grouped-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
    flex: 1;
}

#case-grouped-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Case Group Card */
.case-group-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(110%);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 114, 129, 0.03);
    margin-left: 0;
    margin-right: 0;
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        margin 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.25s ease;
}

.case-group-card:hover {
    border-color: var(--card-border-active);
    box-shadow: 0 6px 28px rgba(0, 114, 129, 0.06);
}

.case-group-card.has-active {
    border-left: 3px solid var(--primary);
}

.case-group-card.expanded {
    margin-left: 20px;
    margin-right: 6px;
    border-color: rgba(0, 114, 129, 0.22);
    box-shadow:
        0 8px 32px rgba(0, 114, 129, 0.09),
        inset 3px 0 0 rgba(0, 114, 129, 0.35);
    background: linear-gradient(90deg, rgba(0, 114, 129, 0.025) 0%, var(--card-bg) 48px);
}

.case-group-card.expanded.has-active {
    border-left-width: 4px;
}

.case-group-card.expanded .case-group-header {
    background: rgba(0, 114, 129, 0.045);
    border-bottom-color: rgba(0, 114, 129, 0.12);
}

/* Case Group Header */
.case-group-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    background: rgba(0, 114, 129, 0.015);
    border-bottom: 1px solid rgba(0, 114, 129, 0.06);
    gap: 16px;
    flex-wrap: wrap;
    cursor: pointer;
    transition: var(--transition-fast);
}

.case-group-header:hover {
    background: rgba(0, 114, 129, 0.03);
}

.case-group-header-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.case-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.case-group-title .case-id {
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0, 114, 129, 0.06);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 114, 129, 0.1);
    white-space: nowrap;
}

.case-group-title .case-name {
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

a.crm-record-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

a.crm-record-link:hover {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a.task-id-badge.crm-record-link {
    color: var(--primary);
}

a.task-id-badge.crm-record-link:hover {
    background: rgba(0, 114, 129, 0.08);
    border-color: rgba(0, 114, 129, 0.2);
}

a.case-id.crm-record-link {
    color: var(--primary);
}

a.case-name.crm-record-link {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

a.crm-record-link.task-subject-link {
    color: var(--text-primary);
    font-weight: 600;
}

a.crm-record-link.drawer-case-link {
    color: var(--text-primary);
}

a.crm-record-link.drawer-case-link:hover {
    color: var(--primary);
}

.case-group-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.case-group-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-case-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-case-type.case-type-incident {
    background: rgba(0, 114, 129, 0.08);
    color: var(--primary);
    border-color: rgba(0, 114, 129, 0.15);
}

.badge-case-type.case-type-claim {
    background: rgba(139, 92, 246, 0.1);
    color: #6D28D9;
    border-color: rgba(139, 92, 246, 0.2);
}

.badge-case-type.case-type-default {
    background: rgba(148, 163, 184, 0.1);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.2);
}

.case-group-assignee {
    font-weight: 600;
    color: var(--text-secondary);
}

.case-group-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.case-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.case-group-badge.active-badge {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.case-group-badge.completed-badge {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.case-group-badge.tasks-count {
    background: rgba(0, 114, 129, 0.05);
    color: var(--primary);
    border: 1px solid rgba(0, 114, 129, 0.12);
}

.case-group-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(0, 114, 129, 0.04);
    border: 1px solid rgba(0, 114, 129, 0.08);
    transition: var(--transition-fast);
}

.case-group-toggle svg {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--text-secondary);
}

.case-group-card.expanded .case-group-toggle svg {
    transform: rotate(180deg);
}

/* Chat Timeline */
.case-chat-timeline {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, padding 0.3s ease;
    padding: 0 20px;
}

.case-group-card.expanded .case-chat-timeline {
    max-height: 5000px;
    opacity: 1;
    padding: 16px 16px 20px 32px;
}

.case-group-card.expanded .case-chat-timeline::before {
    left: 50px;
}

/* Timeline line */
.case-chat-timeline::before {
    content: '';
    position: absolute;
    left: 38px;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: linear-gradient(to bottom, rgba(0, 114, 129, 0.08), rgba(0, 114, 129, 0.15), rgba(0, 114, 129, 0.08));
    border-radius: 1px;
}

/* Chat Bubble */
.chat-bubble {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    position: relative;
    animation: fadeInBubble 0.4s ease both;
}

.chat-bubble-processing {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6366F1;
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
}

.chat-dialog-msg--summary .chat-dialog-text {
    font-style: italic;
    color: var(--text-secondary);
}
    border-top: 1px solid rgba(0, 114, 129, 0.04);
}

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

/* Timeline dot */
.chat-bubble-dot {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 4px;
    z-index: 1;
    box-shadow: 0 0 0 3px #FFFFFF;
}

.chat-bubble--ours .chat-bubble-dot {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 0 0 3px #FFFFFF, 0 0 8px rgba(0, 114, 129, 0.2);
}

.chat-bubble--foreign .chat-bubble-dot {
    background: #94A3B8;
    box-shadow: 0 0 0 3px #FFFFFF, 0 0 4px rgba(148, 163, 184, 0.15);
}

/* Bubble content */
.chat-bubble-content {
    flex: 1;
    min-width: 0;
    background: #FFFFFF;
    border: 1px solid rgba(0, 114, 129, 0.08);
    border-radius: 10px;
    overflow: hidden;
    transition: var(--transition-fast);
}

.chat-bubble--ours .chat-bubble-content {
    border-color: rgba(0, 114, 129, 0.12);
    box-shadow: 0 2px 12px rgba(0, 114, 129, 0.04);
}

.chat-bubble--foreign .chat-bubble-content {
    border-color: rgba(148, 163, 184, 0.15);
    background: rgba(248, 250, 252, 0.8);
}

.chat-bubble--answered .chat-bubble-content {
    border: 2px solid var(--success);
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.08);
}

.chat-bubble--pending .chat-bubble-content {
    border: 2px solid var(--danger);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.08);
}

.chat-bubble--draft .chat-bubble-content {
    border: 2px solid var(--ai-draft);
    box-shadow: 0 2px 12px rgba(159, 122, 234, 0.12);
}

.chat-bubble-content:hover {
    box-shadow: 0 4px 16px rgba(0, 114, 129, 0.06);
}

/* Bubble header bar */
.chat-bubble-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.72rem;
}

.chat-bubble--ours .chat-bubble-bar {
    background: rgba(0, 114, 129, 0.025);
    border-bottom: 1px solid rgba(0, 114, 129, 0.06);
}

.chat-bubble--foreign .chat-bubble-bar {
    background: rgba(148, 163, 184, 0.04);
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.chat-bubble-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-bubble-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.chat-bubble-date {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font-heading);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.chat-bubble-cs {
    font-weight: 700;
    font-family: var(--font-heading);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chat-bubble--ours .chat-bubble-cs {
    background: rgba(0, 114, 129, 0.08);
    color: var(--primary);
    border: 1px solid rgba(0, 114, 129, 0.15);
}

.chat-bubble--foreign .chat-bubble-cs {
    background: rgba(148, 163, 184, 0.08);
    color: #64748B;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.chat-bubble-foreign-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 2px 6px;
    background: rgba(148, 163, 184, 0.06);
    border-radius: 3px;
}

/* Chat dialog — Kaspi question / CS answer / AI draft */
.chat-bubble-messages {
    padding: 8px 10px 10px;
}

.chat-dialog {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 2px 0;
}

.chat-dialog--empty {
    align-items: center;
    padding: 10px 0;
}

.chat-dialog-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    max-width: 100%;
}

.chat-dialog-msg--kaspi {
    align-self: stretch;
}

.chat-dialog-msg--cs,
.chat-dialog-msg--ai {
    align-self: stretch;
    align-items: flex-start;
    padding-left: 14px;
    border-left: 2px solid rgba(0, 114, 129, 0.12);
    margin-left: 6px;
}

.chat-dialog-msg--analyze {
    align-self: stretch;
    align-items: flex-start;
    margin: 0 0 2px 2px;
    padding-left: 0;
    border-left: none;
    max-width: 92%;
}

.chat-dialog-msg--ai {
    border-left-color: rgba(159, 122, 234, 0.35);
}

.chat-dialog-msg--analyze .chat-dialog-meta {
    font-size: 0.56rem;
    font-weight: 600;
    color: #94A3B8;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0 2px;
    margin-bottom: 2px;
}

.chat-dialog-msg--analyze .chat-dialog-bubble {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0 2px 4px;
    box-shadow: none;
}

.chat-dialog-msg--analyze .chat-dialog-text {
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--text-muted);
    font-style: normal;
}

.chat-dialog-msg--analyze .chat-dialog-text--placeholder {
    font-size: 0.68rem;
    font-style: italic;
    color: #A8B4C4;
}

.chat-dialog-meta {
    font-size: 0.62rem;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
    color: var(--text-muted);
    padding: 0 6px;
    line-height: 1.2;
}

.chat-dialog-msg--cs .chat-dialog-meta {
    color: var(--primary);
}

.chat-dialog-msg--ai .chat-dialog-meta {
    color: var(--ai-draft);
}

.chat-dialog-bubble {
    padding: 8px 11px;
    border-radius: 14px;
    line-height: 1.45;
}

.chat-dialog-msg--kaspi .chat-dialog-bubble {
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border: 1px solid #E2E8F0;
    border-radius: 10px 10px 10px 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-dialog-msg--cs .chat-dialog-bubble {
    background: linear-gradient(135deg, rgba(0, 114, 129, 0.1) 0%, rgba(0, 154, 182, 0.08) 100%);
    border: 1px solid rgba(0, 114, 129, 0.18);
    border-radius: 10px 10px 4px 10px;
    box-shadow: 0 1px 3px rgba(0, 114, 129, 0.06);
}

.chat-dialog-msg--cs-ai .chat-dialog-bubble {
    border-color: rgba(0, 154, 182, 0.22);
    background: linear-gradient(135deg, rgba(0, 154, 182, 0.07) 0%, rgba(0, 114, 129, 0.06) 100%);
    box-shadow: 0 1px 3px rgba(0, 154, 182, 0.08);
}

.chat-dialog-msg--ai .chat-dialog-bubble {
    background: var(--ai-draft-bg);
    border: 1px dashed var(--ai-draft-border);
    border-radius: 10px 10px 4px 10px;
}

.chat-dialog-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-dialog-msg--kaspi .chat-dialog-text,
.chat-dialog-msg--cs .chat-dialog-text {
    font-size: 0.92rem;
    line-height: 1.5;
}

.chat-dialog-msg--ai .chat-dialog-text {
    font-size: 0.94rem;
    line-height: 1.52;
}

.chat-dialog-msg--kaspi .chat-dialog-meta,
.chat-dialog-msg--cs .chat-dialog-meta {
    font-size: 0.72rem;
}

.chat-dialog-text--placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.76rem;
}

.chat-dialog-msg--ai .chat-dialog-text--placeholder {
    font-size: 0.88rem;
}

.chat-dialog-reasoning {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(159, 122, 234, 0.25);
    font-size: 0.72rem;
    line-height: 1.5;
    color: #6D28D9;
    font-family: var(--font-reasoning);
    font-style: italic;
}

.chat-dialog-msg--ai .chat-dialog-reasoning {
    font-size: 0.84rem;
    line-height: 1.48;
}

.chat-dialog-reasoning strong {
    font-family: var(--font-heading);
    font-style: normal;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: #7C3AED;
}

/* Bubble action icon buttons (in header bar) */
.chat-bubble-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(0, 114, 129, 0.14);
    border-radius: 7px;
    background: #FFFFFF;
    color: #64748B;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-icon-action:hover:not(:disabled) {
    background: var(--primary-dim);
    border-color: rgba(0, 114, 129, 0.28);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-icon-action--success {
    background: linear-gradient(135deg, var(--success), #059669);
    border-color: transparent;
    color: #FFFFFF;
}

.btn-icon-action--success:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-icon-action--analyze {
    color: #7C3AED;
    border-color: rgba(124, 58, 237, 0.22);
    background: rgba(124, 58, 237, 0.06);
}

.btn-icon-action--analyze:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(124, 58, 237, 0.35);
    color: #6D28D9;
}

.btn-icon-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-icon-action.is-loading svg {
    animation: spin 0.8s linear infinite;
}

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

/* Success button variant */
.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #FFFFFF;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* Layout button active state for third tab */
.btn-layout-tab.active {
    background: #FFFFFF !important;
    color: var(--primary) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ── App confirm modal ── */
body.modal-open {
    overflow: hidden;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.app-modal[hidden] {
    display: none !important;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    animation: modalFadeIn 0.2s ease;
}

.app-modal-panel {
    position: relative;
    width: min(440px, 100%);
    padding: 28px 28px 24px;
    border-radius: var(--border-radius-lg);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--card-border-active);
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    animation: modalSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-modal-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-dim), var(--accent-dim));
    border: 1px solid rgba(0, 114, 129, 0.12);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.app-modal-icon--mass {
    background: linear-gradient(135deg, var(--success-bg), var(--accent-dim));
    border-color: var(--success-border);
}

.app-modal-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.app-modal-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 18px;
}

.app-modal-preview {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-dark);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.app-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-modal-cancel,
.btn-modal-confirm {
    min-width: 120px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-modal-cancel {
    background: #FFFFFF;
    color: var(--text-secondary);
    border-color: var(--card-border);
}

.btn-modal-cancel:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.btn-modal-confirm {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-modal-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 114, 129, 0.28);
}

.btn-modal-confirm--success {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Toast notifications ── */
.app-toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.app-toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--card-border-active);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-toast--success {
    border-color: var(--success-border);
    background: linear-gradient(135deg, rgba(255,255,255,0.98), var(--success-bg));
}

.app-toast--error {
    border-color: var(--danger-border);
    background: linear-gradient(135deg, rgba(255,255,255,0.98), var(--danger-bg));
}

.app-toast-icon {
    font-size: 1.1rem;
    line-height: 1.2;
}

.app-toast-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.45;
}

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

/* ── Analytics Redesign Styles ── */
.kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card-v2 {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 20px rgba(0, 114, 129, 0.03);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(16px);
}

.kpi-card-v2:hover {
    transform: translateY(-2px);
    border-color: var(--card-border-active);
    box-shadow: 0 8px 30px rgba(0, 114, 129, 0.08);
}

.kpi-card-v2::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: transparent;
    transition: var(--transition-fast);
}

.kpi-card-v2--ai::before {
    background: linear-gradient(90deg, #7C3AED, #A78BFA);
}

.kpi-card-v2--gen::before {
    background: linear-gradient(90deg, #6366F1, #818CF8);
}

.kpi-card-v2--time::before {
    background: linear-gradient(90deg, #0EA5E9, #38BDF8);
}

.kpi-card-v2--ring::before {
    background: linear-gradient(90deg, #7C3AED, #06B6D4);
}

.kpi-card-v2__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.kpi-card-v2__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.kpi-card-v2__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card-v2__value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.kpi-card-v2__value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card-v2__badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
}

.kpi-card-v2__badge--purple {
    background: rgba(124, 58, 237, 0.08);
    color: #7C3AED;
    border: 1px solid rgba(124, 58, 237, 0.15);
}

.kpi-card-v2__sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* SVG Ring Progress */
.kpi-ring-container {
    width: 64px;
    height: 64px;
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-ring-svg {
    width: 100%;
    height: 100%;
}

.kpi-ring-text {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 22px;
    fill: var(--text-primary);
}

.kpi-ring-sublabel {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 9px;
    fill: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

/* Operator Leaderboard styles */
.telemetry-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.telemetry-table th {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 114, 129, 0.08);
}

.telemetry-table td {
    padding: 12px 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(0, 114, 129, 0.04);
}

.telemetry-table tr:hover td {
    background: rgba(0, 114, 129, 0.015);
}

/* Operator AI Rate Progress bar in table */
.op-ai-rate-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.op-ai-rate-track {
    flex: 1;
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    overflow: hidden;
}

.op-ai-rate-fill {
    height: 100%;
    background: linear-gradient(90deg, #7C3AED, #06B6D4);
    border-radius: 3px;
    transition: width 0.8s ease-out;
}

.op-ai-rate-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
}


