/* ==========================================================================
   2G Internal Hub — shell styles
   Loads AFTER tokens.css and components.css. Adds only what the hub shell
   needs on top of the 2G Energy Rental Design System: the app bar, the
   tools.json-driven nav, and the tool grid.

   No new colors, no new typefaces. Everything below resolves to a token.
   ========================================================================== */

/* ---- Page frame ---------------------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hub-main {
  flex: 1;
  padding: var(--space-xl) 0 var(--space-3xl);
}

/* ---- App bar -------------------------------------------------------------
   Extends .navbar from components.css. Sticky so the nav is always one
   thumb-reach away on a phone.
------------------------------------------------------------------------- */

.hub-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
}

.hub-bar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  min-height: 44px;
}

.hub-bar__brand img {
  height: 28px;
  width: auto;
  display: block;
}

.hub-bar__wordmark {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-small);
  color: var(--gray-80);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ---- Nav rendered from tools.json ---------------------------------------- */

/* The <nav> wrapper is a flex item of .hub-bar. Flex items default to
   min-width:auto, which means they refuse to shrink below their content —
   so without this the nav forces the whole header (and page) wider than the
   viewport instead of letting the list scroll. */
.hub-bar > nav {
  min-width: 0;
  max-width: 100%;
}

.hub-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  min-width: 0;
}

.hub-nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-small);
  color: var(--gray-80);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  min-height: 44px;              /* phone tap target */
  white-space: nowrap;
}

.hub-nav a:hover {
  background: var(--light-green);
  color: var(--2g-green);
}

.hub-nav a[aria-current='page'] {
  color: var(--2g-green);
  background: var(--light-green);
}

.hub-nav a[aria-disabled='true'] {
  color: var(--gray-40);
  cursor: not-allowed;
  pointer-events: none;
}

.hub-nav__ext {
  font-size: var(--text-caption);
  color: var(--gray-60);
  line-height: 1;
}

/* ---- Page header --------------------------------------------------------- */

.hub-head {
  margin-bottom: var(--space-2xl);
}

.hub-head .tagline {
  margin-top: var(--space-sm);
}

/* ---- Tool grid ----------------------------------------------------------- */

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.hub-tile {
  display: block;
  padding: var(--space-lg);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--white);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.hub-tile:hover {
  border-color: var(--2g-green);
  background: var(--gray-10);
}

.hub-tile__name {
  display: block;
  font-weight: var(--font-weight-bold);
  font-size: var(--text-h4);
  color: var(--2g-green);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-xs);
}

.hub-tile__desc {
  display: block;
  font-size: var(--text-small);
  color: var(--gray-60);
}

.hub-tile--disabled {
  cursor: not-allowed;
  pointer-events: none;
  background: var(--gray-10);
  border-color: var(--gray-10);
}

.hub-tile--disabled .hub-tile__name {
  color: var(--gray-40);
}

.hub-tile--disabled .hub-tile__desc {
  color: var(--gray-40);
}

/* ==========================================================================
   KPI dashboard
   Numbers are the design: large Noto Sans Bold figures, small gray labels
   underneath. Tabular figures so columns of numbers line up without
   reaching for a monospace face (Design System is Noto Sans only).
   ========================================================================== */

.kpi-section {
  margin-bottom: var(--space-2xl);
}

.kpi-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: var(--border-width) solid var(--gray-10);
}

.kpi-section__title {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-caption);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-60);
  margin: 0;
}

.kpi-section__note {
  font-size: var(--text-caption);
  color: var(--gray-60);
  margin: 0;
}

/* ---- Stat grid ----------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg);
}

.kpi-grid--tight {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.kpi-stat {
  min-width: 0;
}

.kpi-stat__value {
  display: block;
  font-weight: var(--font-weight-bold);
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1;
  color: var(--gray-80);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.kpi-stat__unit {
  font-size: 0.45em;
  font-weight: var(--font-weight-bold);
  color: var(--gray-60);
  margin-left: 0.25em;
  letter-spacing: 0.04em;
}

.kpi-stat__label {
  display: block;
  font-size: var(--text-small);
  color: var(--gray-60);
  margin-top: var(--space-xs);
}

.kpi-stat__sub {
  display: block;
  font-size: var(--text-caption);
  color: var(--gray-60);
  margin-top: 2px;
}

/* Hero stat — the one number that leads the page. */
.kpi-stat--hero .kpi-stat__value {
  font-size: clamp(3rem, 13vw, 5rem);
  color: var(--2g-green);
}

.kpi-stat--hero .kpi-stat__unit {
  color: var(--2g-green);
}

