:root {
  --ink: #17211b;
  --muted: #6f7b73;
  --paper: #eef0e9;
  --surface: #fafbf7;
  --surface-strong: #ffffff;
  --line: #d9ddd4;
  --green: #244b35;
  --green-soft: #dce9dd;
  --lime: #b8d36c;
  --orange: #e58b42;
  --red: #c85448;
  --yellow: #d7aa38;
  --blue: #527d8c;
  --shadow: 0 18px 55px rgba(28, 47, 35, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 2%, rgba(184, 211, 108, 0.16), transparent 28rem),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid rgba(23, 33, 27, 0.12);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--green);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark i {
  position: absolute;
  bottom: 9px;
  width: 4px;
  border-radius: 6px;
  background: var(--lime);
  content: "";
}

.brand-mark::before {
  left: 10px;
  height: 9px;
}

.brand-mark i {
  left: 17px;
  height: 16px;
}

.brand-mark::after {
  left: 24px;
  height: 22px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.panel-actions,
.chart-controls,
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.system-state {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9da69f;
}

.system-state.online .status-dot {
  background: #5f9c63;
  box-shadow: 0 0 0 4px rgba(95, 156, 99, 0.13);
}

.system-state.error .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(200, 84, 72, 0.12);
}

.dashboard-header {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px 16px;
}

.dashboard-title {
  flex: 0 0 auto;
}

.dashboard-title .eyebrow {
  margin-bottom: 4px;
}

.dashboard-title .last-update {
  margin: 4px 0 0;
}

.freshness-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(185px, 1fr)) auto;
  gap: 8px;
  align-items: stretch;
}

.freshness-item {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 12px 9px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.freshness-item::before {
  position: absolute;
  top: 15px;
  left: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9da69f;
  content: "";
}

.freshness-item.is-current::before {
  background: #5f9c63;
  box-shadow: 0 0 0 3px rgba(95, 156, 99, 0.13);
}

.freshness-item.is-stale::before {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(229, 139, 66, 0.13);
}

.freshness-item span,
.freshness-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.freshness-item strong {
  overflow: hidden;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refresh-button {
  min-height: 100%;
}

.eyebrow {
  margin: 0 0 12px;
  color: #718071;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.18em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 2.2vw, 34px);
  font-weight: 400;
  letter-spacing: -0.035em;
}

h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

.last-update,
.subtle,
.chart-help,
.dialog-note {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: var(--radius);
  background: rgba(250, 251, 247, 0.88);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 14px;
}

.range-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 13px;
  background: #e5e8e1;
}

.range-tabs button,
.quiet-button,
.small-button,
.icon-button {
  border: 0;
  background: transparent;
}

.range-tabs button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.range-tabs button.active {
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 3px 12px rgba(23, 33, 27, 0.08);
}

.quiet-button,
.small-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #516057;
  background: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 650;
}

.quiet-button:hover,
.small-button:hover {
  color: var(--ink);
  background: #fff;
}

.link-button {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.custom-range {
  display: flex;
  gap: 9px;
  align-items: end;
}

.custom-range[hidden] {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: #74927f;
  box-shadow: 0 0 0 3px rgba(77, 119, 91, 0.13);
  outline: none;
}

.filter-row {
  flex: 1 1 420px;
  justify-content: flex-end;
}

.device-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.device-chip {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.device-chip.active {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.device-chip i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
}

.switch-label {
  display: inline-flex;
  grid: none;
  gap: 7px;
  align-items: center;
  white-space: nowrap;
}

.switch-label input {
  min-height: auto;
  accent-color: var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 170px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 18px;
  background: rgba(250, 251, 247, 0.85);
}

.metric-primary {
  color: #fff;
  background:
    radial-gradient(circle at 88% 16%, rgba(184, 211, 108, 0.22), transparent 9rem),
    var(--green);
}

.metric-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.025em;
}

.metric-primary .metric-head,
.metric-primary .metric-note {
  color: rgba(255, 255, 255, 0.7);
}

.metric-value {
  display: flex;
  gap: 7px;
  align-items: baseline;
  margin: 28px 0 8px;
}

.metric-value strong {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 400;
  letter-spacing: -0.055em;
  text-overflow: ellipsis;
}

.metric-value span {
  color: var(--muted);
  font-size: 12px;
}

.metric-primary .metric-value span {
  color: rgba(255, 255, 255, 0.62);
}

.metric-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.metric-note .positive {
  color: #527c57;
}

.metric-note .negative {
  color: var(--red);
}

.live-pill {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.live-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(184, 211, 108, 0.15);
}

.metric-symbol {
  color: #819087;
  font-family: Georgia, serif;
  font-size: 17px;
}

.traffic-light {
  display: inline-flex;
  gap: 4px;
  padding: 5px 7px;
  border-radius: 999px;
  background: #e4e8e0;
}

.traffic-light i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bdc5bd;
}

