:root {
  --roof-panel-bg: rgba(0, 0, 0, 0.72);
  --roof-panel-soft: rgba(255, 255, 255, 0.08);
  --roof-border: rgba(255, 255, 255, 0.16);
  --roof-muted: rgba(255, 255, 255, 0.68);
  --roof-open: #22c55e;
  --roof-closed: #ef4444;
  --roof-accent: #fbbf24;
  --roof-blue: #60a5fa;
}

.roof-page-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 1.25rem;
}

.roof-title-block {
  grid-column: 2;
  max-width: 54rem;
}

.roof-back-button,
.roof-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 700;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.roof-back-button,
.roof-button {
  padding: 0.7rem 1rem;
}

.roof-button:hover,
.roof-back-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.roof-status-message {
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--roof-muted);
}

.roof-status-message.error {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.roof-status-message.success {
  border-color: rgba(34, 197, 94, 0.38);
  color: #bbf7d0;
}

.roof-view-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(251, 191, 36, 0.34);
  border-radius: 5px;
  background: rgba(251, 191, 36, 0.1);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

.roof-view-mode-bar.hidden {
  display: none;
}

.roof-view-mode-bar > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.2rem;
}

.roof-view-eyebrow {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.roof-view-mode-bar strong {
  color: #fff;
  font-size: 1rem;
}

.roof-view-mode-bar small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.roof-live-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid rgba(34, 197, 94, 0.72);
  border-radius: 5px;
  background: rgba(34, 197, 94, 0.18);
  color: #dcfce7;
  font-weight: 900;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.roof-live-button:hover {
  border-color: rgba(34, 197, 94, 0.95);
  background: rgba(34, 197, 94, 0.28);
}

.roof-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.roof-panel,
.metric-card {
  background: var(--roof-panel-bg);
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.metric-card {
  padding: 1.25rem;
}

.metric-label {
  margin-bottom: 0.75rem;
  color: var(--roof-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.metric-value {
  margin-bottom: 0.35rem;
  color: #fff;
  font-size: clamp(1.7rem, 3.8vw, 2.45rem);
  font-weight: 300;
  line-height: 1;
  white-space: nowrap;
}

.metric-sub {
  color: var(--roof-muted);
  font-size: 0.95rem;
}

.roof-section-header {
  padding: 1.5rem 1.5rem 0;
}

.roof-section-header h2 {
  margin: 0 0 0.35rem;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
}

.roof-section-header p {
  margin: 0;
  color: var(--roof-muted);
  font-size: 0.95rem;
}

.roof-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
  padding: 1.5rem;
}

.roof-current-state-panel .roof-section-header {
  padding-bottom: 0;
}

.roof-state-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
}

.roof-state-pill.open {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}

.roof-state-pill.closed {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
}

.roof-state-name,
.roof-state-meta {
  min-width: 0;
}

.roof-state-name {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.roof-state-meta {
  display: grid;
  justify-items: end;
  gap: 0.15rem;
  text-align: right;
}

.roof-state-status {
  color: var(--roof-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.roof-state-pill small {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.72rem;
  white-space: nowrap;
}

.roof-state-dot {
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--roof-muted);
}

.roof-state-pill.open .roof-state-dot {
  background: var(--roof-open);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.55);
}

.roof-state-pill.closed .roof-state-dot {
  background: var(--roof-closed);
}

.roof-meta {
  color: var(--roof-muted);
  font-size: 0.9rem;
}

.roof-calendar-shell {
  padding: 0.75rem 1.5rem 1.5rem;
}

.roof-calendar-toolbar {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.roof-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.roof-icon-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.roof-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.roof-calendar-heading {
  min-width: 0;
  text-align: center;
}

.roof-calendar-heading h3 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 800;
}

.roof-calendar-heading p {
  margin: 0.25rem 0 0;
  color: var(--roof-muted);
  font-size: 0.9rem;
}

.roof-calendar-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.9rem;
  color: var(--roof-muted);
  font-size: 0.85rem;
}

.roof-calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--roof-muted);
}

.legend-dot.open {
  background: var(--roof-open);
}

.legend-dot.partial {
  background: var(--roof-accent);
}

.legend-dot.closed {
  background: var(--roof-closed);
}

.legend-dot.nodata {
  background: rgba(255, 255, 255, 0.22);
}

.roof-calendar-edit-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  margin-left: auto;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 5px;
  background: rgba(96, 165, 250, 0.12);
  color: #dbeafe;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
}

