:root {
  color-scheme: light;
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --text: #17231d;
  --muted: #5d6b63;
  --border: #d8e0da;
  --border-strong: #bdc9c1;
  --success: #277a55;
  --success-soft: #e8f4ed;
  --reserved: #2f68b2;
  --reserved-soft: #eaf1fb;
  --warning: #9a5b00;
  --warning-soft: #fff4dc;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --neutral-soft: #eef2ef;
  --focus: #255f9e;
  --shadow: 0 1px 2px rgb(23 35 29 / 0.05), 0 8px 24px rgb(23 35 29 / 0.04);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  transform: translateY(-150%);
}

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

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 2px;
}

.shell {
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 0.82);
  backdrop-filter: blur(12px);
}

.header-inner {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding-block: 24px;
}

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

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

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.3;
}

.eyebrow,
.section-kicker {
  margin-bottom: 4px;
  color: var(--success);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.header-copy,
.section-note,
.help-text {
  margin-bottom: 0;
  color: var(--muted);
}

.freshness {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.freshness strong,
.freshness span {
  display: block;
}

.freshness strong {
  font-size: 13px;
}

.freshness div > span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.freshness-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 1px var(--warning);
}

.freshness-dot.is-fresh {
  background: var(--success);
  box-shadow: 0 0 0 1px var(--success);
}

.freshness-dot.is-stale {
  background: var(--warning);
  box-shadow: 0 0 0 1px var(--warning);
}

.freshness-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.refresh-progress {
  position: fixed;
  z-index: 90;
  inset: 0 100% auto 0;
  height: 3px;
  background: var(--reserved);
  opacity: 0;
  transition: inset 180ms ease, opacity 120ms ease;
}

.refresh-progress.is-active {
  inset-right: 18%;
  opacity: 1;
}

.filter-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 150px minmax(150px, 1fr) 150px minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin: 24px 0 32px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.filter-bar label {
  min-width: 0;
}

.filter-bar label > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
}

input::placeholder {
  color: #829087;
}

input:hover,
select:hover {
  border-color: #93a39a;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button {
  padding: 8px 14px;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-primary {
  background: var(--text);
  color: white;
}

.button-primary:hover:not(:disabled) {
  background: #26362e;
}

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

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  background: var(--neutral-soft);
}

.button-quiet {
  background: transparent;
}

.global-message,
.inline-error {
  border: 1px solid #e8c9a0;
  border-radius: 9px;
  background: var(--warning-soft);
  color: #704200;
}

.global-message {
  margin: -16px 0 24px;
  padding: 12px 14px;
}

.inline-error {
  margin: 12px 16px 16px;
  padding: 10px 12px;
  font-size: 13px;
}

.inline-error button {
  margin-left: 8px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  text-decoration: underline;
}

.section {
  margin-bottom: 32px;
}

.section-heading,
.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.panel-heading {
  min-height: 76px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.metric-card,
.panel,
.table-shell,
.incident-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
}

.metric-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric-value {
  margin: 13px 0 4px;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.metric-detail {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: var(--neutral-soft);
  color: var(--muted);
}

.metric-icon.success {
  background: var(--success-soft);
  color: var(--success);
}

.metric-icon.reserved {
  background: var(--reserved-soft);
  color: var(--reserved);
}

.metric-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-content {
  min-height: 300px;
  padding: 18px;
}

.fairness-list,
.pool-list {
  display: grid;
  gap: 14px;
}

.fairness-row,
.pool-row {
  display: grid;
  gap: 7px;
}

.row-heading,
.row-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-values {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.load-bars {
  display: grid;
  gap: 4px;
}

.load-bar {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--neutral-soft);
  appearance: none;
}

.load-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--neutral-soft);
}

.load-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--success);
}

.load-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--success);
}

.load-bar-reserved::-webkit-progress-value {
  background: var(--reserved);
}

.load-bar-reserved::-moz-progress-bar {
  background: var(--reserved);
}

.load-bar-pool {
  height: 9px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-counted {
  background: var(--success);
}

.legend-reserved {
  background: var(--reserved);
}

.legend-problem {
  background: var(--danger);
}

.chart-wrap {
  display: grid;
  align-content: center;
}

.trend-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 210px;
  overflow: visible;
}

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

.chart-label {
  fill: var(--muted);
  font: 11px var(--font);
}

.chart-counted {
  fill: var(--success);
}

.chart-reserved {
  fill: var(--reserved);
}

.chart-problem {
  fill: var(--danger);
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 11px;
}

.chart-summary li {
  padding: 7px;
  border-radius: 6px;
  background: var(--surface-soft);
  text-align: center;
}

