/* ═══════════════════════════════════════════════════════════════════════
   ASSI COGNITIVE DASHBOARD — Design System v1.0
   Dark glassmorphism theme with neon accents
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ─── */
:root {
    /* Background */
    --bg-deep: #060b18;
    --bg-card: rgba(12, 20, 40, 0.75);
    --bg-card-hover: rgba(18, 30, 55, 0.85);
    --bg-surface: rgba(20, 35, 65, 0.5);
    --bg-input: rgba(15, 25, 50, 0.8);
    --bg-modal: rgba(8, 14, 28, 0.95);

    /* Borders */
    --border-subtle: rgba(60, 100, 180, 0.15);
    --border-glow: rgba(0, 212, 255, 0.25);
    --border-accent: rgba(0, 212, 255, 0.5);

    /* Accent Colors */
    --cyan: #00d4ff;
    --cyan-dim: rgba(0, 212, 255, 0.15);
    --magenta: #ff006e;
    --magenta-dim: rgba(255, 0, 110, 0.15);
    --green: #00ff88;
    --green-dim: rgba(0, 255, 136, 0.15);
    --yellow: #ffaa00;
    --yellow-dim: rgba(255, 170, 0, 0.15);
    --red: #ff4444;
    --red-dim: rgba(255, 68, 68, 0.15);
    --blue: #4488ff;
    --purple: #aa66ff;

    /* Text */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-dim: rgba(255, 255, 255, 0.35);
    --text-accent: var(--cyan);

    /* Typography */
    --font-main: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    /* Spacing */
    --gap: 12px;
    --radius: 12px;
    --radius-sm: 8px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 212, 255, 0.1);
    --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.1);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.7);

    /* Safe Area Insets for Mobile / iOS Notch */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

.clickable {
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.clickable:hover {
    background: rgba(255, 255, 255, 0.05);
}

.clickable:active {
    transform: scale(0.995);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

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

/* Subtle grid background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(0, 212, 255, 0.03) 1px, transparent 0);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ═══ HEADER ═══ */
#main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: rgba(6, 11, 24, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

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

.logo {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
}

#main-header h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-primary);
}

#main-header h1 .accent { color: var(--cyan); }

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

.health-indicators { display: flex; gap: 6px; }

.health-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.health-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.3s, box-shadow 0.3s;
}

.health-pill.online .health-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-pill.offline .health-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
.health-pill.warning .health-dot { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.health-detail { font-size: 0.65rem; color: var(--text-dim); margin-left: 2px; }

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

/* Search */
.search-box {
    position: relative;
}

#global-search {
    width: 240px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    outline: none;
    transition: all 0.3s ease;
}

#global-search:focus {
    border-color: var(--border-accent);
    box-shadow: 0 0 12px var(--cyan-dim);
    width: 320px;
}

#global-search::placeholder { color: var(--text-dim); }

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 420px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-modal);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    backdrop-filter: blur(20px);
    display: none;
    z-index: 200;
}

.search-results.visible { display: block; }

.search-group { padding: 8px 0; }
.search-group-title {
    padding: 4px 14px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.search-item {
    display: block;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.search-item:hover { background: var(--bg-surface); }
.search-item-name { font-weight: 500; color: var(--text-primary); }
.search-item-detail { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* Clock */
.live-clock {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--cyan);
    letter-spacing: 1px;
    text-shadow: 0 0 12px var(--cyan-dim);
}

/* Connection status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.pulse-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: all 0.3s;
}

.connection-status.connected .pulse-dot {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s ease-in-out infinite;
}

.connection-status.disconnected .pulse-dot {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ═══ MAIN GRID ═══ */
#dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
    padding: var(--gap);
    padding-bottom: 50px; /* space for footer */
    position: relative;
    z-index: 1;
}

/* ═══ CARD SYSTEM ═══ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-full {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
}

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

.card-body {
    padding: 12px 16px;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
    overflow: hidden;
}

.card-body.collapsed {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.card-body.scrollable {
    max-height: 320px;
    overflow-y: auto;
}

/* Custom scrollbar */
.card-body.scrollable::-webkit-scrollbar,
.matrix-events-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.deep-body::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 5px;
}

.card-body.scrollable::-webkit-scrollbar-track,
.matrix-events-list::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.deep-body::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.card-body.scrollable::-webkit-scrollbar-thumb,
.matrix-events-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.deep-body::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.2);
    border-radius: 4px;
}

.collapse-btn {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-dim);
    width: 28px; height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.collapse-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.collapse-btn svg { transition: transform 0.3s ease; }
.collapse-btn.is-collapsed svg { transform: rotate(-90deg); }

/* Header action buttons */
.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 16px;
    height: 30px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
    white-space: nowrap;
}
.header-action-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

.badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.live-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--red);
    color: white;
    font-weight: 700;
    letter-spacing: 1px;
    animation: pulse 2s ease-in-out infinite;
    vertical-align: middle;
    margin-left: 6px;
}

.placeholder {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.85rem;
    padding: 20px 0;
    text-align: center;
}

/* ═══ HARDWARE MONITOR ═══ */
.hw-row {
    display: grid;
    grid-template-columns: 120px 70px 1fr 60px 1fr;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.hw-row:last-of-type { border-bottom: none; }

.hw-label {
    font-weight: 500;
    font-size: 0.82rem;
    white-space: nowrap;
}

.hw-icon { margin-right: 4px; }

.hw-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-align: right;
    font-weight: 500;
}

.hw-ram { color: var(--cyan); }
.hw-cpu { color: var(--yellow); }

.sparkline-container {
    height: 24px;
    overflow: hidden;
}

.sparkline {
    width: 100%;
    height: 24px;
}

.hw-summary {
    display: flex;
    gap: 16px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.hw-summary span { font-family: var(--font-mono); }

/* ═══ OLLAMA MODELS ═══ */
.model-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.model-card:last-child { border-bottom: none; }

.model-icon { font-size: 1.2rem; }

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

.model-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--cyan);
}

.model-meta {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.model-bar-container {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.model-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--magenta));
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* Split RAM Sections */
.ollama-split {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ram-section-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 10px;
}

.model-card.history {
    opacity: 0.7;
    border-color: transparent;
    background: rgba(255, 255, 255, 0.02);
}

.model-card.history:hover {
    opacity: 1;
    border-color: var(--border-subtle);
}

.model-duration {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.model-size {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
    text-align: right;
}

/* ═══ ACTIVITY LOG ═══ */
.log-filters {
    display: flex;
    gap: 4px;
}

.filter-btn {
    padding: 3px 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    background: none;
    color: var(--text-dim);
    font-size: 0.65rem;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.filter-btn.active { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(0,212,255,0.3); }

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 0.8rem;
    animation: fadeSlideIn 0.3s ease;
}

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

.log-time {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    min-width: 55px;
    flex-shrink: 0;
}

.log-icon { font-size: 0.9rem; flex-shrink: 0; }

.log-label {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    min-width: 55px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.log-label.green { background: var(--green-dim); color: var(--green); }
.log-label.blue { background: rgba(68,136,255,0.15); color: var(--blue); }
.log-label.cyan { background: var(--cyan-dim); color: var(--cyan); }
.log-label.magenta { background: var(--magenta-dim); color: var(--magenta); }
.log-label.yellow { background: var(--yellow-dim); color: var(--yellow); }
.log-label.red { background: var(--red-dim); color: var(--red); }

.log-msg { color: var(--text-secondary); word-break: break-word; }

/* ═══ WORKERS / EXECUTION MATRIX ═══ */
.worker-group { margin-bottom: 14px; }

.worker-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.worker-group-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--magenta);
}

.worker-timer {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-surface);
}

