:root {
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --header-bg: #1e293b;
    --header-text: #ffffff;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.85);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --primary: #38bdf8;
    --primary-hover: #0284c7;
    --header-bg: #0284c7;
    --header-text: #ffffff;
}

/* Theme Corporate */
[data-theme="corporate"] {
    --bg-main: #f0f4f8;
    --card-bg: #ffffff;
    --text-main: #102a43;
    --text-muted: #486581;
    --border-color: #bcccdc;
    --primary: #0967d2;
    --primary-hover: #054288;
    --header-bg: #0b69a3;
    --header-text: #ffffff;
}


* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', 'Segoe UI', Arial, sans-serif; }
body { background: var(--bg-main); color: var(--text-main); line-height: 1.5; transition: background 0.3s ease; }

.navbar { background: var(--header-bg); color: var(--header-text); padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.brand { font-size: 1.3rem; font-weight: 700; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
.brand-logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.brand-logo img { height: 60px; width: auto; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; text-align: center;}
.brand-title { font-size: 1.2rem; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; line-height: 1.1; }
.brand-sub { font-size: 0.6rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.menu { display: flex; gap: 15px; align-items: center; }
.menu a { color: var(--header-text); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 6px; transition: background 0.2s; }
.menu a:hover { background: rgba(255,255,255,0.15); }

.container { max-width: 1200px; margin: 25px auto; padding: 0 20px; }

.card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 22px; margin-bottom: 22px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

/* Clock Card Gradient Normal */
.card-clock.normal {
    border: 2px solid #10b981 !important;
    background: radial-gradient(circle, #f0fdf4 0%, #d1fae5 70%, #a7f3d0 100%) !important;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
    transition: all 0.4s ease;
}

/* Clock Card Gradient Alarm */
.card-clock.alarm {
    border: 2px solid #ef4444 !important;
    background: radial-gradient(circle, #fef2f2 0%, #fecaca 70%, #fca5a5 100%) !important;
    border-radius: 16px;
    animation: cardPulseGlow 2s infinite ease-in-out;
    transition: all 0.4s ease;
}

@keyframes cardPulseGlow {
    0% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.85); }
    100% { box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
}

.bell-pulse {
    display: inline-block;
    color: #dc2626;
    font-size: 1.3rem;
    animation: ringBell 1.2s infinite ease-in-out;
}

@keyframes ringBell {
    0% { transform: scale(1) rotate(0deg); }
    15% { transform: scale(1.2) rotate(15deg); }
    30% { transform: scale(1.2) rotate(-15deg); }
    45% { transform: scale(1.2) rotate(10deg); }
    60% { transform: scale(1) rotate(0deg); }
}

.badge-normal { color: #059669; font-weight: bold; }
.badge-alarm { color: #dc2626; font-weight: bold; }

.metrics-box { display: flex; justify-content: space-around; margin: 15px 0; background: rgba(255,255,255,0.7); padding: 12px; border-radius: 8px; }
.metric-val { font-size: 1.8rem; font-weight: 800; }

table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th, td { border: 1px solid var(--border-color); padding: 12px; text-align: center; font-size: 14px; }
th { background: rgba(0,0,0,0.03); font-weight: 700; }

.btn { background: var(--primary); color: white; border: none; padding: 9px 18px; border-radius: 6px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; transition: background 0.2s; }
.btn:hover { background: var(--primary-hover); }
.btn-danger { background: #ef4444; } .btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; } .btn-success:hover { background: #059669; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 14px; border-top: 1px solid var(--border-color); margin-top: 40px; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.auth-box { background: #ffffff; width: 400px; padding: 35px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); text-align: center; }
.auth-box input, .auth-box select { width: 100%; margin: 10px 0; padding: 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }

/* SVG Circular Gauge */
.gauge-container { display: flex; justify-content: space-around; flex-wrap: wrap; margin: 20px 0; }
.gauge-box { text-align: center; width: 180px; }
.gauge-svg { width: 140px; height: 140px; }
.gauge-bg { fill: none; stroke: #e2e8f0; stroke-width: 10; }
.gauge-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
/* Styling Đồng hồ Gauge 1/2 vòng tròn SVG giống hình mẫu */
.gauge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.gauge-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.gauge-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.gauge-svg-wrap {
    position: relative;
    width: 220px;
    height: 120px;
    margin: 0 auto;
}

.gauge-half-svg {
    width: 100%;
    height: 100%;
}

.gauge-bg-path {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 12;
    stroke-linecap: round;
}

.gauge-fill-path {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease-in-out;
}

.gauge-value-text {
    font-size: 2.2rem;
    font-weight: 800;
    margin-top: 10px;
}

.gauge-status-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 8px;
}

.status-normal-bg { background: #d1fae5; color: #059669; }
.status-alarm-bg { background: #fee2e2; color: #dc2626; }

.gauge-analysis-section {
    border-top: 1px dashed var(--border-color);
    margin-top: 20px;
    padding-top: 15px;
}

.gauge-analysis-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.gauge-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.gauge-stat-item h5 {
    font-size: 0.8rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.gauge-stat-item span {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Biểu đồ Responsive Wrapper */
.chart-container-responsive {
    position: relative;
    width: 100%;
    min-height: 260px;
}