:root {
  --bg: var(--page-bg);
  --ink: var(--brand-navy);
  --muted: var(--text-secondary);
  --line: var(--border);
  --teal: var(--primary);
  --teal-soft: var(--selected-bg);
  --card: var(--surface);
  --danger: var(--negative);
  --issuance: var(--primary);
  --maturity: var(--series-4);
  font-family: var(--font-family);
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
main.debt-main { max-width: 1440px; }

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
h1, h2 { margin: 0; color: var(--ink); }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
.subtitle, .panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.freshness { text-align: left; color: var(--muted); font-size: 12px; }
.freshness strong { display: block; color: var(--ink); font-size: 14px; }
.status { min-height: 20px; margin: 0 0 10px; color: var(--danger); font-size: 13px; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }

.mode-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  background: var(--page-bg);
  border-radius: 10px;
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mode-btn[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: none;
}

.maturity-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0 0 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.strip-item {
  flex: 1 1 140px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  border-left: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.strip-item:last-child { border-left: 0; }
.strip-label { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.strip-item strong {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.strip-amount {
  direction: ltr;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}
.recent-strip { background: var(--selected-bg); }

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.toolbar label {
  display: grid;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.toolbar select {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}
.toolbar select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: none;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-heading { padding: 14px 16px 10px; }
.row-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}
.pager { display: flex; align-items: center; gap: 8px; }
.ghost-btn, .icon-btn, .primary-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}
.ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
}
.ghost-btn:disabled { opacity: 0.45; cursor: default; }
#page-label { font-size: 12px; color: var(--muted); min-width: 72px; text-align: center; }

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  min-height: 120px;
  border-top: 1px solid var(--page-bg);
}
.tl-month {
  padding: 12px 10px 14px;
  border-left: 1px solid var(--page-bg);
  min-height: 120px;
}
.tl-month:last-child { border-left: 0; }
.tl-month-label {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.tl-month-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
}
.tl-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tl-event {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: right;
  padding: 4px 6px;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
}
.tl-event:hover, .tl-event.selected { background: var(--teal-soft); }
.tl-marker {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
}
.tl-marker.issuance { color: var(--issuance); }
.tl-marker.maturity { color: var(--maturity); }
.tl-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tl-empty { color: var(--muted); font-size: 12px; padding: 8px 2px; }

.table-scroll { overflow-x: auto; }
.event-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 12px;
}
.event-table th, .event-table td {
  padding: 11px 14px;
  text-align: right;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}
.event-table th {
  color: var(--brand-navy);
  background: var(--page-bg);
  font-weight: 600;
}
.event-table tbody tr {
  cursor: pointer;
}
.event-table tbody tr:hover { background: var(--selected-bg); }
.event-table tbody tr.selected { background: var(--teal-soft); }
.event-table td.number {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.issuance { background: var(--selected-bg); color: var(--primary); }
.badge.maturity { background: color-mix(in srgb, var(--warning) 8%, var(--surface)); color: var(--warning); }
.empty-row td { color: var(--muted); text-align: center; cursor: default; }

.definitions {
  margin: 8px 2px 24px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.9;
}
.definitions summary { color: var(--teal); cursor: pointer; font-weight: 700; }
.definitions p { margin: 7px 0; }

.backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--brand-navy) 50.2%, transparent);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--card);
  box-shadow: none;
}
.drawer[hidden], .backdrop[hidden] { display: none !important; }
.preview-drawer {
  left: 0;
  width: min(440px, 96vw);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-head .eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 12px; font-weight: 700; }
.drawer-head h2 { font-size: 18px; }
.drawer-head p { margin: 3px 0; color: var(--muted); font-size: 12px; }
.drawer-body { padding: 16px 18px; overflow: auto; flex: 1; }
.drawer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
}
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 0;
  background: var(--teal);
  color: var(--surface);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
}
.unmap-note { color: var(--muted); font-size: 12px; }
.kv { display: grid; gap: 8px; }
.kv-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; color: var(--ink); }
.kv-row dd.ltr { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .page-header { flex-direction: column; align-items: start; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .timeline { grid-template-columns: 1fr; }
  .strip-item { border-left: 0; border-top: 1px solid var(--line); }
  .strip-item:first-child { border-top: 0; }
  .row-heading { flex-direction: column; align-items: start; }
}

/* Keep the event list primary and the timeline visually supportive. */
.page-header { padding-bottom: 12px; margin-bottom: 12px; }
.mode-seg { gap: 4px; padding: 3px; margin-bottom: 10px; border-radius: 8px; }
.mode-btn { padding: 7px 12px; border-radius: 6px; }
.maturity-strip { margin-bottom: 12px; border-radius: 8px; }
.strip-item { padding: 9px 12px; }
.toolbar { gap: 8px; margin-bottom: 12px; }
.toolbar select { min-height: 38px; border-radius: 7px; }
.panel { border-radius: 9px; box-shadow: none; }
.panel-heading { padding: 12px 15px 9px; }
.event-table th, .event-table td { padding: 9px 12px; }
.timeline-panel { background: var(--surface); box-shadow: none; }
.timeline { border-top-color: var(--border); }
.definitions { margin-top: 6px; font-size: 12px; }

@media (max-width: 800px) {
  main.debt-main { padding: 14px 12px 30px; }
  .page-header { gap: 8px; }
  .toolbar { gap: 8px; }
  .strip-item { padding: 8px 10px; }
  .panel-heading { padding: 11px 12px 8px; }
}
