* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* No max-width - fills the window on any size screen, since more room is
     directly more of the ~90-bar Day view and 48-bar Hour view visible
     without scrolling. */
  margin: 0 auto;
  padding: 16px 32px 40px;
  color: #1b1b1b;
  font-size: 14px;
}

a {
  color: #6b2c81;
}

.electricity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}

.electricity-header h1 {
  font-size: 18px;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status {
  font-size: 12px;
  color: #888;
  max-width: 240px;
  text-align: right;
}

.sync-status.hidden {
  display: none;
}

.sync-status.sync-status-error {
  color: #c0392b;
}

.sync-now-btn {
  background: none;
  border: 1px solid #6b2c81;
  color: #6b2c81;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.sync-now-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

#refresh-btn {
  background: none;
  border: none;
  color: #6b2c81;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

#refresh-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

@keyframes electricity-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

#refresh-btn.refreshing {
  animation: electricity-refresh-spin 0.8s linear infinite;
}

.state {
  padding: 40px 0;
  text-align: center;
  color: #888;
  font-size: 13px;
}

#error p {
  color: #c0392b;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #e2e2e2;
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 16px;
}

.view-toggle-btn {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #6b2c81;
  background: #fff;
  border: none;
  cursor: pointer;
}

.view-toggle-btn + .view-toggle-btn {
  border-left: 1px solid #e2e2e2;
}

.view-toggle-btn.active {
  background: #6b2c81;
  color: #fff;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: -6px 0 14px;
  font-size: 12px;
}

.breadcrumb-item {
  background: none;
  border: none;
  padding: 2px 3px;
  font: inherit;
  font-size: 12px;
  color: #6b2c81;
  cursor: pointer;
}

.breadcrumb-item:disabled {
  color: #888;
  font-weight: 600;
  cursor: default;
}

.breadcrumb-item:not(:disabled):hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #ccc;
}

.summary-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.summary-card {
  flex: 1 1 120px;
  min-width: 110px;
  padding: 10px 12px;
  background: #f7f2f9;
  border: 1px solid #e6d9ec;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.summary-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
}

.summary-card-value {
  font-size: 16px;
  font-weight: 700;
  color: #1b1b1b;
}

.chart-section {
  margin-bottom: 24px;
}

.chart-scroll {
  overflow-x: auto;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 8px 4px 0;
}

#usage-chart,
#interval-chart {
  display: block;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 11px;
  color: #555;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chart-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.weekend-swatch {
  background: rgba(107, 44, 129, 0.06);
  border: 1px solid rgba(107, 44, 129, 0.35);
}

.appliance-estimate-swatch {
  background: repeating-linear-gradient(
    45deg,
    rgba(107, 44, 129, 0.18),
    rgba(107, 44, 129, 0.18) 2px,
    rgba(107, 44, 129, 0.55) 2px,
    rgba(107, 44, 129, 0.55) 3px
  );
  border: 1px solid #6b2c81;
}

.chart-legend-line-swatch {
  width: 10px;
  height: 0;
  border-radius: 0;
  border-top: 1.5px solid #6b2c81;
  align-self: center;
}

.chart-hint {
  font-size: 11px;
  color: #999;
  margin: 6px 0 0;
}

.day-month-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.hour-section {
  margin-bottom: 24px;
  padding: 12px 14px;
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
}

.hour-day-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.hour-day-label-wrap {
  position: relative;
  display: inline-block;
}

.hour-day-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #1b1b1b;
  min-width: 160px;
  text-align: center;
  cursor: pointer;
  border-bottom: 1px dashed #ccc;
  border-radius: 2px;
}

.hour-day-label:hover,
.hour-day-label:focus-visible {
  color: #6b2c81;
  border-bottom-color: #6b2c81;
  outline: none;
}

.hour-day-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  border: none;
}

.day-nav {
  background: none;
  border: none;
  color: #888;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}

.day-nav:hover:not(:disabled) {
  color: #6b2c81;
}

.day-nav:disabled {
  color: #ddd;
  cursor: default;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 12px;
  color: #555;
}

.detail-meta strong {
  color: #1b1b1b;
}

.same-time-yesterday {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: #f7f2f9;
  border: 1px solid #e6d9ec;
  border-radius: 8px;
  font-size: 12px;
  color: #555;
}

.same-time-yesterday strong {
  color: #1b1b1b;
}

.amount-negative {
  color: #c0392b;
}

.amount-positive {
  color: #22875a;
}

.table-details {
  margin-bottom: 16px;
  font-size: 12px;
}

.table-details summary {
  cursor: pointer;
  color: #6b2c81;
  font-weight: 600;
  padding: 4px 0;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#data-table th,
#data-table td {
  padding: 6px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid #f0f0f0;
}

#data-table th:first-child,
#data-table td:first-child {
  text-align: left;
}

#data-table th {
  color: #888;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#data-table tbody tr:hover {
  background: #f7f2f9;
}

.muted {
  font-size: 12px;
  color: #888;
}

.page-footer {
  margin-top: 24px;
  text-align: right;
}

.page-footer a {
  margin-right: 12px;
}

.app-version {
  color: #bbb;
  cursor: default;
}

.chart-tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: #1b1b1b;
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 6px;
  max-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}
