:root {
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-selected: #eef4ff;
  --text: #172033;
  --text-soft: #4f5d73;
  --muted: #758196;
  --border: #dfe4ea;
  --border-strong: #cbd3df;
  --primary: #2457d6;
  --primary-hover: #1d47b4;
  --primary-soft: #e9f0ff;
  --success: #18794e;
  --success-soft: #eaf7f0;
  --warning: #a15c07;
  --warning-soft: #fff6df;
  --danger: #b4233c;
  --danger-soft: #fff0f2;
  --tool: #6d4cc7;
  --tool-soft: #f2edff;
  --shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.04), 0 1px 5px rgba(23, 32, 51, 0.03);
  --shadow-md: 0 10px 30px rgba(23, 32, 51, 0.09);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --content: 1480px;
  --header-height: 64px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-nav-open {
  overflow: hidden;
}

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

a:hover {
  color: var(--primary-hover);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

code {
  font-size: 0.91em;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

h3 {
  margin-bottom: 4px;
  font-size: 15px;
}

p {
  margin-bottom: 0;
}

:focus-visible {
  outline: 3px solid rgba(36, 87, 214, 0.25);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
}

.skip-link:focus {
  color: #fff;
  transform: translateY(0);
}

.app-header {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: var(--header-height);
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(23, 32, 51, 0.02);
}

.app-header__inner {
  display: flex;
  width: min(100% - 40px, var(--content));
  min-height: var(--header-height);
  margin: 0 auto;
  align-items: center;
  gap: 26px;
}

.brand,
.login-card__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

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

.brand__mark {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(36, 87, 214, 0.22);
}

.brand__mark--large {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 17px;
}

.app-header__navigation {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.main-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
}

.main-nav__link {
  padding: 8px 11px;
  color: var(--text-soft);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease;
}

.main-nav__link:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.main-nav__link.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.account-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-menu__login {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-left: auto;
  place-items: center;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.nav-toggle__lines,
.nav-toggle__lines::before,
.nav-toggle__lines::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 150ms ease, opacity 150ms ease;
}

.nav-toggle__lines {
  position: relative;
}

.nav-toggle__lines::before,
.nav-toggle__lines::after {
  position: absolute;
  left: 0;
  content: "";
}

.nav-toggle__lines::before { top: -6px; }
.nav-toggle__lines::after { top: 6px; }

.nav-toggle[aria-expanded="true"] .nav-toggle__lines {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__lines::before {
  top: 0;
  transform: rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__lines::after {
  top: 0;
  transform: rotate(-45deg);
}

.page-shell {
  width: min(100% - 40px, var(--content));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.page-heading,
.entity-heading,
.run-heading {
  display: flex;
  margin-bottom: 24px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading > div:first-child,
.entity-heading > div:first-child,
.run-heading > div:first-child {
  min-width: 0;
}

.page-heading p:not(.eyebrow),
.entity-heading p:not(.eyebrow),
.run-heading p:not(.eyebrow) {
  color: var(--text-soft);
}

.page-heading--with-actions {
  align-items: flex-end;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.075em;
  line-height: 1.3;
  text-transform: uppercase;
}

.data-freshness {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  padding: 9px 15px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.button:hover {
  color: var(--text);
  background: var(--surface-subtle);
  border-color: #b5bfce;
}

.button--primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(36, 87, 214, 0.2);
}

.button--primary:hover {
  color: #fff;
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button--secondary {
  background: var(--surface);
}

.button--ghost {
  min-height: 34px;
  color: var(--text-soft);
  background: transparent;
  border-color: transparent;
}

.button--ghost:hover {
  background: var(--surface-subtle);
  border-color: var(--border);
}

.button--danger {
  color: var(--danger);
  border-color: #efbdc5;
}

.button--danger:hover {
  color: #8d172c;
  background: var(--danger-soft);
  border-color: #e39aa6;
}

.button--compact {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
}

.button--full {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select,
.search-field input,
.table-filters select,
.period-filter select,
.period-filter input {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:hover,
.field select:hover,
.search-field input:hover,
.table-filters select:hover,
.period-filter select:hover,
.period-filter input:hover {
  border-color: #aeb9c9;
}

.field input:focus,
.field select:focus,
.search-field input:focus,
.table-filters select:focus,
.period-filter select:focus,
.period-filter input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.12);
}

.field--compact {
  gap: 3px;
}

.field--compact input,
.field--compact select {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.field--inline {
  display: flex;
  align-items: center;
  gap: 7px;
}

.field--inline .field__label {
  white-space: nowrap;
}

.field--inline select {
  min-height: 36px;
  padding: 6px 28px 6px 9px;
  font-size: 12px;
}

.period-filter {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 8px;
}

.period-filter__custom {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.period-filter__custom input {
  width: 132px;
}

.panel {
  min-width: 0;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel__header {
  display: flex;
  min-height: 68px;
  padding: 18px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.panel__header > div:first-child {
  min-width: 0;
}

.panel__header p:not(.eyebrow) {
  color: var(--muted);
  font-size: 12px;
}

.panel__header--responsive,
.panel__header--filters {
  align-items: flex-end;
}

.panel__actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.panel__note {
  padding: 13px 20px;
  color: var(--muted);
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 12px;
}

.summary-periods {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) repeat(2, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.summary-card {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.summary-card--primary {
  border-top: 3px solid var(--primary);
}

.summary-card__header {
  display: flex;
  margin-bottom: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.summary-card__header h2 {
  margin: 1px 0 0;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  padding: 4px 7px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  margin: 0;
  gap: 16px;
}

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

.metric-grid > div,
.metric-list > div {
  min-width: 0;
}

.metric-grid dt,
.metric-list dt,
.stat-card span,
.stat-strip span,
.run-metrics span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.metric-grid dd,
.metric-list dd {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.metric-list {
  display: grid;
  margin: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
}

.quick-insights {
  display: grid;
  margin-bottom: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.insight-card {
  display: grid;
  min-width: 0;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
}

.insight-card__label,
.insight-card small {
  color: var(--muted);
  font-size: 11px;
}

.insight-card__label {
  grid-column: 1 / -1;
}

.insight-card__link,
.insight-card__value {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-card > strong:not(.insight-card__value) {
  font-variant-numeric: tabular-nums;
}

.insight-card small {
  grid-column: 1 / -1;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.segmented-control button {
  min-width: 48px;
  padding: 5px 9px;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.segmented-control button.is-active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.chart-panel {
  overflow: hidden;
}

.chart {
  position: relative;
  min-height: 300px;
  padding: 18px 18px 4px;
}

.chart__canvas {
  width: 100%;
  height: 280px;
}

.chart__tooltip {
  position: absolute;
  z-index: 3;
  min-width: 120px;
  padding: 8px 10px;
  color: #fff;
  background: #202a3c;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}

.chart__tooltip strong {
  display: block;
  font-size: 12px;
}

.chart-legend {
  display: flex;
  min-height: 38px;
  padding: 8px 22px 12px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend > span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 3px;
  background: var(--primary);
  border-radius: 3px;
}

.stat-strip,
.run-metrics,
.entity-facts {
  display: grid;
  margin: 0 0 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-strip > div,
.run-metrics > div,
.entity-facts > div {
  min-width: 0;
  padding: 13px 16px;
  border-right: 1px solid var(--border);
}

.stat-strip > div:last-child,
.run-metrics > div:last-child,
.entity-facts > div:last-child {
  border-right: 0;
}

.stat-strip strong,
.run-metrics strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.definition-note {
  display: flex;
  margin: -8px 0 16px;
  padding: 10px 13px;
  align-items: baseline;
  gap: 9px;
  color: #5f4a21;
  background: var(--warning-soft);
  border: 1px solid #efdfb5;
  border-radius: 9px;
  font-size: 12px;
}

.definition-note strong {
  flex: none;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.search-field {
  position: relative;
  display: block;
}

.search-field svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 10px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.7;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 230px;
  min-height: 36px;
  padding: 6px 10px 6px 32px;
  font-size: 12px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.025em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background 100ms ease;
}

.data-table tbody tr:hover {
  background: #fafbfd;
}

.data-table--compact th,
.data-table--compact td {
  padding: 10px 12px;
}

.data-table--dense {
  min-width: 1060px;
}

.number-cell {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.money-cell {
  color: #172c55;
  font-weight: 720;
}

.text-cell-wide {
  min-width: 230px;
  max-width: 390px;
}

.truncate-text {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-name,
.entity-meta {
  display: block;
}

.entity-name {
  color: var(--text);
  font-weight: 650;
}

.entity-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 450;
  white-space: nowrap;
}

.entity-link {
  display: inline-block;
  max-width: 210px;
  vertical-align: middle;
}

.row-primary-link,
.code-link {
  color: var(--primary);
  font-weight: 700;
}

.code-link code,
.code-heading code {
  color: #5137a4;
  background: var(--tool-soft);
  border-radius: 5px;
}

.code-link code {
  padding: 3px 5px;
}

.code-heading code {
  display: inline-block;
  padding: 4px 8px;
  font-size: 0.8em;
}

.clickable-row {
  cursor: pointer;
}

.subtle-separator {
  color: var(--border-strong);
}

.error-value {
  color: var(--danger) !important;
}

.value-missing {
  color: var(--muted);
  font-weight: 450;
}

.status {
  display: inline-flex;
  min-height: 22px;
  padding: 3px 7px;
  align-items: center;
  color: var(--text-soft);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.status--completed,
.status--active,
.status--calculated {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bfe4d0;
}

.status--running,
.status--pending {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #c7d7ff;
}

.status--failed,
.status--revoked {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efc2ca;
}

.status--incomplete,
.status--expired,
.status--unknown-model,
.status--missing-usage {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #eedda9;
}

.pagination {
  display: flex;
  min-height: 58px;
  padding: 10px 15px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
}

.pagination__summary {
  color: var(--muted);
  font-size: 11px;
}

.pagination__links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination__link {
  display: inline-grid;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  place-items: center;
  color: var(--text-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
}

.pagination__link:hover {
  color: var(--text);
  background: var(--surface-subtle);
  border-color: var(--border);
}

.pagination__link.is-current {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #c8d7fb;
}

.pagination__link.is-disabled {
  color: #b1bac7;
}

.pagination__ellipsis {
  padding: 0 4px;
  color: var(--muted);
}

.empty-state {
  display: grid;
  min-height: 210px;
  padding: 34px 20px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-state__icon {
  display: grid;
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  place-items: center;
  color: var(--muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 20px;
}

.empty-state h2 {
  margin-bottom: 4px;
}

.empty-state p,
.inline-empty {
  color: var(--muted);
}

.empty-state p {
  max-width: 480px;
  margin-bottom: 15px;
  font-size: 12px;
}

.inline-empty {
  padding: 24px 20px;
  font-size: 12px;
}

.breadcrumbs {
  display: flex;
  margin-bottom: 14px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumbs a {
  color: var(--text-soft);
}

.entity-heading__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: none;
  place-items: center;
  color: #21488d;
  background: #e6efff;
  border: 1px solid #ccdaf5;
  border-radius: 13px;
  font-size: 18px;
  font-weight: 800;
}

.entity-facts {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.entity-facts dt,
.settings-list dt,
.detail-grid dt,
.token-structure dt {
  color: var(--muted);
  font-size: 11px;
}

.entity-facts dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  margin: 22px 0 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-strong);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs__link {
  position: relative;
  flex: none;
  padding: 10px 14px 11px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

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

.tabs__link.is-active {
  color: var(--primary);
}

.tabs__link.is-active::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  content: "";
}

.stat-card-grid {
  display: grid;
  margin-bottom: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card-grid--wide {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-card strong {
  display: block;
  margin: 3px 0 1px;
  overflow: hidden;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card small {
  color: var(--muted);
  font-size: 10px;
}

.content-grid {
  display: grid;
  gap: 18px;
}

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

.content-grid--settings {
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.6fr);
}

.content-grid > .panel {
  margin-bottom: 0;
}

.token-structure {
  display: grid;
  padding: 8px 20px 12px;
  margin: 0;
}

.token-structure > div {
  display: flex;
  padding: 10px 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.token-structure > div:last-child {
  border-bottom: 0;
}

.token-structure dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.token-structure__total dt,
.token-structure__total dd {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.token-structure--large {
  padding-top: 12px;
}

.token-structure--large dd {
  font-size: 16px;
}

.text-link {
  flex: none;
  font-size: 12px;
  font-weight: 650;
}

.compact-list {
  display: grid;
}

.compact-list__item {
  display: flex;
  min-width: 0;
  padding: 13px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.compact-list__item:last-child {
  border-bottom: 0;
}

.compact-list__item:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.compact-list__main {
  min-width: 0;
}

.compact-list__main strong,
.compact-list__main span,
.compact-list__aside strong,
.compact-list__aside small {
  display: block;
}

.compact-list__main span {
  max-width: 440px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-list__aside {
  flex: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compact-list__aside small {
  color: var(--muted);
  font-size: 10px;
}

.run-heading {
  align-items: flex-start;
}

.run-heading h1 {
  max-width: 1000px;
  margin-bottom: 8px;
  font-size: clamp(20px, 2.5vw, 27px);
  overflow-wrap: anywhere;
}

.run-heading__title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.run-heading__title .eyebrow {
  margin-bottom: 0;
}

.run-heading .entity-link {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.run-heading .entity-link span {
  display: inline;
}

.run-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.run-metrics__cost {
  background: #fbfcff;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.timeline-panel {
  overflow: hidden;
}

.timeline {
  position: relative;
  padding: 20px 22px 22px;
  margin: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 35px;
  bottom: 35px;
  left: 41px;
  width: 1px;
  background: var(--border-strong);
  content: "";
}

.timeline-step {
  position: relative;
  display: grid;
  margin-bottom: 12px;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
}

.timeline-step:last-child {
  margin-bottom: 0;
}

.timeline-step__marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #c7d7fb;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
}

.timeline-step--tool_call .timeline-step__marker {
  color: var(--tool);
  background: var(--tool-soft);
  border-color: #d8cbfa;
}

.timeline-step--final_response .timeline-step__marker {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bfe4d0;
}

.timeline-step__card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.timeline-step__summary {
  display: flex;
  min-height: 58px;
  padding: 11px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.timeline-step__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.timeline-step__identity > div {
  min-width: 0;
}

.timeline-step__identity strong,
.timeline-step__identity span:not(.timeline-step__sequence) {
  display: block;
}

.timeline-step__identity span:not(.timeline-step__sequence) {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-step__sequence {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: none;
  place-items: center;
  color: var(--muted);
  background: var(--surface-subtle);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
}

.timeline-step__meta {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.timeline-step__meta strong {
  color: var(--text);
}

.step-details {
  border-top: 1px solid var(--border);
}

.step-details > summary {
  width: fit-content;
  padding: 9px 13px;
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  list-style-position: inside;
}

.step-details[open] > summary {
  margin-bottom: 2px;
}

.detail-grid {
  display: grid;
  padding: 2px 13px 13px;
  margin: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.detail-grid > div {
  min-width: 0;
  padding: 9px 10px;
  background: var(--surface-subtle);
  border-radius: 8px;
}

.detail-grid dd {
  margin: 2px 0 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.breakable {
  overflow-wrap: anywhere;
}

.preview-block {
  margin: 0 13px 13px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.preview-block__heading {
  display: flex;
  padding: 7px 10px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
}

.preview-block__heading span {
  color: var(--muted);
}

.preview-block pre {
  max-height: 240px;
  padding: 11px;
  margin: 0;
  overflow: auto;
  color: #29364a;
  background: #fbfcfe;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-block--text {
  padding: 11px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: pre-wrap;
}

.settings-list {
  display: grid;
  padding: 8px 20px 13px;
  margin: 0;
}

.settings-list > div {
  display: flex;
  padding: 10px 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--border);
}

.settings-list > div:last-child {
  border-bottom: 0;
}

.settings-list dd {
  margin: 0;
  font-weight: 700;
}

.session-list {
  display: grid;
}

.session-item {
  display: flex;
  padding: 14px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.session-item:last-child {
  border-bottom: 0;
}

.session-item strong,
.session-item span,
.session-item small {
  display: block;
}

.session-item span,
.session-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.current-label {
  display: inline-flex !important;
  padding: 2px 5px;
  color: var(--success) !important;
  background: var(--success-soft);
  border-radius: 5px;
  font-size: 9px !important;
  font-weight: 750;
  text-transform: uppercase;
}

.warning-list {
  padding: 13px 18px;
  color: #694a13;
  background: var(--warning-soft);
  border-top: 1px solid #efdfb5;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 12px;
}

.warning-list ul {
  padding-left: 18px;
  margin: 7px 0 0;
}

.flash-stack {
  display: grid;
  margin-bottom: 16px;
  gap: 8px;
}

.flash {
  display: flex;
  padding: 10px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
}

.flash--error {
  color: #7f1d31;
  background: var(--danger-soft);
  border-color: #efc2ca;
}

.flash--success {
  color: #155e3d;
  background: var(--success-soft);
  border-color: #bfe4d0;
}

.flash--info {
  color: #21488d;
  background: var(--primary-soft);
  border-color: #c7d7fb;
}

.flash__close {
  flex: none;
  padding: 1px 5px;
  color: currentColor;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 18px;
  line-height: 1;
}

.auth-page {
  background: #f3f5f8;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 28px 18px;
  place-items: center;
}

.auth-shell .flash-stack {
  position: fixed;
  z-index: 10;
  top: 20px;
  right: 20px;
  max-width: 400px;
}

.login-card {
  width: min(100%, 420px);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.login-card__brand {
  margin-bottom: 30px;
}

.login-card__heading {
  margin-bottom: 22px;
}

.login-card__heading h1 {
  margin-bottom: 7px;
  font-size: 25px;
}

.login-card__heading p,
.login-card__security {
  color: var(--muted);
}

.login-card__heading p {
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 15px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 76px;
}

.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  padding: 5px 7px;
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 650;
  transform: translateY(-50%);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-soft);
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.checkbox strong,
.checkbox small {
  display: block;
}

.checkbox strong {
  font-size: 12px;
}

.checkbox small {
  color: var(--muted);
  font-size: 10px;
}

.login-card__security {
  margin-top: 18px;
  text-align: center;
  font-size: 10px;
}

@media (max-width: 1180px) {
  .app-header__inner {
    gap: 15px;
  }

  .main-nav__link {
    padding-inline: 8px;
  }

  .account-menu__login {
    display: none;
  }

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

  .summary-card--primary {
    grid-column: 1 / -1;
  }

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

  .panel__header--filters {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-filters {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 920px) {
  .app-header__inner {
    width: min(100% - 28px, var(--content));
  }

  .nav-toggle {
    display: grid;
  }

  .app-header__navigation {
    position: fixed;
    z-index: 99;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    padding: 14px;
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    gap: 14px;
    background: rgba(244, 246, 248, 0.98);
    border-top: 1px solid var(--border);
  }

  .app-header__navigation.is-open {
    display: flex;
  }

  .main-nav {
    display: grid;
    width: 100%;
    padding: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  .main-nav__link {
    padding: 11px 12px;
    font-size: 14px;
  }

  .account-menu {
    padding: 10px 12px;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .account-menu__login {
    display: block;
  }

  .page-shell {
    width: min(100% - 28px, var(--content));
  }

  .page-heading,
  .entity-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading .period-filter,
  .entity-heading .period-filter {
    width: 100%;
  }

  .quick-insights,
  .stat-card-grid,
  .stat-card-grid--wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-insights .insight-card:last-child {
    grid-column: 1 / -1;
  }

  .panel__header--responsive {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel__actions {
    width: 100%;
    align-items: flex-end;
    justify-content: space-between;
  }

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

  .entity-facts > div:nth-child(3) {
    border-right: 0;
  }

  .entity-facts > div:nth-child(-n + 3) {
    border-bottom: 1px solid var(--border);
  }

  .content-grid--balanced,
  .content-grid--settings {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .run-metrics > div:nth-child(3) {
    border-right: 0;
  }

  .run-metrics > div:nth-child(-n + 3) {
    border-bottom: 1px solid var(--border);
  }

  .run-metrics__cost {
    border-radius: 0 0 var(--radius) 0;
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: 58px;
  }

  .app-header__inner,
  .page-shell {
    width: min(100% - 20px, var(--content));
  }

  .page-shell {
    padding-top: 20px;
  }

  .brand__mark {
    width: 28px;
    height: 28px;
  }

  .summary-periods,
  .quick-insights,
  .stat-card-grid,
  .stat-card-grid--wide {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-card--primary,
  .quick-insights .insight-card:last-child {
    grid-column: auto;
  }

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

  .period-filter {
    width: 100%;
    flex-wrap: wrap;
  }

  .period-filter > .field:first-of-type {
    flex: 1;
    min-width: 130px;
  }

  .period-filter__custom {
    width: 100%;
    order: 3;
  }

  .period-filter__custom .field {
    flex: 1;
  }

  .period-filter__custom input {
    width: 100%;
  }

  .panel__header,
  .panel__header--responsive {
    padding: 15px;
  }

  .panel__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .table-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .search-field input {
    width: 100%;
  }

  .field--inline {
    align-items: stretch;
    flex-direction: column;
    gap: 3px;
  }

  .field--inline .field__label {
    display: block;
  }

  .data-table {
    min-width: 760px;
  }

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

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

  .entity-heading__identity {
    align-items: flex-start;
  }

  .entity-facts,
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entity-facts > div,
  .stat-strip > div {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .entity-facts > div:nth-child(2n),
  .stat-strip > div:nth-child(2n) {
    border-right: 0;
  }

  .entity-facts > div:last-child,
  .stat-strip > div:last-child,
  .stat-strip > div:nth-last-child(2) {
    border-bottom: 0;
  }

  .entity-facts > div:last-child {
    border-right: 1px solid var(--border);
  }

  .tabs__link {
    padding-inline: 11px;
  }

  .run-heading h1 {
    font-size: 20px;
  }

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

  .run-metrics > div,
  .run-metrics > div:nth-child(3) {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .run-metrics > div:nth-child(2n) {
    border-right: 0;
  }

  .run-metrics > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .timeline {
    padding: 15px 12px 16px;
  }

  .timeline::before {
    left: 29px;
  }

  .timeline-step {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 5px;
  }

  .timeline-step__marker {
    width: 30px;
    height: 30px;
  }

  .timeline-step__summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .timeline-step__meta {
    width: 100%;
    flex-wrap: wrap;
    padding-left: 34px;
  }

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

  .definition-note {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .session-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-card {
    padding: 24px 20px;
  }
}

@media (max-width: 420px) {
  .metric-grid--three,
  .metric-list,
  .entity-facts,
  .stat-strip,
  .run-metrics,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .entity-facts > div,
  .entity-facts > div:nth-child(2n),
  .stat-strip > div,
  .stat-strip > div:nth-child(2n),
  .run-metrics > div,
  .run-metrics > div:nth-child(2n),
  .run-metrics > div:nth-child(3) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .entity-facts > div:last-child,
  .stat-strip > div:last-child,
  .run-metrics > div:last-child {
    border-right: 0;
    border-bottom: 0;
  }

  .table-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-field {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .app-header,
  .period-filter,
  .table-filters,
  .pagination,
  .button,
  .nav-toggle {
    display: none !important;
  }

  body,
  .page-shell {
    width: 100%;
    color: #000;
    background: #fff;
  }

  .panel,
  .summary-card,
  .stat-card,
  .stat-strip,
  .run-metrics {
    box-shadow: none;
    break-inside: avoid;
  }
}
