:root {
  --bg: #060a0f;
  --panel: rgba(16, 25, 35, .88);
  --panel-2: rgba(21, 32, 44, .92);
  --line: rgba(129, 161, 193, .18);
  --text: #eef5ff;
  --muted: #a8b4c4;
  --blue: #2d8cff;
  --green: #62c747;
  --yellow: #ffc400;
  --orange: #ff7a00;
  --purple: #a855f7;
  --red: #ff4757;
  --shadow: 0 18px 55px rgba(0, 0, 0, .35);
  --kpi-card-height: 88px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

html {
  background-color: #05080d;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
}

html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}

html.is-scrolling {
  scrollbar-color: rgba(255, 255, 255, .35) transparent;
}

html.is-scrolling::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .35);
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(45, 140, 255, .16), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(33, 201, 116, .12), transparent 30%),
    linear-gradient(135deg, #05080d, #0a121b 52%, #05070b);
}

body.has-custom-background {
  background-image:
    var(--dashboard-background),
    radial-gradient(circle at 12% 0%, rgba(45, 140, 255, .16), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(33, 201, 116, .12), transparent 30%),
    linear-gradient(135deg, #05080d, #0a121b 52%, #05070b);
  background-position: center, center, center, center;
  background-size: cover, auto, auto, auto;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

@media (max-width: 900px) {
  body.has-custom-background {
    background-position: center top, center, center, center;
    background-size: auto 100vh, auto, auto, auto;
    background-size: auto 100svh, auto, auto, auto;
    background-repeat: repeat-y, no-repeat, no-repeat, no-repeat;
    background-attachment: scroll;
  }
}

.dashboard {
  width: min(1800px, 100vw);
  margin: 0 auto;
  padding: 10px 14px 12px;
}

.topbar {
  height: 78px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  background: rgba(5, 10, 17, .72);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-icon, .refresh-icon, .kpi-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 900;
}

.brand-icon {
  background: linear-gradient(135deg, #d9e5f2, #8ea3b8);
  color: #0b1119;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#statusText {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.refresh-card {
  display: grid;
  grid-template-columns: 38px auto auto;
  align-items: center;
  gap: 18px;
  color: var(--muted);
}

.refresh-card div:not(.refresh-icon) {
  display: grid;
  gap: 2px;
}

.refresh-card span {
  font-size: 12px;
}

.refresh-card strong {
  color: var(--text);
  font-size: 14px;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  right: auto;
  z-index: 30;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(10, 18, 28, .96);
  border: 1px solid rgba(255, 255, 255, .08);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.success {
  border-color: rgba(98, 199, 71, .35);
}

.toast.error {
  border-color: rgba(255, 71, 87, .35);
}

.toast-text {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .toast {
    max-width: calc(100vw - 32px);
  }
}

.refresh-icon {
  color: var(--blue);
  background: rgba(45, 140, 255, .09);
  border: 1px solid rgba(45, 140, 255, .18);
  padding: 0;
  cursor: pointer;
}

.refresh-icon:hover {
  background: rgba(45, 140, 255, .16);
  transform: translateY(-1px);
}

button {
  border: 1px solid rgba(129, 161, 193, .22);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  padding: 9px 11px;
  font-weight: 800;
  cursor: pointer;
}

button:hover { background: rgba(255, 255, 255, .11); }

.setup-warning {
  margin-top: 10px;
  border: 1px solid rgba(255, 174, 0, .28);
  background: rgba(255, 174, 0, .11);
  border-radius: 12px;
  padding: 12px 16px;
  color: #ffe2a1;
}

.hidden { display: none; }

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  margin-top: 0;
}

.content { min-width: 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.kpi, .panel, .weather-now, .forecast-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 96px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  position: relative;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  opacity: .12;
  background: currentColor;
}

.kpi-icon { font-size: 22px; }

.kpi strong {
  display: block;
  font-size: 38px;
  line-height: 1;
  margin-bottom: 5px;
}

.kpi span {
  color: #dbe8f8;
  font-weight: 700;
}

.kpi.blue { color: var(--blue); }
.kpi.blue .kpi-icon { background: var(--blue); color: #06111f; }
.kpi.red { color: var(--red); }
.kpi.red .kpi-icon { background: var(--red); color: #1f0508; }
.kpi.green { color: var(--green); }
.kpi.green .kpi-icon { background: var(--green); color: #03150b; }
.kpi.yellow { color: var(--yellow); }
.kpi.yellow .kpi-icon { background: var(--yellow); color: #191300; }
.kpi.orange { color: var(--orange); }
.kpi.orange .kpi-icon { background: var(--orange); color: #1a1000; }
.kpi.purple { color: var(--purple); }
.kpi.purple .kpi-icon { background: var(--purple); color: #16031f; }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.28fr;
  gap: 14px;
}

.panel-right-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel-right-stack .panel {
  min-height: 165px;
}

#mobileAirQualitySlot {
  display: none;
}

@media (max-width: 900px) {
  .panel-right-stack {
    grid-template-columns: 1fr;
  }
  #mobileAirQualitySlot {
    display: block;
  }
}

.panel {
  padding: 14px 16px;
  min-height: 215px;
  background:
    linear-gradient(160deg, rgba(33, 48, 66, .78), rgba(11, 18, 26, .86));
}

.panel-air-quality {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  align-items: stretch;
  gap: 14px;
  min-height: 215px;
  padding-bottom: 8px;
  overflow: visible;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
}

.aq-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 10px;
  min-height: 100%;
}

.aq-info-trigger {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.aq-info-trigger:focus-visible,
.aq-info-trigger:hover {
  background: rgba(255, 255, 255, .15);
}

.aq-tooltip {
  position: absolute;
  top: 110%;
  right: 0;
  width: 220px;
  padding: 10px 10px 8px;
  border-radius: 14px;
  background: rgba(10, 16, 22, .96);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #e8f1fc;
  font-size: 11px;
  line-height: 1.4;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 1;
}

.aq-info-trigger:hover .aq-tooltip,
.aq-info-trigger.is-tooltip-open .aq-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tooltip-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.tooltip-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tooltip-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.aq-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 10px;
}

.aq-circles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 136px));
  justify-content: center;
  justify-items: center;
  gap: 24px;
  max-width: 296px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .aq-circles {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 16px;
  }
}

.aq-circle-group {
  display: grid;
  gap: 8px;
  justify-items: center;
  width: auto;
}

.aq-circle-heading {
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .95);
}

.aq-circle {
  display: grid;
  place-items: center;
  gap: 6px;
  width: 126px;
  min-width: 126px;
  height: 126px;
  border-radius: 50%;
  padding: 12px;
  background: #0f172a;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .18);
  text-align: center;
  color: #ffffff;
}

.aq-circle-category {
  display: block;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.aq-circle strong {
  font-size: 28px;
  line-height: 1;
  color: inherit;
}

.aq-circle p {
  margin: 0;
  color: inherit;
  font-size: 10px;
  line-height: 1.3;
}

.aq-badge-neutral { background: #64748b; color: #ffffff; }
.aq-badge-good { background: #16a34a; color: #ffffff; }
.aq-badge-moderate { background: #eab308; color: #0f172a; }
.aq-badge-unhealthy-sensitive { background: #f97316; color: #0f172a; }
.aq-badge-unhealthy { background: #dc2626; color: #ffffff; }
.aq-badge-very-unhealthy { background: #8b5cf6; color: #f8fafc; }
.aq-badge-hazardous { background: #7f1d1d; color: #ffffff; }

.aq-reference {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.aq-reference strong {
  color: var(--text);
  font-weight: 700;
}

.aq-label {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  color: var(--muted);
}

.aq-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}

.aq-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel h2, .forecast-panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: #e8f1fc;
}

.chart-box {
  position: relative;
  height: 180px;
}

.panel-list .chart-box,
.panel-members .chart-box,
.panel-due .chart-box { height: 180px; }

.panel-labels {
  min-height: 215px;
}

.label-layout {
  display: grid;
  grid-template-columns: 255px 1fr;
  gap: 18px;
  align-items: center;
}

.pie-wrap {
  width: 245px;
  height: 245px;
  aspect-ratio: 1 / 1;
  margin: -6px auto -12px;
}

.pie-wrap canvas {
  width: 245px !important;
  height: 245px !important;
}

.label-legend {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 12px;
  row-gap: 5px;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow: auto;
}

.label-legend li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: #dce7f4;
  font-size: 11px;
  line-height: 14px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  box-shadow: 0 0 14px currentColor;
}

.tag {
  display: inline-block;
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  color: #071019;
  white-space: nowrap;
}

.card-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  max-height: 170px;
  overflow: hidden;
}

.card-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: #dce7f4;
  font-size: 13px;
}

.card-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.complete-check {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
  color: #06150d;
  font-size: 12px;
  font-weight: 1000;
}

.card-list .meta {
  color: var(--muted);
  font-size: 12px;
}

.due-today { color: var(--orange); font-weight: 900; }
.due-overdue { color: var(--red); font-weight: 900; }
.due-soon { color: #73bdff; font-weight: 800; }

.weather-column {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.sidebar-kpi {
  min-height: var(--kpi-card-height);
  height: var(--kpi-card-height);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  clip-path: inset(0 round 12px);
  border-color: rgba(255, 174, 0, .3);
  background: var(--panel);
}

.sidebar-kpi::after {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  opacity: .12;
  background: var(--orange);
}

.sidebar-kpi > * {
  position: relative;
  z-index: 1;
}

.sidebar-kpi-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--orange);
  color: #1a1000;
  font-size: 22px;
  font-weight: 900;
}

.sidebar-kpi-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.sidebar-kpi-content {
  min-width: 0;
  width: 100%;
}

.sidebar-kpi h2 {
  color: var(--orange);
  margin-bottom: 7px;
}

.sidebar-kpi-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #dce7f4;
  font-size: 12px;
  line-height: 1.3;
}

.sidebar-kpi-list li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-now, .forecast-panel {
  padding: 12px;
  background:
    linear-gradient(160deg, rgba(21, 33, 47, .85), rgba(9, 15, 23, .92));
}

.weather-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #dce7f4;
  font-weight: 800;
  margin-bottom: 12px;
}

.weather-title button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
}

.weather-hero {
  text-align: center;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.weather-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 2px;
  transform-origin: center;
}

.weather-icon.weather-refreshing {
  animation: weather-loading 650ms ease-in-out infinite alternate;
}

.weather-icon.weather-refreshed {
  animation: weather-refreshed 600ms ease-out;
}

.aq-circle.refreshing {
  animation: aq-refreshing 650ms ease-in-out infinite alternate;
}

.aq-circle.refreshed {
  animation: aq-refreshed 600ms ease-out;
}

@keyframes weather-loading {
  from { transform: translateY(2px) rotate(-5deg) scale(.96); }
  to { transform: translateY(-5px) rotate(5deg) scale(1.06); }
}

@keyframes weather-refreshed {
  0% { transform: scale(.9) rotate(-8deg); }
  45% { transform: scale(1.18) rotate(7deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes aq-refreshing {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0.1); }
  to { transform: scale(1.04); box-shadow: 0 0 12px 6px rgba(255,255,255,0.12); }
}

@keyframes aq-refreshed {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .weather-icon.weather-refreshing,
  .weather-icon.weather-refreshed {
    animation: none;
  }
}

.weather-hero strong {
  font-size: 42px;
  line-height: 1.02;
}

.weather-hero p {
  color: #d8e2ef;
  margin: 4px 0 0;
  font-size: 16px;
}

.weather-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.weather-metrics div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  border-bottom: 1px solid rgba(129, 161, 193, .12);
  padding-bottom: 8px;
}

.weather-metrics strong { color: var(--text); }

.forecast-list {
  display: grid;
  gap: 0;
}

.forecast-day {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.forecast-day:first-child { border-top: 0; padding-top: 6px; }

.forecast-day .icon {
  font-size: 32px;
}

.forecast-day strong {
  display: block;
  font-size: 13px;
  color: #eaf2fb;
}

.forecast-day p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.forecast-day .temps {
  display: grid;
  gap: 4px;
  text-align: right;
  font-size: 14px;
}

.forecast-day .high { color: #ff765f; font-weight: 900; }
.forecast-day .low { color: #73bdff; font-weight: 900; }
.forecast-day .rain { color: #73bdff; font-size: 12px; }

footer {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(5, 10, 17, .55);
  border-radius: 12px;
  padding: 0 28px;
  margin-top: 14px;
  font-size: 14px;
}

footer strong, footer a {
  color: var(--blue);
  font-weight: 900;
}

footer a { text-decoration: none; }
footer a:hover { text-decoration: underline; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
  margin-right: 6px;
}

@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 1fr; }
  .charts-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .panel-right-stack {
    grid-template-columns: 1fr;
  }
  .weather-column {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .main-grid {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .content {
    display: block !important;
  }

  .charts-grid {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .panel-right-stack {
    grid-template-columns: 1fr;
  }

  .weather-column {
    grid-template-columns: 1fr 1fr;
    height: auto !important;
    min-height: 0 !important;
  }

  .panel,
  .weather-now,
  .forecast-panel {
    overflow: visible;
  }

  .chart-box,
  .panel-list .chart-box,
  .panel-members .chart-box,
  .panel-due .chart-box {
    height: auto;
    min-height: 170px;
  }

  .below-fold {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

@media (max-width: 900px) {
  .topbar, .refresh-card { grid-template-columns: 1fr; height: auto; }
  .topbar { align-items: stretch; }
  .refresh-card { display: grid; }
  .kpi-grid, .charts-grid, .weather-column { grid-template-columns: 1fr; }
  .label-layout { grid-template-columns: 1fr; }
}

@media (min-width: 1500px) {
  .dashboard { padding-top: 9px; }
  .main-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .chart-box { height: 190px; }
}

/* v3 refinements */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
}

#statusText {
  display: none;
}

.refresh-card {
  grid-template-columns: 48px auto;
  gap: 16px;
}

.refresh-icon {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  line-height: 1;
  overflow: hidden;
}

.refresh-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.main-grid {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

.kpi {
  min-height: var(--kpi-card-height);
  height: var(--kpi-card-height);
  padding: 14px 20px;
}

.kpi strong {
  font-size: 34px;
}

.charts-grid {
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.panel {
  min-height: 0;
}

.chart-box,
.panel-list .chart-box,
.panel-members .chart-box,
.panel-due .chart-box {
  height: clamp(145px, 18vh, 190px);
}

.panel-labels {
  min-height: 0;
}

.label-layout {
  grid-template-columns: minmax(180px, 250px) 1fr;
}

.pie-wrap {
  width: clamp(190px, 21vh, 245px);
  height: clamp(190px, 21vh, 245px);
}

.pie-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.weather-column {
  min-height: 0;
}

.weather-now,
.forecast-panel {
  padding: 14px;
}

.weather-title {
  margin-bottom: 8px;
}

.weather-icon {
  font-size: 42px;
}

.weather-hero {
  padding: 0 0 8px;
}

.weather-hero strong {
  font-size: 40px;
}

.weather-hero p {
  font-size: 14px;
}

.weather-metrics {
  gap: 6px;
  margin-top: 8px;
}

.weather-metrics div {
  padding-bottom: 5px;
}

.forecast-day {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 0;
}

.forecast-day .icon {
  font-size: 28px;
}

.below-fold {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
  scroll-snap-align: start;
}

footer {
  flex: 0 0 auto;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.github-link svg {
  width: 21px;
  height: 21px;
  color: #eef5ff;
}

@media (min-width: 1201px) {
  .main-grid {
    max-height: calc(100vh - 68px - 42px - 52px);
  }
}

@media (max-width: 900px) {
  .below-fold { grid-template-columns: 1fr; }
  .panel-upcoming { order: 1; }
  .panel-recent { order: 2; }
  .refresh-icon { width: 44px; height: 44px; }
}

html {
  scroll-snap-type: none;
}

.topbar,
.main-grid,
.below-fold {
  scroll-snap-align: start;
}

/* v4 corrections */
.refresh-card {
  grid-template-columns: 48px auto auto;
  gap: 18px;
}

.weather-refresh-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 10px;
}

.weather-refresh-icon svg {
  width: 19px;
  height: 19px;
  display: block;
}

.main-grid {
  min-height: calc(100vh - 68px - 28px);
}

.content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.charts-grid {
  min-height: 0;
}

.panel {
  overflow: visible;
}

.card-list {
  max-height: none;
}

.below-fold {
  min-height: 0;
  align-content: start;
}

footer strong#totalLoadedCards {
  color: var(--text);
  font-weight: 900;
}

footer > span:first-child {
  color: var(--text);
  font-weight: 900;
}

@media (min-width: 1201px) {
  .main-grid {
    max-height: none;
  }

  .weather-column {
    grid-template-rows: minmax(0, .9fr) minmax(0, 1.1fr);
  }

  .sidebar-kpi {
    height: var(--kpi-card-height);
  }

  .forecast-panel {
    overflow: hidden;
  }

  .forecast-list {
    height: calc(100% - 34px);
    align-content: stretch;
  }
}

@media (max-width: 900px) {
  .dashboard {
    width: 100%;
    padding: 10px;
  }

  .topbar {
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .refresh-card {
    grid-template-columns: 44px 1fr 1fr;
  }

  .main-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
  }

  .content {
    display: block;
  }

  .kpi-grid,
  .charts-grid,
  .weather-column,
  .below-fold {
    grid-template-columns: 1fr;
  }

  .chart-box,
  .panel-list .chart-box,
  .panel-members .chart-box,
  .panel-due .chart-box {
    height: 260px;
  }

  .label-layout {
    grid-template-columns: 1fr;
  }

  .pie-wrap {
    width: min(280px, 78vw);
    height: min(280px, 78vw);
  }

  .below-fold {
    min-height: 0;
  }

  footer {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 18px;
  }
}

@media (max-width: 560px) {
  .refresh-card {
    grid-template-columns: 44px 1fr;
  }

  .refresh-card div:last-child {
    grid-column: 2;
  }

  h1 {
    white-space: normal;
  }

  .kpi {
    min-height: 74px;
  }
}

/* v4 layout + polish */
@media (min-width: 901px) {
  .dashboard {
    min-height: 100vh;
    padding-bottom: 12px;
  }

  .topbar {
    height: 68px;
    flex: 0 0 68px;
  }

  .refresh-card {
    grid-template-columns: 48px auto auto;
    gap: 16px;
  }

  .main-grid {
    flex: 0 0 auto;
    height: calc(100vh - 68px - 42px - 64px - var(--kpi-card-height));
    min-height: 478px;
    max-height: none;
    overflow: hidden;
    scroll-snap-align: start;
  }

  .content {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }

  .kpi-grid {
    flex: 0 0 auto;
  }

  .charts-grid {
    min-height: 0;
    height: 100%;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .panel {
    min-height: 0;
    overflow: hidden;
  }

  .chart-box,
  .panel-list .chart-box,
  .panel-members .chart-box,
  .panel-due .chart-box {
    height: calc(100% - 30px);
    min-height: 130px;
  }

  .panel-labels .label-layout {
    height: calc(100% - 30px);
  }

  .label-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 12px;
    max-height: 100%;
  }

  .weather-column {
    height: 100%;
    min-height: 0;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .weather-now {
    padding: 8px 12px;
  }

  .weather-now .weather-title {
    margin-bottom: 4px;
  }

  .weather-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 2px 0 7px;
  }

  .weather-icon {
    font-size: 40px;
    margin-bottom: 0;
  }

  .weather-hero strong {
    font-size: 34px;
  }

  .weather-hero p {
    margin-top: 2px;
    font-size: 13px;
  }

  .weather-metrics {
    gap: 4px;
    margin-top: 7px;
    font-size: 15px;
  }

  .weather-metrics div {
    padding-bottom: 4px;
  }

  .sidebar-kpi,
  .weather-now,
  .forecast-panel {
    min-height: 0;
    overflow: hidden;
  }

  .sidebar-kpi {
    height: var(--kpi-card-height);
  }

  .forecast-list {
    max-height: calc(100% - 34px);
    overflow: hidden;
  }

  .forecast-panel {
    padding: 10px 14px;
  }

  .forecast-day {
    padding: 5px 0;
  }

  .forecast-day .temps {
    gap: 1px;
    line-height: 1.1;
  }

  footer {
    flex: 0 0 42px;
    margin-top: 8px;
    margin-bottom: 0;
    scroll-snap-align: end;
  }

  .below-fold {
    flex: 0 0 auto;
    min-height: 0;
    margin-top: 26px;
    padding-bottom: 0;
    scroll-snap-align: start;
  }
}

.footer-total,
.footer-total strong {
  color: var(--text) !important;
  font-weight: 900;
}

.weather-refresh-icon {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  border-radius: 12px !important;
  color: var(--blue) !important;
  background: rgba(45, 140, 255, .09) !important;
  border: 1px solid rgba(45, 140, 255, .18) !important;
  display: grid !important;
  place-items: center !important;
}

.weather-refresh-icon svg {
  width: 21px;
  height: 21px;
  display: block;
}

.weather-refresh-icon:hover {
  background: rgba(45, 140, 255, .16) !important;
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  html { scroll-snap-type: none; }

  .dashboard {
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    gap: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  h1 {
    white-space: normal;
    font-size: 22px;
  }

  .refresh-card {
    grid-template-columns: 44px 1fr 1fr;
    gap: 10px;
    align-items: center;
  }

  .main-grid,
  .content,
  .kpi-grid,
  .charts-grid,
  .weather-column,
  .below-fold {
    display: grid;
    grid-template-columns: 1fr !important;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .main-grid {
    gap: 12px;
  }

  .charts-grid {
    grid-template-rows: repeat(4, minmax(0, auto));
    min-width: 0;
    width: 100%;
  }

  .charts-grid > .panel,
  .charts-grid canvas {
    min-width: 0;
    max-width: 100%;
  }

  .charts-grid > .panel {
    width: 100%;
  }

  .kpi-grid,
  .charts-grid,
  .weather-column,
  .below-fold {
    gap: 12px;
  }

  .below-fold {
    order: 1;
  }

  .kpi {
    min-height: 84px;
  }

  .panel,
  .weather-now,
  .forecast-panel {
    overflow: visible;
  }

  .chart-box,
  .panel-list .chart-box,
  .panel-members .chart-box,
  .panel-due .chart-box {
    height: 250px;
  }

  .label-layout {
    grid-template-columns: 1fr !important;
    justify-items: center;
  }

  .pie-wrap {
    width: min(280px, 78vw);
    height: min(280px, 78vw);
  }

  .label-legend {
    width: 100%;
    max-height: none;
  }

  .forecast-list,
  .card-list {
    max-height: none;
    overflow: visible;
  }

  footer {
    order: 2;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 10px;
    padding: 14px 16px;
    margin-top: 12px;
  }
}

@media (max-width: 520px) {
  .refresh-card {
    grid-template-columns: 44px 1fr;
  }

  .kpi {
    padding: 14px 16px;
  }

  .kpi strong {
    font-size: 30px;
  }

  .weather-hero strong {
    font-size: 44px;
  }

  .card-list li {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
