/* HeatSync v2 — dashboard shell (mockup-aligned) */
:root {
  --hs-green: #7FD11B;
  --hs-navy: #1E3A8A;
  --hs-grey: #5A5A5A;
  --sidebar-bg: #0c1a3a;
  --sidebar-w: 220px;
  --page-bg: #eef1f6;
  --card-bg: #ffffff;
  --card-radius: 10px;
  --card-shadow: 0 1px 4px rgba(12, 26, 58, 0.08);
  --text: #0c1a3a;
  --text-muted: #6b7a99;
  --border: #e2e8f0;
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
  --accent-purple: #8b5cf6;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--page-bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Layout */
.hs-app {
  display: flex;
  min-height: 100vh;
}

.hs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #c8d4e8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.hs-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Sidebar brand */
.hs-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.hs-brand-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.hs-brand img, .hs-brand svg { width: 36px; height: 36px; flex-shrink: 0; }

.hs-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.hs-brand-tagline {
  font-size: 0.68rem;
  color: #8fa3c4;
  margin-top: 0.15rem;
  line-height: 1.3;
}

/* Nav */
.hs-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.hs-nav-group {
  margin-bottom: 0.5rem;
}

.hs-nav-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #5a6f94;
  padding: 0.5rem 1rem 0.35rem;
  text-transform: uppercase;
}

.hs-nav a {
  display: block;
  padding: 0.55rem 1rem 0.55rem 1.15rem;
  font-size: 0.82rem;
  color: #a8b8d4;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.hs-nav a:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}

.hs-nav a.active {
  background: rgba(59, 130, 246, 0.12);
  color: #fff;
  border-left-color: var(--accent-blue);
  font-weight: 600;
}

.hs-user {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.78rem;
}

.hs-user-name { color: #fff; font-weight: 600; }
.hs-user-org { color: #6b84a8; margin-top: 0.15rem; font-size: 0.72rem; }

/* Header */
.hs-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hs-header-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.hs-header-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}

.hs-header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hs-live {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hs-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-blue);
  animation: hs-pulse 2s infinite;
}

@keyframes hs-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hs-building-badge {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
}

.hs-building-badge strong { color: var(--text); }
.hs-building-badge span { color: var(--text-muted); display: block; font-size: 0.68rem; margin-top: 0.1rem; }

.hs-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Content */
.hs-content {
  padding: 1.25rem 1.5rem 2rem;
  flex: 1;
}

/* Cards */
.hs-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 1rem 1.15rem;
}

.hs-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hs-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.hs-card-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0;
}

.hs-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #eff6ff;
  color: var(--accent-blue);
  white-space: nowrap;
}

/* KPI row */
.hs-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hs-kpi {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent-blue);
  position: relative;
  overflow: hidden;
}

.hs-kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-blue), var(--accent-red));
}

.hs-kpi-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hs-kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.25rem 0 0.1rem;
  color: var(--text);
}

.hs-kpi-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.hs-kpi-value.danger { color: var(--accent-red); }

/* Grid layouts */
.hs-grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hs-grid-1-1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hs-grid-2-1-b {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
}

.hs-stack { display: flex; flex-direction: column; gap: 1rem; }

/* Chart containers */
.hs-chart-wrap {
  position: relative;
  height: 220px;
}

.hs-chart-wrap.sm { height: 160px; }
.hs-chart-wrap.lg { height: 260px; min-height: 260px; }

.hs-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Zone bars (comfort / efficiency) */
.hs-zone-bars { display: flex; flex-direction: column; gap: 0.55rem; }

.hs-zone-row {
  display: grid;
  grid-template-columns: 1fr 2.5fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}

.hs-zone-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hs-zone-track {
  height: 8px;
  background: #e8edf4;
  border-radius: 4px;
  overflow: hidden;
}

.hs-zone-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-blue), #a855f7);
  transition: width 0.4s ease;
}

.hs-zone-val {
  font-weight: 700;
  font-size: 0.78rem;
  min-width: 2.5rem;
  text-align: right;
}

/* Actions list */
.hs-actions { display: flex; flex-direction: column; gap: 0.65rem; }