.timer-running { color: var(--green); }
.timer-overdue { color: var(--yellow); }
.timer-stall { color: var(--red); }
.timer-normal { color: var(--text-secondary); }

.worker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 4px 16px;
}

.worker-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.worker-dot.running {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 1.5s ease-in-out infinite;
}

.worker-dot.idle {
    background: var(--text-dim);
}

.worker-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex: 1;
}

.worker-status {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.worker-status.running { color: var(--green); }
.worker-status.idle { color: var(--text-dim); }

.sub-header {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 10px 0 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.matrix-events-list {
    max-height: 140px;
    overflow-y: auto;
}

.matrix-event {
    font-size: 0.75rem;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: var(--text-secondary);
}

.matrix-event-prefix {
    font-weight: 600;
    margin-right: 6px;
}

.matrix-event-prefix.PULSE { color: var(--magenta); }
.matrix-event-prefix.THINK { color: var(--cyan); }

.matrix-event-time {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-left: 4px;
}

/* ═══ CONTEXT WINDOWS ═══ */
.ctx-session {
    display: grid;
    grid-template-columns: 2fr 120px 1fr 120px 48px;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.15s;
}

.ctx-session:hover { background: var(--bg-surface); border-radius: 6px; padding-left: 6px; margin-left: -6px; }

.ctx-agent-group { display: flex; flex-direction: column; min-width: 0; }

.ctx-agent-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--cyan);
    letter-spacing: 0.5px;
}

.ctx-session-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctx-model {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: center;
}

