/* Unified Clean Professional Theme */
:root {
    --bg-color: #343541;
    --header-bg: #202123;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --text-tertiary: #8e8ea0;
    --accent-color: #10a37f;
    --accent-hover: #1a7f64;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --card-bg: #444654; 
    --input-bg: #40414f;
    --border-color: #565869;
    --hover-bg: #2a2b32;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

a {
    color: var(--text-primary);
    text-decoration: none;
}

/* Layout */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
    padding: 0.75rem 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
}

.logo-icon img {
    width: 100%;
    height: auto;
}

.logo-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-divider {
    color: var(--text-tertiary);
    margin: 0 0.5rem;
}

.page-title {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Cards */
.glass-card, .card, .option-card, .login-card {
    background: var(--header-bg); 
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.2s;
    box-shadow: none;
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
}

.glass-card:hover, .option-card:hover, .login-card:hover {
    border-color: var(--text-secondary);
}

/* Buttons */
.btn, .toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1;
}

.btn-primary, .toggle-btn.active, .login-button {
    background-color: var(--accent-color);
    color: white;
    border: 1px solid transparent;
}

.btn-primary:hover, .toggle-btn.active:hover, .login-button:hover {
    background-color: var(--accent-hover);
}

.btn-secondary, .toggle-btn {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover, .toggle-btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

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

.btn-ghost.active {
    color: var(--accent-color);
    background: rgba(16, 163, 127, 0.1);
}

.btn-success {
    background-color: var(--accent-color);
    color: white;
}

.btn:disabled, .login-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Inputs */
input, textarea, select, .form-input, .query-input, .query-textarea, .filter-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    font-family: inherit;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
    font-size: 1rem;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent-color);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

ul {
    list-style: none;
}

/* Tables */
.table-wrapper, .results-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--header-bg);
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

td {
    color: var(--text-secondary);
}

tr:hover td {
    background-color: var(--hover-bg);
}

/* Badges & Status */
.badge, .stat-badge, .loading-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--hover-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    background: var(--card-bg);
}

/* Header Stat Badges */
.header-stats .stat-badge {
    background: rgba(16, 163, 127, 0.1);
    border-color: rgba(16, 163, 127, 0.2);
    color: var(--accent-color);
    flex-direction: row;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
}
.header-stats .stat-label {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}
.header-stats .stat-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

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

/* Status Dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger-color);
    display: inline-block;
}

.status-dot.connected {
    background-color: var(--accent-color) !important;
}

/* Utilities */
.hidden { display: none !important; }
.mb-4 { margin-bottom: 1rem; }
.text-center { text-align: center; }

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.error-message.show {
    display: flex;
}

/* Landing Page */
.landing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
}

.landing-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin-top: 3rem;
}

.option-card {
    text-align: left;
    height: 100%;
    align-items: flex-start;
}

.option-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: var(--hover-bg);
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-features li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.option-features li::before {
    content: "•";
    color: var(--accent-color);
}

/* Activity Feed */
.activity-feed-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 2rem;
}

/* Subtle gradient at top to indicate more content */
.activity-feed::before {
    content: '';
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, var(--bg-color) 0%, transparent 100%);
    z-index: 5;
    pointer-events: none;
    margin-bottom: -20px;
}

/* Unit badge styling */
.event-unit {
    font-weight: 600;
    color: var(--accent-color);
    background: rgba(16, 163, 127, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    border: 1px solid rgba(16, 163, 127, 0.2);
}

/* Time display styling */
.event-time {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.event-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(68, 70, 84, 0.8) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--text-tertiary);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    overflow: visible;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.event-card:hover {
    background: linear-gradient(135deg, var(--hover-bg) 0%, rgba(42, 43, 50, 0.95) 100%);
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: var(--text-secondary);
}

/* ============================================
   ENHANCED REAL-TIME EVENT ANIMATIONS
   For dashboard viewing - smooth & satisfying
   ============================================ */

/* New event entrance - multi-stage animation */
.event-card.new-event {
    animation: eventEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* The glow effect that fades out over time */
.event-card.new-event::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: calc(var(--radius-md) + 2px);
    background: linear-gradient(135deg,
        rgba(16, 163, 127, 0.4) 0%,
        rgba(59, 130, 246, 0.3) 50%,
        rgba(16, 163, 127, 0.4) 100%);
    opacity: 1;
    z-index: -1;
    animation: glowFade 3s ease-out forwards;
    filter: blur(4px);
}

/* Pulsing dot indicator for new events */
.event-card.new-event::after {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 12px var(--accent-color), 0 0 24px var(--accent-color);
    animation: newDotPulse 2s ease-in-out infinite, newDotFade 4s ease-out forwards;
}

@keyframes eventEntrance {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
        filter: blur(4px);
    }
    40% {
        opacity: 1;
        transform: translateY(8px) scale(1.02);
        filter: blur(0);
    }
    70% {
        transform: translateY(-3px) scale(1);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes glowFade {
    0% {
        opacity: 1;
        filter: blur(4px);
    }
    30% {
        opacity: 0.6;
        filter: blur(6px);
    }
    100% {
        opacity: 0;
        filter: blur(8px);
    }
}

@keyframes newDotPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 8px var(--accent-color), 0 0 16px var(--accent-color);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 16px var(--accent-color), 0 0 32px var(--accent-color);
    }
}

