:root {
  --ink: #0d0d10;
  --muted: #6a6a75;
  --purple-600: #5c2bd6;
  --purple-500: #7f5ce0;
  --purple-300: #a893ea;
  --purple-200: #d2c7f5;
  --purple-150: #ded6f3;
  --purple-100: #ece6fa;
  --purple-800: #3d1b96;
  --link-underline: #cabdf0;
  --bar-border: #3a3543;
  --panel: #fff;
  --ground: #f5f4f7;
  --rule-strong: #d4d4d8;
  --rule-soft: #e4e4e7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--purple-600);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
}

a:hover {
  color: var(--purple-800);
  border-bottom-color: var(--purple-800);
}

.dashboard {
  max-width: 980px;
  margin: 0 auto;
  background: var(--ground);
  border: 1px solid var(--rule-strong);
  box-sizing: border-box;
}

/* Brand bar */
.brand-bar {
  height: 58px;
  background: var(--ink);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-bar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  width: 26px;
  height: 26px;
  background: var(--purple-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-word {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.refresh-btn {
  padding: 6px 12px;
  border: 1px solid var(--bar-border);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 120ms ease-out;
  flex-shrink: 0;
}

.refresh-btn.is-busy {
  opacity: 0.5;
}

/* Context strip */
.context-strip {
  background: var(--panel);
  padding: 11px 22px;
  border-bottom: 1px solid var(--rule-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.context-strip__month {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.context-strip__meta {
  font-size: 12px;
  color: var(--muted);
}

/* Error line */
.error-line {
  margin: 0;
  padding: 20px 22px 0;
  background: var(--panel);
  font-size: 15px;
  color: var(--ink);
}

/* Hero row */
.hero-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--panel);
  border-bottom: 1px solid var(--rule-strong);
}

.hero-cell {
  padding: 30px 22px 28px;
  border-right: 1px solid var(--rule-soft);
}

.hero-cell:last-child {
  border-right: none;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 16px;
}

.figure {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.figure--forecast {
  color: var(--purple-600);
}

.figure--savings {
  color: var(--ink);
}

.figure__sign {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.figure__currency,
.figure__pounds,
.figure__pence {
  display: inline-block;
}

.figure__currency {
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
}

.figure__pounds {
  font-size: 80px;
  font-weight: 600;
  line-height: 0.84;
  letter-spacing: -0.035em;
}

.figure__pence {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.figure__currency.is-loading,
.figure__pounds.is-loading,
.figure__pence.is-loading {
  color: transparent;
  background: var(--purple-100);
}

.figure__currency.is-loading {
  min-width: 20px;
}

.figure__pounds.is-loading {
  min-width: 110px;
}

.figure__pence.is-loading {
  min-width: 34px;
}

.progress {
  margin-top: 20px;
  height: 8px;
  background: var(--purple-100);
}

.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--purple-600);
  transition: width 200ms ease-out;
}

.sparkline {
  margin-top: 20px;
  height: 34px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.sparkline__bar {
  flex: 1;
  min-height: 1px;
  background: var(--purple-100);
}

.caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.caption strong {
  color: var(--ink);
  font-weight: 600;
}

/* Daily panel */
.daily-panel {
  background: var(--panel);
  padding: 22px 22px 18px;
}

.daily-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.daily-panel__header .eyebrow {
  margin-bottom: 0;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend__swatch {
  width: 9px;
  height: 9px;
  display: inline-block;
}

.legend__swatch--actual {
  background: var(--purple-600);
}

.legend__swatch--forecast {
  background: var(--purple-150);
}

.daily-chart {
  overflow-x: auto;
}

.daily-chart svg {
  display: block;
  min-width: 480px;
  width: 100%;
  height: auto;
}

.daily-chart text {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.dc-bar {
  fill: var(--purple-600);
}

.dc-bar.is-forecast {
  fill: var(--purple-150);
}

.dc-average {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
}

@media (hover: hover) and (pointer: fine) {
  .dc-bar {
    transition: fill 120ms ease-out;
    cursor: default;
  }

  .dc-bar:hover {
    fill: var(--purple-800);
  }

  .mc-bar {
    transition: fill 120ms ease-out;
    cursor: default;
  }

  .mc-bar:hover {
    fill: var(--purple-800);
  }
}

/* Monthly cost chart */
.monthly-panel {
  background: var(--panel);
  padding: 22px 22px 18px;
  border-top: 1px solid var(--rule-strong);
}

.monthly-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.monthly-panel__header .eyebrow {
  margin-bottom: 0;
}

.legend__swatch--trend {
  width: 12px;
  height: 0;
  border-top: 2px dashed var(--muted);
  background: none;
}

.monthly-chart {
  overflow-x: auto;
}

.monthly-chart svg {
  display: block;
  min-width: 480px;
  width: 100%;
  height: auto;
}

.monthly-chart text {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.mc-bar {
  fill: var(--purple-600);
}

.mc-bar.is-empty {
  fill: var(--purple-150);
}

.mc-trend {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
}

.mc-gridline {
  stroke: var(--rule-soft);
  stroke-width: 1;
}

.mc-axis {
  stroke: var(--rule-strong);
  stroke-width: 1;
}

.mc-tick-label {
  fill: var(--muted);
  font-size: 11px;
}

/* Monthly history */
.history-panel {
  background: var(--panel);
  padding: 22px 22px 18px;
  border-top: 1px solid var(--rule-strong);
}

.history-panel__header {
  margin-bottom: 16px;
}

.history-panel__header .eyebrow {
  margin-bottom: 0;
}

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

.history-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th,
.history-table td {
  padding: 8px 6px;
  text-align: right;
  white-space: nowrap;
}

.history-table th:first-child,
.history-table td:first-child {
  padding-left: 0;
}

.history-table th:last-child,
.history-table td:last-child {
  padding-right: 0;
}

.history-table th.is-left,
.history-table td.is-left {
  text-align: left;
}

.history-table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule-strong);
}

.history-table tbody td {
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table td.is-muted {
  color: var(--muted);
}

.history-table td.is-left {
  color: var(--muted);
  font-size: 11px;
}

.history-table .is-loading-row td {
  color: transparent;
  background: var(--purple-100);
}

.bar-tooltip {
  position: fixed;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  padding: 6px 8px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  transform: translate(-50%, -100%);
}

/* Mobile composition - below ~720px the hero grid collapses to stacked
   full-width bands (dropping the border-right in favour of a border-bottom),
   and every section shrinks to the mobile type/spacing scale. */
@media (max-width: 720px) {
  .brand-bar {
    height: 52px;
    padding: 0 16px;
    gap: 12px;
  }

  .brand-bar__left {
    gap: 9px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .brand-word {
    font-size: 11px;
    letter-spacing: 0.01em;
  }

  .refresh-btn {
    padding: 6px 11px;
    font-size: 11px;
  }

  .context-strip {
    padding: 10px 16px;
    gap: 12px;
  }

  .context-strip__month {
    font-size: 14px;
  }

  .context-strip__meta {
    font-size: 11px;
  }

  .error-line {
    padding: 16px 16px 0;
  }

  .hero-row {
    display: block;
    border-bottom: none;
  }

  .hero-cell {
    padding: 20px 16px;
    border-right: none;
    border-bottom: 1px solid var(--rule-strong);
  }

  .eyebrow {
    font-size: 10px;
    margin-bottom: 10px;
  }

  .figure {
    gap: 3px;
  }

  .figure__sign,
  .figure__currency {
    font-size: 22px;
  }

  .figure__pounds {
    font-size: 56px;
  }

  .figure__pence {
    font-size: 22px;
  }

  .figure__pounds.is-loading {
    min-width: 76px;
  }

  .progress,
  .sparkline {
    margin-top: 14px;
  }

  .sparkline {
    gap: 2px;
  }

  .caption {
    margin-top: 7px;
    font-size: 11px;
  }

  .daily-panel {
    padding: 18px 16px 16px;
  }

  .daily-panel__header {
    margin-bottom: 12px;
  }

  .daily-panel__header .legend {
    display: none;
  }

  .monthly-panel {
    padding: 18px 16px 16px;
  }

  .monthly-panel__header {
    margin-bottom: 12px;
  }

  .monthly-panel__header .legend {
    display: none;
  }

  .history-panel {
    padding: 18px 16px 16px;
  }

  .history-panel__header {
    margin-bottom: 12px;
  }
}
