.writeoff-layout {
  margin-top: 24px;
  display: grid;
  gap: 20px;
}

.writeoff-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.toolbar-stack {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.chart-controls {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.chart-switch {
  align-items: center;
}

.range-select-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  justify-items: end;
}

.range-select {
  min-width: 150px;
  padding: 9px 34px 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: end;
}

.mode-chip {
  width: auto;
  margin-top: 0;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.mode-chip.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.action-button {
  width: auto;
  margin-top: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.action-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.compact {
  margin-top: 6px;
}

.compact-data {
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
}

.compact-data dt {
  white-space: nowrap;
}

.narrative-stack {
  display: grid;
  gap: 12px;
}

.summary-callout {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(11, 107, 87, 0.08);
  border: 1px solid rgba(11, 107, 87, 0.16);
}

.summary-callout strong {
  display: block;
  margin-bottom: 8px;
}

.summary-callout p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.methodology-note p {
  margin: 0;
  color: #d4e2dd;
  line-height: 1.5;
}

.inline-header {
  padding: 0 0 18px;
  justify-content: space-between;
  align-items: start;
  border-bottom: 1px solid var(--line);
  gap: 14px;
}

.chart-host {
  margin-top: 18px;
  min-height: 460px;
}

.chart-shell {
  position: relative;
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.94) 100%),
    radial-gradient(circle at top left, rgba(11, 107, 87, 0.09), transparent 48%);
}

.chart-shell svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-empty {
  min-height: 200px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.series-legend {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.series-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin-top: 0;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-swatch.writeoff {
  background: #8f3f2a;
}

.legend-swatch.yield {
  background: #0b6b57;
}

.legend-swatch.net {
  background: #2d5f8b;
}

.legend-swatch.prior {
  background: repeating-linear-gradient(
    90deg,
    rgba(20, 35, 31, 0.55) 0 4px,
    transparent 4px 7px
  );
}

.axis-label,
.tick-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: Georgia, "Times New Roman", serif;
}

.x-tick-label {
  font-size: 11px;
}

.grid-line {
  stroke: rgba(87, 112, 106, 0.16);
  stroke-width: 1;
}

.axis-line {
  stroke: rgba(20, 35, 31, 0.25);
  stroke-width: 1;
}

.prior-line {
  opacity: 0.55;
  stroke-dasharray: 7 7;
}

.table-card {
  overflow: hidden;
}

.writeoff-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
}

.writeoff-table th,
.writeoff-table td {
  padding: 8px 6px;
  border: 1px solid var(--line);
  font-size: 11px;
  text-align: right;
  white-space: normal;
  word-break: break-word;
  background: rgba(248, 246, 241, 0.96);
  vertical-align: top;
}

.writeoff-table th {
  z-index: 2;
  background: #edf2e8;
  font-size: 10px;
  line-height: 1.3;
}

.writeoff-table th:first-child,
.writeoff-table td:first-child {
  text-align: left;
  width: 11%;
  background: #f3f5ee;
}

.month-cell {
  display: grid;
  gap: 4px;
}

.month-cell strong {
  color: var(--ink);
}

.month-cell span {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1280px) {
  .writeoff-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .writeoff-table th,
  .writeoff-table td {
    font-size: 11px;
    padding: 8px 6px;
  }
}

@media (max-width: 900px) {
  .writeoff-summary-grid {
    grid-template-columns: 1fr;
  }

  .mode-switch,
  .toolbar-stack,
  .chart-controls,
  .range-select-label {
    justify-items: start;
    justify-content: start;
  }

  .inline-header {
    flex-direction: column;
  }

  .writeoff-table {
    table-layout: auto;
  }
}