@keyframes newDotFade {
    0%, 60% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Severity-based glow colors */
.event-card.new-event.important::before {
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.5) 0%,
        rgba(99, 102, 241, 0.4) 50%,
        rgba(59, 130, 246, 0.5) 100%);
}

.event-card.new-event.important::after {
    background: var(--info-color);
    box-shadow: 0 0 12px var(--info-color), 0 0 24px var(--info-color);
}

.event-card.new-event.critical::before {
    background: linear-gradient(135deg,
        rgba(239, 68, 68, 0.5) 0%,
        rgba(249, 115, 22, 0.4) 50%,
        rgba(239, 68, 68, 0.5) 100%);
}

.event-card.new-event.critical::after {
    background: var(--danger-color);
    box-shadow: 0 0 12px var(--danger-color), 0 0 24px var(--danger-color);
}

/* Event type specific entrance accents */
.event-card.new-event.admission::before {
    background: linear-gradient(135deg,
        rgba(16, 163, 127, 0.5) 0%,
        rgba(52, 211, 153, 0.4) 100%);
}

.event-card.new-event.discharge::before {
    background: linear-gradient(135deg,
        rgba(156, 163, 175, 0.4) 0%,
        rgba(107, 114, 128, 0.3) 100%);
}

.event-card.important { border-left-color: var(--info-color); }
.event-card.critical { border-left-color: var(--danger-color); }
.event-card.admission { border-left-color: var(--accent-color); }
.event-card.discharge { border-left-color: var(--text-tertiary); }

.event-header {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.event-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--input-bg) 0%, rgba(64, 65, 79, 0.6) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.event-card:hover .event-icon {
    transform: scale(1.08);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.08), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.event-icon.important {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.25) 0%, rgba(99, 102, 241, 0.15) 100%);
    box-shadow: inset 0 1px 2px rgba(59, 130, 246, 0.2), 0 0 12px rgba(59, 130, 246, 0.1);
}

.event-icon.critical {
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.25) 0%, rgba(249, 115, 22, 0.15) 100%);
    box-shadow: inset 0 1px 2px rgba(239, 68, 68, 0.2), 0 0 12px rgba(239, 68, 68, 0.1);
}

.event-icon.info {
    background: linear-gradient(145deg, rgba(107, 114, 128, 0.2) 0%, rgba(75, 85, 99, 0.15) 100%);
}

.event-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    align-items: center;
    margin-bottom: 0.25rem;
}

.event-time {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.event-unit {
    font-weight: 600;
    color: var(--text-primary);
}

.event-severity {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-tertiary);
    border: 1px solid rgba(107, 114, 128, 0.2);
    transition: all 0.2s ease;
}

.event-severity.important {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.1);
}

.event-severity.critical {
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.1);
    animation: criticalPulse 2s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.1); }
    50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.25); }
}

.event-summary {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Explore Page */
.query-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.example-chip {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--text-primary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.example-chip:hover {
    border-color: var(--accent-color);
    background: var(--hover-bg);
    transform: translateY(-1px);
}

.chip-icon {
    font-size: 1.5rem;
    opacity: 0.8;
}

.chip-text {
    font-weight: 500;
}

/* Synthetic Explorer */
.explorer-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 150px);
}