.ctx-bar-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.ctx-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.ctx-bar.green { background: linear-gradient(90deg, #004d40, var(--green)); }
.ctx-bar.yellow { background: linear-gradient(90deg, #5c4a00, var(--yellow)); }
.ctx-bar.red { background: linear-gradient(90deg, #5c0000, var(--red)); }

.ctx-tokens {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: right;
}

.ctx-status {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
}

.ctx-status.Active { background: var(--green-dim); color: var(--green); }
.ctx-status.Idle { background: rgba(255,255,255,0.03); color: var(--text-dim); }

/* ═══ THINKING STREAM ═══ */
.thinking-stream {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    animation: thinkGlow 3s ease-in-out infinite;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
}

@keyframes thinkGlow {
    0%, 100% { box-shadow: inset 0 0 16px rgba(0, 212, 255, 0.03); }
    50% { box-shadow: inset 0 0 16px rgba(0, 212, 255, 0.08); }
}

/* ═══ SIDE DRAWER (DEEP DATA) ═══ */
.side-drawer {
    position: fixed;
    top: 56px; /* header height */
    right: -850px;
    width: 800px;
    max-width: 100vw;
    height: calc(100vh - 56px);
    background: var(--bg-modal);
    border-left: 1px solid var(--border-glow);
    box-shadow: var(--shadow-modal);
    backdrop-filter: blur(24px);
    z-index: 900;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.side-drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.3);
}

.drawer-close {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.drawer-close:hover {
    color: var(--red);
    background: var(--red-dim);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 0 !important;
}

.tabs-header {
    padding: 0;
}

.tab-buttons {
    display: flex;
    width: 100%;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: var(--font-main);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
    background: rgba(0, 212, 255, 0.03);
}

.tab-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    background: var(--bg-surface);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    color: var(--text-dim);
}

.tab-btn.active .tab-count { background: var(--cyan-dim); color: var(--cyan); }

.deep-body { padding: 0 !important; }

.deep-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

#tab-search {
    flex: 1;
    padding: 7px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.3s;
}

#tab-search:focus { border-color: var(--cyan); }
#tab-search::placeholder { color: var(--text-dim); }

#tab-filter {
    padding: 7px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.82rem;
    outline: none;
}

#tab-filter.hidden { display: none; }

.tab-panel { display: none; overflow-x: auto; }
.tab-panel.active { display: block; }

/* ═══ DATA TABLES ═══ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    background: rgba(6, 11, 24, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    vertical-align: top;
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-surface);
}

.data-table tbody tr.clickable { cursor: pointer; }

.data-table tbody tr.clickable:hover {
    background: rgba(0, 212, 255, 0.05);
}

.td-name { color: var(--text-primary); font-weight: 500; }
.td-mono { font-family: var(--font-mono); font-size: 0.75rem; }
.td-truncate {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.td-amount { color: var(--green); font-weight: 600; font-family: var(--font-mono); }

.td-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.td-badge.business { background: var(--green-dim); color: var(--green); }
.td-badge.noise { background: var(--red-dim); color: var(--red); }
.td-badge.unknown { background: rgba(255,255,255,0.05); color: var(--text-dim); }
.td-badge.client { background: var(--cyan-dim); color: var(--cyan); }
.td-badge.lead { background: var(--yellow-dim); color: var(--yellow); }
.td-badge.prospecto { background: var(--magenta-dim); color: var(--magenta); }
.td-badge.whatsapp { background: rgba(37, 211, 102, 0.12) !important; color: #25d366 !important; }
.td-badge.email { background: rgba(0, 170, 255, 0.12) !important; color: #33b5ff !important; }
.td-badge.intent { background: rgba(138, 43, 226, 0.12) !important; color: #bb88ff !important; text-transform: capitalize !important; }

.view-btn {
    padding: 4px 10px;
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-btn:hover {
    background: rgba(0, 212, 255, 0.25);
    border-color: var(--cyan);
}

/* ═══ PAGINATION ═══ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px;
    border-top: 1px solid var(--border-subtle);
}

.page-btn {
    padding: 6px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--cyan);
    color: var(--cyan);
}

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

.page-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ═══ MODAL ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-overlay.visible {
    display: flex;
    animation: fadeIn 0.25s ease;
}

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

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { color: var(--red); background: var(--red-dim); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Modal sections */
.modal-section {
    margin-bottom: 24px;
}

.modal-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--cyan);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-field {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 6px;
    padding: 5px 0;
    font-size: 0.85rem;
}

.modal-field-label {
    color: var(--text-dim);
    font-weight: 500;
}

.modal-field-value {
    color: var(--text-primary);
    word-break: break-word;
}

.modal-text-block {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.modal-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 6px;
}

.modal-mini-table th {
    padding: 6px 10px;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-mini-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: var(--text-secondary);
}

/* ═══ SUMMARY BAR (FOOTER) ═══ */
#summary-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 8px 20px;
    background: rgba(6, 11, 24, 0.92);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
}

.summary-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.footer-btn {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.footer-btn:hover {
    background: var(--bg-surface);
    color: var(--cyan);
}

.summary-stats strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* ═══ RESPONSIVE ═══ */
/* ═══ RESPONSIVE DESIGN (Tablets & Smartphones) ═══ */
@media (max-width: 900px) {
    #dashboard-grid {
        grid-template-columns: 1fr;
    }
    .ctx-session {
        grid-template-columns: 1fr 100px 1fr 80px 40px;
    }
    #global-search { width: 180px; }
    #global-search:focus { width: 220px; }
}

@media (max-width: 768px) {
    /* 1. Prevent iOS Safari automatic viewport zoom */
    input[type="text"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* 2. Sleek, Ergonomic Mobile Header */
    #main-header {
        height: auto;
        padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "brand actions"
            "tray tray";
        gap: 8px;
    }

    .header-left {
        grid-area: brand;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .header-left .logo {
        font-size: 1.3rem;
    }

    .header-left h1 {
        font-size: 0.92rem;
        letter-spacing: 0.5px;
        white-space: nowrap;
    }

    .header-right {
        grid-area: actions;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .header-right .live-clock,
    .header-right #btn-db-explorer,
    .header-right .search-box {
        display: none !important;
    }

    .connection-status {
        padding: 4px 8px;
        background: rgba(255, 255, 255, 0.04);
        border-radius: 6px;
    }

    .connection-status .status-text {
        font-size: 0.7rem;
    }

    .header-center {
        grid-area: tray;
        order: unset;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .health-indicators {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        width: 100%;
        padding-bottom: 2px;
        justify-content: flex-start;
    }
    .health-indicators::-webkit-scrollbar { display: none; }

    .health-pill {
        flex-shrink: 0;
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .header-actions {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        width: 100%;
        padding-bottom: 2px;
        justify-content: flex-start;
    }
    .header-actions::-webkit-scrollbar { display: none; }

    .header-action-btn {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 0.74rem;
        min-height: 32px;
    }

    /* 3. Main Navigation Sticky Tabs */
    .dashboard-main-nav {
        top: 0;
        padding: 6px calc(12px + var(--safe-right)) 6px calc(12px + var(--safe-left));
        gap: 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .dashboard-main-nav::-webkit-scrollbar { display: none; }

    .nav-view-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-height: 36px;
    }

    /* 4. Dashboard Grid & Hardware Monitor */
    #dashboard-grid {
        grid-template-columns: 1fr;
        padding: 10px calc(10px + var(--safe-right)) calc(65px + var(--safe-bottom)) calc(10px + var(--safe-left));
        gap: 10px;
    }

    .card {
        border-radius: 10px;
    }

    .hw-row {
        grid-template-columns: 80px 1fr auto;
        font-size: 0.75rem;
        gap: 6px;
    }
    .hw-value {
        font-size: 0.72rem;
    }

    .ctx-session {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .tab-buttons {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .tab-buttons::-webkit-scrollbar { display: none; }

    /* 5. Pendix Standalone View & Controls */
    #card-pendix.view-standalone {
        min-height: calc(100dvh - 120px);
        margin-bottom: 0;
        border-radius: 10px;
    }

    #card-pendix.view-standalone #pendix-list {
        max-height: calc(100dvh - 275px) !important;
    }

    .pendix-subnav {
        padding: 4px;
        gap: 6px;
        margin-bottom: 10px;
    }

    .pendix-subnav-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 38px;
    }

    /* Pendix Quick Add Bar on Mobile */
    .pendix-add-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
        gap: 8px;
        margin-bottom: 10px;
    }

    .pendix-input-wrapper {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #pendix-input-text {
        width: 100%;
        padding: 4px 0;
    }

    .pendix-controls-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    #pendix-input-contact {
        grid-column: 1 / -1;
        width: 100% !important;
        max-width: 100% !important;
        padding: 8px 10px;
        border-radius: 6px;
        font-size: 16px !important;
    }

    #pendix-input-category {
        grid-column: 1 / 2;
        width: 100%;
        padding: 8px 10px;
        border-radius: 6px;
        font-size: 16px !important;
    }

    #pendix-input-priority {
        grid-column: 2 / 3;
        width: 100%;
        padding: 8px 10px;
        border-radius: 6px;
        font-size: 16px !important;
    }

    #pendix-input-date {
        grid-column: 1 / -1;
        width: 100%;
        padding: 8px 10px;
        border-radius: 6px;
        font-size: 16px !important;
    }

    #btn-add-task {
        grid-column: 1 / 2;
        width: 100%;
        padding: 10px 14px;
        font-size: 0.88rem;
        min-height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 6px;
    }

    .pendix-controls-wrapper button[type="button"] {
        grid-column: 2 / 3;
        width: 100%;
        padding: 10px 14px;
        font-size: 0.82rem;
        min-height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 6px;
    }

    /* Proposals Banner */
    .proposals-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    .proposals-banner-text {
        min-width: unset;
        font-size: 0.8rem;
    }

    .proposals-banner-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .proposals-banner-actions button {
        width: 100%;
        min-height: 36px;
        justify-content: center;
        display: flex;
        align-items: center;
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    /* Pendix Toolbar & Filter Pills on Mobile */
    .pendix-toolbar {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        gap: 6px;
        margin-bottom: 8px;
    }
    .pendix-toolbar::-webkit-scrollbar { display: none; }

    .filter-btn {
        flex-shrink: 0;
        padding: 7px 12px;
        font-size: 0.78rem;
        min-height: 36px;
        border-radius: 6px;
    }

    .pendix-toolbar-actions {
        flex-shrink: 0;
        margin-left: 0 !important;
    }

    .pendix-toolbar-actions .btn-pendix-action {
        min-height: 36px;
        padding: 7px 12px;
        flex-shrink: 0;
    }

    /* Pendix Order & Priority Bar on Mobile */
    .pendix-order-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 10px;
        margin-bottom: 10px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-subtle);
        border-radius: 8px;
    }

    .pendix-sort-control {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .pendix-sort-control .pendix-order-label {
        font-size: 0.76rem;
        flex-shrink: 0;
    }

    .pendix-sort-control .pendix-select-sm {
        flex: 1;
        min-height: 36px;
        font-size: 0.85rem;
        padding: 6px 10px;
        border-radius: 6px;
    }

    .priority-filter-group {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        width: 100%;
        padding: 2px 0;
    }
    .priority-filter-group::-webkit-scrollbar { display: none; }

    .priority-filter-group .pendix-order-label {
        display: none;
    }

    .filter-prio-btn {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 0.76rem;
        min-height: 32px;
        border-radius: 16px;
    }

    /* Pendix To-Do Item Layout on Mobile */
    .pendix-item {
        display: grid;
        grid-template-columns: 20px 28px 1fr;
        grid-template-areas:
            "drag check main"
            "actions actions actions";
        align-items: start;
        gap: 6px 10px;
        padding: 12px 14px;
        border-radius: 10px;
        margin-bottom: 8px;
        -webkit-user-select: none;
        user-select: none;
    }

    .pendix-drag-handle {
        grid-area: drag;
        align-self: center;
        justify-self: center;
        font-size: 1.15rem;
        padding: 6px 2px;
        color: var(--text-dim);
        touch-action: none;
        cursor: grab;
    }

    .pendix-check-col {
        grid-area: check;
        padding-top: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .pendix-checkbox {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }

    .pendix-main {
        grid-area: main;
        min-width: 0;
        overflow-wrap: break-word;
        word-break: break-word;
        -webkit-user-select: text;
        user-select: text;
    }

    .pendix-header {
        flex-wrap: wrap;
        gap: 4px 6px;
        margin-bottom: 4px;
    }

    .pendix-header .badge {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .prio-tag {
        padding: 3px 8px;
        font-size: 0.72rem;
        min-height: 24px;
    }

    .pendix-text {
        font-size: 0.9rem;
        line-height: 1.42;
        margin: 4px 0;
    }

    .pendix-meta {
        flex-wrap: wrap;
        gap: 6px 12px;
        font-size: 0.74rem;
        margin-top: 4px;
    }

    .pendix-actions {
        grid-area: actions;
        width: 100%;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .btn-pendix-action {
        min-height: 34px;
        padding: 6px 12px;
        font-size: 0.78rem;
        border-radius: 6px;
    }

    /* Closure Proposal Box inside Task */
    .closure-proposal-box {
        margin-top: 8px;
        padding: 10px;
    }

    .closure-proposal-actions {
        flex-direction: column;
        gap: 6px;
    }

    .closure-proposal-actions button {
        width: 100%;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.78rem;
    }

    /* 6. Summary Bar (Fixed Footer) on Mobile */
    #summary-bar {
        padding: 6px calc(12px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(12px + var(--safe-left));
        background: rgba(6, 11, 24, 0.96);
    }

    .summary-stats {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 12px;
        white-space: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        font-size: 0.72rem;
    }
    .summary-stats::-webkit-scrollbar { display: none; }

    .footer-btn {
        flex-shrink: 0;
        padding: 4px 8px;
        min-height: 28px;
        display: inline-flex;
        align-items: center;
    }

    /* Other Grids */
    .heartbeat-grid,
    .global-board-container,
    .timing-grid {
        grid-template-columns: 1fr;
    }

    .log-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .log-filters::-webkit-scrollbar { display: none; }

    /* 7. Modals & Dialogs on Mobile */
    .modal-overlay {
        padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
        align-items: flex-end;
    }

    .modal {
        max-height: 90dvh;
        width: 100%;
        border-radius: 16px 16px 10px 10px;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-body {
        padding: 14px 16px;
    }

    .pendix-edit-modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92dvh !important;
        border-radius: 16px 16px 12px 12px !important;
    }

    .pendix-modal-header {
        padding: 12px 16px;
    }

    .pendix-modal-body {
        padding: 14px;
        gap: 12px;
    }

    .btn-quick-pick {
        padding: 6px 10px;
        font-size: 0.76rem;
        min-height: 32px;
    }

    .pendix-modal-footer {
        padding: 12px 14px calc(12px + var(--safe-bottom)) 14px;
        flex-direction: column-reverse;
        gap: 10px;
    }

    .modal-footer-left,
    .modal-footer-right {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .modal-footer-left button,
    .modal-footer-right button {
        flex: 1;
        min-height: 42px;
        justify-content: center;
        display: flex;
        align-items: center;
    }

    /* PIN Overlay */
    .pin-overlay {
        padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
        overflow-y: auto;
    }
}

/* ─── Extra Small Mobile Phones (max-width: 480px) ─── */
@media (max-width: 480px) {
    .header-left h1 {
        font-size: 0.84rem;
    }

    .pendix-subnav-btn {
        font-size: 0.75rem;
        padding: 7px 6px;
    }

    .proposals-banner-actions {
        grid-template-columns: 1fr;
    }

    .pendix-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .pendix-actions .btn-pendix-action.btn-chat-assi {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 38px;
        font-size: 0.82rem;
    }

    .pendix-actions .btn-pendix-action.btn-approve-proposal {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 38px;
        font-size: 0.82rem;
    }

    .pendix-actions .btn-pendix-action.btn-calendar {
        flex: 1;
        justify-content: center;
        min-height: 36px;
    }

    .pendix-actions .btn-pendix-action.btn-edit,
    .pendix-actions .btn-pendix-action.btn-dismiss {
        flex: 0 0 auto;
        min-width: 42px;
        min-height: 36px;
        justify-content: center;
    }

    .pin-card {
        padding: 24px 18px;
    }

    .pin-key {
        width: 62px;
        height: 62px;
        font-size: 1.4rem;
    }
}

/* ═══ UTILITY ═══ */
.hidden { display: none !important; }
.clickable { cursor: pointer; transition: background 0.1s; }
.clickable:hover { background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-magenta { color: var(--magenta); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-dim { color: var(--text-dim); }
.font-mono { font-family: var(--font-mono); }

.schema-table-card:hover {
    border-color: var(--cyan-dim) !important;
    background: rgba(0, 212, 255, 0.05) !important;
}

.clickable-table:hover {
    color: white !important;
    text-shadow: 0 0 8px var(--cyan);
}

/* ─── Accent variable ─── */
:root { --accent: #6c8aff; }

/* ═══ MODEL STATE PILLS ═══ */
.state-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.state-active {
    background: rgba(0, 255, 136, 0.15);
    color: var(--green);
    border: 1px solid var(--green);
}

.state-warm {
    background: rgba(255, 170, 0, 0.12);
    color: var(--yellow);
    border: 1px solid var(--yellow);
}

.state-expiring {
    background: rgba(255, 80, 0, 0.15);
    color: #ff8040;
    border: 1px solid #ff8040;
}

/* Model name row (name + pill side by side) */
.model-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* KV context badge */
.ctx-badge {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(108, 138, 255, 0.12);
    color: var(--accent);
    border: 1px solid rgba(108, 138, 255, 0.25);
}

/* Countdown timer text */
.model-countdown {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* ═══ AGENT TIMING ═══ */
.timing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.timing-card {
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
}

.timing-card.timing-running {
    border-color: var(--yellow);
    background: rgba(255, 170, 0, 0.05);
    box-shadow: 0 0 12px rgba(255, 170, 0, 0.08);
}

.timing-agent-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.timing-icon { font-size: 1rem; }

.timing-agent-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.timing-running-pill {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255, 170, 0, 0.2);
    border: 1px solid var(--yellow);
    color: var(--yellow);
}

.timing-stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
}

.timing-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.timing-stat-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.timing-stat-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.timing-task {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* ═══ ACTIVITY LOG — enhanced entries ═══ */
.log-agent {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0, 212, 255, 0.08);
    color: var(--cyan);
    border: 1px solid rgba(0, 212, 255, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.log-detail {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
    flex-shrink: 0;
}

.log-color-green  { color: var(--green) !important; }
.log-color-blue   { color: var(--blue) !important; }
.log-color-cyan   { color: var(--cyan) !important; }
.log-color-yellow { color: var(--yellow) !important; }
.log-color-magenta{ color: var(--magenta) !important; }
.log-color-red    { color: var(--red) !important; }
.log-color-dim    { color: var(--text-dim) !important; }

/* ═══ RUN WORKER BUTTON ═══ */
.run-worker-btn {
    padding: 8px 18px;
    background: rgba(0, 255, 136, 0.08);
    border: 1px solid var(--green);
    border-radius: var(--radius-sm);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.run-worker-btn:hover {
    background: rgba(0, 255, 136, 0.15);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

.run-worker-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ═══ IDLE MOMENT WIDGET ═══ */
.idle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}
.idle-label {
    color: var(--text-dim);
    width: 60px;
    flex-shrink: 0;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.idle-val { color: var(--text); }
.idle-age { color: var(--text-dim); font-size: 0.72rem; }
.idle-dim { color: var(--text-dim); }
.idle-bar-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}
.idle-bar {
    height: 8px;
    border-radius: 4px;
    min-width: 4px;
    transition: width 1.2s ease;
    flex-shrink: 0;
}
.idle-bar.idle-ok { background: var(--green); }
.idle-bar.idle-warn { background: var(--yellow); }
.idle-bar-label { font-size: 0.76rem; color: var(--text); white-space: nowrap; }
.idle-ready {
    margin-top: 10px;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}
.idle-ready.ready {
    background: rgba(80, 200, 120, 0.1);
    color: var(--green);
    border: 1px solid rgba(80, 200, 120, 0.3);
}
.idle-ready.blocked {
    background: rgba(100, 100, 120, 0.08);
    color: var(--text-dim);
    border: 1px solid rgba(100, 100, 120, 0.2);
}

/* Warning banner for multiple Ollama instances */
.warning-banner {
    background: rgba(255, 80, 0, 0.1);
    border: 1px solid #ff8040;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.78rem;
    color: #ff8040;
    margin-bottom: 14px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════
   AGENT HEARTBEATS — Redesigned with richer cards
   ═══════════════════════════════════════════════════════════════════════ */
.heartbeat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.heartbeat-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.heartbeat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-subtle);
    transition: background 0.3s;
}
.heartbeat-card.status-active::before { background: var(--green); box-shadow: 0 0 10px var(--green-dim); }
.heartbeat-card.status-idle::before { background: var(--yellow); }
.heartbeat-card.status-stale::before { background: var(--red); }
.heartbeat-card:hover {
    border-color: rgba(0, 212, 255, 0.4);
    background: rgba(0, 212, 255, 0.04);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.hb-header {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}
.hb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}
.hb-avatar.active { background: var(--green-dim); border-color: var(--green); }
.hb-avatar.idle { background: var(--yellow-dim); border-color: var(--yellow); }
.hb-avatar.stale { background: var(--red-dim); border-color: var(--red); }
.hb-name-group { flex: 1; min-width: 0; }
.hb-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hb-status-text {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hb-tasks {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.4;
    padding: 6px 8px;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    border-left: 2px solid var(--border-subtle);
}
.hb-tasks.hb-has-tasks {
    color: var(--cyan);
    border-left-color: var(--cyan);
}
.hb-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-dim);
}
.hb-footer .font-mono {
    color: var(--text-secondary);
}
.hb-click-hint {
    font-size: 0.6rem;
    color: var(--text-dim);
    opacity: 0;
    transition: opacity 0.2s;
}
.heartbeat-card:hover .hb-click-hint { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════ */
.text-cyan { color: var(--cyan) !important; }
.text-magenta { color: var(--magenta) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-green { color: var(--green) !important; }
.text-blue { color: var(--blue) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-red { color: var(--red) !important; }

.thinking-stream {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════════════════
   GLOBAL BOARD STYLING
   ═══════════════════════════════════════════════════════════════════════ */
.global-board-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    padding: 4px 0;
}

.gb-col {
    background: rgba(12, 22, 45, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.gb-col:hover {
    transform: translateY(-2px);
    background: rgba(18, 32, 64, 0.5);
}

.gb-col.alerts:hover { border-color: rgba(255, 68, 68, 0.4); box-shadow: 0 0 15px rgba(255, 68, 68, 0.08); }
.gb-col.hot_threads:hover { border-color: rgba(255, 0, 110, 0.4); box-shadow: 0 0 15px rgba(255, 0, 110, 0.08); }
.gb-col.active_entities:hover { border-color: rgba(255, 170, 0, 0.4); box-shadow: 0 0 15px rgba(255, 170, 0, 0.08); }
.gb-col.strategic_context:hover { border-color: rgba(0, 212, 255, 0.4); box-shadow: 0 0 15px rgba(0, 212, 255, 0.08); }

.gb-title {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 6px;
}

.gb-title.alerts { color: var(--red); }
.gb-title.hot_threads { color: var(--magenta); }
.gb-title.active_entities { color: var(--yellow); }
.gb-title.strategic_context { color: var(--cyan); }

.gb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 250px;
    overflow-y: auto;
}

.gb-item {
    font-size: 0.8rem;
    line-height: 1.45;
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.01);
    border-left: 2px solid transparent;
    transition: background 0.15s;
    word-break: break-word;
}

.gb-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.gb-col.alerts .gb-item { border-left-color: var(--red); }
.gb-col.hot_threads .gb-item { border-left-color: var(--magenta); }
.gb-col.active_entities .gb-item { border-left-color: var(--yellow); }
.gb-col.strategic_context .gb-item { border-left-color: var(--cyan); }

.gb-item-empty {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 8px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   TABBED MODAL SYSTEM
   ═══════════════════════════════════════════════════════════════════════ */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 14px;
    gap: 4px;
    overflow-x: auto;
}

.modal-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.modal-tab-btn.active {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
}

.modal-tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

.modal-tab-content.active {
    display: block;
}

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

/* Checklist items inside Heartbeat MD */
.hb-checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.82rem;
}

.hb-checklist-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    cursor: default;
}

.hb-checklist-check.checked {
    background: var(--green);
    border-color: var(--green);
    color: var(--bg-deep);
}

/* History logs list style */
.history-logs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-log-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-log-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: bold;
    color: var(--cyan);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-log-body {
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.15);
}

/* Session trace lists */
.agent-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════
   RECENT INGESTION PANEL
   ═══════════════════════════════════════════════════════════════════════ */
.ri-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.ri-tab-btn { padding: 8px 14px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-dim); font-family: var(--font-main); font-size: 0.78rem; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.ri-tab-btn:hover { color: var(--text-secondary); }
.ri-tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.ri-panel { display: none; }
.ri-panel.active { display: block; }
.ri-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.03); transition: background 0.15s; cursor: pointer; border-radius: 6px; }
.ri-item:hover { background: var(--bg-surface); }
.ri-icon { font-size: 1rem; flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: rgba(255,255,255,0.03); }
.ri-icon.email { background: var(--cyan-dim); }
.ri-icon.whatsapp { background: var(--green-dim); }
.ri-icon.entity { background: var(--magenta-dim); }
.ri-content { flex: 1; min-width: 0; }
.ri-title { font-size: 0.82rem; color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-meta { font-size: 0.72rem; color: var(--text-dim); font-family: var(--font-mono); margin-top: 2px; }
.ri-time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-dim); flex-shrink: 0; }
.ri-empty { text-align: center; color: var(--text-dim); font-style: italic; padding: 20px; font-size: 0.85rem; }

/* Telemetry event types */
.matrix-event.ev-error { border-left: 2px solid var(--red); padding-left: 8px; }
.matrix-event.ev-success { border-left: 2px solid var(--green); padding-left: 8px; }
.matrix-event.ev-warning { border-left: 2px solid var(--yellow); padding-left: 8px; }
.matrix-event.ev-info { border-left: 2px solid var(--border-subtle); padding-left: 8px; }

/* Timing bar visualization */
.timing-bar-container { height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.timing-bar { height: 100%; border-radius: 3px; transition: width 0.6s ease; background: linear-gradient(90deg, var(--cyan), var(--magenta)); }

/* Global board clickable */
.gb-item { cursor: pointer; }
.gb-item:active { transform: scale(0.98); }




/* ═══════════════════════════════════════════════════════════════════════
   WA INGESTA BUTTON & QR MODAL
   ═══════════════════════════════════════════════════════════════════════ */

/* Botón de WA Ingesta — rojo/naranja, llama la atención */
.wa-ingest-btn {
    background: linear-gradient(135deg, rgba(255, 60, 0, 0.15), rgba(255, 140, 0, 0.12)) !important;
    border: 1px solid #ff5500 !important;
    color: #ff8844 !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease !important;
}

.wa-ingest-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 80, 0, 0.08);
    opacity: 0;
    transition: opacity 0.25s;
}

.wa-ingest-btn:hover {
    background: linear-gradient(135deg, rgba(255, 60, 0, 0.25), rgba(255, 140, 0, 0.20)) !important;
    border-color: #ff7700 !important;
    color: #ffaa66 !important;
    box-shadow: 0 0 16px rgba(255, 80, 0, 0.25), 0 0 32px rgba(255, 80, 0, 0.1) !important;
    transform: translateY(-1px);
}

.wa-ingest-btn:hover::before { opacity: 1; }

/* Pulsación sutil para llamar la atención */
@keyframes wa-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 80, 0, 0.3); }
    50%       { box-shadow: 0 0 14px rgba(255, 80, 0, 0.6); }
}
.wa-ingest-btn { animation: none; }
.wa-ingest-btn:hover { animation: none; }

