/* ============================================================================
 * Eastern Kentucky University (EKU) Official Brand Palette & Theme Tokens
 * Primary:   EKU Maroon (#861F41), Solid White (#FFFFFF), Solid Black (#000000)
 * Accents:   Goldenrod Yellow (#FFC658), Kentucky Bluegrass (#009681),
 *            Boone Bronze (#E6A65D), Autumn Orange (#DC5829)
 * Neutrals:  Dark Gray (#87909A), Light Gray (#C5CFDA)
 * Typography: Barlow / Barlow Condensed (with Avenir / system-ui fallback)
 * ========================================================================== */

:root {
  /* Official EKU Brand Tokens */
  --eku-maroon: #861f41;
  --eku-maroon-deep: #62152f;
  --eku-white: #ffffff;
  --eku-black: #000000;
  --eku-goldenrod: #ffc658;
  --eku-bluegrass: #009681;
  --eku-bronze: #e6a65d;
  --eku-autumn: #dc5829;
  --eku-dark-gray: #87909a;
  --eku-light-gray: #c5cfda;

  /* Light Surface Tokens */
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-subtle: #eff2f6;
  --border: #d8e0e8;
  --text: #14171c;
  --text-muted: #56606b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(0, 0, 0, 0.04);

  /* Status Tokens (aligned with Kentucky Bluegrass & Autumn Orange) */
  --status-ok-bg: #e2f5f2;
  --status-ok-fg: #006b5c;
  --status-warn-bg: #fff4df;
  --status-warn-fg: #8c4b00;
  --status-err-bg: #fde8e2;
  --status-err-fg: #9c3312;

  /* Chart Tokens */
  --chart-grid: rgba(135, 144, 154, 0.22);
  --chart-axis: #56606b;
  --chart-line: #dc5829;
  --chart-fill-top: rgba(255, 198, 88, 0.48);
  --chart-fill-bottom: rgba(255, 198, 88, 0.04);
  --chart-bar: #861f41;
  --chart-bar-hover: #e6a65d;

  --font-display: "Barlow Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --font-body: "Barlow", "Avenir Next", "Avenir", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #181c22;
  --surface-subtle: #20262f;
  --border: #2e3642;
  --text: #f4f6f9;
  --text-muted: #a6b0bc;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.42);

  --status-ok-bg: rgba(0, 150, 129, 0.2);
  --status-ok-fg: #5de0cb;
  --status-warn-bg: rgba(255, 198, 88, 0.16);
  --status-warn-fg: #ffc658;
  --status-err-bg: rgba(220, 88, 41, 0.22);
  --status-err-fg: #ff9c7a;

  --chart-grid: rgba(197, 207, 218, 0.14);
  --chart-axis: #a6b0bc;
  --chart-line: #ffc658;
  --chart-fill-top: rgba(255, 198, 88, 0.34);
  --chart-fill-bottom: rgba(255, 198, 88, 0.02);
  --chart-bar: #b33961;
  --chart-bar-hover: #ffc658;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #181c22;
    --surface-subtle: #20262f;
    --border: #2e3642;
    --text: #f4f6f9;
    --text-muted: #a6b0bc;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.42);

    --status-ok-bg: rgba(0, 150, 129, 0.2);
    --status-ok-fg: #5de0cb;
    --status-warn-bg: rgba(255, 198, 88, 0.16);
    --status-warn-fg: #ffc658;
    --status-err-bg: rgba(220, 88, 41, 0.22);
    --status-err-fg: #ff9c7a;

    --chart-grid: rgba(197, 207, 218, 0.14);
    --chart-axis: #a6b0bc;
    --chart-line: #ffc658;
    --chart-fill-top: rgba(255, 198, 88, 0.34);
    --chart-fill-bottom: rgba(255, 198, 88, 0.02);
    --chart-bar: #b33961;
    --chart-bar-hover: #ffc658;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Single Clean EKU Maroon Header */
.site-header {
  background: linear-gradient(135deg, var(--eku-maroon) 0%, var(--eku-maroon-deep) 100%);
  color: var(--eku-white);
  border-bottom: 3px solid var(--eku-goldenrod);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.eku-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.eku-logo {
  display: block;
  height: 42px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, 0.32);
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.05;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  color: var(--eku-white);
}

.status-pill.status-online {
  background: var(--status-ok-bg);
  color: var(--status-ok-fg);
}

.status-pill.status-stale {
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
}

.status-pill.status-offline {
  background: var(--status-err-bg);
  color: var(--status-err-fg);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.18);
  color: var(--eku-white);
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.34);
}

.icon-btn:focus-visible,
.range-tab:focus-visible,
a:focus-visible {
  outline: 2px solid var(--eku-goldenrod);
  outline-offset: 2px;
}

/* Main */
.main-content {
  flex: 1;
  padding-top: 1.6rem;
  padding-bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.alert-banner {
  background: var(--status-warn-bg);
  color: var(--status-warn-fg);
  border-left: 4px solid var(--eku-autumn);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--eku-maroon);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-primary {
  border-top: 3px solid var(--eku-goldenrod);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Chart Card */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.chart-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chart-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.range-tabs {
  display: inline-flex;
  background: var(--surface-subtle);
  padding: 0.22rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 0.15rem;
}

.range-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.42rem 0.82rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.range-tab:hover {
  color: var(--text);
}

.range-tab[aria-selected="true"] {
  background: var(--eku-maroon);
  color: var(--eku-white);
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.stat-chip {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.86rem;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.chart-stage {
  position: relative;
  width: 100%;
  height: 360px;
}

#solar-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--eku-maroon);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  z-index: 10;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip .tt-time {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.chart-tooltip .tt-row {
  color: var(--text-muted);
}

.chart-tooltip .tt-row strong {
  color: var(--text);
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.chart-empty[hidden] {
  display: none;
}

/* EKU Institutional Footer */
.site-footer {
  background: var(--eku-black);
  color: var(--eku-light-gray);
  border-top: 3px solid var(--eku-maroon);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding-top: 1.35rem;
  padding-bottom: 1.35rem;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

.footer-logo {
  display: block;
  height: 28px;
  width: auto;
  margin-bottom: 0.4rem;
}

.footer-addr {
  color: var(--eku-dark-gray);
}

.footer-meta {
  text-align: right;
}

.footer-links {
  margin-top: 0.2rem !important;
  color: var(--eku-dark-gray);
}

.footer-links a {
  color: var(--eku-goldenrod);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .eku-logo {
    height: 34px;
  }
  .brand-divider {
    display: none;
  }
  .chart-stage {
    height: 280px;
  }
  .kpi-value {
    font-size: 1.9rem;
  }
  .footer-meta {
    text-align: left;
  }
}
