@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Orbitron:wght@400;700;900&family=Roboto+Condensed:wght@700&display=swap');

@font-face {
  font-family: 'DSEG7';
  src: url('https://cdn.jsdelivr.net/npm/dseg@0.46.0/fonts/DSEG7-Classic/DSEG7Classic-Bold.woff2') format('woff2');
}

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-card: rgba(25, 25, 55, 0.7);
  --bg-glass: rgba(30, 30, 70, 0.45);
  --border-glass: rgba(100, 120, 255, 0.15);
  --text-primary: #e8eaff;
  --text-secondary: #8888aa;
  --accent-blue: #4466ff;
  --accent-cyan: #00ccff;
  --color-ok: #00dd66;
  --color-warn: #ffaa00;
  --color-danger: #ff3344;
  --color-o2: #00bbff;
  --color-n2o: #aa66ff;
  --color-co2: #ff6644;
  --color-air: #44ddaa;
  --color-vacuum: #ff66aa;
  --color-airmotor: #ffcc00;
  --gauge-bg: #0d0d24;
  --shadow-glow: 0 0 30px rgba(68, 102, 255, 0.15);
  --radius: 16px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(68, 102, 255, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(0, 204, 255, 0.04) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* ===== TOP BAR ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 64px;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}

.topbar-logo { display: flex; align-items: center; gap: 12px; }
.topbar-logo img { height: 32px; }
.topbar-logo span { font-family: 'Orbitron', monospace; font-size: 14px; font-weight: 700; color: var(--accent-cyan); letter-spacing: 2px; }

.topbar-center { font-size: 13px; color: var(--text-secondary); font-family: 'Orbitron', monospace; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-ok);
  box-shadow: 0 0 8px var(--color-ok);
  animation: pulse-dot 2s infinite;
}

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

.topbar-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  position: relative;
}
.topbar-btn:hover { background: rgba(68, 102, 255, 0.2); }
.topbar-btn .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--color-danger); color: #fff;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== NAV ===== */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: 72px;
  background: rgba(10, 10, 26, 0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-glass);
  display: flex; align-items: center; justify-content: space-around;
}

.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 12px;
  transition: var(--transition);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
}
.nav-item:hover { color: var(--accent-cyan); }
.nav-item.active { color: var(--accent-cyan); background: rgba(0, 204, 255, 0.1); }
.nav-item .nav-icon { font-size: 22px; }

/* ===== MAIN ===== */
.main { padding: 80px 20px 88px; position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.4s ease; }

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

.page-title {
  font-size: 22px; font-weight: 700; margin-bottom: 20px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

/* ===== GAUGE CARD ===== */
.gauge-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gauge-card:hover {
  transform: translateY(-4px);
  border-color: rgba(100, 120, 255, 0.35);
  box-shadow: var(--shadow-glow);
}

.gauge-card.alarm-low {
  border-color: rgba(255, 170, 0, 0.4);
  box-shadow: 0 0 20px rgba(255, 170, 0, 0.12);
  animation: pulse-warn 2s infinite;
}
.gauge-card.alarm-high {
  border-color: rgba(255, 51, 68, 0.5);
  box-shadow: 0 0 20px rgba(255, 51, 68, 0.15);
  animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 170, 0, 0.1); }
  50% { box-shadow: 0 0 25px rgba(255, 170, 0, 0.25); }
}
@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 51, 68, 0.12); }
  50% { box-shadow: 0 0 30px rgba(255, 51, 68, 0.3); }
}

/* ===== NAME PLATE (metal nameplate) ===== */
.gauge-plate {
  position: relative;
  width: 100%;
  height: 34px;
  background: linear-gradient(180deg, #d8d8e0 0%, #a8a8b0 40%, #b8b8c0 60%, #c0c0c8 100%);
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.6),
    inset 0 -1px 0 rgba(0,0,0,0.15);
  border: 1px solid #888;
}

/* screws */
.gauge-plate::before,
.gauge-plate::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e0e0e0, #888 60%, #666);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.5), 0 1px 3px rgba(0,0,0,0.5);
  top: 50%;
  transform: translateY(-50%);
}
.gauge-plate::before { left: 8px; }
.gauge-plate::after  { right: 8px; }

.gauge-plate-text {
  font-family: 'Roboto Condensed', Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #2a2a2a;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 1px 1px 0px rgba(255,255,255,0.6);
}

.gauge-plate-led {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
}
.gauge-plate-led.ok {
  background: #00dd66;
  box-shadow: 0 0 6px #00dd66;
}
.gauge-plate-led.low {
  background: #ffaa00;
  box-shadow: 0 0 6px #ffaa00;
  animation: pulse-alert 1s infinite;
}
.gauge-plate-led.high {
  background: #ff3344;
  box-shadow: 0 0 6px #ff3344;
  animation: pulse-alert 0.5s infinite;
}

@keyframes pulse-alert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== GAUGE FACE (SVG container) ===== */
.gauge-face {
  position: relative;
  width: 100%;
  aspect-ratio: 200 / 165;
  background: radial-gradient(ellipse at 50% 45%, #151530 0%, #0a0a1e 70%, #060612 100%);
  border-radius: 10px;
  border: 2px solid #2a2a40;
  box-shadow:
    inset 0 2px 15px rgba(0,0,0,0.6),
    inset 0 -1px 5px rgba(100,120,255,0.05),
    0 4px 12px rgba(0,0,0,0.4);
  overflow: hidden;
}

/* subtle glass reflection */
.gauge-face::after {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 35%;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 100%);
  border-radius: 0 0 50% 50%;
  pointer-events: none;
  z-index: 2;
}