/* WhatsApp states */
.wa-ingest-btn.wa-connected {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.12), rgba(37, 211, 102, 0.08)) !important;
    border: 1px solid #25d366 !important;
    color: #25d366 !important;
    box-shadow: none !important;
}
.wa-ingest-btn.wa-connected:hover {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.22), rgba(37, 211, 102, 0.15)) !important;
    border-color: #2ebd70 !important;
    color: #58e891 !important;
    box-shadow: 0 0 12px rgba(37, 211, 102, 0.2) !important;
}

.wa-ingest-btn.wa-needs-pairing {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.1)) !important;
    border: 1px solid #fbbf24 !important;
    color: #fbbf24 !important;
    animation: wa-pulse 2.5s ease-in-out infinite !important;
}
.wa-ingest-btn.wa-needs-pairing:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(251, 191, 36, 0.18)) !important;
    border-color: #fcd34d !important;
    color: #fef08a !important;
}

.wa-ingest-btn.wa-offline {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.1)) !important;
    border: 1px solid #ef4444 !important;
    color: #f87171 !important;
}
.wa-ingest-btn.wa-offline:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.18)) !important;
    border-color: #f87171 !important;
    color: #fca5a5 !important;
}

/* Overlay del modal QR */
#wa-qr-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}
#wa-qr-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

