html:has(.dashboard) { scroll-padding-top: 24px; }

.dashboard {
  display: grid;
  grid-template-columns: 215px minmax(0, 1fr);
  min-height: 100vh;
  background: #f4f6fa;
  line-height: 1.4;
}

.dashboard-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 33px 16px;
  border-inline-end: 1px solid var(--line);
  background: #fff;
}

.dashboard-sidebar .brand { margin-inline: 7px; font-size: 25px; }
.dashboard-sidebar .brand-mark { flex: none; }
.dashboard-nav { display: grid; gap: 5px; margin-top: 45px; }
.dashboard-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 12px;
  border-radius: 999px;
  color: #4f5a70;
  font-size: .95rem;
  font-weight: 600;
  transition: background .2s, color .2s;
}
.dashboard-nav .icon { width: 19px; height: 19px; }
.dashboard-nav .nav-narrow { display: none; }
.dashboard-nav a:hover, .dashboard-nav a[aria-current] { color: #1e40c0; background: #eaf0ff; }

.dashboard-main {
  width: 100%;
  max-width: 1460px;
  margin-inline: auto;
  padding: 42px clamp(24px, 3.2vw, 56px) 26px;
}
.dashboard-heading, .dashboard-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dashboard-heading { align-items: center; margin-bottom: 26px; }
.dashboard-heading h1 { font-size: clamp(2rem, 3.65vw, 3.25rem); line-height: 1.02; letter-spacing: -.045em; overflow-wrap: anywhere; }
.dashboard-heading > div { min-width: 0; }
.dashboard-heading p { margin-top: 8px; color: var(--muted); }
.dashboard-context { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; }
.dashboard-meter { padding: 3px 9px; border-radius: 8px; background: #e9eef8; color: #485674; font-size: .875rem; }
.dashboard-meter strong { color: var(--ink); }
.dashboard .reading-action { min-height: 46px; padding: 10px 19px; gap: 8px; background: #cc332d; }
.dashboard .reading-action:hover { background: #b62a26; }
.dashboard .reading-action .icon { transform: none; }
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dashboard .route-action { min-height: 46px; padding: 10px 17px; gap: 8px; }
.dashboard .route-action .icon { transform: none; }
.overview-link { align-self: baseline; color: #1e40c0; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.overview-link:hover { text-decoration: underline; }
.overview-empty { padding-block: 12px; color: var(--muted); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  grid-template-areas: 'usage invoices' 'reminders invoices';
  gap: 20px;
}
.dashboard-panel, .usage-card { border-radius: 30px; padding: clamp(20px, 2.25vw, 32px); }
.dashboard-panel { background: #fff; border: 1px solid #e4e8ef; }
.dashboard-panel-heading h2 { font-size: clamp(1.4rem, 2.1vw, 1.75rem); line-height: 1.15; letter-spacing: -.025em; }
.dashboard-panel-heading p { margin-top: 4px; color: var(--muted); font-size: .9375rem; }

.usage-card {
  grid-area: usage;
  color: #fff;
  background: radial-gradient(ellipse at 95% 0%, #5678f5b3, transparent 59%), linear-gradient(140deg, #284fe4, #1b36b7 90%);
}
.usage-card .dashboard-panel-heading p { color: #e3eaff; }
.usage-update { text-align: right; line-height: 1.2; }
.usage-update time { display: block; margin-top: 4px; font-weight: 600; }
.usage-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  padding: 16px 18px;
  border: 1px solid #ffffff32;
  border-radius: 19px;
  background: #ffffff12;
  font-variant-numeric: tabular-nums;
}
.usage-total > span { color: #e3eaff; font-size: .875rem; }
.usage-total > div { font-size: clamp(1.9rem, 4vw, 3.45rem); line-height: 1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.usage-total small { font-size: .38em; letter-spacing: 0; color: #e3eaff; }
.usage-tariffs { display: grid; gap: 8px; margin: 0; padding-inline-start: 16px; border-inline-start: 1px solid #ffffff33; }
.usage-tariffs > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 6px; }
.usage-tariffs dt { display: flex; align-items: center; gap: 7px; color: #eaf0ff; font-size: .875rem; }
.usage-tariffs dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.usage-tariffs small { font-size: .8125rem; font-weight: 500; }
.swatch { width: 8px; height: 8px; border-radius: 2px; }
.swatch-high { background: #edf3ff; }
.swatch-low { background: #95b4ff; }

.usage-trend { position: relative; min-width: 0; margin: 24px 0 0; font-variant-numeric: tabular-nums; }
.usage-trend figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-weight: 650; }
.usage-trend figcaption span, .trend-scale, .trend-dates, .trend-key, .chart-note { color: #e0e8ff; font-size: .8125rem; font-weight: 400; }
.trend-key { display: flex; gap: 16px; margin-top: 4px; }
.trend-chart { --plot-height: clamp(108px, 11vw, 152px); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
.trend-scale { display: flex; flex-direction: column; justify-content: space-between; height: calc(var(--plot-height) + 1em); margin-top: calc(24px - .5em); line-height: 1; text-align: right; }
.trend-scroll { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #ffffff6b transparent; }
.trend-series { min-width: calc(var(--point-count) * 56px); padding-top: 24px; }
.trend-plot { position: relative; height: var(--plot-height); background: linear-gradient(#ffffff40, #ffffff40) top / 100% 1px, linear-gradient(#ffffff2b, #ffffff2b) center / 100% 1px, linear-gradient(#ffffff5c, #ffffff5c) bottom / 100% 1px; background-repeat: no-repeat; }
.trend-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trend-plot path { fill: none; stroke: #edf4ff; stroke-width: 2.75; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.trend-point { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.trend-point::after { content: ''; width: 11px; height: 11px; border: 2.5px solid #f4f7ff; border-radius: 50%; background: #364fc9; }
.trend-point.is-reading::after { transform: rotate(45deg); border-radius: 2px; }
.trend-point:is(:hover,:focus-visible,[aria-describedby])::after { background: #fff; box-shadow: 0 0 0 5px #ffffff35; }
.trend-point:focus-visible { outline: 2px solid white; outline-offset: -5px; }
.trend-dates { display: grid; grid-template-columns: repeat(var(--point-count), minmax(0, 1fr)); margin: 12px 0 6px; text-align: center; }
.trend-tooltip { pointer-events: none; position: absolute; z-index: 3; width: max-content; max-width: min(100%, 280px); padding: 12px 14px; border-radius: 12px; background: #fff; color: #142246; box-shadow: 0 6px 24px #10265b40; font-size: .875rem; overflow-wrap: anywhere; }
.trend-tooltip strong, .trend-tooltip small { display: block; }
.trend-tooltip small { color: #53637a; font-size: .78rem; }
.trend-tooltip > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; margin: 6px 0 3px; }
.trend-tooltip b { font-size: 1.05rem; }
.partial-marker { color: #ffccbf; }
.chart-note { margin: 10px 0 0 0; }

.invoices-card { grid-area: invoices; display: flex; flex-direction: column; }
.invoice-list, .reminder-list { margin: 14px 0 0; padding: 0; list-style: none; }
.invoice-list { display: grid; flex: 1; grid-template-rows: repeat(5, 1fr); }
.invoice-list li + li, .reminder-list li + li { border-top: 1px solid var(--line); }
.invoice-button, .reminder-row {
  display: grid;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  text-align: left;
  transition: background .2s;
}
.invoice-button { grid-template-columns: auto minmax(0, 1fr) auto auto; height: 100%; min-height: 68px; }
.invoice-button:hover, .reminder-row:hover { background: #f5f7fd; }
.item-icon { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 11px; color: #2c4cba; background: #edf2ff; }
.item-icon .icon { width: 19px; height: 19px; }
.coral-icon { background: #ffede8; color: #b72d27; }
.invoice-month, .invoice-value, .reminder-copy { display: grid; gap: 1px; }
.invoice-month span, .invoice-value span, .reminder-copy span { color: var(--muted); font-size: .875rem; }
.invoice-value { text-align: right; white-space: nowrap; }
.invoice-value .invoice-unpaid { color: #ae302b; font-weight: 600; }
.row-chevron { width: 16px; height: 16px; color: #68758e; }
.invoice-summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding: 14px 16px; border-radius: 16px; background: #fff3ef; color: #8c332f; font-size: .9375rem; }
.invoice-summary strong { white-space: nowrap; font-size: 1.125rem; }

.reminders-card { grid-area: reminders; padding-block: 22px 17px; }
.reminder-list { margin-top: 8px; }
.reminder-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.reminder-row time { font-size: .875rem; color: #364569; font-weight: 600; text-align: right; white-space: nowrap; }
.reminder-list li:first-child time { color: #a72e29; }
.dashboard-footer { padding-top: 18px; color: var(--muted); font-size: .8125rem; }

.dashboard-dialog { padding: 28px; max-width: 440px; }
.dashboard-dialog h2 { margin: 0 34px 12px 0; font-size: 1.8rem; letter-spacing: -.04em; }
.dashboard-dialog > p { margin-bottom: 18px; font-size: .9375rem; line-height: 1.4; }
.dialog-dismiss { position: absolute; top: 18px; right: 18px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: #edf1f8; color: var(--navy); }
.reading-meter-context { padding: 9px 12px; border-radius: 10px; background: #edf2ff; }
.reading-meter-context strong { color: var(--ink); }

.invoice-drawer {
  inset: 0 0 0 auto;
  width: min(640px, 100%);
  height: 100dvh;
  max-width: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border-radius: 24px 0 0 24px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.invoice-drawer[open] { animation: invoice-enter .28s var(--ease) both; }
.invoice-drawer::backdrop { background: #12213b65; backdrop-filter: blur(3px); }
@keyframes invoice-enter { from { transform: translateX(32px); opacity: .35; } }

.invoice-drawer-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 26px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.invoice-drawer-header h2 { margin: 0; font-size: clamp(1.625rem, 4vw, 2rem); letter-spacing: -.04em; }
.invoice-drawer-header p { margin-top: 5px; color: var(--muted); font-size: .9375rem; }
.invoice-drawer .dialog-dismiss { position: static; }
.invoice-drawer .dialog-dismiss:hover { background: #dfe8fb; }
.invoice-drawer-body { padding: 20px 26px 24px; }
.invoice-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 19px;
  border-radius: 18px;
  background: linear-gradient(130deg, #edf2ff, #f5f7fd);
}
.invoice-balance > div { display: grid; gap: 4px; }
.invoice-balance > div:last-child { justify-items: end; text-align: right; }
.invoice-balance span { color: #4a5874; font-size: .875rem; }
.invoice-balance strong { font-size: clamp(1.65rem, 5vw, 2.45rem); letter-spacing: -.045em; line-height: 1.1; }
.invoice-balance .invoice-status { padding: 3px 9px; border-radius: 999px; background: #e1f1e9; color: #215a44; font-weight: 700; }
.invoice-balance .balance-unpaid { background: #ffe9e2; color: #9f2f28; }
.invoice-balance time { color: var(--navy); font-weight: 600; white-space: nowrap; }

.invoice-source { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.invoice-source p, .invoice-consumption > p { color: var(--muted); font-size: .875rem; }
.invoice-source-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; }
.pdf-select, .pdf-open { display: inline-flex; align-items: center; min-height: 40px; padding: 5px 12px; border: 0; border-radius: 999px; background: #edf2ff; color: #1e40c0; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.pdf-select:hover, .pdf-open:hover { background: #dce6ff; }
.pdf-open { background: var(--navy); color: white; }
.pdf-open:hover { background: #2449bf; }
.invoice-source [hidden] { display: none; }

.invoice-section { margin-top: 22px; }
.invoice-section h3, .invoice-section summary { font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
.invoice-metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 10px 0 0; }
.invoice-metadata > div { padding: 10px 12px; border-radius: 10px; background: #f5f7fb; }
.invoice-metadata dt { color: #54617b; font-size: .875rem; }
.invoice-metadata dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }

.invoice-section-heading { display: flex; gap: 6px; flex-wrap: wrap; justify-content: space-between; align-items: baseline; }
.invoice-section-heading > strong { color: #2143c1; white-space: nowrap; }
.invoice-reading-context { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 10px; margin-top: 4px; }
.invoice-tariff-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.invoice-tariff-table th, .invoice-tariff-table td { padding: 8px 5px; text-align: end; }
.invoice-tariff-table thead th { background: #f5f7fb; font-size: .875rem; color: #4d5b74; font-weight: 600; }
.invoice-tariff-table tbody tr + tr { border-top: 1px solid var(--line); }
.invoice-tariff-table th:first-child { padding-inline-start: 12px; text-align: start; }
.invoice-tariff-table th:last-child, .invoice-tariff-table td:last-child { padding-inline-end: 12px; }
.invoice-tariff-table tbody td:last-child { font-weight: 700; }

.invoice-charges { border-block: 1px solid var(--line); }
.invoice-charges summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 2px; list-style: none; cursor: pointer; }
.invoice-charges summary::-webkit-details-marker { display: none; }
.invoice-charges summary .icon { width: 16px; height: 16px; color: var(--blue); }
.invoice-charges[open] summary .icon { transform: rotate(90deg); }
.invoice-charge-list { margin: 0 0 10px; font-size: .9375rem; }
.invoice-charge-list div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-top: 1px solid #edf0f5; }
.invoice-charge-list dd { margin: 0; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.invoice-charge-list div:last-child { font-weight: 700; }
.invoice-detail-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.reading-form { display: grid; gap: 5px; }
.reading-form label { font-weight: 700; }
.reading-form small { color: var(--muted); font-size: .875rem; }
.reading-form input { width: 100%; min-width: 0; height: 44px; margin-bottom: 10px; padding: 8px 12px; border: 1px solid #b3bed1; border-radius: 10px; background: white; color: var(--ink); font: inherit; }
.reading-error { color: #a12c26; }
.reading-feedback { position: fixed; z-index: 2; inset: auto 16px 16px auto; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: 0 8px 24px #13234426; }

@media (max-width: 1130px) {
  .dashboard { grid-template-columns: 183px minmax(0, 1fr); }
  .dashboard-sidebar { padding-inline: 12px; }
  .dashboard-sidebar .brand { margin-inline: 0; font-size: 23px; }
  .dashboard-grid { gap: 14px; }
  .invoice-button { gap: 8px; }
  .row-chevron { display: none; }
  .invoice-button { grid-template-columns: auto minmax(0, 1fr) auto; }
}

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'usage' 'reminders' 'invoices'; }
  .invoice-list { grid-template-rows: none; }
  .row-chevron { display: block; }
  .invoice-button { grid-template-columns: auto minmax(0, 1fr) auto auto; }
}

@media (max-width: 640px) {
  .dashboard { display: block; }
  .dashboard-sidebar { position: static; min-height: 0; padding: 12px 16px 8px; border-inline-end: 0; border-block-end: 1px solid var(--line); }
  .dashboard-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin-top: 8px; }
  .dashboard-nav a { flex-direction: column; justify-content: center; gap: 3px; padding: 6px 1px; border-radius: 13px; font-size: .8125rem; }
  .dashboard-nav .nav-wide { display: none; }
  .dashboard-nav .nav-narrow { display: inline; }
  .dashboard-main { padding: 24px 14px; }
  .dashboard-heading { align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  .dashboard-heading h1 { font-size: clamp(1.65rem, 6.5vw, 2.35rem); }
  .dashboard-heading p { font-size: .875rem; }
  .dashboard-heading:has(.app-actions) { flex-wrap: wrap; }
  .app-actions { justify-content: flex-start; }
  .dashboard .reading-action { min-height: 42px; padding: 8px 12px; gap: 4px; font-size: .875rem; }
  .dashboard .route-action { min-height: 42px; padding: 8px 12px; gap: 4px; font-size: .875rem; }
  .dashboard .reading-action .icon { width: 16px; height: 16px; }
  .dashboard .route-action .icon { width: 16px; height: 16px; }
  .dashboard-panel, .usage-card { border-radius: 23px; padding-inline: 16px; }
  .usage-update { max-width: 9.25rem; }
  .usage-metrics { margin-top: 18px; padding: 13px; gap: 9px; }
  .usage-tariffs { padding-inline-start: 10px; }
  .usage-tariffs > div { gap: 0 4px; }
  .invoice-drawer { border-radius: 0; }
  .invoice-drawer-header { padding: 17px 16px 13px; }
  .invoice-drawer-body { padding: 15px 16px 22px; }
  .invoice-source { grid-template-columns: auto minmax(0, 1fr); }
  .invoice-source-actions { grid-column: 2; justify-content: start; }
  .invoice-metadata { gap: 8px; }
}

@media (max-width: 365px) {
  .dashboard-sidebar { padding-inline: 8px; }
  .dashboard-heading { flex-wrap: wrap; }
  .usage-metrics { grid-template-columns: minmax(0, .8fr) minmax(0, 1fr); }
  .row-chevron { display: none; }
  .invoice-button { grid-template-columns: auto minmax(0, 1fr) auto; }
  .dashboard-nav { gap: 2px; }
  .invoice-tariff-table { font-size: .875rem; }
  .invoice-balance { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html:has(.dashboard) { scroll-behavior: auto; }
  .dashboard a, .dashboard button { transition: none; }
  .dashboard .button:hover, .dashboard .button:active { transform: none; }
  .invoice-drawer[open] { animation: none; }
}