.traffic-light [data-color="rot"].active {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 84, 72, 0.14);
}

.traffic-light [data-color="gelb"].active {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(215, 170, 56, 0.14);
}

.traffic-light [data-color="gruen"].active {
  background: #5d9b64;
  box-shadow: 0 0 0 3px rgba(93, 155, 100, 0.14);
}

.chart-panel,
.heatmap-panel,
.device-panel,
.price-detail-panel,
.lower-grid .panel {
  margin-bottom: 18px;
  padding: 24px;
}

.panel-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.chart-head {
  align-items: end;
}

.chart-controls {
  align-items: end;
}

.chart-controls label {
  min-width: 150px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 4px;
}

.chart-wrap {
  position: relative;
  height: 390px;
  min-height: 280px;
}

#power-chart {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  width: max-content;
  max-width: min(310px, calc(100vw - 64px));
  padding: 10px 12px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: #fff;
  background: rgba(23, 33, 27, 0.94);
  box-shadow: 0 12px 35px rgba(23, 33, 27, 0.22);
  font-size: 11px;
  line-height: 1.6;
}

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

.empty-chart {
  position: absolute;
  inset: 45% 0 auto;
  color: var(--muted);
  text-align: center;
}

.chart-help {
  margin: 8px 0 0;
  text-align: right;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.compact-panel {
  min-height: 280px;
  padding: 21px;
}

.compact-panel .panel-head {
  margin-bottom: 20px;
}

.compact-panel h2 {
  font-size: 25px;
}

.distribution {
  display: grid;
  gap: 15px;
}

.distribution-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 7px 12px;
  align-items: center;
  font-size: 12px;
}

.distribution-row strong {
  font-variant-numeric: tabular-nums;
}

.bar-track {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e7df;
}

.bar-track i {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.distribution-row[data-color="gruen"] i {
  background: #6aa36c;
}

.distribution-row[data-color="gelb"] i {
  background: var(--yellow);
}

.distribution-row[data-color="rot"] i {
  background: var(--red);
}

.forecast-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.forecast-value {
  min-height: 85px;
  padding: 13px;
  border-radius: 13px;
  background: #eef1ea;
}

.forecast-value span,
.forecast-value strong {
  display: block;
}

.forecast-value span {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
}

.forecast-value strong {
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 400;
}

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

.peak-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.peak-list strong {
  color: var(--ink);
  font-size: 12px;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap {
  display: grid;
  grid-template-columns: 42px repeat(24, minmax(19px, 1fr));
  gap: 3px;
  min-width: 760px;
}

.heat-cell,
.heat-label {
  min-height: 25px;
  border-radius: 5px;
}

.heat-cell {
  border: 0;
  background: #e6eae3;
}

.heat-cell:hover {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.heat-label {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 9px;
}

.heat-day {
  justify-content: start;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-variant-numeric: tabular-nums;
}

td.device-name {
  min-width: 170px;
  font-weight: 720;
}

.device-badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
}

.device-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.device-badge.online i {
  background: #68a46d;
}

.control-button {
  min-width: 78px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #fff;
  font-size: 10px;
}

.control-button.on {
  border-color: #779a7e;
  color: #285538;
  background: #e2eee2;
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.loading-cell {
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.price-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.price-summary > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.48);
}

.price-summary span,
.price-summary strong {
  display: block;
}

.price-summary span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.price-summary strong {
  font-family: Georgia, serif;
  font-size: 19px;
  font-weight: 400;
}

.price-table-wrap {
  max-height: 430px;
  overflow: auto;
}

.price-table-wrap th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--surface);
}

.price-badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 10px;
}

.price-badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9da69f;
}

.price-badge[data-color="gruen"] i {
  background: #5f9c63;
}

.price-badge[data-color="gelb"] i {
  background: var(--yellow);
}

.price-badge[data-color="rot"] i {
  background: var(--red);
}

.lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.event-list {
  display: grid;
  gap: 9px;
}

.event-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 12px;
  border-radius: 13px;
  background: #eef1ea;
}

.event-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--orange);
}

.event-item.resolved .event-dot {
  background: #8ea092;
}

.event-item strong,
.event-item small {
  display: block;
}