/* Modal QR */
.qr-modal {
    max-width: 440px;
    width: 92vw;
    border: 1px solid rgba(255, 60, 60, 0.4) !important;
    box-shadow: 0 0 40px rgba(255, 60, 0, 0.2), 0 20px 60px rgba(0,0,0,0.6) !important;
}

/* Contenedor del QR - fondo blanco para buen contraste al escanear */
#wa-qr-container {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#wa-qr-container canvas,
#wa-qr-container img {
    border-radius: 6px;
    display: block;
}

/* Status text bajo el QR */
#wa-qr-status {
    font-size: 0.82rem;
    line-height: 1.5;
    font-family: var(--font-mono);
    padding: 0 8px;
}

/* ═══ COGNITIVE VELOCITY & COMMUNICATIONS FLOW ═══ */
.cognitive-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    align-items: stretch;
}

@media (max-width: 960px) {
    .cognitive-container {
        grid-template-columns: 1fr;
    }
}

/* Cognitive Flow Stages */
.flow-pipeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    height: 100%;
}

.flow-stage {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.25s ease;
}

.flow-stage.clickable {
    cursor: pointer;
}

.flow-stage:hover {
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.03);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.clickable {
    cursor: pointer;
}

.flow-arrow {
    text-align: center;
    color: var(--text-dim);
    font-size: 1.1rem;
    line-height: 1;
    margin: -4px 0;
    opacity: 0.7;
    animation: flowPulse 2s infinite ease-in-out;
}