.table-cards {
    overflow-y: auto;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.table-card {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    cursor: pointer;
}

.table-card:hover {
    border-color: var(--accent-color);
}

.column-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.results-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Darker backdrop */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: rgba(255,255,255,0.02);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

/* Improved Checkbox Styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* Improved Config Modal Styling */
.config-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.config-summary-item {
    flex: 1;
    text-align: center;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.config-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.config-card-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.config-card-value {
    color: var(--text-primary);
    font-weight: 600;
}

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

.config-section h4 {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

/* Chart Card (for Saved Charts) */
.chart-card {
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chart-card:hover {
    border-color: var(--text-secondary);
    transform: translateY(-2px);
}

.chart-card h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
}

.chart-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    opacity: 0.8;
}

.chart-card .meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

@media (max-width: 768px) {
    .explorer-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Stat Updates Animation */
@keyframes stat-pulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.3);
        filter: brightness(1.5);
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

.stat-value-animate {
    display: inline-block;
    will-change: transform, filter;
    /* Ensure it doesn't shift layout too much, though inline-block usually handles scale from center */
}

.stat-value-animate.updating {
    animation: stat-pulse 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Chart Update Pulse */
@keyframes chart-update-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0);
        border-color: var(--border-color);
    }
    25% {
        box-shadow: 0 0 20px rgba(16, 163, 127, 0.3);
        border-color: var(--accent-color);
        transform: scale(1.01);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0);
        border-color: var(--border-color);
        transform: scale(1);
    }
}

.chart-card.updated {
    animation: chart-update-flash 1s ease-out;
    z-index: 1; /* Bring to front during animation */
}

/* ============================================
   TOAST NOTIFICATIONS - Dashboard Style
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: rgba(32, 33, 35, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-success {
    border-left: 3px solid var(--accent-color);
}

.toast-success::before {
    content: '✓';
    color: var(--accent-color);
    font-weight: bold;
}

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

.toast-error::before {
    content: '✕';
    color: var(--danger-color);
    font-weight: bold;
}

.toast-info {
    border-left: 3px solid var(--info-color);
}

.toast-info::before {
    content: '→';
    color: var(--info-color);
    font-weight: bold;
}

/* ============================================
   CONNECTION STATUS - Dashboard Style
   ============================================ */

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connection-status .status-dot {
    position: relative;
}

.connection-status .status-dot.connected {
    animation: connectedPulse 3s ease-in-out infinite;
}

.connection-status .status-dot.connected::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.3;
    animation: connectedRing 3s ease-in-out infinite;
}

@keyframes connectedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes connectedRing {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.8); opacity: 0; }
}

/* ============================================
   NEW EVENT BADGE - Dashboard Style
   ============================================ */

.new-event-badge {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--accent-color) 0%, #059669 100%);
    color: white;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(16, 163, 127, 0.4), 0 0 0 0 rgba(16, 163, 127, 0.4);
    animation: badgePulse 2s ease-in-out infinite;
    transition: all 0.2s ease;
    z-index: 50;
}

.new-event-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(16, 163, 127, 0.5);
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(16, 163, 127, 0.4), 0 0 0 0 rgba(16, 163, 127, 0.4);
    }
    50% {
        box-shadow: 0 4px 16px rgba(16, 163, 127, 0.4), 0 0 0 8px rgba(16, 163, 127, 0);
    }
}

/* ============================================
   EMPTY STATE - Dashboard Style
   ============================================ */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    margin: auto;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    opacity: 0.4;
    animation: emptyFloat 4s ease-in-out infinite;
}

@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* ============================================
   PATIENT PROFILE MODAL
   Beautiful profile view for patient data
   ============================================ */

.patient-profile-modal {
    max-width: 700px;
    max-height: 85vh;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Patient Header */
.patient-profile-header {
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.15) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-bottom: 1px solid rgba(16, 163, 127, 0.2);
    padding: 1.5rem;
}

.patient-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.patient-avatar {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
    flex-shrink: 0;
}

.patient-header-text {
    flex: 1;
}

.patient-header-text h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.patient-meta-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.patient-id-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    background: rgba(107, 114, 128, 0.2);
    border: 1px solid rgba(107, 114, 128, 0.3);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.patient-status-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.patient-status-badge.active {
    background: rgba(16, 163, 127, 0.15);
    border: 1px solid rgba(16, 163, 127, 0.3);
    color: var(--accent-color);
}

.patient-status-badge.discharged {
    background: rgba(107, 114, 128, 0.15);
    border: 1px solid rgba(107, 114, 128, 0.3);
    color: var(--text-tertiary);
}

.patient-status-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    animation: criticalPulse 2s ease-in-out infinite;
}

/* Patient Body */
.patient-profile-body {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(85vh - 120px);
}