.event-item strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.event-item p,
.event-item small {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.event-delete {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 3px 36px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

dialog {
  width: min(520px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid rgba(23, 33, 27, 0.13);
  border-radius: 20px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(23, 33, 27, 0.28);
}

dialog:not([open]) {
  display: none;
}

dialog::backdrop {
  background: rgba(21, 30, 25, 0.45);
  backdrop-filter: blur(4px);
}

.wide-dialog {
  width: min(900px, calc(100% - 28px));
}

.dialog-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dialog-actions,
.key-actions,
.settings-section-head {
  display: flex;
  gap: 9px;
  align-items: center;
}

.dialog-actions {
  justify-content: flex-end;
}

.dialog-actions .primary-button,
.dialog-actions .quiet-button {
  min-width: 110px;
}

.key-settings {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 9px 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
}

.key-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.key-status.is-ok {
  color: #3f7448;
}

.key-status.is-error {
  color: var(--red);
}

.key-status.is-pending {
  color: #8a6817;
}

.settings-section-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.settings-section-head h3 {
  margin-bottom: 0;
}

.icon-button {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  color: var(--muted);
  background: #e7eae4;
  font-size: 23px;
  line-height: 1;
}

.settings-devices {
  display: grid;
  gap: 10px;
}

.settings-device {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(85px, 0.7fr)) auto;
  gap: 9px;
  align-items: end;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.settings-device .checkbox-field {
  display: flex;
  align-items: center;
  min-height: 38px;
}

.settings-device .checkbox-field input {
  min-height: auto;
}

.settings-rules {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.rule-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.rule-row span {
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(430px, calc(100vw - 44px));
  padding: 13px 16px;
  border-radius: 12px;
  color: #fff;
  background: rgba(23, 33, 27, 0.95);
  box-shadow: 0 16px 45px rgba(23, 33, 27, 0.25);
  font-size: 12px;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #e5e9e2;
  font-family: Consolas, monospace;
  font-size: 0.92em;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1280px) {
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100% - 24px, 1540px);
  }

  .top-actions #notification-button {
    display: none;
  }

  .dashboard-header {
    align-items: stretch;
    padding: 14px 2px;
  }

  .freshness-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr)) auto;
  }

  .control-panel,
  .filter-row {
    align-items: stretch;
  }

  .control-panel {
    flex-direction: column;
  }

  .range-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
  }

  .range-tabs button {
    padding: 0 6px;
  }

  .filter-row {
    flex: 0 1 auto;
    flex-direction: column;
    width: 100%;
  }

  .device-filters {
    justify-content: flex-start;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lower-grid {
    grid-template-columns: 1fr;
  }

  .settings-device {
    grid-template-columns: 1fr 1fr;
  }

  .settings-device > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 580px) {
  .brand small,
  .system-state span:last-child,
  .chart-help {
    display: none;
  }

  .system-state {
    padding: 10px;
  }

  .top-actions {
    gap: 6px;
  }

  .dashboard-header {
    display: grid;
    gap: 10px;
  }

  .dashboard-title {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: space-between;
  }

  .dashboard-title .eyebrow {
    display: none;
  }

  .dashboard-title h1 {
    font-size: 27px;
  }

  .dashboard-title .last-update {
    margin: 0;
    font-size: 10px;
  }

  .freshness-grid {
    grid-template-columns: 1fr 1fr;
  }

  .refresh-button {
    grid-column: 1 / -1;
    min-height: 38px;
  }

  .custom-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .custom-range button {
    grid-column: 1 / -1;
  }

  .metric-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 145px;
  }

  .metric-value {
    margin-top: 20px;
  }

  .chart-panel,
  .heatmap-panel,
  .device-panel,
  .price-detail-panel,
  .lower-grid .panel {
    padding: 17px;
  }

  .chart-head {
    display: grid;
  }

  .chart-controls {
    width: 100%;
  }

  .chart-controls label {
    flex: 1;
  }

  .chart-wrap {
    height: 315px;
  }

  .panel-head {
    flex-wrap: wrap;
  }

  footer {
    gap: 12px;
  }

  .settings-device {
    grid-template-columns: 1fr;
  }

  .settings-device > :first-child {
    grid-column: auto;
  }

  .price-summary {
    grid-template-columns: 1fr 1fr;
  }

  .key-settings {
    grid-template-columns: 1fr;
  }

  .key-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .key-status {
    grid-column: auto;
  }

  .dialog-form {
    padding: 18px;
  }

  .dialog-actions {
    align-items: stretch;
  }

  .dialog-actions > * {
    flex: 1;
  }
}

@media print {
  .top-actions,
  .control-panel,
  .panel-actions,
  .chart-controls,
  .chart-help,
  .event-delete,
  .control-button,
  footer {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page-shell {
    width: 100%;
  }

  .panel,
  .metric {
    break-inside: avoid;
    box-shadow: none;
  }
}