@keyframes flowPulse {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 0.9; transform: translateY(2px); }
}

.stage-icon {
    font-size: 1.6rem;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#stage-ingestion .stage-icon { background: rgba(0, 212, 255, 0.08); border-color: rgba(0, 212, 255, 0.2); }
#stage-resolution .stage-icon { background: rgba(0, 255, 136, 0.08); border-color: rgba(0, 255, 136, 0.2); }
#stage-actions .stage-icon { background: rgba(255, 0, 110, 0.08); border-color: rgba(255, 0, 110, 0.2); }

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

.stage-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    font-weight: 600;
}

.stage-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* Timeline Interactive SVG Chart */
.chart-wrapper {
    position: relative;
    user-select: none;
}

.cognitive-chart {
    display: block;
}

.chart-grid-line {
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 1px;
}

.chart-grid-line-x {
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 1px;
}

.chart-axis-text {
    fill: var(--text-dim);
    font-size: 0.65rem;
    font-family: var(--font-mono);
}

.chart-axis-line {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1px;
}

.chart-line-total { stroke: var(--cyan); filter: drop-shadow(0 0 4px rgba(0,212,255,0.4)); }
.chart-line-email { stroke: var(--cyan); }
.chart-line-chat { stroke: var(--green); }
.chart-line-instruction { stroke: var(--magenta); }
.chart-line-other { stroke: var(--text-dim); }

.chart-point {
    fill: var(--bg-card);
    stroke-width: 2px;
    cursor: pointer;
    transition: r 0.2s, stroke-width 0.2s, fill 0.2s;
}

.chart-point:hover {
    r: 6px;
    stroke-width: 3px;
    fill: white;
}

.chart-point-total { stroke: var(--cyan); }
.chart-point-email { stroke: var(--cyan); }
.chart-point-chat { stroke: var(--green); }
.chart-point-instruction { stroke: var(--magenta); }
.chart-point-other { stroke: var(--text-dim); }

.chart-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
}

.chart-tooltip-row:first-child {
    margin-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
    font-weight: bold;
}

/* ─── Localtunnel Tunnel States ─── */
.tunnel-btn.tunnel-connected {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(0, 212, 255, 0.08)) !important;
    border: 1px solid var(--cyan) !important;
    color: var(--cyan) !important;
    box-shadow: none !important;
}
.tunnel-btn.tunnel-connected:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.22), rgba(0, 212, 255, 0.15)) !important;
    border-color: #33e0ff !important;
    color: #80ebff !important;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2) !important;
}

.tunnel-btn.tunnel-offline {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.08)) !important;
    border: 1px solid var(--red) !important;
    color: #ff8888 !important;
}
.tunnel-btn.tunnel-offline:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.15)) !important;
    border-color: #ff6666 !important;
    color: #ffaaaa !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2) !important;
}

#tunnel-url-badge {
    transition: all 0.2s ease-in-out;
}
#tunnel-url-badge:hover {
    background: rgba(0, 212, 255, 0.25) !important;
    border-color: #33e0ff !important;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
    transform: translateY(-1px);
}
#tunnel-url-badge:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════════
   DOSSIER EDITING & AI ACTIONS
   ═══════════════════════════════════════════════════════════════════════ */
.dossier-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.dossier-edit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dossier-field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dossier-input-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cyan);
}

.dossier-textarea {
    width: 100%;
    min-height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.82rem;
    line-height: 1.4;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dossier-textarea:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.25);
    background: rgba(0, 0, 0, 0.4);
}

/* ═══════════════════════════════════════════════════════════════════════
   NOTES & COMMENTS SYSTEM
   ═══════════════════════════════════════════════════════════════════════ */
.comments-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.add-comment-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px;
}

.comment-textarea {
    width: 100%;
    min-height: 60px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px;
    color: var(--text-primary);
    font-size: 0.82rem;
    resize: vertical;
    font-family: var(--font-main);
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--cyan);
}

.comment-actions {
    display: flex;
    justify-content: flex-end;
}

.comment-btn {
    padding: 6px 14px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--cyan);
    color: var(--cyan);
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.comment-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 4px;
}

.comment-bubble {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.comment-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.comment-author {
    font-weight: 700;
    color: var(--cyan);
    font-family: var(--font-mono);
}

.comment-date {
    color: var(--text-dim);
    font-size: 0.7rem;
    margin-right: 20px;
}

.comment-body {
    font-size: 0.82rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    white-space: pre-wrap;
}

.delete-comment-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s;
}

.delete-comment-btn:hover {
    color: var(--red);
    background: rgba(255, 0, 0, 0.15);
}

/* Premium modal buttons */
.btn-primary {
    background: rgba(0, 212, 255, 0.08) !important;
    border: 1px solid var(--cyan) !important;
    color: var(--cyan) !important;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-secondary) !important;
}

.btn-danger {
    background: rgba(255, 68, 68, 0.08) !important;
    border: 1px solid var(--red) !important;
    color: var(--red) !important;
}

.modal-action-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-mono);
    font-weight: 600;
}

.modal-action-btn:hover:not(:disabled) {
    filter: brightness(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

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

/* Tab contents active logic */
.modal-tab-content {
    display: none;
}
.modal-tab-content.active-content {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Markdown parsing custom styles */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--cyan);
    margin-top: 15px;
    margin-bottom: 8px;
    font-weight: 600;
}
.markdown-body h2 { font-size: 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); padding-bottom: 4px; }
.markdown-body h3 { font-size: 0.88rem; }
.markdown-body ul {
    margin-left: 18px;
    margin-bottom: 10px;
    list-style-type: square;
}
.markdown-body li {
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.85);
}
.markdown-body p {
    font-size: 0.82rem;
    line-height: 1.55;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.85);
}

/* ═══════════════════════════════════════════════════════════════════════
   PENDIX — COMMITMENT & PROMISE RADAR STYLES
   ═══════════════════════════════════════════════════════════════════════ */
