/* ═══════════════════════════════════════════════════════════
   HVAC Monitor — Industrial Dark UI
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Barlow:wght@300;400;500;600;700&family=Barlow+Condensed:wght@400;600;700&display=swap');

:root {
  --bg:           #0d0f14;
  --bg2:          #141820;
  --bg3:          #1c2030;
  --surface:      #1e2433;
  --border:       #2a3045;
  --border2:      #3a4560;
  --text:         #c8d0e0;
  --text-muted:   #5a6480;
  --text-dim:     #8090b0;
  --accent:       #00c8ff;
  --accent2:      #0090cc;
  --green:        #00e090;
  --yellow:       #ffb800;
  --orange:       #ff7c30;
  --red:          #ff3c50;
  --red-dim:      #3a1520;
  --yellow-dim:   #2a2000;
  --green-dim:    #00200f;
  --blue-dim:     #001830;
  --mono:         'Share Tech Mono', monospace;
  --sans:         'Barlow', sans-serif;
  --condensed:    'Barlow Condensed', sans-serif;
  --radius:       3px;
  --radius-lg:    6px;
  --transition:   0.15s ease;
}

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

.hvac-wrap {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.hvac-topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
}

.hvac-logo {
  font-family: var(--condensed);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  margin-right: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hvac-nav { display: flex; height: 100%; }

.hvac-nav-item {
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-family: var(--condensed);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  user-select: none;
}
.hvac-nav-item:hover { color: var(--text); }
.hvac-nav-item.active { color: var(--accent); border-bottom-color: var(--accent); }

.hvac-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hvac-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green { 0%,100%{opacity:1} 50%{opacity:0.5} }

.hvac-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Content ─────────────────────────────────────────────── */
.hvac-content { padding: 24px; }
.hvac-view { display: none; }
.hvac-view.active { display: block; }

/* ── Section Header ──────────────────────────────────────── */
.hvac-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.hvac-section-title {
  font-family: var(--condensed);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.hvac-section-title span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-left: 10px;
}

/* ── Stats Bar ───────────────────────────────────────────── */
.hvac-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.hvac-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}
.hvac-stat-card::before {
  content:'';
  position: absolute;
  top:0; left:0;
  width: 3px; height: 100%;
  background: var(--accent);
}
.hvac-stat-card.has-alert::before { background: var(--red); }

.hvac-stat-label {
  font-family: var(--condensed);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.hvac-stat-value {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--text);
  line-height: 1;
}
.hvac-stat-card.has-alert .hvac-stat-value { color: var(--red); }