.pool-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pool-cursor {
  display: inline-flex;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--neutral-soft);
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.anomaly-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.anomaly-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}

.anomaly-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

.anomaly-copy {
  min-width: 0;
}

.anomaly-copy strong,
.anomaly-copy span {
  display: block;
}

.anomaly-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-shell {
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: #fafcfb;
}

.cell-primary,
.cell-secondary {
  display: block;
}

.cell-primary {
  font-weight: 650;
}

.jira-link,
.jira-link:visited {
  color: var(--reserved);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.jira-link:hover {
  color: var(--focus);
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: #435149;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.status-chip::before {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.status-counted,
.status-completed,
.status-resolved,
.status-healthy,
.status-succeeded {
  background: var(--success-soft);
  color: var(--success);
}

.status-reserved,
.status-running,
.status-leased,
.status-pending,
.status-in_progress {
  background: var(--reserved-soft);
  color: var(--reserved);
}

.status-uncertain,
.status-warning,
.status-retrying {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-blocked,
.status-failed,
.status-critical,
.status-open,
.status-dead_letter {
  background: var(--danger-soft);
  color: var(--danger);
}

.record-button {
  border: 0;
  background: none;
  color: var(--reserved);
  cursor: pointer;
  font-weight: 700;
  padding: 5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.load-more {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.incident-list {
  min-height: 180px;
  overflow: hidden;
}

.incident-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

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

.incident-severity {
  width: 4px;
  min-height: 44px;
  border-radius: 99px;
  background: var(--border-strong);
}

.severity-warning {
  background: var(--warning);
}

.severity-critical,
.severity-error {
  background: var(--danger);
}

.incident-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.incident-heading strong {
  min-width: 0;
}

.incident-copy {
  margin: 0 0 5px;
  color: var(--muted);
}

.incident-meta {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  margin-bottom: 3px;
  color: var(--text);
}

.skeleton-block {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent, rgb(255 255 255 / 0.75), transparent),
    var(--neutral-soft);
  background-size: 220% 100%, auto;
  animation: skeleton 1.4s ease-in-out infinite;
}

.table-skeleton {
  min-height: 260px;
}

.detail-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgb(23 35 29 / 0.22);
}

.detail-dialog::backdrop {
  background: rgb(23 35 29 / 0.48);
  backdrop-filter: blur(2px);
}

.dialog-heading {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.icon-button {
  width: 42px;
  padding: 0;
  border-color: var(--border);
  background: var(--surface);
  font-size: 24px;
  font-weight: 400;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 0.65fr);
  margin: 0;
  padding: 8px 20px 20px;
}

.detail-grid dt,
.detail-grid dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid dd {
  font-variant-numeric: tabular-nums;
}

.noscript-message {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 100;
  padding: 12px;
  border-radius: 8px;
  background: var(--danger);
  color: white;
  text-align: center;
}

@keyframes skeleton {
  from {
    background-position: 150% 0, 0 0;
  }
  to {
    background-position: -70% 0, 0 0;
  }
}

@media (max-width: 1279px) {
  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-field {
    grid-column: span 2;
  }

  .filter-actions {
    justify-content: end;
  }

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

  .analytics-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .shell {
    width: min(100% - 24px, 1440px);
  }

  .header-inner {
    min-height: 0;
    align-items: start;
    flex-direction: column;
    gap: 18px;
  }

  .freshness {
    width: 100%;
    grid-template-columns: auto 1fr auto;
  }

  .freshness .button {
    width: 44px;
    padding-inline: 0;
    overflow: hidden;
    color: transparent;
  }

  .freshness .button span {
    color: var(--text);
    font-size: 18px;
  }

  .filter-bar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
    padding: 12px;
  }

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

  .filter-actions .button {
    flex: 1;
    min-height: 44px;
  }

  input,
  select {
    min-height: 44px;
  }

  .section-heading,
  .panel-heading {
    align-items: start;
  }

  .panel-heading {
    flex-direction: column;
    gap: 6px;
  }

  .legend {
    justify-content: start;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 114px;
  }

  .panel-content {
    min-height: 260px;
    padding: 14px;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }

  tbody tr:last-child {
    border-bottom: 0;
  }

  td {
    display: grid;
    grid-template-columns: minmax(90px, 0.35fr) minmax(0, 0.65fr);
    gap: 10px;
    padding: 7px 0;
    border: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .cell-secondary {
    max-width: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid dt {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .detail-grid dd {
    padding-top: 3px;
  }
}

@media (max-width: 420px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .search-field,
  .filter-actions {
    grid-column: auto;
  }

  .section-heading {
    flex-direction: column;
    gap: 4px;
  }
}

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