.roof-calendar-edit-toggle.active,
.roof-calendar-edit-toggle:hover {
  border-color: rgba(251, 191, 36, 0.78);
  background: rgba(251, 191, 36, 0.16);
  color: #fef3c7;
}

.roof-calendar-edit-notice {
  margin-bottom: 0.9rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(251, 191, 36, 0.34);
  border-radius: 5px;
  background: rgba(251, 191, 36, 0.1);
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.86rem;
  font-weight: 700;
}

.roof-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
}

.roof-calendar-weekday {
  min-height: 2.2rem;
  padding: 0.6rem 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.roof-calendar-day {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.35rem;
  min-width: 0;
  min-height: clamp(5.8rem, 9vw, 7.5rem);
  padding: 0.65rem;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.44);
  color: #fff;
  text-align: left;
}

.roof-calendar-day > span:not(.calendar-moon-img),
.roof-calendar-day > img:not(.calendar-moon-img) {
  position: relative;
  z-index: 2;
}

.roof-calendar-day:hover,
.roof-calendar-day.selected {
  outline: 2px solid rgba(251, 191, 36, 0.86);
  outline-offset: -2px;
}

.roof-calendar.editing .roof-calendar-day {
  cursor: copy;
}

.roof-calendar-day.manual::after {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  content: "M";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  z-index: 3;
}

.calendar-moon-img {
  position: absolute;
  left: var(--moon-x, 50%);
  top: var(--moon-y, 50%);
  width: clamp(2.0rem, 4.5vw, 3.5rem);
  aspect-ratio: 1;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
  opacity: 0.85;
}

.roof-calendar-day.outside {
  opacity: 0.42;
}

.roof-calendar-day.today .calendar-day-number {
  border-color: rgba(251, 191, 36, 0.82);
  color: #111827;
  background: rgba(251, 191, 36, 0.95);
}

.roof-calendar-day.open {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.22), rgba(0, 0, 0, 0.48));
}

.roof-calendar-day.partial {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.25), rgba(0, 0, 0, 0.48));
}

.roof-calendar-day.closed {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.18), rgba(0, 0, 0, 0.5));
}

.roof-calendar-day.nodata {
  background: rgba(0, 0, 0, 0.36);
}

.calendar-day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}

.calendar-day-status {
  align-self: end;
  overflow: hidden;
  font-size: clamp(0.78rem, 1.5vw, 1rem);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day-count {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.75rem;
  font-weight: 700;
}

.roof-calendar-details {
  display: grid;
  grid-template-columns: minmax(210px, 0.35fr) 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.calendar-detail-summary,
.calendar-building-chip {
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
}

.calendar-detail-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
}

.calendar-detail-summary strong {
  color: #fff;
  font-size: 1rem;
}

.calendar-detail-summary span {
  font-size: 1.35rem;
  font-weight: 800;
}

.calendar-detail-summary small {
  color: var(--roof-muted);
  font-size: 0.82rem;
}

.calendar-detail-summary.open span {
  color: var(--roof-open);
}

.calendar-detail-summary.partial span {
  color: var(--roof-accent);
}

.calendar-detail-summary.closed span {
  color: var(--roof-closed);
}

.calendar-detail-summary.manual {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.1);
}

.calendar-detail-buildings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-content: flex-start;
}

.calendar-building-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.55rem 0.75rem;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
}

.calendar-building-chip small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.74rem;
  font-weight: 700;
}

.calendar-building-chip.open {
  border-color: rgba(34, 197, 94, 0.42);
  background: rgba(34, 197, 94, 0.12);
}

.calendar-building-chip.partial {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.12);
}

.calendar-building-chip.closed {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.calendar-building-chip.nodata {
  color: var(--roof-muted);
}

.roof-year-timeline-shell {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.roof-year-timeline-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.roof-year-timeline-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}

.roof-year-timeline-header p {
  margin: 0.2rem 0 0;
  color: var(--roof-muted);
  font-size: 0.86rem;
}

.roof-year-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.roof-year-stat-card {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
}

.roof-year-stat-card.highlight {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.1);
}

