/* ══════════════════════════════════════════════
   COND. SPAZIO — Material Design Theme
   ══════════════════════════════════════════════ */

:root {
  /* Material Dark — Slate Blue + Teal accent */
  --primary: #26A69A;
  --primary-light: #4DB6AC;
  --primary-dark: #00897B;
  --primary-rgb: 38,166,154;
  --bg: #121820;
  --bg2: #161e28;
  --surface: #1c2530;
  --surface2: #222d3a;
  --surface3: #283544;
  --border: rgba(255,255,255,.06);
  --txt: #e0e6ed;
  --txt2: #7b8fa3;
  --txt3: #4e6070;
  --green: #66BB6A;
  --red: #EF5350;
  --cyan: #4FC3F7;
  --yellow: #FFD54F;
  --purple: #CE93D8;
  --orange: #FFB74D;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
  --radius: 8px;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif; background: var(--bg); color: var(--txt);
  font-size: 13px; min-height: 100vh; overflow-x: hidden;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); }

/* ══════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100; transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; flex-shrink: 0;
}
.sidebar-brand-text { font-size: 14px; font-weight: 700; color: var(--txt); letter-spacing: -.3px; }
.sidebar-brand-sub { font-size: 9px; color: var(--txt2); font-weight: 400; display: block; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-section { font-size: 9px; font-weight: 700; color: var(--txt3); text-transform: uppercase; letter-spacing: 1px; padding: 12px 12px 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px; color: var(--txt2);
  font-size: 13px; font-weight: 500; transition: all var(--transition);
  text-decoration: none; margin-bottom: 2px;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 14px; }
.sidebar-link:hover { background: rgba(var(--primary-rgb),.08); color: var(--txt); }
.sidebar-link.active {
  background: rgba(var(--primary-rgb),.15); color: var(--primary-light);
}
.sidebar-link.active i { color: var(--primary); }

.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface3); display: flex; align-items: center; justify-content: center;
  color: var(--primary-light); font-size: 14px; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 600; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: var(--txt2); text-transform: capitalize; }
.sidebar-logout {
  color: var(--txt3); font-size: 16px; padding: 4px;
  background: none; border: none; cursor: pointer; transition: color var(--transition);
}
.sidebar-logout:hover { color: var(--red); }

/* Overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 99; opacity: 0; transition: opacity .3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ══════════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 90;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-hamburger {
  display: none; background: none; border: none; color: var(--txt);
  font-size: 20px; cursor: pointer; padding: 4px;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--txt2); font-weight: 500;
}
.topbar-dot { width: 8px; height: 8px; border-radius: 50%; }
.topbar-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(102,187,106,.4); animation: pulse 2s infinite; }
.topbar-dot.off { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.topbar-btn {
  background: none; border: none; color: var(--txt2); font-size: 18px;
  cursor: pointer; padding: 6px; border-radius: 50%;
  transition: all var(--transition);
}
.topbar-btn:hover { background: rgba(var(--primary-rgb),.1); color: var(--primary-light); }

/* ══════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w); padding-top: var(--topbar-h);
  min-height: 100vh;
}
.content { padding: 20px; max-width: 1400px; }

/* ══════════════════════════════════════════════
   STATS ROW
   ══════════════════════════════════════════════ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 14px;
  transition: all var(--transition);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.stat.s1 .stat-icon { background: rgba(79,195,247,.12); color: var(--cyan); }
.stat.s2 .stat-icon { background: rgba(102,187,106,.12); color: var(--green); }
.stat.s3 .stat-icon { background: rgba(255,213,79,.12); color: var(--yellow); }
.stat.s4 .stat-icon { background: rgba(206,147,216,.12); color: var(--purple); }
.stat-info { flex: 1; }
.stat-val { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: 10px; color: var(--txt2); text-transform: uppercase; letter-spacing: .8px; font-weight: 500; margin-top: 2px; }

/* ══════════════════════════════════════════════
   GRID
   ══════════════════════════════════════════════ */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-h {
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-h h3 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-h h3 i { color: var(--primary); font-size: 14px; }
.card-h .badge {
  font-size: 10px; background: rgba(var(--primary-rgb),.12); color: var(--primary-light);
  padding: 3px 10px; border-radius: 12px; font-weight: 600;
}
.card-body { padding: 16px; }

/* ══════════════════════════════════════════════
   TERMINAL
   ══════════════════════════════════════════════ */
.terminal {
  background: #0c1018; border-radius: 6px; padding: 12px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  height: 280px; overflow-y: auto; line-height: 1.7;
}
.terminal.full-height { height: calc(100vh - var(--topbar-h) - 100px); }
.terminal::-webkit-scrollbar { width: 5px; }
.terminal::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
.terminal::-webkit-scrollbar-track { background: transparent; }
.t-line { animation: fadeIn .2s ease; }
.t-time { color: #546e7a; }
.t-ip { color: var(--cyan); }
.t-topic { color: var(--green); }
.t-payload { color: var(--yellow); }
.t-arrow { color: #546e7a; }
.t-ok { color: var(--green); }
.t-err { color: var(--red); }
.t-raw { color: var(--purple); }
@keyframes fadeIn { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:none} }

/* ══════════════════════════════════════════════
   TANK
   ══════════════════════════════════════════════ */
.tank-wrap { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.tank-pct { font-size: 26px; font-weight: 700; color: var(--primary-light); margin-bottom: 6px; }
.tank-outer {
  width: 100%; max-width: 160px; height: 200px; position: relative;
  border: 2px solid var(--surface3); border-radius: 0 0 12px 12px;
  background: var(--bg); overflow: hidden;
}
.tank-cap {
  width: calc(100% + 16px); height: 8px; background: var(--surface3); border-radius: 4px;
  position: absolute; top: -9px; left: -8px;
}
.tank-water {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(var(--primary-rgb),.25) 0%, rgba(var(--primary-rgb),.55) 100%);
  transition: height .8s cubic-bezier(.4,0,.2,1);
  border-radius: 0 0 10px 10px;
}
.tank-water::before {
  content: ''; position: absolute; top: -4px; left: 0; right: 0; height: 8px;
  background: rgba(var(--primary-rgb),.4);
  border-radius: 50%; filter: blur(2px);
}
.tank-levels { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.tank-level {
  position: absolute; left: 0; right: 0; display: flex; align-items: center;
  height: 1px; border-top: 1px dashed rgba(255,255,255,.06);
}
.tank-level-dot {
  width: 9px; height: 9px; border-radius: 50%; margin-left: 8px;
  border: 2px solid var(--surface3); background: var(--bg2);
  transition: all .4s ease; flex-shrink: 0;
}
.tank-level-dot.active {
  background: var(--green); border-color: var(--green);
  box-shadow: 0 0 8px rgba(102,187,106,.5);
}
.tank-level-lbl {
  position: absolute; right: 8px; font-size: 9px; color: var(--txt2); font-weight: 600;
}

/* ══════════════════════════════════════════════
   CONNECTIONS
   ══════════════════════════════════════════════ */
.conn-empty { text-align: center; padding: 20px; color: var(--txt2); font-size: 12px; }
.conn-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12px;
}
.conn-item:last-child { border-bottom: none; }
.conn-addr { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.conn-addr::before { content:''; width:6px; height:6px; border-radius:50%; background:var(--green); }
.conn-dur { color: var(--txt2); font-size: 11px; }

/* ══════════════════════════════════════════════
   TOPIC CARDS
   ══════════════════════════════════════════════ */
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.topic-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; transition: all var(--transition);
}
.topic-card:hover { border-color: rgba(var(--primary-rgb),.2); box-shadow: var(--shadow); }
.topic-name { font-size: 12px; font-weight: 600; color: var(--primary-light); margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.topic-name i { font-size: 10px; }
.topic-meta { font-size: 10px; color: var(--txt2); margin-bottom: 8px; }
.topic-leds { display: flex; gap: 6px; flex-wrap: wrap; }
.led { width: 20px; height: 20px; border-radius: 50%; position: relative; }
.led::before {
  content:''; position:absolute; top:3px; left:4px; width:6px; height:4px;
  border-radius:50%; background:rgba(255,255,255,.2); transform:rotate(-30deg);
}
.led.on { background: radial-gradient(circle at 35% 35%, #81C784, #43A047); box-shadow: 0 0 8px rgba(67,160,71,.5); }
.led.off { background: radial-gradient(circle at 35% 35%, #3a3a3a, #252525); }
.led-idx { font-size: 9px; color: var(--txt2); text-align: center; margin-top: 2px; }

.empty-msg { text-align: center; padding: 30px; color: var(--txt2); font-size: 13px; }
.empty-msg i { font-size: 32px; display: block; margin-bottom: 8px; opacity: .25; }

/* ══════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 16px; text-align: left;
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--txt2); font-weight: 600; border-bottom: 2px solid var(--border);
}
tbody td {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(var(--primary-rgb),.04); }
tbody tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 600; color: var(--txt2);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 12px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--txt); font-family: inherit; transition: all var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15); }
select.form-control { cursor: pointer; }
select.form-control[multiple] { min-height: 80px; }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-hint { font-size: 10px; color: var(--txt3); margin-top: 4px; }

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 12px; font-weight: 600;
  border: none; border-radius: 6px; cursor: pointer;
  text-decoration: none; transition: all var(--transition); font-family: inherit;
  letter-spacing: .2px;
}
.btn i { font-size: 11px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(var(--primary-rgb),.3); }
.btn-success { background: rgba(102,187,106,.12); color: var(--green); border: 1px solid rgba(102,187,106,.2); }
.btn-success:hover { background: rgba(102,187,106,.2); }
.btn-danger { background: rgba(239,83,80,.1); color: var(--red); border: 1px solid rgba(239,83,80,.15); }
.btn-danger:hover { background: rgba(239,83,80,.2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-group { display: flex; gap: 8px; align-items: center; }

/* ══════════════════════════════════════════════
   ALERT
   ══════════════════════════════════════════════ */
.alert {
  padding: 10px 14px; border-radius: 6px; font-size: 12px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.alert-danger { background: rgba(239,83,80,.1); color: var(--red); border: 1px solid rgba(239,83,80,.15); }
.alert-success { background: rgba(102,187,106,.1); color: var(--green); border: 1px solid rgba(102,187,106,.15); }

/* ══════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════ */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, var(--bg) 0%, #1a2535 100%);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; margin-bottom: 12px;
}
.login-logo h2 { font-size: 18px; font-weight: 700; }
.login-logo p { font-size: 12px; color: var(--txt2); margin-top: 4px; }

/* ══════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.page-header h2 i { color: var(--primary); }

/* ══════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════ */
.role { font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.role-admin { background: rgba(206,147,216,.15); color: var(--purple); }
.role-operador { background: rgba(255,213,79,.15); color: var(--yellow); }
.role-viewer { background: rgba(79,195,247,.15); color: var(--cyan); }

.dtype { font-size: 10px; padding: 2px 8px; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.dtype-tank { background: rgba(var(--primary-rgb),.12); color: var(--primary-light); }
.dtype-sensor { background: rgba(102,187,106,.12); color: var(--green); }
.dtype-switch { background: rgba(255,213,79,.12); color: var(--yellow); }
.dtype-generic { background: rgba(255,255,255,.06); color: var(--txt2); }
.dtype-gauge { background: rgba(255,183,77,.12); color: var(--orange); }
.dtype-chart { background: rgba(206,147,216,.12); color: var(--purple); }
.dtype-cylinder { background: rgba(38,166,154,.12); color: var(--primary); }
.dtype-speedometer { background: rgba(255,183,77,.12); color: var(--orange); }

/* ══════════════════════════════════════════════
   DEVICES GRID
   ══════════════════════════════════════════════ */
.devices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.device-card { position: relative; min-height: 340px; display: flex; flex-direction: column; }
.device-card .card-body { flex: 1; display: flex; flex-direction: column; padding-bottom: 48px; position: relative; }
.device-card .dev-last-seen {
  position: absolute; bottom: 0; left: 0; right: 0;
  margin-top: 0; padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.device-card.card-chart { grid-column: span 2; min-height: 340px; }

.device-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
}
.device-status.online { background: rgba(102,187,106,.12); color: var(--green); }
.device-status.offline { background: rgba(239,83,80,.12); color: var(--red); }
.device-status-dot { width: 6px; height: 6px; border-radius: 50%; }
.device-status.online .device-status-dot { background: var(--green); }
.device-status.offline .device-status-dot { background: var(--red); }

/* ══════════════════════════════════════════════
   CONNECTION TYPE BADGE
   ══════════════════════════════════════════════ */
.conn-type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
  letter-spacing: .3px;
}
.conn-type-badge i { font-size: 9px; }
.conn-eth { background: rgba(79,195,247,.12); color: var(--cyan); }
.conn-4g { background: rgba(255,183,77,.12); color: var(--orange); }
.conn-unknown { background: rgba(255,255,255,.06); color: var(--txt3); }

/* ══════════════════════════════════════════════
   LAST SEEN ROW
   ══════════════════════════════════════════════ */
.dev-last-seen {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11px; color: #ffffff;
}
.dev-last-seen i { font-size: 11px; color: #ffffff; }

/* ══════════════════════════════════════════════
   CONFIG BUTTON
   ══════════════════════════════════════════════ */
.dev-config-btn {
  background: none; border: none; color: var(--txt3);
  font-size: 14px; cursor: pointer; padding: 4px;
  border-radius: 50%; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
}
.dev-config-btn:hover { background: rgba(var(--primary-rgb),.1); color: var(--primary-light); }

/* ══════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); animation: modalIn .2s ease;
}
@keyframes modalIn { from{opacity:0;transform:scale(.95)} to{opacity:1;transform:none} }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--primary); }
.modal-close {
  background: none; border: none; color: var(--txt3);
  font-size: 16px; cursor: pointer; padding: 4px;
  border-radius: 50%; transition: all var(--transition);
}
.modal-close:hover { background: rgba(239,83,80,.1); color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ══════════════════════════════════════════════
   GAUGE (VELOCÍMETRO)
   ══════════════════════════════════════════════ */
.gauge-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 8px 8px 0;
}
.gauge-canvas-container {
  display: flex; justify-content: center; align-items: center;
  width: 100%; max-width: 240px;
}
.gauge-canvas-container canvas { display: block; }
.gauge-minmax {
  display: flex; justify-content: space-between; width: 100%;
  font-size: 10px; color: var(--txt2);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px; padding: 0 8px;
}
.gauge-minmax span { display: flex; align-items: center; gap: 4px; }
.gauge-minmax i { font-size: 9px; }
.gauge-minmax span:first-child i { color: #4FC3F7; }
.gauge-minmax span:last-child i { color: #EF5350; }

/* ══════════════════════════════════════════════
   SPEEDOMETER (FusionCharts angulargauge)
   ══════════════════════════════════════════════ */
.speedometer-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 4px 0 0;
}
.speedo-fc-container { width: 100%; min-height: 220px; }
.speedo-minmax {
  display: flex; justify-content: space-between; width: 100%;
  font-size: 10px; color: var(--txt2);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px; padding: 0 8px;
}
.speedo-minmax span { display: flex; align-items: center; gap: 4px; }
.speedo-minmax i { font-size: 9px; }
.speedo-minmax span:first-child i { color: #4FC3F7; }
.speedo-minmax span:last-child i { color: #EF5350; }

/* ══════════════════════════════════════════════
   CYLINDER (FusionCharts)
   ══════════════════════════════════════════════ */
.cylinder-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 0; flex: 1; width: 100%;
}
.cylinder-fc-container { width: 100%; min-height: 300px; max-width: 320px; }
/* Esconder watermark FusionCharts */
a[href*="fusioncharts.com"],
.fc__credit,
[class*="fusioncharts-credit"],
[class*="fc-watermark"],
[class*="trial"] {
  display: none !important; visibility: hidden !important;
  height: 0 !important; width: 0 !important; overflow: hidden !important;
  position: absolute !important; pointer-events: none !important;
  opacity: 0 !important; font-size: 0 !important; line-height: 0 !important;
}

/* ══════════════════════════════════════════════
   CHART (GRÁFICO DE LINHA)
   ══════════════════════════════════════════════ */
.chart-wrap {
  display: flex; flex-direction: column;
  padding: 8px; position: relative;
}
.chart-canvas-box {
  position: relative; width: 100%; height: 220px;
}
.chart-canvas-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.chart-link-info {
  font-size: 10px; color: var(--txt2); text-align: center; margin-bottom: 4px;
}
.chart-link-info i { color: var(--primary); margin-right: 4px; }

/* ══════════════════════════════════════════════
   SENSOR TEMPERATURA
   ══════════════════════════════════════════════ */
.temp-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 16px 8px;
}
.temp-value {
  font-size: 36px; font-weight: 700; letter-spacing: -1px;
  font-family: 'JetBrains Mono', monospace;
  color: #66BB6A; transition: color .4s ease;
}
.temp-bar-container {
  display: flex; align-items: center; gap: 8px; width: 100%;
}
.temp-bar-label {
  font-size: 10px; font-weight: 600; color: var(--txt2);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap; min-width: 36px;
}
.temp-bar-min { text-align: right; }
.temp-bar-max { text-align: left; }
.temp-bar {
  flex: 1; height: 14px; border-radius: 7px; position: relative;
  background: var(--surface2); overflow: visible;
}
.temp-bar-fill {
  height: 100%; border-radius: 7px; transition: width .5s ease;
  background: linear-gradient(90deg, #4FC3F7 0%, #66BB6A 35%, #FFA726 65%, #EF5350 100%);
}
.temp-bar-marker {
  position: absolute; top: 50%; width: 4px; height: 22px;
  background: #ffffff; border-radius: 2px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(255,255,255,.5);
  transition: left .5s ease;
}
.temp-minmax {
  display: flex; justify-content: space-between; width: 100%;
  font-size: 10px; color: var(--txt2);
  font-family: 'JetBrains Mono', monospace;
}
.temp-minmax span { display: flex; align-items: center; gap: 4px; }
.temp-minmax i { font-size: 9px; }
.temp-minmax span:first-child i { color: #4FC3F7; }
.temp-minmax span:last-child i { color: #EF5350; }

/* ══════════════════════════════════════════════
   ALERTS & CONTACTS
   ══════════════════════════════════════════════ */
.alert-cond {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 4px;
}
.alert-cond i { font-size: 10px; }
.alert-cond-below { background: rgba(79,195,247,.12); color: var(--cyan); }
.alert-cond-above { background: rgba(239,83,80,.12); color: var(--red); }
.alert-cond-equal { background: rgba(255,213,79,.12); color: var(--yellow); }

.alert-fired {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
  background: rgba(239,83,80,.15); color: var(--red);
  margin-left: 6px; animation: pulse 2s infinite;
}

.alert-status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
}
.alert-active { background: rgba(102,187,106,.12); color: var(--green); }
.alert-inactive { background: rgba(255,255,255,.06); color: var(--txt3); }

.contact-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 500; padding: 2px 8px; border-radius: 4px;
  background: rgba(37,211,102,.1); color: #25D366;
  margin: 1px 2px;
}
.contact-badge i { font-size: 12px; }

/* ══════════════════════════════════════════════
   TEMA CLARO
   ══════════════════════════════════════════════ */
body.theme-light {
  --bg: #f5f5f5;
  --bg2: #eeeeee;
  --surface: #ffffff;
  --surface2: #fafafa;
  --surface3: #e0e0e0;
  --border: rgba(0,0,0,.08);
  --txt: #212121;
  --txt2: #757575;
  --txt3: #9e9e9e;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
}
body.theme-light .sidebar { background: #fff; border-right-color: rgba(0,0,0,.08); }
body.theme-light .topbar { background: #fff; border-bottom-color: rgba(0,0,0,.08); }
body.theme-light .terminal { background: #1e1e2e; color: #cdd6f4; }
body.theme-light .tank-outer { border-color: #bdbdbd; background: #f5f5f5; }
body.theme-light .tank-cap { background: #bdbdbd; }
body.theme-light .tank-level-dot { border-color: #bdbdbd; background: #e0e0e0; }
body.theme-light .tank-level { border-top-color: rgba(0,0,0,.06); }
body.theme-light .led.off { background: radial-gradient(circle at 35% 35%, #d0d0d0, #b0b0b0); }
body.theme-light .login-wrap { background: linear-gradient(135deg, #f5f5f5, #e8e8e8); }
body.theme-light .sidebar-overlay { background: rgba(0,0,0,.3); }

/* ══════════════════════════════════════════════
   RESPONSIVIDADE
   ══════════════════════════════════════════════ */

/* Tablet & Mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .topbar { left: 0; }
  .topbar-hamburger { display: block; }
  .main { margin-left: 0; }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .devices-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .device-card.card-chart { grid-column: span 1; }
  .page-header { flex-wrap: wrap; gap: 8px; }
  .terminal.full-height { height: calc(100vh - var(--topbar-h) - 120px); }
}

@media (max-width: 480px) {
  .content { padding: 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 14px; }
  .stat-val { font-size: 18px; }
  .stat-lbl { font-size: 9px; }
  .devices-grid { grid-template-columns: 1fr; }
  .card-h { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
  .card-body { padding: 12px; }
  .tank-outer { max-width: 140px; height: 180px; }
  .tank-pct { font-size: 22px; }
  .terminal { font-size: 10px; padding: 8px; }
  .terminal.full-height { height: calc(100vh - var(--topbar-h) - 140px); }
  .t-line { word-break: break-all; }
  table { font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 9px; }
  tbody td { padding: 8px 10px; }
  .form-control { padding: 8px 10px; font-size: 12px; }
  .btn { padding: 7px 12px; font-size: 11px; }
  .btn-sm { padding: 4px 8px; font-size: 10px; }
  .login-box { padding: 24px 20px; }
  .page-header h2 { font-size: 15px; }
  .conn-item { padding: 8px 12px; font-size: 11px; }
  .topics-grid { grid-template-columns: 1fr; }
}
