:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #d8dee6;
  --border-strong: #b8c2ce;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #1e4d7b;
  --accent-hover: #163a5e;
  --positive: #0d7a52;
  --negative: #b42318;
  --font: sans-serif;
  --mono: monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.925rem;
}

.info {
  margin: -0.5rem 0 1.25rem;
}

.info p {
  margin: 0;
  font-size: 0.925rem;
  line-height: 1.6;
}

.info a {
  color: var(--accent);
  text-decoration: none;
}

.info a:hover {
  text-decoration: underline;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(26, 35, 50, 0.04);
}

.card.table-card {
  padding: 0;
  overflow: hidden;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.control label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.control input[type="number"],
.control input[type="date"],
.control select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.925rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

.control input:disabled {
  color: var(--muted);
  background: #f7f9fb;
}

.control input:focus,
.control select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30, 77, 123, 0.15);
}

.control.actions {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.week-count {
  font-size: 0.825rem;
  color: var(--muted);
  white-space: nowrap;
}

button {
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  background: rgba(30, 77, 123, 0.04);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: #f7f9fb;
}

thead th {
  border-bottom: 2px solid var(--border-strong);
}

th.num,
td.num {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.825rem;
}

th.num[data-sort="asset"] {
  text-align: left;
}

th.sparkline-col {
  width: 132px;
  padding: 0.65rem 0.5rem;
  background: #f7f9fb;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable.sort-active {
  color: var(--accent);
}

th.sortable::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  margin-left: 0.35em;
  opacity: 0.35;
}

th.sortable.sort-active[aria-sort="descending"]::after {
  content: "↓";
  opacity: 1;
}

th.sortable.sort-active[aria-sort="ascending"]::after {
  content: "↑";
  opacity: 1;
}

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

tbody tr:hover {
  background: #f7f9fb;
}

.loading,
.error {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.error {
  color: var(--negative);
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.partial-data {
  color: var(--negative);
  font-family: var(--mono);
  font-weight: 600;
}

.stacked-metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  line-height: 1.25;
}

.stacked-date {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
}

.data-since-cell {
  text-align: right;
}

.sparkline-cell {
  width: 132px;
  padding: 0.45rem 0.5rem !important;
}

.sparkline {
  display: block;
  width: 120px;
  height: 32px;
}

.sparkline-rf {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1;
  stroke-opacity: 0.4;
  stroke-dasharray: 3 2;
}

.sparkline-asset {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-asset.positive {
  stroke: var(--positive);
}

.sparkline-asset.negative {
  stroke: var(--negative);
}

.sparkline-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

.table-footnote {
  margin: 0;
  padding: 0.85rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.table-footnote[hidden] {
  display: none;
}

footer.site-footer {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.775rem;
  color: var(--muted);
}

footer.site-footer p {
  margin: 0;
}

footer.site-footer p + p {
  margin-top: 0.5rem;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
}

.footer-sep {
  color: var(--border-strong);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .page {
    padding: 1.25rem 1rem 2rem;
  }

  th,
  td {
    padding: 0.55rem 0.45rem;
  }
}
