.battery-main {
  padding-bottom: 48px;
}

.battery-page-header {
  min-height: 132px;
}

.battery-header-meta,
.battery-toolbar,
.battery-card__header,
.chart-legend,
.chart-footer {
  display: flex;
  align-items: center;
}

.battery-header-meta {
  justify-content: flex-end;
  gap: 10px;
}

.vehicle-identity {
  display: grid;
  min-height: 44px;
  align-content: center;
  gap: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 0 14px;
  background: var(--surface);
}

.vehicle-identity span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
}

.vehicle-identity strong {
  color: var(--text-soft);
  font-size: 11px;
}

.quality-badge,
.estimate-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgb(254 201 49 / 28%);
  border-radius: 999px;
  padding: 9px 11px;
  background: rgb(254 201 49 / 7%);
  color: var(--tertiary-soft);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  white-space: nowrap;
}

.quality-badge svg {
  width: 14px;
  height: 14px;
  color: var(--tertiary);
}

.estimate-pill--direct {
  border-color: rgb(0 230 118 / 30%);
  background: rgb(0 230 118 / 8%);
  color: var(--secondary-soft);
}

.battery-toolbar {
  position: relative;
  z-index: 5;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0;
}

.range-picker {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.range-picker button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--border-soft);
  padding: 0 15px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.range-picker button:last-child {
  border-right: 0;
}

.range-picker button:hover,
.range-picker button[aria-pressed="true"] {
  background: var(--primary-soft);
  color: #04343a;
}

.estimated-note {
  position: relative;
}

.estimated-note summary {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.estimated-note summary::-webkit-details-marker {
  display: none;
}

.estimated-note summary svg {
  width: 15px;
  height: 15px;
  color: var(--tertiary);
}

.estimated-note p {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, 80vw);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px;
  background: var(--surface-raised);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.6;
}

.battery-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.battery-kpi,
.battery-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 20px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--border-soft);
}

.diagnostics-grid > div {
  min-height: 124px;
  padding: 17px;
  background: var(--surface-raised);
}

.diagnostics-grid > div > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .08em;
}

.diagnostics-grid strong {
  display: block;
  margin-top: 13px;
  color: var(--text);
  font-size: 25px;
  letter-spacing: -.03em;
}

.diagnostics-grid strong small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 10px;
}

.diagnostics-grid p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.battery-kpi {
  min-height: 170px;
  padding: 20px;
}

.battery-kpi--health {
  border-color: rgb(0 229 255 / 55%);
  background: linear-gradient(145deg, rgb(0 229 255 / 8%), transparent 62%), var(--surface);
}

.battery-kpi__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
}

.battery-kpi__heading svg {
  width: 18px;
  height: 18px;
  color: var(--text-soft);
}

.battery-kpi__value {
  margin-top: 13px;
  color: var(--text);
  font-size: clamp(33px, 3.2vw, 47px);
  font-weight: 850;
  letter-spacing: -.045em;
  line-height: 1;
}

.battery-kpi__value small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.battery-kpi__value--primary {
  color: var(--primary-soft);
}

.battery-kpi__value--warning {
  color: var(--tertiary);
}

.battery-kpi p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.battery-kpi p strong {
  color: var(--text-soft);
}

.health-scale,
.degradation-scale {
  position: relative;
  height: 4px;
  margin-top: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hover);
}

.health-scale span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--tertiary), var(--secondary), var(--primary));
}

.degradation-scale {
  overflow: visible;
  background: linear-gradient(90deg, var(--secondary), var(--tertiary), var(--danger));
}

.battery-card {
  margin-top: 14px;
  padding: 22px;
}

.battery-card__header {
  justify-content: space-between;
  gap: 20px;
}

.battery-card__header h2 {
  margin: 6px 0 5px;
  font-size: 24px;
  letter-spacing: -.035em;
}

.battery-card__header p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.export-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.export-button svg {
  width: 16px;
  height: 16px;
}

.capacity-chart-wrap {
  position: relative;
  min-height: 360px;
  margin-top: 20px;
}

.capacity-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  min-height: 330px;
  overflow: visible;
}

.capacity-chart[hidden],
.chart-empty-state[hidden],
.drain-empty[hidden] {
  display: none;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-grid--vertical {
  opacity: .45;
}

.chart-axis-label,
.chart-axis-title {
  fill: var(--muted);
  font-family: Inter, sans-serif;
}

.chart-axis-label {
  font-size: 10px;
}

.chart-axis-title {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.chart-trend {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 5px rgb(0 229 255 / 35%));
}

.chart-baseline {
  stroke: var(--tertiary);
  stroke-dasharray: 7 6;
  stroke-width: 1.2;
  opacity: .8;
}

.chart-point {
  stroke-width: 2;
}

.chart-point--qualified {
  fill: var(--primary);
  stroke: var(--surface);
}

.chart-point--excluded {
  fill: var(--surface);
  stroke: var(--tertiary);
  opacity: .8;
}

.chart-empty-state {
  display: grid;
  min-height: 330px;
  place-items: center;
  align-content: center;
  gap: 9px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.chart-empty-state svg {
  width: 30px;
  height: 30px;
  color: var(--tertiary);
}

.chart-empty-state h3,
.chart-empty-state p {
  margin: 0;
}

.chart-empty-state h3 {
  color: var(--text-soft);
  font-size: 17px;
}

.chart-empty-state p {
  max-width: 540px;
  font-size: 12px;
  line-height: 1.6;
}

.chart-footer {
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  color: var(--muted);
  font-size: 9px;
}

.drain-table-wrap {
  overflow-x: auto;
  margin-top: 20px;
}

.drain-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.drain-table th,
.drain-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 13px 12px;
  color: var(--text-soft);
  font-size: 10px;
  text-align: left;
  white-space: nowrap;
}

.drain-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.drain-table tbody tr:hover {
  background: var(--surface-raised);
}

.drain-detail-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary-soft);
  font: inherit;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.drain-detail-button:hover {
  text-decoration: underline;
}

.drain-empty {
  padding: 42px 0 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1180px) {
  .battery-page-header {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 22px 0;
  }

  .battery-header-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .battery-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diagnostics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .battery-main {
    padding-inline: 18px;
  }

  .battery-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .range-picker {
    width: 100%;
    overflow-x: auto;
  }

  .range-picker button {
    flex: 1 0 auto;
  }

  .capacity-chart-wrap {
    overflow-x: auto;
  }

}

@media (max-width: 620px) {
  .battery-page-header {
    min-height: auto;
  }

  .battery-header-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .vehicle-identity {
    grid-column: 1 / -1;
  }

  .quality-badge,
  .freshness-badge {
    justify-content: center;
  }

  .battery-kpi-grid {
    grid-template-columns: 1fr;
  }

  .battery-kpi {
    min-height: 150px;
  }

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

  .battery-card {
    padding: 18px 15px;
  }

  .battery-card__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-button {
    width: 100%;
    justify-content: center;
  }

  .chart-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .drain-table {
    min-width: 0;
  }

  .drain-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .drain-table tbody,
  .drain-table tr,
  .drain-table td {
    display: block;
  }

  .drain-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 9px;
    padding: 9px 12px;
    background: var(--surface-raised);
  }

  .drain-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border-soft);
    padding: 9px 0;
    text-align: right;
  }

  .drain-table td:last-child {
    border-bottom: 0;
  }

  .drain-table td::before {
    color: var(--muted);
    font-size: 8px;
    font-weight: 750;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    content: attr(data-label);
  }

  .drain-detail-button {
    text-align: right;
  }

}
