:root {
  color-scheme: light;
  --ink: #4c3431;
  --muted: #907b76;
  --line: #efd9d5;
  --surface: #ffffff;
  --background: #fae7e3;
  --accent: #e97b70;
  --accent-dark: #c9544b;
  --success: #168a47;
  --success-bg: #e8f8ee;
  --warning: #a96808;
  --warning-bg: #fff4d8;
  --danger: #b63737;
  --shadow: 0 12px 32px rgba(101, 52, 47, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.7), transparent 28rem),
    var(--background);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.tester {
  width: min(940px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
}

.intro {
  margin: 10px 0 26px;
  color: var(--muted);
}

.service-form {
  margin-bottom: 14px;
}

.service-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  outline: none;
}

.input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 123, 112, 0.18);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 0 20px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.performance-card {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head,
.card-foot,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card-head h2 {
  margin: 0;
  max-width: 680px;
  font-size: 15px;
  line-height: 1.45;
}

.badge {
  flex: 0 0 auto;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.badge[data-state="delayed"],
.badge[data-state="unstable"] {
  background: var(--warning-bg);
  color: var(--warning);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.metric {
  min-width: 0;
}

.metric-label,
.metric small {
  display: block;
  color: var(--muted);
}

.metric-label {
  margin-bottom: 5px;
  font-size: 12px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.metric small {
  margin-top: 5px;
  font-size: 11px;
}

.card-foot {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid #f2e8e5;
  color: var(--muted);
  font-size: 11px;
}

.is-loading {
  opacity: 0.72;
}

.is-error {
  border-color: rgba(182, 55, 55, 0.35);
}

.actions {
  justify-content: flex-start;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.65);
}

.error-message {
  padding: 12px 14px;
  border: 1px solid rgba(182, 55, 55, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--danger);
}

.service-overview {
  margin-top: 26px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.overview-head h2 {
  margin: 0;
  font-size: 22px;
}

.overview-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.overview-filters {
  display: flex;
  gap: 8px;
}

.overview-filters input,
.overview-filters select {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}

.overview-filters input {
  width: min(270px, 36vw);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.summary-grid div {
  padding: 12px;
  border-radius: 12px;
  background: #fff8f6;
}

.summary-grid span,
.summary-grid strong,
td small {
  display: block;
}

.summary-grid span {
  color: var(--muted);
  font-size: 11px;
}

.summary-grid strong {
  margin-top: 4px;
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #f2e8e5;
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #f2e8e5;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fff8f6;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

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

tbody tr:hover {
  background: #fffbfa;
}

td:first-child {
  max-width: 340px;
}

td small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.table-badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.table-badge[data-state="monitoring"] {
  background: #eef2f7;
  color: #657184;
}

.table-badge[data-state="no_data"] {
  background: #f6f1ef;
  color: var(--muted);
}

.table-badge[data-state="delayed"],
.table-badge[data-state="unstable"] {
  background: var(--warning-bg);
  color: var(--warning);
}

.table-action {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 11px;
}

.empty-cell {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 640px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .card-head,
  .card-foot,
  .actions {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .overview-head,
  .overview-filters {
    flex-direction: column;
  }

  .overview-filters,
  .overview-filters input,
  .overview-filters select {
    width: 100%;
  }

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