:root {
    /* Dark Theme (Default) */
    --bg-main: #05070a;
    --card-glass: rgba(15, 23, 42, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --blob-opacity: 0.3;
    
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-magenta: #d946ef;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
}

body.theme-light {
    --bg-main: #f0f4f8;
    --card-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.1);
    --text-main: #0f172a;
    --text-dim: #475569;
    --blob-opacity: 0.15;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    height: 100vh;
    overflow: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Blobs */
.blob {
    position: absolute; border-radius: 50%; filter: blur(80px);
    z-index: -1; opacity: var(--blob-opacity);
    animation: blobFloat 20s infinite alternate ease-in-out;
    transition: opacity 0.4s;
}
.blob-1 { width: 400px; height: 400px; background: var(--accent-purple); top: -100px; left: -100px; }
.blob-2 { width: 500px; height: 500px; background: var(--accent-cyan); bottom: -150px; right: -100px; animation-delay: -5s; }
.blob-3 { width: 300px; height: 300px; background: var(--accent-magenta); top: 30%; left: 40%; animation-delay: -10s; }

@keyframes blobFloat {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 50px) scale(1.2); }
}

.app-shell { height: 100%; display: flex; flex-direction: column; padding: 1rem 1.5rem; }

/* Header */
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.header-left, .header-center, .header-right { flex: 1; display: flex; }
.header-center { justify-content: center; }
.header-right { justify-content: flex-end; align-items: center; gap: 1rem; }

.brand-logo h2 { font-weight: 800; background: -webkit-linear-gradient(45deg, var(--accent-cyan), var(--accent-purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.system-tag { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* Nav */
.top-nav { background: var(--card-glass); padding: 0.4rem; border-radius: 100px; border: 1px solid var(--border-glass); display: flex; gap: 0.5rem; backdrop-filter: blur(10px); }
.nav-link { color: var(--text-dim); text-decoration: none; padding: 0.4rem 1.2rem; border-radius: 100px; font-size: 0.85rem; font-weight: 500; transition: all 0.3s; }
.nav-link:hover { color: var(--text-main); }
.nav-link.active { background: var(--accent-cyan); color: #fff; box-shadow: 0 0 10px rgba(6, 182, 212, 0.4); }

/* Controls */
.enterprise-dropdown { background: var(--card-glass); border: 1px solid var(--border-glass); color: var(--text-main); padding: 0.4rem 1rem; border-radius: 8px; outline: none; }
.theme-switch { cursor: pointer; user-select: none; font-size: 1.2rem; }
.ws-status { font-size: 0.8rem; }
.datetime { font-family: 'Courier New', monospace; font-size: 0.9rem; }

/* Main Content Area */
.content-area { flex-grow: 1; position: relative; overflow-y: auto; }
.view-section { display: none; height: 100%; animation: fadeIn 0.4s ease; }
.view-section.active-view { display: flex; flex-direction: column; gap: 1rem;}

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

/* Cards */
.card-glass { background: var(--card-glass); border: 1px solid var(--border-glass); border-radius: 1.2rem; backdrop-filter: blur(20px); padding: 1.2rem; }

/* OVERVIEW */
.overview-grid { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; flex-grow: 1; }
.map-card { padding: 0; overflow: hidden; position: relative; min-height: 300px; }
#map-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.sources-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; overflow-y: auto; }
.source-card { display: flex; flex-direction: column; gap: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-glass); padding-bottom: 0.8rem; margin-bottom: 0.8rem; }

/* Source Metrics (From original) */
.hero-metrics { display: flex; gap: 1rem; }
.metric-box { flex: 1; background: rgba(0,0,0,0.1); padding: 0.8rem; border-radius: 0.8rem; text-align: center; border: 1px solid var(--border-glass); }
.metric-box label { display: block; font-size: 0.7rem; color: var(--text-dim); }
.metric-box .val { font-size: 1.5rem; font-weight: bold; }

.substance-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; padding: 0.4rem 0; border-bottom: 1px solid rgba(255,255,255,0.02); position: relative; }
.substance-row:last-child { border: none; }
.sub-name { font-weight: bold; width: 50px;}
.sub-val { font-family: monospace; }
.sub-bar-bg { width: 40%; height: 4px; background: rgba(128,128,128,0.2); border-radius: 2px; overflow: hidden; }
.sub-bar-fill { height: 100%; transition: width 0.3s; }

.chart-card { height: 250px; display: flex; flex-direction: column; }
.live-chart-container { flex-grow: 1; position: relative; }

/* ANALYTICS */
.analytics-grid { display: grid; grid-template-columns: 350px 1fr; gap: 1rem; height: 100%; }
.weather-card { display: flex; flex-direction: column; gap: 1rem; }
.weather-content { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem;}
.w-metrics { background: rgba(0,0,0,0.1); padding: 1rem; border-radius: 8px; line-height: 1.8; }
.w-status { font-weight: bold; font-size: 1.2rem; color: var(--accent-cyan); }
.w-summary { color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; }
.stats-card { display: flex; flex-direction: column; }
.stats-chart-wrapper { flex-grow: 1; position: relative; min-height: 300px;}

/* HISTORY */
.history-card { height: 100%; display: flex; flex-direction: column; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.table-container { flex-grow: 1; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 0.8rem; border-bottom: 1px solid var(--border-glass); }
.data-table th { background: rgba(0,0,0,0.1); color: var(--text-dim); position: sticky; top: 0; backdrop-filter: blur(5px); }

/* SETTINGS */
.settings-card { max-width: 600px; margin: 0 auto; }
.settings-form { display: flex; flex-direction: column; gap: 1.2rem; margin-top: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input { background: var(--bg-main); color: var(--text-main); border: 1px solid var(--border-glass); padding: 0.8rem; border-radius: 8px; outline: none; }
input:focus { border-color: var(--accent-cyan); }

/* Buttons */
.btn { background: var(--bg-main); color: var(--text-main); border: 1px solid var(--border-glass); padding: 0.6rem 1.2rem; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.btn:hover { background: rgba(255,255,255,0.1); }
.btn-primary { background: var(--accent-cyan); color: #fff; border: none; font-weight: bold; }
.btn-primary:hover { background: #0891b2; filter: brightness(1.1); box-shadow: 0 0 10px var(--accent-cyan); }
.msg-success { color: var(--accent-cyan); font-size: 0.9rem; margin-left: 1rem; }