.kpi-stat--hero .kpi-stat__label {
  font-size: var(--text-body);
}

/* Muted stat — the deliberately-not-the-hero counter row. */
.kpi-stat--muted .kpi-stat__value {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  color: var(--gray-60);
}

/* Alert stat — stale accounts. */
.kpi-stat--alert .kpi-stat__value {
  color: var(--color-danger);
}

/* ---- Hero band ----------------------------------------------------------- */

.kpi-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-2xl);
  align-items: start;
  padding: var(--space-xl);
  background: var(--gray-10);
  border-radius: var(--radius-md);
}

/* ---- Vertical split bars -------------------------------------------------- */

.kpi-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: 0;
}

.kpi-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-sm) var(--space-md);
  align-items: baseline;
}

.kpi-bar__label {
  font-size: var(--text-small);
  color: var(--gray-80);
}

.kpi-bar__value {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-body);
  color: var(--gray-80);
  font-variant-numeric: tabular-nums;
}

.kpi-bar__track {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--white);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.kpi-bar__fill {
  display: block;
  height: 100%;
  background: var(--2g-green);
  border-radius: var(--radius-pill);
  min-width: 2px;
}

/* Stage bars sit on white, so their track needs the gray tint instead. */
.kpi-bars--onwhite .kpi-bar__track {
  background: var(--gray-10);
}

/* ---- Stale list ----------------------------------------------------------- */

.kpi-stale {
  list-style: none;
  margin: var(--space-md) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.kpi-stale li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: var(--border-width) solid var(--gray-10);
  font-size: var(--text-small);
}

.kpi-stale li:last-child {
  border-bottom: 0;
}

.kpi-stale__name {
  font-weight: var(--font-weight-bold);
  color: var(--gray-80);
}

.kpi-stale__vertical {
  color: var(--gray-60);
  font-size: var(--text-caption);
}

.kpi-stale__days {
  color: var(--color-danger);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-empty {
  font-size: var(--text-small);
  color: var(--gray-60);
  margin: var(--space-md) 0 0;
}

/* ---- Source-pending tiles -------------------------------------------------
   Speced, deliberately empty. No sample data, no "coming soon" copy.
------------------------------------------------------------------------- */

.kpi-pending {
  padding: var(--space-lg);
  border: var(--border-width) dashed var(--gray-40);
  border-radius: var(--radius-md);
  background: var(--white);
}

.kpi-pending__label {
  display: block;
  font-weight: var(--font-weight-bold);
  font-size: var(--text-body);
  color: var(--gray-40);
  margin-bottom: var(--space-xs);
}

.kpi-pending__reason {
  display: block;
  font-size: var(--text-small);
  color: var(--gray-60);
  margin-bottom: var(--space-sm);
}

.kpi-pending__tag {
  display: inline-block;
  font-size: var(--text-caption);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-40);
}

/* A bar for a vertical that has leads but no MW entered. Reads as an empty
   track rather than a missing row — the absence IS the signal. */
.kpi-bar__fill--empty {
  background: var(--gray-40);
}

.kpi-banner--warn {
  border-left-color: var(--color-warning);
}

/* ---- As-of stamp ---------------------------------------------------------- */

.kpi-asof {
  font-size: var(--text-caption);
  color: var(--gray-60);
  font-variant-numeric: tabular-nums;
}

.kpi-banner {
  margin-bottom: var(--space-xl);
  padding: var(--space-sm) var(--space-md);
  border-left: 4px solid var(--color-warning);
  background: var(--gray-10);
  font-size: var(--text-small);
  color: var(--gray-80);
}

/* ---- Phone --------------------------------------------------------------- */

@media (max-width: 760px) {
  .kpi-hero {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
    padding: var(--space-lg);
  }
}

/* ---- Placeholder note ---------------------------------------------------- */

.hub-note {
  margin-top: var(--space-2xl);
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--gray-40);
  background: var(--gray-10);
  font-size: var(--text-small);
  color: var(--gray-60);
}

/* ---- Footer -------------------------------------------------------------- */

.hub-foot {
  border-top: var(--border-width) solid var(--gray-10);
  padding: var(--space-lg) 0;
  font-size: var(--text-caption);
  color: var(--gray-60);
}

/* ---- Phone --------------------------------------------------------------- */

@media (max-width: 640px) {
  .hub-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .hub-bar__wordmark {
    font-size: var(--text-caption);
  }

  .hub-bar > nav {
    flex: 1 1 100%;
  }

  .hub-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-xs);
  }

  .hub-nav::-webkit-scrollbar {
    display: none;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .headline-underline {
    font-size: var(--text-h2);
  }
}