/* Stats Grid */
.patient-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.patient-stat-card {
    background: linear-gradient(145deg, var(--input-bg) 0%, rgba(64, 65, 79, 0.6) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.patient-stat-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.patient-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(16, 163, 127, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.patient-stat-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.patient-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-tertiary);
}

.patient-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Patient Sections */
.patient-section {
    margin-bottom: 1.5rem;
}

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

.patient-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

/* Encounter Details */
.encounter-details {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
}

.encounter-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(86, 88, 105, 0.3);
}

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

.encounter-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.encounter-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
}

/* Patient Timeline */
.patient-timeline-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.patient-timeline {
    position: relative;
    padding-left: 2rem;
}

/* Timeline vertical line */
.patient-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent-color) 0%, var(--border-color) 100%);
    border-radius: 1px;
}

.timeline-event {
    position: relative;
    padding: 0.75rem 0 0.75rem 1rem;
    border-bottom: 1px solid rgba(86, 88, 105, 0.2);
    animation: timelineEventFade 0.3s ease-out;
}

.timeline-event:last-child {
    border-bottom: none;
}

@keyframes timelineEventFade {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Timeline dot */
.timeline-event::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 1rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 3px solid var(--text-tertiary);
    z-index: 1;
}

.timeline-event.admission::before {
    border-color: var(--accent-color);
    background: rgba(16, 163, 127, 0.2);
    box-shadow: 0 0 8px rgba(16, 163, 127, 0.4);
}

.timeline-event.discharge::before {
    border-color: var(--text-tertiary);
    background: rgba(107, 114, 128, 0.2);
}

.timeline-event.transfer::before {
    border-color: var(--info-color);
    background: rgba(59, 130, 246, 0.2);
}

.timeline-event.important::before,
.timeline-event.clinical_update::before {
    border-color: var(--info-color);
    background: rgba(59, 130, 246, 0.2);
}

.timeline-event.critical::before {
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.timeline-event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.timeline-event-type {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

.timeline-event-type.admission {
    background: rgba(16, 163, 127, 0.15);
    color: var(--accent-color);
}

.timeline-event-type.discharge {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-tertiary);
}

.timeline-event-type.transfer {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.timeline-event-type.clinical_update,
.timeline-event-type.status_change {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.timeline-event-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.timeline-event-summary {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.timeline-event-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.timeline-event-unit,
.timeline-event-bed {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(16, 163, 127, 0.1);
    color: var(--accent-color);
    border: 1px solid rgba(16, 163, 127, 0.2);
}

.timeline-event-bed {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.2);
}

/* Loading state for patient modal */
.patient-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.patient-loading .spinner {
    width: 32px;
    height: 32px;
}

.patient-loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Make event cards clickable */
.event-card {
    cursor: pointer;
}

.event-card:active {
    transform: scale(0.995);
}

/* Scrollbar styling for timeline */
.patient-timeline-container::-webkit-scrollbar {
    width: 6px;
}

.patient-timeline-container::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 3px;
}

.patient-timeline-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.patient-timeline-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .patient-profile-modal {
        max-width: 95vw;
        max-height: 90vh;
    }

    .patient-stats-grid {
        grid-template-columns: 1fr;
    }

    .patient-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
    }

    .patient-header-text h2 {
        font-size: 1.2rem;
    }
}

/* ============================================
   STAT CHIPS - Header Statistics
   ============================================ */

.stat-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: rgba(64, 65, 79, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: help;
    transition: all 0.2s ease;
    position: relative;
}

.stat-chip:hover {
    background: rgba(64, 65, 79, 0.8);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
}

.stat-chip-icon {
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-chip-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Primary stat chip (highlighted) */
.stat-chip.stat-chip-primary {
    background: rgba(16, 163, 127, 0.15);
    border-color: rgba(16, 163, 127, 0.3);
}

.stat-chip.stat-chip-primary:hover {
    background: rgba(16, 163, 127, 0.25);
    border-color: var(--accent-color);
}

.stat-chip.stat-chip-primary span:not(.stat-chip-label):not(.stat-chip-icon) {
    color: var(--accent-color);
}

/* Info stat chip */
.stat-chip.stat-chip-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

.stat-chip.stat-chip-info:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--info-color);
}

.stat-chip.stat-chip-info span:not(.stat-chip-label):not(.stat-chip-icon) {
    color: #60a5fa;
}

/* Warning stat chip (orange - high occupancy) */
.stat-chip.stat-chip-warning {
    background: rgba(251, 146, 60, 0.15);
    border-color: rgba(251, 146, 60, 0.3);
}