.hs-action {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.45;
}

.hs-action-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.hs-action-icon.blue { background: #dbeafe; color: var(--accent-blue); }
.hs-action-icon.red { background: #fee2e2; color: var(--accent-red); }

/* Data table */
.hs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.hs-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.hs-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
}

.hs-table tr:last-child td { border-bottom: none; }

.hs-table .co2-high { color: var(--accent-red); font-weight: 600; }

.hs-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #eff6ff;
  color: var(--accent-blue);
}

/* Alert list */
.hs-alert-list { display: flex; flex-direction: column; gap: 0.5rem; }

.hs-alert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
}

.hs-alert-badge {
  min-width: 36px;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
}

.hs-alert-badge.high { background: #fee2e2; color: var(--accent-red); }
.hs-alert-badge.med { background: #fce7f3; color: #db2777; }
.hs-alert-badge.warn { background: #fef3c7; color: #d97706; }

.hs-alert-title { font-weight: 600; color: var(--text); }
.hs-alert-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.15rem; }

/* KPI accent variants */
.hs-kpi.accent-red::before { background: var(--accent-red); }
.hs-kpi.accent-green::before { background: var(--accent-green); }
.hs-kpi.accent-purple::before { background: var(--accent-purple); }

/* Placeholder / coming soon */
.hs-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.hs-placeholder h3 { margin: 0 0 0.5rem; color: var(--text); }

/* Loading */
.hs-loading {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 1100px) {
  .hs-grid-2-1, .hs-grid-2-1-b, .hs-grid-1-1 {
    grid-template-columns: 1fr;
  }
}

/* Header controls */
.hs-header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.hs-control {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hs-control-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.hs-select {
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 160px;
}

/* Toolbar & buttons */
.hs-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.hs-btn {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  background: var(--hs-navy);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.hs-btn:hover { background: var(--accent-blue); color: #fff; }

.hs-btn-outline {
  background: #fff;
  color: var(--hs-navy);
  border: 1px solid var(--border);
}

.hs-btn-outline:hover {
  background: #f8fafc;
  color: var(--hs-navy);
}

/* Floor plan */
.hs-floorplan-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.hs-floorplan-svg { width: 100%; max-width: 300px; height: auto; }

.hs-floor-label {
  font-size: 9px;
  fill: var(--text-muted);
  font-weight: 600;
}

.hs-floor-zone {
  font-size: 8px;
  fill: var(--text);
  font-weight: 600;
}

.hs-floor-val {
  font-size: 9px;
  fill: var(--text-muted);
}

/* Timeline */
.hs-timeline { display: flex; flex-direction: column; gap: 0.65rem; }

.hs-timeline-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.78rem;
}

.hs-timeline-bar {
  width: 4px;
  min-height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.hs-table-scroll { overflow-x: auto; }

/* DataTable */
.hs-dt { display: flex; flex-direction: column; gap: 0.65rem; }

.hs-dt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hs-dt-search-wrap {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}

.hs-dt-search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.hs-dt-search {
  width: 100%;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.45rem 0.65rem 0.45rem 1.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.hs-dt-search:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.hs-dt-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.hs-btn-sm {
  font-size: 0.72rem;
  padding: 0.35rem 0.65rem;
}

.hs-dt-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.hs-dt-table-wrap { margin: 0 -0.25rem; }

.hs-dt-table tbody tr.hs-dt-row-click { cursor: pointer; }
.hs-dt-table tbody tr.hs-dt-row-click:hover td { background: #f8fafc; }
.hs-dt-table tbody tr.hs-dt-row-selected td {
  background: #eff6ff;
}
.hs-dt-table tbody tr.hs-dt-row-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.hs-dt-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem !important;
}

.hs-dt-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

.hs-dt-nav {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--hs-navy);
  cursor: pointer;
}

.hs-dt-nav:hover:not(:disabled) { background: #f8fafc; }
.hs-dt-nav:disabled { opacity: 0.45; cursor: not-allowed; }

.hs-dt-pages { display: flex; gap: 0.25rem; flex-wrap: wrap; }

.hs-dt-page {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 1.85rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--hs-navy);
  cursor: pointer;
}

.hs-dt-page:hover { background: #f8fafc; }
.hs-dt-page.is-active {
  background: var(--hs-navy);
  border-color: var(--hs-navy);
  color: #fff;
}

.hs-error-banner {
  border-left: 3px solid var(--accent-red);
  margin-bottom: 1rem;
  background: #fef2f2;
}
.hs-error-banner strong { color: var(--accent-red); display: block; margin-bottom: 0.35rem; }
.hs-error-banner p { margin: 0.35rem 0; font-size: 0.82rem; }
.hs-error-banner a { color: var(--accent-blue); text-decoration: underline; }

@media (max-width: 1100px) {
  .hs-header { flex-direction: column; }
}

@media (max-width: 768px) {
  .hs-sidebar { width: 100%; position: relative; }
  .hs-main { margin-left: 0; }
  .hs-app { flex-direction: column; }
}

/* Map page (Limerick pilot) */
.hs-body-map .hs-content {
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hs-body-map .hs-main {
  min-height: 100vh;
}

.hs-map-page {
  position: relative;
  flex: 1;
  min-height: calc(100vh - 88px);
}

.hs-map-canvas {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 88px);
  background: var(--page-bg);
  z-index: 1;
}

.hs-map-brand {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--hs-navy);
  color: #fff;
  padding: 0.55rem 1rem 0.55rem 0.65rem;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(12, 26, 58, 0.28);
  border-left: 4px solid var(--hs-green);
  transition: transform 0.15s, box-shadow 0.15s;
}

.hs-map-brand:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(12, 26, 58, 0.32);
}

.hs-map-brand img {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.hs-map-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}

.hs-map-brand-sub {
  font-size: 0.68rem;
  color: #a8c4e8;
  margin-top: 0.1rem;
}

.hs-map-legend {
  position: absolute;
  bottom: 1.25rem;
  left: 1rem;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: var(--card-shadow);
  min-width: 160px;
}

.hs-map-legend-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hs-navy);
  margin-bottom: 0.5rem;
}

.hs-map-legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
  color: var(--text);
}

.hs-map-legend-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}