.gauge-face svg {
  width: 100%;
  height: 100%;
}

/* SVG internal classes */
.gauge-tick { stroke: #444466; stroke-width: 1.5; }
.gauge-tick-text {
  fill: #8888aa;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-anchor: middle;
}
.gauge-needle {
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.gauge-needle-cap {
  fill: #333;
  stroke: #555;
  stroke-width: 1.5;
}
.gauge-value-text {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
}
.gauge-unit-text {
  fill: #6666888;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
}
.gauge-label-low {
  fill: var(--color-warn);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  text-anchor: middle;
}
.gauge-label-high {
  fill: var(--color-danger);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  text-anchor: middle;
}

/* ===== LED DISPLAY (under gauge) ===== */
.gauge-led {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.led-display {
  position: relative;
  display: inline-block;
  background: #000;
  border: 2px solid #1a1a30;
  border-radius: 4px;
  padding: 2px 8px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.4);
}

.led-bg, .led-val {
  font-family: 'DSEG7', monospace;
  font-size: 22px;
  letter-spacing: 1px;
  font-style: italic;
  line-height: 1;
}
.led-bg {
  color: rgba(80, 80, 80, 0.12);
  user-select: none;
}
.led-val {
  position: absolute;
  top: 2px; left: 8px; right: 8px;
  text-align: right;
  color: #00ff66;
  text-shadow: 0 0 10px rgba(0, 255, 102, 0.7);
  transition: color 0.2s, text-shadow 0.2s;
}
.led-val.warn {
  color: #ffaa00;
  text-shadow: 0 0 10px rgba(255, 170, 0, 0.7);
}
.led-val.danger {
  color: #ff3344;
  text-shadow: 0 0 10px rgba(255, 51, 68, 0.7);
}

.led-unit {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 14px;
  color: #999;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ===== DETAIL VIEW ===== */
.detail-back {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent-cyan); cursor: pointer;
  font-size: 13px; font-weight: 600;
  margin-bottom: 20px; padding: 8px 16px;
  background: var(--bg-glass); border: 1px solid var(--border-glass);
  border-radius: 8px; transition: var(--transition);
}
.detail-back:hover { background: rgba(0, 204, 255, 0.1); }

.detail-container {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}

.detail-gauge-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 32px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
}

.detail-gauge-panel .gauge-plate {
  height: 46px;
  margin-bottom: 4px;
}
.detail-gauge-panel .gauge-plate-text {
  font-size: 20px;
  letter-spacing: 3px;
}
.detail-gauge-panel .gauge-plate-led {
  width: 12px; height: 12px;
  right: 36px;
}
.detail-gauge-panel .gauge-face {
  max-width: 420px;
}
.detail-gauge-panel .led-bg,
.detail-gauge-panel .led-val {
  font-size: 32px;
}
.detail-gauge-panel .led-unit {
  font-size: 20px;
}

.detail-info-panel {
  display: flex; flex-direction: column; gap: 16px;
}

.info-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 20px;
}
.info-card h3 {
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
}

.threshold-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.threshold-row:last-child { border-bottom: none; }
.threshold-label { font-size: 13px; color: var(--text-secondary); }
.threshold-value { font-family: 'Orbitron', monospace; font-size: 16px; font-weight: 700; }
.threshold-value.low { color: var(--color-warn); }
.threshold-value.high { color: var(--color-danger); }
.threshold-value.current { color: var(--color-ok); }

/* ===== ALARM LOG ===== */
.alarm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}
.alarm-table th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid var(--border-glass);
}
.alarm-table td {
  padding: 12px 16px; font-size: 13px;
  background: var(--bg-glass);
}
.alarm-table tr td:first-child { border-radius: 8px 0 0 8px; }
.alarm-table tr td:last-child { border-radius: 0 8px 8px 0; }

.alarm-table tr.resolved td { border-left: 3px solid var(--color-ok); }
.alarm-table tr.active-low td { border-left: 3px solid var(--color-warn); }
.alarm-table tr.active-high td { border-left: 3px solid var(--color-danger); }
.alarm-table tr.active-low td { background: rgba(255, 170, 0, 0.06); }
.alarm-table tr.active-high td { background: rgba(255, 51, 68, 0.08); }

/* ===== SETTINGS ===== */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px;
}

.setting-group {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 24px;
}
.setting-group h3 {
  font-size: 13px; font-weight: 700; color: var(--accent-cyan);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-glass);
}

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.setting-label { font-size: 13px; color: var(--text-secondary); }
.setting-value {
  font-family: 'Orbitron', monospace; font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 4px;
  background: #333; border-radius: 2px; outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.toggle {
  width: 44px; height: 24px; border-radius: 12px;
  background: #333; position: relative; cursor: pointer;
  transition: var(--transition);
}
.toggle.on { background: var(--color-ok); }
.toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: var(--transition);
}
.toggle.on::after { left: 22px; }

/* status badges in alarm table */
.gas-status {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 4px;
}
.gas-status.ok { color: var(--color-ok); background: rgba(0,221,102,0.1); }
.gas-status.low { color: var(--color-warn); background: rgba(255,170,0,0.1); }
.gas-status.high { color: var(--color-danger); background: rgba(255,51,68,0.1); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-container { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .topbar-center { display: none; }
}