.stat-chip.stat-chip-warning:hover {
    background: rgba(251, 146, 60, 0.25);
    border-color: #fb923c;
}

.stat-chip.stat-chip-warning span:not(.stat-chip-label):not(.stat-chip-icon) {
    color: #fb923c;
}

/* Danger stat chip (red - critical occupancy) */
.stat-chip.stat-chip-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.stat-chip.stat-chip-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

.stat-chip.stat-chip-danger span:not(.stat-chip-label):not(.stat-chip-icon) {
    color: #ef4444;
}

/* Divider between stat groups */
.stat-chip-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Tooltip styling (native title enhanced via CSS) */
.stat-chip[title] {
    position: relative;
}

/* Custom tooltip on hover */
.stat-chip::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: var(--header-bg);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    min-width: 200px;
    max-width: 350px;
    white-space: normal;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    pointer-events: none;
    line-height: 1.4;
}

.stat-chip::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 101;
}

.stat-chip:hover::after,
.stat-chip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Hide native tooltip */
.stat-chip[title]:hover {
    /* Native tooltip is disabled via CSS custom tooltip */
}

/* Connection status in stat bar */
.feed-status .connection-status {
    padding-left: 0.5rem;
}

.feed-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-color);
}

/* ============================================
   ENHANCED CHART CARDS - Real-time Dashboard
   ============================================ */

.chart-card {
    background: linear-gradient(145deg, var(--header-bg) 0%, rgba(32, 33, 35, 0.95) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: default;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 350px;
    position: relative;
    overflow: hidden;
    /* Containment prevents internal changes from triggering parent reflows */
    contain: layout style;
    /* GPU acceleration hints for smoother animations */
    will-change: transform, box-shadow;
    transform: translateZ(0);
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chart-card:hover {
    border-color: rgba(16, 163, 127, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(16, 163, 127, 0.1);
}

.chart-card:hover::before {
    opacity: 1;
}

/* Card view toggle buttons */
.card-toggle-btn {
    background: transparent;
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.card-toggle-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.3);
}

.card-toggle-btn svg {
    stroke: currentColor;
    fill: none;
}

/* Card content area */
.card-content {
    flex: 1;
    min-height: 0;
    position: relative;
    /* Contain layout changes within the content area */
    contain: layout;
    overflow: hidden;
}

.chart-view, .table-view {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
    backface-visibility: hidden;
}

/* Smooth crossfade transitions for view switching */
.chart-view.fading-out, .table-view.fading-out {
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
}

.chart-view.fading-in, .table-view.fading-in {
    opacity: 1;
    transform: scale(1);
}

/* Mini table styling - STABLE LAYOUT */
.mini-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    table-layout: fixed; /* CRITICAL: prevents column width changes */
}

/* All cells use tabular numbers and have stable widths */
.mini-data-table th,
.mini-data-table td {
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-data-table th {
    background: rgba(16, 163, 127, 0.1);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.mini-data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(86, 88, 105, 0.3);
    color: var(--text-secondary);
    /* ONLY safe transitions - no layout-affecting properties */
    transition: color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.mini-data-table tr:hover td {
    background: rgba(16, 163, 127, 0.05);
}

/* Numeric cells - right aligned */
.mini-data-table .numeric-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--text-primary);
}

/* Old number animations removed - see TABLE ANIMATIONS section below */

/* Value changed - layout-safe */
.mini-data-table td.value-changed {
    background-color: rgba(16, 163, 127, 0.25);
    color: var(--accent-color);
}

/* Stat value animation class (for dashboard stats) */
.stat-value-animate {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.stat-value-animate.updating {
    animation: statPulse 0.4s ease-out;
}

@keyframes statPulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.15);
        filter: brightness(1.3);
        color: var(--accent-color);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* New row animation */
.mini-data-table tr.new-row {
    animation: rowSlideIn 0.4s ease-out;
}

@keyframes rowSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
        background: rgba(16, 163, 127, 0.2);
    }
    to {
        opacity: 1;
        transform: translateX(0);
        background: transparent;
    }
}

/* Live pulse animation */
@keyframes livePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

.live-dot {
    transition: all 0.3s ease;
}

/* Chart update animation - single consolidated rule (avoids conflicts) */
/* Other .data-changed rules have been removed to prevent animation conflicts */