.hs-map-legend-foot {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.hs-map-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--hs-navy);
}

.hs-map-dot-res { background: var(--hs-green); }
.hs-map-dot-apt { background: var(--accent-blue); }
.hs-map-dot-comm { background: var(--accent-purple); }
.hs-map-dot-pub { background: var(--accent-red); }

.hs-map-marker {
  background: transparent;
  border: none;
}

.hs-map-marker span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--hs-navy);
  box-shadow: 0 0 0 3px rgba(127, 209, 27, 0.25);
}

.hs-map-marker-res span { background: var(--hs-green); }
.hs-map-marker-apt span { background: var(--accent-blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
.hs-map-marker-comm span { background: var(--accent-purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
.hs-map-marker-pub span { background: var(--accent-red); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  border-top: 3px solid var(--hs-green);
  box-shadow: 0 4px 16px rgba(12, 26, 58, 0.15);
}

.leaflet-popup-content {
  margin: 0.75rem 1rem;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.45;
}

.hs-map-popup strong {
  display: block;
  color: var(--hs-navy);
  font-size: 0.9rem;
}

.hs-map-popup-id {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  margin-top: 0.15rem;
}

.hs-map-popup p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.hs-map-popup a {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--hs-navy);
  font-weight: 600;
  font-size: 0.78rem;
}

.hs-map-popup a:hover {
  color: var(--hs-green);
}

.leaflet-control-zoom a {
  color: var(--hs-navy) !important;
}

.leaflet-control-attribution {
  font-size: 0.65rem !important;
  background: rgba(255, 255, 255, 0.85) !important;
  color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
  color: var(--hs-navy) !important;
}

@media (max-width: 768px) {
  .hs-map-page,
  .hs-map-canvas {
    min-height: 420px;
  }

  .hs-map-legend {
    right: 1rem;
    left: auto;
    bottom: 4.5rem;
    max-width: 150px;
  }
}
