:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --line: #d9e0e7;
  --line-strong: #bfccd8;
  --text: #17202a;
  --muted: #637083;
  --accent: #0f7b6c;
  --accent-soft: #e4f3f0;
  --warn: #b66a00;
  --error: #b42318;
  --ok: #177245;
  --shadow: 0 10px 24px rgba(27, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 760;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 720;
}

#eventTitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}

.dot.ok {
  background: var(--ok);
}

.dot.error {
  background: var(--error);
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.metrics article {
  min-height: 84px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metrics span,
.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.jp {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.78;
  margin-left: 0.35em;
  font-size: 0.82em;
  white-space: nowrap;
}

th .jp {
  display: block;
  margin-left: 0;
  margin-top: 1px;
  font-size: 0.78em;
}

h1 .jp {
  font-size: 0.5em;
}

.metrics strong {
  font-size: 20px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 10px;
}

#refreshButton {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease;
}

#refreshButton:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

#refreshButton:focus-visible {
  outline: 3px solid rgba(15, 123, 108, 0.24);
  outline-offset: 2px;
}

.tableWrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tableWrap.tall {
  max-height: 560px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

td {
  font-variant-numeric: tabular-nums;
}

.nameCell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.idCell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

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

.deltaUp {
  color: var(--ok);
  font-weight: 700;
}

.deltaFlat {
  color: var(--muted);
}

.deltaDown {
  color: var(--error);
  font-weight: 700;
}

#trendCanvas {
  width: 100%;
  height: 320px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 12px;
}

.eventsList {
  display: grid;
  gap: 10px;
}

.eventItem,
.adviceItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.eventItem strong,
.adviceItem strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.eventItem span,
.adviceItem span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.adviceList {
  display: grid;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  min-width: 72px;
  justify-content: center;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 720;
}

.tag.warn {
  background: #fff3dc;
  color: var(--warn);
}

.tag.hot {
  background: #fde7e3;
  color: var(--error);
}

.empty {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-top: 16px;
  }

  .topbar {
    flex-direction: column;
  }

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

  h1 {
    font-size: 24px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .nameCell {
    max-width: 128px;
  }
}

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