/* Update indicator glow */
.chart-card.updated::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), rgba(20, 184, 166, 0.8), var(--accent-color));
    background-size: 200% 100%;
    animation: updateGlow 1s ease-out;
}

@keyframes updateGlow {
    0% {
        opacity: 1;
        background-position: 100% 0;
    }
    100% {
        opacity: 0;
        background-position: -100% 0;
    }
}

/* Meta footer styling */
.chart-card .meta {
    padding-top: 0.5rem;
    border-top: 1px solid rgba(86, 88, 105, 0.3);
}

.chart-card .update-time {
    transition: all 0.3s ease;
}

.chart-card .live-indicator {
    color: var(--accent-color);
    font-weight: 500;
}

/* Delete button */
.chart-card .delete-btn {
    opacity: 0.5;
    transition: all 0.2s ease;
}

.chart-card:hover .delete-btn {
    opacity: 1;
}

.chart-card .delete-btn:hover {
    color: var(--danger-color) !important;
    background: rgba(239, 68, 68, 0.1);
}

/* Empty dashboard state */
.charts-grid .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--header-bg);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
}

.charts-grid .empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .chart-card {
        min-height: 280px;
        padding: 0.75rem 1rem;
    }

    .card-toggle-btn {
        padding: 4px 6px;
    }

    .mini-data-table {
        font-size: 0.7rem;
    }

    .mini-data-table th,
    .mini-data-table td {
        padding: 0.35rem 0.5rem;
    }
}

/* ============================================
   ENHANCED REAL-TIME ANIMATIONS
   Premium dashboard update effects
   ============================================ */

/* Chart canvas - no transitions to prevent flicker during Chart.js redraws */
.chart-card canvas {
    /* Removed opacity/filter transitions - they cause blinking when Chart.js redraws */
}

/* Update sweep bar - animated accent line */
.chart-update-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--accent-color) 20%,
        rgba(20, 184, 166, 0.9) 50%,
        var(--accent-color) 80%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: updateSweep 1.2s ease-out forwards;
    border-radius: 3px 3px 0 0;
    z-index: 10;
}

@keyframes updateSweep {
    0% {
        opacity: 1;
        background-position: 100% 0;
        box-shadow: 0 0 20px var(--accent-color), 0 2px 10px rgba(16, 163, 127, 0.5);
    }
    60% {
        opacity: 1;
        background-position: -50% 0;
    }
    100% {
        opacity: 0;
        background-position: -100% 0;
        box-shadow: none;
    }
}

/* Single consolidated data-changed animation - subtle border glow */
.chart-card.data-changed {
    animation: cardDataUpdate 0.8s ease-out;
}

@keyframes cardDataUpdate {
    0% {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 0 rgba(16, 163, 127, 0.3);
    }
    50% {
        border-color: var(--accent-color);
        box-shadow: 0 0 12px rgba(16, 163, 127, 0.2);
    }
    100% {
        border-color: var(--border-color);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
}

/* Old conflicting rules removed - see TABLE ANIMATIONS section */

/* Enhanced live dot with perpetual glow */
.live-dot {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 8px var(--accent-color);
}

.chart-card:hover .live-dot {
    box-shadow: 0 0 12px var(--accent-color), 0 0 24px rgba(16, 163, 127, 0.5);
}

/* Update timestamp glow effect */
.chart-card .update-time {
    transition: all 0.3s ease;
    font-variant-numeric: tabular-nums;
}

/* Table row - ONLY transition safe properties */
.mini-data-table tbody tr {
    transition: background-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.mini-data-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(16, 163, 127, 0.08), transparent);
    box-shadow: inset 3px 0 0 var(--accent-color);
}

@keyframes rowHighlight {
    from {
        opacity: 0.4;
        background: rgba(16, 163, 127, 0.1);
    }
    to {
        opacity: 1;
        background: transparent;
    }
}

/* Card header subtle animation */
.chart-card .card-header h3 {
    transition: color 0.3s ease;
}

.chart-card.data-changed .card-header h3 {
    color: var(--accent-color);
}

/* Loading panel enhancements */
#loadingPanel {
    backdrop-filter: blur(8px);
}

#loadingPanel.active {
    animation: panelFadeIn 0.3s ease-out;
}

@keyframes panelFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading status text animation */
#loadingStatusPrimary,
#loadingStatusSecondary {
    transition: all 0.3s ease;
}

#loadingStatusPrimary {
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Charts grid responsive with animation */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.charts-grid .chart-card {
    animation: cardEnter 0.5s ease-out backwards;
}

