:root {
    --primary: #4A90A4;
    --primary-light: #6BA893;
    --primary-dark: #3a7a8e;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(74, 144, 164, 0.3);
}

.header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

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

.config-bar {
    background: white;
    padding: 15px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.config-bar input {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.config-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.config-bar button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.config-bar button:hover {
    background: var(--primary-dark);
}

.tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 30px;
    overflow-x: auto;
}

.tab {
    padding: 15px 25px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--primary);
    background: rgba(74, 144, 164, 0.05);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

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

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.stat-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.highlight h3 {
    color: rgba(255,255,255,0.8);
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover td {
    background: rgba(74, 144, 164, 0.03);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(74, 144, 164, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.chart-container {
    position: relative;
    height: 300px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

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

.component-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: transform 0.2s;
}

.component-card:hover {
    transform: translateX(5px);
}

.component-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.component-stats {
    display: flex;
    gap: 20px;
}

.component-stat {
    text-align: center;
}

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

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

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4) !important;
}

button:active {
    transform: translateY(0);
}

/* Heatmap Styles */
.heatmap-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 20px;
}

.heatmap-container {
    display: grid;
    grid-template-columns: 80px repeat(24, minmax(28px, 1fr));
    gap: 2px;
    min-width: 750px;
}

.heatmap-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.heatmap-hour-label {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 4px;
}

.user-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.user-card:hover {
    background: white;
    border-color: var(--primary);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(74, 144, 164, 0.2);
}

.export-btn {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: none !important;
}

.export-btn:hover {
    background: var(--primary);
    color: white;
    transform: none !important;
    box-shadow: none !important;
}

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

.loading-error {
    text-align: center;
    padding: 20px;
    color: var(--error);
    font-weight: 500;
}

/* Info Button */
.stat-card {
    position: relative;
}

.info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    box-shadow: none !important;
    transform: none !important;
}

.info-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: none !important;
    box-shadow: none !important;
}

.stat-card.highlight .info-btn {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
}

.stat-card.highlight .info-btn:hover {
    background: rgba(255,255,255,0.3);
    color: white;
    border-color: rgba(255,255,255,0.6);
}

.info-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: var(--text);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.4;
    width: 240px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    text-align: left;
}

.info-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--text);
}

.stat-card:hover .info-tooltip,
.info-btn:focus + .info-tooltip,
.info-tooltip.visible {
    display: block;
}