.roof-year-stat-card span {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.68rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.roof-year-stat-card strong {
  display: block;
  margin-top: 0.35rem;
  color: #fff;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 300;
  line-height: 1;
}

.roof-year-stat-card small {
  display: block;
  margin-top: 0.4rem;
  color: var(--roof-muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.roof-year-timeline {
  width: 100%;
  overflow: hidden;
}

.roof-year-scroll {
  width: 100%;
  min-width: 0;
}

.roof-year-months,
.roof-year-days {
  display: grid;
}

.roof-year-months {
  margin-bottom: 0.4rem;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.roof-year-months span {
  min-width: 0;
  overflow: hidden;
  padding-right: 0.35rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roof-year-days {
  gap: 0;
  min-height: 2.1rem;
  padding: 1px;
  border: 1px solid var(--roof-border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
}

.roof-year-day {
  display: block;
  min-width: 0;
  min-height: 2rem;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.12);
}

.roof-year-day.open {
  background: var(--roof-open);
}

.roof-year-day.partial {
  background: var(--roof-accent);
}

.roof-year-day.closed {
  background: var(--roof-closed);
}

.roof-year-day.nodata {
  background: rgba(255, 255, 255, 0.18);
}

.roof-year-day.future {
  background: rgba(255, 255, 255, 0.055);
}

.roof-year-day.manual {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.roof-year-day.today {
  box-shadow: inset 0 0 0 2px #111827, 0 0 0 1px rgba(251, 191, 36, 0.95);
}

.roof-year-monthly {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.roof-month-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.55rem;
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.055);
}

.roof-month-row strong {
  grid-row: span 4;
  min-width: 2.4rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.roof-month-row span,
.roof-month-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roof-month-row span {
  font-size: 0.76rem;
  font-weight: 800;
}

.roof-month-row .open {
  color: var(--roof-open);
}

.roof-month-row .partial {
  color: var(--roof-accent);
}

.roof-month-row .closed {
  color: #fca5a5;
}

.roof-month-row small {
  color: var(--roof-muted);
  font-size: 0.72rem;
}

.roof-chart-card {
  min-height: 25rem;
  padding: 1.5rem;
}

.roof-canvas-frame {
  position: relative;
  height: 26rem;
}

.roof-timeline-frame {
  position: relative;
  height: 29rem;
}

#timelineChart,
#tempChart,
#humidityWindChart,
#snapshotChart {
  width: 100%;
  height: 100%;
}

.chart-wrap {
  display: flex;
  min-height: 23rem;
  flex-direction: column;
}

.chart-svg {
  width: 100%;
  min-height: 21rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--roof-border);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.95rem;
}

.legend-swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
}

.table-wrap,
.weather-list {
  padding: 1.5rem;
  overflow-x: auto;
}

.roof-table {
  width: 100%;
  border-collapse: collapse;
}

.roof-table th,
.roof-table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  vertical-align: top;
}

.roof-table th {
  background: rgba(255, 255, 255, 0.06);
  color: var(--roof-muted);
  font-weight: 700;
}

.status-open {
  color: var(--roof-open);
}

.status-closed {
  color: var(--roof-closed);
}

.message-box {
  padding: 1.5rem;
  color: var(--roof-muted);
  font-style: italic;
}

.message-box.error {
  color: #fecaca;
  font-style: normal;
}

@media (max-width: 640px) {
  .roof-page-header,
  .roof-view-mode-bar,
  .roof-button {
    width: 100%;
  }

  .roof-page-header {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .roof-title-block {
    grid-column: 1;
  }

  .roof-back-button {
    justify-self: start;
  }

  .roof-view-mode-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .roof-live-button {
    width: 100%;
  }

  .roof-section-header,
  .roof-compact-grid,
  .roof-calendar-shell,
  .roof-chart-card,
  .table-wrap,
  .weather-list {
    padding: 1rem;
  }

  .roof-compact-grid {
    grid-template-columns: 1fr;
  }

  .roof-calendar-toolbar {
    grid-template-columns: 2.25rem 1fr 2.25rem;
    gap: 0.6rem;
  }

  .roof-icon-button {
    width: 2.25rem;
    height: 2.25rem;
  }

  .roof-calendar-day {
    min-height: 4.75rem;
    padding: 0.45rem;
  }

  .calendar-day-status {
    font-size: 0.72rem;
  }

  .calendar-day-count {
    display: none;
  }

  .roof-calendar-details {
    grid-template-columns: 1fr;
  }

  .roof-year-stats,
  .roof-year-monthly {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .roof-year-day {
    min-height: 1.55rem;
  }

  .calendar-building-chip {
    width: 100%;
    justify-content: space-between;
  }
}
