:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --success: #52C41A;
    --warning: #FAAD14;
    --danger: #FF4D4F;
    --danger-dark: #CF1322;
    --info: #1890FF;
    --bg-light: #F5F7FA;
    --bg-white: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-muted: #BDC3C7;
    --border-color: #E8ECF1;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: linear-gradient(135deg, #52C41A, #389E0D);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #FF4D4F, #CF1322);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #FAAD14, #D48806);
    color: white;
}

.btn-block {
    width: 100%;
}

.status-safe { color: var(--success); }
.status-warning { color: var(--warning); }
.status-danger { color: var(--danger); }
.status-info { color: var(--info); }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-safe, .badge-green {
    background: #F6FFED;
    color: #52C41A;
    border: 1px solid #B7EB8F;
}

.badge-warning, .badge-orange {
    background: #FFFBE6;
    color: #FAAD14;
    border: 1px solid #FFE58F;
}

.badge-danger, .badge-red {
    background: #FFF1F0;
    color: #FF4D4F;
    border: 1px solid #FFA39E;
}

.badge-info, .badge-blue {
    background: #E6F7FF;
    color: #1890FF;
    border: 1px solid #91D5FF;
}

.badge-gray {
    background: #F5F5F5;
    color: #999;
    border: 1px solid #D9D9D9;
}

.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-tabs {
    display: flex;
    gap: 8px;
}

.nav-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
}

.nav-tab:hover,
.nav-tab.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-card { text-align: center; padding: 24px; }
.stat-value { font-size: 36px; font-weight: 700; margin: 8px 0; }
.stat-label { color: var(--text-secondary); font-size: 14px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    background: #FAFAFA;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
}
.table tr:hover { background: #F8F9FA; }

.alert-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 77, 79, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: alertPulse 1.5s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { background: rgba(255, 77, 79, 0.95); }
    50% { background: rgba(255, 77, 79, 0.85); }
}

.alert-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.alert-icon { font-size: 64px; margin-bottom: 20px; }
.alert-title { font-size: 24px; font-weight: 700; color: var(--danger); margin-bottom: 12px; }
.alert-message { color: var(--text-secondary); margin-bottom: 24px; }
.timer { font-size: 48px; font-weight: 700; color: var(--primary); margin: 20px 0; }

.progress-ring { transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.progress-bg { stroke: var(--border-color); }
.progress-fg {
    stroke: var(--primary);
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.5s ease;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 16/9;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.risk-meter {
    height: 8px;
    background: linear-gradient(to right, #52C41A, #FAAD14, #FF4D4F);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.risk-indicator {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 16px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    transition: left 0.5s ease;
}

.event-list { max-height: 400px; overflow-y: auto; }
.event-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}
.event-item:hover { background: #F8F9FA; }
.event-time { color: var(--text-muted); font-size: 13px; min-width: 140px; }
.event-type { flex: 1; padding: 0 16px; }
.event-status { font-size: 12px; }

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

.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-item {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    color: var(--text-secondary);
    font-weight: 500;
}

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

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

.fade-in { animation: fadeIn 0.5s ease; }

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

@keyframes toastSlideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastSlideUp {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

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

.pulse { animation: pulse 2s ease-in-out infinite; }

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

@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

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

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

.ripple { position: relative; overflow: hidden; }
.ripple::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}
.ripple:active::after { width: 300px; height: 300px; }

/* Push notification animation */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(400px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Emergency alert banner pulse */
@keyframes emergencyPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.7); }
    50% { box-shadow: 0 0 0 20px rgba(255, 77, 79, 0); }
}

.emergency-pulse { animation: emergencyPulse 1.5s ease-in-out infinite; }

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Icon button hover effect */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    transform: scale(1.1);
    background: rgba(102, 126, 234, 0.1);
}

/* Smooth hover transitions */
.smooth-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.risk-meter-value {
    font-size: 48px;
    font-weight: 700;
    text-align: center;
    margin: 16px 0;
}
.risk-meter-value.safe { color: var(--success); }
.risk-meter-value.low { color: #40A9FF; }
.risk-meter-value.medium { color: var(--warning); }
.risk-meter-value.high { color: #FA541C; }
.risk-meter-value.critical { color: var(--danger); }

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: blink 1s infinite;
}

@media (max-width: 768px) {
    .container { padding: 12px; }
    .card { padding: 16px; }
    .header-content { flex-direction: column; gap: 12px; }
    .stat-value { font-size: 28px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