/* ── Monitor Grid ────────────────────────────────────────── */
.hvac-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.hvac-system-card {
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.hvac-system-card:hover { border-color: var(--border2); }
.hvac-system-card.status-alert   { border-color: rgba(255,60,80,0.5); }
.hvac-system-card.status-warning { border-color: rgba(255,184,0,0.4); }

.status-stripe { height: 3px; width: 100%; background: var(--border); }
.status-alert   .status-stripe { background: var(--red); }
.status-warning .status-stripe { background: var(--yellow); }
.status-normal  .status-stripe { background: var(--green); }
.status-idle    .status-stripe { background: var(--text-muted); }

.hvac-system-card-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hvac-system-name {
  font-family: var(--condensed);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.hvac-system-location { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.hvac-badge-group { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.hvac-badge {
  font-family: var(--condensed);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius);
}
.hvac-badge.normal  { background: var(--green-dim);  color: var(--green);  border: 1px solid var(--green); }
.hvac-badge.warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid var(--yellow); }
.hvac-badge.alert   { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red); }
.hvac-badge.idle    { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.hvac-badge.calling { background: var(--blue-dim); color: var(--accent); border: 1px solid var(--accent2); animation: calling-blink 1.5s infinite; }
@keyframes calling-blink { 0%,100%{opacity:1} 50%{opacity:0.6} }

.hvac-system-card-body { padding: 14px 16px; }

.hvac-temp-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.hvac-temp-block {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}
.hvac-temp-label {
  font-family: var(--condensed);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.hvac-temp-value {
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1;
}
.hvac-temp-unit { font-size: 11px; color: var(--text-muted); vertical-align: super; }
.hvac-temp-block.delta .hvac-temp-value { color: var(--accent); }
.hvac-temp-block.delta-warn .hvac-temp-value { color: var(--yellow); }
.hvac-temp-block.delta-alert .hvac-temp-value { color: var(--red); }

.hvac-health-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hvac-health-bar-track { flex:1; height:4px; background: var(--bg3); border-radius:2px; overflow:hidden; }
.hvac-health-bar-fill { height:100%; border-radius:2px; transition: width 0.4s ease; }
.score-high .hvac-health-bar-fill { background: var(--green); }
.score-mid  .hvac-health-bar-fill { background: var(--yellow); }
.score-low  .hvac-health-bar-fill { background: var(--red); }
.hvac-health-score { font-family: var(--mono); font-size:12px; color: var(--text-dim); white-space:nowrap; }

.hvac-message { font-size:11px; color: var(--text-muted); line-height:1.4; min-height:28px; }

.hvac-system-card-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hvac-last-update { font-family: var(--mono); font-size:10px; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────── */
.hvac-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--condensed);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.hvac-btn-primary { background: var(--accent); color:#000; }
.hvac-btn-primary:hover { background: #22d8ff; }
.hvac-btn-secondary { background: var(--bg3); color: var(--text-dim); border:1px solid var(--border2); }
.hvac-btn-secondary:hover { color: var(--text); border-color: var(--text-dim); }
.hvac-btn-danger { background: var(--red-dim); color: var(--red); border:1px solid var(--red); }
.hvac-btn-danger:hover { background: var(--red); color:#fff; }
.hvac-btn-sm { padding: 4px 10px; font-size:10px; }
.hvac-btn-icon {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
  line-height: 1.5;
}
.hvac-btn-icon:hover { color: var(--text); border-color: var(--text-dim); }

/* ── Tables ──────────────────────────────────────────────── */
.hvac-table-wrap { border:1px solid var(--border); overflow:hidden; }
.hvac-table { width:100%; border-collapse:collapse; font-size:13px; }
.hvac-table thead th {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-family: var(--condensed);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.hvac-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.hvac-table tbody tr:last-child td { border-bottom: none; }
.hvac-table tbody tr:hover td { background: var(--bg3); }
.hvac-table .actions { display:flex; gap:6px; }

/* ── Modal ───────────────────────────────────────────────── */
.hvac-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.hvac-modal-overlay.open { display:flex; }
.hvac-modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.hvac-modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hvac-modal-title {
  font-family: var(--condensed);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hvac-modal-close { background:transparent; border:none; color:var(--text-muted); font-size:22px; cursor:pointer; line-height:1; }
.hvac-modal-close:hover { color: var(--text); }
.hvac-modal-body { padding: 20px; }
.hvac-modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; }

/* ── Form Fields ─────────────────────────────────────────── */
.hvac-field { margin-bottom: 14px; }
.hvac-label {
  display: block;
  font-family: var(--condensed);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.hvac-input, .hvac-select, .hvac-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 13px;
  border-radius: var(--radius);
  transition: border-color var(--transition);
  outline: none;
}
.hvac-input:focus, .hvac-select:focus, .hvac-textarea:focus { border-color: var(--accent); }
.hvac-textarea { min-height: 80px; resize: vertical; }
.hvac-select option { background: var(--bg2); }

/* ── Alert Bar ───────────────────────────────────────────── */
.hvac-alert-bar {
  padding: 10px 16px;
  margin-bottom: 16px;
  border-left: 3px solid var(--yellow);
  background: var(--yellow-dim);
  font-size: 12px;
  color: var(--yellow);
  display: none;
}
.hvac-alert-bar.visible { display: block; }
.hvac-alert-bar.error   { border-color: var(--red); background: var(--red-dim); color: var(--red); }
.hvac-alert-bar.success { border-color: var(--green); background: var(--green-dim); color: var(--green); }

/* ── Misc ────────────────────────────────────────────────── */
.hvac-loading { display:flex; align-items:center; justify-content:center; padding:40px; color:var(--text-muted); font-family:var(--mono); font-size:12px; gap:10px; }
.hvac-spinner { width:16px; height:16px; border:2px solid var(--border2); border-top-color:var(--accent); border-radius:50%; animation:spin 0.6s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.hvac-empty { text-align:center; padding:48px 24px; color:var(--text-muted); }
.hvac-empty-icon { font-size:40px; margin-bottom:12px; opacity:0.4; }
.hvac-empty-title { font-family:var(--condensed); font-size:16px; font-weight:600; text-transform:uppercase; letter-spacing:0.1em; margin-bottom:6px; color:var(--text-dim); }

.hvac-login-required { padding:40px; text-align:center; background:var(--surface); border:1px solid var(--border); color:var(--text-muted); }
.hvac-login-required a { color:var(--accent); }

.hvac-chart-wrap { background:var(--surface); border:1px solid var(--border); padding:16px; margin-top:16px; }
.hvac-chart-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.hvac-chart-title { font-family:var(--condensed); font-size:12px; font-weight:600; letter-spacing:0.1em; text-transform:uppercase; color:var(--text-muted); }
canvas.hvac-chart { max-height:200px; }

.hvac-input-panel { background:var(--bg3); border:1px solid var(--border); padding:14px 16px; margin-top:12px; display:none; }
.hvac-input-panel.open { display:block; }
.hvac-inline-form { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.hvac-inline-form .hvac-field { margin-bottom:0; min-width:130px; flex:1; }

.mono { font-family: var(--mono); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }

@media (max-width: 768px) {
  .hvac-stats-bar { grid-template-columns: repeat(2,1fr); }
  .hvac-monitor-grid { grid-template-columns: 1fr; }
  .hvac-topbar { padding: 0 12px; }
  .hvac-content { padding: 16px; }
  .hvac-nav-item { padding: 0 10px; font-size:11px; }
}

/* ── Chart Collapse ──────────────────────────────────────── */
.hvac-chart-collapse {
  display: none;
  animation: slideDown 0.2s ease;
}
.hvac-chart-collapse.open { display: block; }
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

/* ── Notification Log ────────────────────────────────────── */
.hvac-notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
  display: none;
}
.hvac-notif-badge:not(:empty) { display: inline-flex; }
.hvac-notif-badge.flash { animation: badge-flash 0.4s ease; }
@keyframes badge-flash { 0%,100%{transform:scale(1)} 50%{transform:scale(1.4)} }

.hvac-notif-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}
.hvac-notif-row:last-child { border-bottom: none; }
.hvac-notif-row.alert   { background: rgba(58,21,32,0.3); }
.hvac-notif-row.warning { background: rgba(42,32,0,0.3); }

.hvac-notif-time   { color: var(--text-muted); min-width: 56px; }
.hvac-notif-system { font-weight: 600; color: var(--text); }
.hvac-notif-msg    { color: var(--text-muted); flex: 1; }
.hvac-notif-delta  { color: var(--text-dim); }