.pendix-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}
.pendix-item:hover {
    border-color: var(--border-glow);
    background: var(--bg-card-hover);
}
.pendix-item.alert-missing {
    border-left: 4px solid var(--red);
    background: rgba(255, 68, 68, 0.05);
}
.pendix-item.status-pending {
    border-left: 4px solid var(--yellow);
}
.pendix-item.status-synced {
    border-left: 4px solid var(--cyan);
}
.pendix-item.status-fulfilled {
    border-left: 4px solid var(--green);
    opacity: 0.75;
}
.pendix-main {
    flex: 1;
}
.pendix-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.pendix-code {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
.pendix-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 4px;
}
.pendix-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}
.pendix-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}
.btn-pendix-action {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}
.btn-pendix-action:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.btn-pendix-action.btn-approve {
    background: var(--green-dim);
    color: var(--green);
    border-color: var(--green);
}
.btn-pendix-action.btn-approve:hover {
    background: var(--green);
    color: #000;
}
.btn-pendix-action.btn-calendar {
    background: var(--cyan-dim);
    color: var(--cyan);
    border-color: var(--cyan);
}
.btn-pendix-action.btn-calendar:hover {
    background: var(--cyan);
    color: #000;
}
.btn-pendix-action.btn-dismiss {
    color: var(--text-dim);
}
.btn-pendix-action.btn-dismiss:hover {
    background: var(--red-dim);
    color: var(--red);
}

/* ─── Pendix Toolbar & Filters ─── */
.pendix-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.pendix-toolbar-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Pendix To-Do Quick Add Bar ─── */
.pendix-add-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 14px;
    transition: all 0.2s ease;
}
.pendix-add-bar:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.15);
}
.pendix-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.pendix-input-icon {
    font-size: 0.95rem;
    color: var(--cyan);
}
#pendix-input-text {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}
.pendix-controls-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}
#pendix-input-date,
#pendix-input-category,
#pendix-input-priority {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.78rem;
    outline: none;
    color-scheme: dark;
}
.btn-pendix-add {
    background: var(--cyan);
    color: #000;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn-pendix-add:hover {
    background: #38bdf8;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

/* ─── Pendix To-Do Checkbox & Completion ─── */
.pendix-check-col {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pendix-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.2s ease;
}
.pendix-checkbox:hover {
    border-color: var(--green);
    background: rgba(0, 255, 136, 0.1);
    transform: scale(1.1);
}
.pendix-checkbox.checked {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}
.pendix-text.done-text {
    text-decoration: line-through;
    opacity: 0.5;
}
.btn-pendix-action.btn-edit {
    color: var(--cyan);
}
.btn-pendix-action.btn-edit:hover {
    background: var(--cyan-dim);
    color: var(--cyan);
}

/* ─── Pendix Order & Priority Bar ─── */
.pendix-order-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 12px;
}
.pendix-sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pendix-order-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 500;
    white-space: nowrap;
}
.pendix-select-sm {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    outline: none;
    color-scheme: dark;
}
.priority-filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.filter-prio-btn {
    padding: 3px 8px;
    font-size: 0.73rem;
    font-weight: 500;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.filter-prio-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
.filter-prio-btn.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    border-color: var(--cyan);
    font-weight: 600;
}
.filter-prio-btn.prio-urgent.active {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
    border-color: #ef4444;
}
.filter-prio-btn.prio-high.active {
    background: rgba(249, 115, 22, 0.25);
    color: #fb923c;
    border-color: #f97316;
}
.filter-prio-btn.prio-medium.active {
    background: rgba(234, 179, 8, 0.25);
    color: #facc15;
    border-color: #eab308;
}
.filter-prio-btn.prio-low.active {
    background: rgba(34, 197, 94, 0.25);
    color: #4ade80;
    border-color: #22c55e;
}

/* ─── Priority Badges on Cards (Click to Cycle) ─── */
.prio-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}
.prio-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}
.prio-tag.prio-urgent {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #f87171;
}
.prio-tag.prio-high {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid #f97316;
    color: #fb923c;
}
.prio-tag.prio-medium {
    background: rgba(234, 179, 8, 0.2);
    border: 1px solid #eab308;
    color: #facc15;
}
.prio-tag.prio-low {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

/* ─── Card Row Accent based on Priority ─── */
.pendix-item.prio-urgent-row {
    border-left: 4px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.04);
}
.pendix-item.prio-high-row {
    border-left: 4px solid #f97316 !important;
}

/* ─── Drag & Drop Reordering ─── */
.pendix-drag-handle {
    cursor: grab;
    opacity: 0.35;
    font-size: 0.95rem;
    padding: 0 4px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    color: var(--text-dim);
}
.pendix-drag-handle:active {
    cursor: grabbing;
}
.pendix-item:hover .pendix-drag-handle {
    opacity: 0.9;
    color: var(--cyan);
}
.pendix-item.dragging {
    opacity: 0.35;
    border: 2px dashed var(--cyan) !important;
    background: rgba(0, 212, 255, 0.08) !important;
}
.pendix-item.drag-over-top {
    border-top: 3px solid var(--cyan) !important;
}
.pendix-item.drag-over-bottom {
    border-bottom: 3px solid var(--cyan) !important;
}



/* ─── Main View Navigation Tabs ─── */
.dashboard-main-nav {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    white-space: nowrap;
    position: sticky;
    top: 56px;
    z-index: 90;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.nav-view-btn {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.nav-view-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-glow);
}
.nav-view-btn.active {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
}
#pendix-list {
    max-height: 420px;
    overflow-y: auto;
}
#card-pendix.view-standalone {
    grid-column: 1 / -1;
    width: 100%;
    margin-bottom: 20px;
    min-height: calc(100vh - 180px);
}
#card-pendix.view-standalone #pendix-list {
    max-height: calc(100vh - 270px) !important;
}



/* ─── Pendix Sub-navigation (Segmented Control) ─── */
.pendix-subnav {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.25);
    padding: 5px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    margin-bottom: 14px;
}
.pendix-subnav-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.pendix-subnav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}
.pendix-subnav-btn.active {
    background: var(--bg-surface);
    color: var(--cyan);
    border-color: var(--cyan-dim);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Proposals Banner */
.proposals-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.proposals-banner-text {
    font-size: 0.82rem;
    color: #fef08a;
    line-height: 1.4;
    flex: 1;
    min-width: 240px;
}
.proposals-banner-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.btn-approve-proposal {
    background: rgba(0, 255, 136, 0.15) !important;
    border: 1px solid var(--green) !important;
    color: var(--green) !important;
    font-weight: 600 !important;
    padding: 6px 12px !important;
}
.btn-approve-proposal:hover {
    background: rgba(0, 255, 136, 0.3) !important;
}
.proposal-item {
    border-left: 3px solid #eab308 !important;
    background: rgba(234, 179, 8, 0.03) !important;
}

/* ─── Closure Proposals on Real Tasks ─── */
.pendix-item.has-closure-proposal {
    border-left: 3px solid #f59e0b !important;
    background: rgba(245, 158, 11, 0.04) !important;
}

.closure-proposal-box {
    margin-top: 8px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.closure-proposal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 600;
    color: #fbbf24;
}

.closure-proposal-evidence {
    font-size: 0.78rem;
    color: #fef3c7;
    line-height: 1.35;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 3px solid #f59e0b;
}

.closure-proposal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 2px;
}

