/* Generic dot Business Ltd. + subtle AWS-inspired parity + macOS 26 radii */
:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ec7211;
  --accent-dim: rgba(236, 114, 17, 0.15);
  --border: #334155;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(236, 114, 17, 0.04), transparent);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: clamp(0.5rem, 2vw, 1rem);
  gap: clamp(0.5rem, 2vh, 0.75rem);
}

@media (max-width: 768px) {
  body {
    overflow-y: auto;
  }
}

@media (min-width: 769px) {
  body {
    height: 100vh;
    overflow: hidden;
  }

  .layout {
    height: 100%;
    max-width: 100%;
    min-height: 0;
  }
}

/* Main content - scrollable area so KPIs + charts always visible */
.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 2vh, 0.75rem);
}

/* Header - logo left, tagline centered, solar meter, menu right */
.header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  flex-shrink: 0;
  padding: 0.25rem 0;
  gap: 0.5rem;
  max-height: 5.5rem;
  min-height: 4.25rem;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-align: center;
}

.logo-badge {
  background: linear-gradient(145deg, #fff7ed 0%, #ffedd5 100%);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid rgba(236, 114, 17, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.region-pill {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  opacity: 0.8;
  letter-spacing: 0.03em;
}

.region-pill::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 0.3rem;
  background: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
}

.ehws-logo {
  display: block;
  height: clamp(3.25rem, 5.5vw, 4.5rem);
  width: auto;
  object-fit: contain;
  vertical-align: middle;
}

.tagline {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tagline .at {
  color: var(--accent);
}

/* Solar meter: Powered X% by Y kW renewable solar */
.header-solar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-solar .solar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

@keyframes solar-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.9; }
}

.header-solar.solar-pulsing .solar-icon {
  animation: solar-pulse 1.8s ease-in-out infinite;
}

.header-solar.solar-hidden {
  display: none;
}

.header-solar .solar-text {
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.header-solar .solar-pct {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}

.header-solar .solar-kw {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}

@media (max-width: 900px) {
  .header-solar .solar-text {
    font-size: 0.72rem;
  }
}

@media (max-width: 768px) {
  .header-solar {
    padding: 0.28rem 0.45rem;
    font-size: 0.68rem;
  }

  .header-solar .solar-text {
    font-size: 0.65rem;
  }
}

.menu-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.menu-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--text-muted);
}

.menu-icon {
  display: block;
  width: 18px;
  height: 14px;
  position: relative;
}

.menu-icon::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}

/* KPIs - single row, horizontal scroll only at extremes */
.kpis {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.kpis .section-label {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  opacity: 0.8;
}

.kpi-row {
  display: flex;
  flex-wrap: nowrap;
  gap: clamp(0.4rem, 1vw, 0.6rem);
  overflow-x: auto;
  padding-bottom: 0.15rem; /* scrollbar clearance */
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .kpi-row {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .kpi {
    flex: 1 1 100px;
    min-width: 2.5rem;
  }

  .kpi-value {
    font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  }

  .kpi-label {
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
  }
}

.kpi {
  flex: 1 1 0;
  min-width: 3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex-shrink: 0;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 2.2vw, 1.4rem);
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
}

.kpi-label {
  font-size: clamp(0.55rem, 1vw, 0.8rem);
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

@media (max-width: 600px) {
  .kpi {
    padding: 0.3rem 0.35rem;
  }

  .kpi-value {
    font-size: clamp(0.7rem, 3.5vw, 1rem);
  }

  .kpi-label {
    font-size: clamp(0.5rem, 2vw, 0.7rem);
  }
}

/* Charts - 2 columns, collapse to 1 when narrow (desktop or mobile) */
.charts {
  flex: 1;
  min-height: 240px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr auto;
  gap: clamp(0.4rem, 1.5vw, 0.6rem);
}

@media (max-width: 900px) {
  .charts {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(100px, 1fr)) auto;
  }
}

.chart-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-cell-wide {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .chart-cell-wide {
    grid-column: 1;
  }
}

.chart-wrap-tall {
  max-height: 180px;
  flex: 1;
}

.chart-wrap {
  flex: 1;
  min-height: 80px;
  max-height: 140px;
  position: relative;
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

@media (max-width: 768px) {
  .tagline {
    display: none;
  }

  .region-pill {
    display: none;
  }

  .chart-wrap {
    max-height: 120px;
  }

  .chart-wrap-tall {
    max-height: 140px;
  }
}

/* Footer */
.footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.35rem 0;
}

.footer-text {
  color: var(--text-muted);
}

/* Generic logo in footer - same proportions as generic.business, tail of tagline */
.footer-generic-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--text-muted);
  font-family: "Open Sans", sans-serif;
  line-height: 1;
  transition: color 0.15s;
}

.footer-generic-logo:hover {
  color: var(--accent);
}

.footer-generic-img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}

.footer-generic-text {
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.footer-generic-logo .generic-bold {
  font-weight: 700;
}

.footer-flag {
  font-size: 0.9em;
  margin-left: 0.15rem;
}

/* Drawer */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.drawer.is-open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
}

.drawer.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 90vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.drawer-close:hover {
  background: var(--bg-card);
  color: var(--text);
}

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.drawer-category {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0.75rem 0 0.35rem;
  padding-left: 0.5rem;
}

.drawer-category:first-child {
  margin-top: 0;
}

.drawer-link {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  margin-bottom: 0.15rem;
}

.drawer-link:hover {
  background: var(--bg-card);
}

.drawer-link .app-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.drawer-link .app-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.drawer-group {
  margin-bottom: 0.15rem;
}

.drawer-group-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.4rem 0.75rem;
}

.drawer-sublink {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  margin-bottom: 0.1rem;
}

.drawer-sublink:hover {
  background: var(--bg-card);
}

.drawer-sublink .app-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.drawer-sublink .app-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.05rem;
}