.charts-grid .chart-card:nth-child(1) { animation-delay: 0ms; }
.charts-grid .chart-card:nth-child(2) { animation-delay: 100ms; }
.charts-grid .chart-card:nth-child(3) { animation-delay: 200ms; }
.charts-grid .chart-card:nth-child(4) { animation-delay: 300ms; }
.charts-grid .chart-card:nth-child(5) { animation-delay: 400ms; }
.charts-grid .chart-card:nth-child(6) { animation-delay: 500ms; }

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

/* ============================================
   DRAMATIC REAL-TIME EFFECTS
   Premium live dashboard animations
   ============================================ */

/* Delta indicators - float up/down showing change amount */
.delta-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    z-index: 9999;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    transform: translateY(-50%);
}

.delta-indicator.delta-up {
    color: #22c55e;
}

.delta-indicator.delta-down {
    color: #ef4444;
}

.delta-indicator.delta-animate {
    animation: deltaFloat 1.2s ease-out forwards;
}

.delta-indicator.delta-up.delta-animate {
    animation: deltaFloatUp 1.2s ease-out forwards;
}

.delta-indicator.delta-down.delta-animate {
    animation: deltaFloatDown 1.2s ease-out forwards;
}

@keyframes deltaFloatUp {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: translateY(-8px) scale(1.2);
    }
    30% {
        transform: translateY(-12px) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateY(-16px);
    }
    100% {
        opacity: 0;
        transform: translateY(-24px);
    }
}

@keyframes deltaFloatDown {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: translateY(8px) scale(1.2);
    }
    30% {
        transform: translateY(12px) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateY(16px);
    }
    100% {
        opacity: 0;
        transform: translateY(24px);
    }
}

.delta-indicator.delta-fade {
    animation: deltaFadeOut 0.3s ease-out forwards;
}

@keyframes deltaFadeOut {
    to {
        opacity: 0;
        transform: translateY(-30px);
    }
}

/* ===========================================
   TABLE ANIMATIONS - LAYOUT SAFE ONLY
   NO transforms, NO position changes, NO font-weight changes
   =========================================== */

/* Number cells - use tabular nums to prevent width changes */
.mini-data-table td.numeric-cell {
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Increasing value - green glow, NO font-weight change */
.numeric-cell.increasing {
    color: #22c55e !important;
    background-color: rgba(34, 197, 94, 0.15);
    box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.3);
}

/* Decreasing value - red glow, NO font-weight change */
.numeric-cell.decreasing {
    color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.15);
    box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.3);
}

/* Rolling animation - just color, NO font-weight */
.numeric-cell.number-rolling {
    text-shadow: 0 0 10px currentColor;
}

/* Settling back to normal */
.numeric-cell.number-settling {
    transition: color 0.5s ease-out, background-color 0.5s ease-out, box-shadow 0.5s ease-out, text-shadow 0.5s ease-out;
    color: var(--text-primary) !important;
    background-color: transparent;
    box-shadow: none;
    text-shadow: none;
}

/* Row updated - ONLY background color, NO position, NO pseudo-elements */
.mini-data-table tbody tr.row-updated {
    background: linear-gradient(90deg, rgba(16, 163, 127, 0.2), rgba(16, 163, 127, 0.1), transparent) !important;
    box-shadow: inset 4px 0 0 var(--accent-color);
}

/* New row - ONLY opacity and background */
.mini-data-table tbody tr.new-row-entering {
    opacity: 0;
    background-color: rgba(16, 163, 127, 0.3);
}

.mini-data-table tbody tr.new-row-entered {
    animation: newRowFadeIn 0.5s ease-out forwards;
}

@keyframes newRowFadeIn {
    0% {
        opacity: 0;
        background-color: rgba(16, 163, 127, 0.4);
    }
    50% {
        opacity: 1;
        background-color: rgba(16, 163, 127, 0.2);
    }
    100% {
        opacity: 1;
        background-color: transparent;
    }
}

/* Text change - ONLY opacity and background */
.mini-data-table td.text-changing {
    opacity: 0.5;
}

.mini-data-table td.text-changed {
    background-color: rgba(16, 163, 127, 0.3);
    transition: background-color 0.6s ease-out;
}

/* Enhanced live indicator with heartbeat */
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    }
    15% {
        transform: scale(1.3);
        box-shadow: 0 0 20px var(--accent-color), 0 0 40px var(--accent-color);
    }
    30% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.2);
        box-shadow: 0 0 15px var(--accent-color), 0 0 30px var(--accent-color);
    }
}