.btn-confirm-closure {
    background: rgba(0, 255, 136, 0.15) !important;
    border: 1px solid var(--green) !important;
    color: var(--green) !important;
    font-weight: 600 !important;
    padding: 4px 10px !important;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.btn-confirm-closure:hover {
    background: var(--green) !important;
    color: #000 !important;
}

.btn-dismiss-closure {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: var(--text-dim) !important;
    padding: 4px 10px !important;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.btn-dismiss-closure:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   PENDIX EDIT MODAL (Top-Tier Executive Design)
   ═══════════════════════════════════════════════════════════════════════ */
.pendix-edit-modal {
    max-width: 620px !important;
    width: 92vw !important;
    background: rgba(13, 17, 26, 0.96) !important;
    border: 1px solid rgba(0, 212, 255, 0.3) !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 35px rgba(0, 212, 255, 0.12) !important;
    border-radius: 14px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pendix-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.09) 0%, rgba(255, 255, 255, 0.02) 100%);
}

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

.pendix-modal-title-wrap h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.pendix-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(85vh - 145px);
    overflow-y: auto;
}

.pendix-context-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pendix-context-row {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pendix-context-snippet {
    font-size: 0.78rem;
    color: #94a3b8;
    background: rgba(0, 0, 0, 0.35);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--cyan);
    font-style: italic;
    line-height: 1.45;
}

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

.form-label-pendix {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-hint-pendix {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: normal;
}

.pendix-modal-textarea {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.92rem;
    color: #fff;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.pendix-modal-textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.25);
    outline: none;
    background: rgba(0, 0, 0, 0.55);
}

.pendix-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 600px) {
    .pendix-modal-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.pendix-modal-select,
.pendix-modal-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    padding: 9px 12px;
    font-size: 0.85rem;
    color: #fff;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.pendix-modal-select:focus,
.pendix-modal-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
    background: rgba(0, 0, 0, 0.55);
}

.date-quick-picks {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-pick-label {
    font-size: 0.74rem;
    color: var(--text-dim);
    font-weight: 500;
}

.quick-picks-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-quick-pick {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-quick-pick:hover {
    background: rgba(0, 212, 255, 0.18);
    color: var(--cyan);
    border-color: var(--cyan);
}

.btn-quick-pick-clear:hover {
    background: rgba(239, 68, 68, 0.18);
    color: var(--red);
    border-color: var(--red);
}

.pendix-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
    flex-wrap: wrap;
    gap: 10px;
}

.modal-footer-left,
.modal-footer-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-modal-primary {
    background: var(--cyan) !important;
    color: #000 !important;
    font-weight: 700 !important;
    border-radius: 7px !important;
    padding: 8px 18px !important;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 12px rgba(0, 212, 255, 0.35);
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-modal-primary:hover {
    background: #4ae3ff !important;
    box-shadow: 0 4px 18px rgba(0, 212, 255, 0.5);
    transform: translateY(-1px);
}

.btn-modal-secondary {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-secondary) !important;
    font-weight: 500 !important;
    border-radius: 7px !important;
    padding: 8px 14px !important;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}

.btn-modal-secondary:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

.btn-modal-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--red) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    font-weight: 500 !important;
    border-radius: 7px !important;
    padding: 8px 12px !important;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.82rem;
}

.btn-modal-danger:hover {
    background: var(--red) !important;
    color: #000 !important;
}

.btn-modal-approve {
    background: rgba(0, 255, 136, 0.15) !important;
    color: var(--green) !important;
    border: 1px solid var(--green) !important;
    font-weight: 600 !important;
    border-radius: 7px !important;
    padding: 8px 14px !important;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.82rem;
}

.btn-modal-approve:hover {
    background: var(--green) !important;
    color: #000 !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   PIN LOCK SCREEN OVERLAY & KEYPAD (iOS Style)
   ═══════════════════════════════════════════════════════════════════════ */
.pin-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 7, 15, 0.94);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.pin-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pin-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    padding: 34px 28px;
    width: 92%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(0, 212, 255, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pin-header {
    margin-bottom: 20px;
}

.pin-logo {
    font-size: 2.8rem;
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 14px rgba(0, 212, 255, 0.45));
}

.pin-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pin-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.pin-dots-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
    transition: transform 0.2s;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-dot.filled {
    background: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.7);
    transform: scale(1.15);
}

.pin-dots-container.error .pin-dot {
    border-color: #ef4444;
    background: #ef4444;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
}

.pin-error-msg {
    min-height: 22px;
    font-size: 0.82rem;
    color: #ef4444;
    font-weight: 600;
    margin-bottom: 14px;
    transition: opacity 0.2s;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    justify-items: center;
    margin-bottom: 20px;
}

.pin-key {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 1.55rem;
    font-weight: 500;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

@media (hover: hover) {
    .pin-key:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: var(--cyan);
    }
}

.pin-key:active {
    transform: scale(0.92);
    background: rgba(0, 212, 255, 0.25);
    border-color: var(--cyan);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.pin-key-action {
    font-size: 1.2rem;
    color: var(--text-muted);
    background: transparent;
    border-color: transparent;
}

.pin-key-action:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.pin-footer {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.3;
}

@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-12px); }
    40%, 80% { transform: translateX(12px); }
}

.pin-card.shake {
    animation: pinShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ═══════════════════════════════════════════════════════════════════════
   PENDIX CHAT CON ASSI (Cognitive Task Assistant)
   ═══════════════════════════════════════════════════════════════════════ */

.btn-pendix-action.btn-chat-assi {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.btn-pendix-action.btn-chat-assi:hover {
    background: rgba(168, 85, 247, 0.35);
    color: #f3e8ff;
    border-color: #a855f7;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.35);
}

.pendix-chat-modal {
    max-width: 660px;
    width: 95%;
    height: 82vh;
    max-height: 720px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: #0b1120;
    border: 1px solid rgba(168, 85, 247, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(168, 85, 247, 0.2);
}

.pendix-chat-task-bar {
    background: rgba(168, 85, 247, 0.08);
    border-bottom: 1px solid rgba(168, 85, 247, 0.2);
    padding: 10px 16px;
}

.chat-task-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-task-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.35;
}

.chat-task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: #94a3b8;
}

.pendix-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.06), transparent 70%);
}

.chat-msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: fadeInMsg 0.2s ease-out;
}

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

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
}

.chat-msg-row.user .chat-avatar {
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid rgba(0, 212, 255, 0.4);
}

.chat-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.chat-msg-row.user .chat-bubble-wrap {
    align-items: flex-end;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-bubble.assi {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-top-left-radius: 2px;
}

.chat-bubble.user {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(14, 165, 233, 0.35));
    border: 1px solid rgba(0, 212, 255, 0.45);
    color: #ffffff;
    border-top-right-radius: 2px;
}

.chat-msg-time {
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-top: 3px;
    padding: 0 4px;
}

.chat-action-pill {
    align-self: center;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 500;
    margin: 4px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: fadeInMsg 0.25s ease-out;
}

.chat-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border-top-left-radius: 2px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c084fc;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

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

.pendix-chat-chips {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
    scrollbar-width: none;
}

.pendix-chat-chips::-webkit-scrollbar {
    display: none;
}

.chat-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 0.74rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.chat-chip:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: #a855f7;
    color: #f3e8ff;
    transform: translateY(-1px);
}

.pendix-chat-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #070c17;
}

.pendix-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.pendix-chat-input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.25);
}

.btn-pendix-chat-send {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    padding: 0 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: transform 0.1s, box-shadow 0.15s;
}

.btn-pendix-chat-send:hover {
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
    transform: translateY(-1px);
}

.btn-pendix-chat-send:active {
    transform: scale(0.97);
}

@media (max-width: 640px) {
    .pendix-chat-modal {
        width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    .pendix-chat-footer {
        padding: 10px 14px calc(10px + var(--safe-bottom)) 14px !important;
    }

    .pendix-chat-input {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
    }

    .chat-bubble {
        font-size: 0.84rem;
        padding: 9px 13px;
    }
}