/* Duplicate .data-changed rule removed - consolidated above */

/* Update sweep bar - more dramatic */
.chart-update-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent-color) 15%,
        #14b8a6 35%,
        #22c55e 50%,
        #14b8a6 65%,
        var(--accent-color) 85%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: updateBarSweep 1s ease-out forwards;
    border-radius: 4px 4px 0 0;
    z-index: 10;
    box-shadow: 0 0 20px var(--accent-color), 0 2px 10px rgba(16, 163, 127, 0.5);
}

@keyframes updateBarSweep {
    0% {
        opacity: 1;
        background-position: 100% 0;
        box-shadow: 0 0 30px var(--accent-color), 0 2px 20px rgba(16, 163, 127, 0.8);
    }
    70% {
        opacity: 1;
        background-position: -50% 0;
    }
    100% {
        opacity: 0;
        background-position: -100% 0;
        box-shadow: none;
    }
}

/* Persistent ambient pulse on live cards */
.chart-card {
    --pulse-opacity: 0;
}

.chart-card::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--accent-color), transparent, var(--accent-color));
    background-size: 400% 400%;
    opacity: var(--pulse-opacity);
    animation: ambientPulse 4s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes ambientPulse {
    0%, 100% {
        background-position: 0% 50%;
        opacity: 0.05;
    }
    50% {
        background-position: 100% 50%;
        opacity: 0.1;
    }
}

/* Timestamp flash effect */
.update-time.timestamp-flash {
    color: var(--accent-color) !important;
    font-weight: 600 !important;
    text-shadow: 0 0 15px var(--accent-color);
    animation: timestampPulse 2s ease-out forwards;
}

@keyframes timestampPulse {
    0% {
        color: var(--accent-color);
        text-shadow: 0 0 20px var(--accent-color);
        transform: scale(1.05);
    }
    30% {
        transform: scale(1);
    }
    100% {
        color: var(--text-tertiary);
        text-shadow: none;
        font-weight: normal;
    }
}

/* Live dot burst on update */
.live-dot.live-burst {
    animation: liveBurst 0.6s ease-out !important;
}

@keyframes liveBurst {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    }
    30% {
        transform: scale(2);
        box-shadow: 0 0 30px var(--accent-color), 0 0 60px var(--accent-color), 0 0 80px rgba(16, 163, 127, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    }
}

/* Canvas effects for live updates */
/* Canvas transitions removed - they cause flickering during Chart.js redraws */
/* Visual feedback for data changes is handled by the card border/shadow instead */

/* Connection status live indicator */
.connection-status.live {
    position: relative;
}

.connection-status.live::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
    animation: statusPulse 2s ease-in-out infinite;
}

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

/* Numeric cells - no transforms to avoid layout shift */
.mini-data-table td.numeric-cell {
    transition: color 0.3s ease-out, text-shadow 0.3s ease-out, background 0.3s ease-out;
}
/* ============================================
   NURSING & ASSET CARE SECTIONS
   ============================================ */

.patient-care-content {
    background: var(--input-bg);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 80px;
}

.care-loading {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem;
}

.care-empty {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    text-align: center;
    font-style: italic;
}

.care-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.care-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    background: rgba(64, 65, 79, 0.3);
    border-radius: 6px;
}

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

.care-stat-value.above {
    color: var(--warning-color, #f59e0b);
}

.care-stat-value.below {
    color: var(--info-color, #3b82f6);
}

.care-stat-value.at {
    color: var(--accent-color);
}

.care-stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    margin-top: 0.15rem;
}

.care-recent {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.care-record {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    background: rgba(64, 65, 79, 0.2);
    border-radius: 4px;
    font-size: 0.75rem;
}

.care-time {
    color: var(--text-tertiary);
    min-width: 70px;
}

.care-minutes {
    color: var(--text-primary);
    font-weight: 500;
}

.care-variance {
    margin-left: auto;
    font-weight: 600;
}

.care-variance.above {
    color: var(--warning-color, #f59e0b);
}

.care-variance.below {
    color: var(--info-color, #3b82f6);
}

.care-variance.at {
    color: var(--accent-color);
}

.asset-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.asset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: rgba(64, 65, 79, 0.3);
    border-radius: 6px;
}

.asset-tag {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

.asset-type {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* Responsive for patient care row */
@media (max-width: 600px) {
    .patient-care-row {
        grid-template-columns: 1fr !important;
    }
}
