:root {
  color-scheme: light;
  --paper: #efe6d6;
  --card: #fbf7ef;
  --ink: #221c16;
  --muted: #6d5c49;
  --line: #ddcbb3;
  --stamp: #9d2c2c;
  --up: #1f6b45;
  --down: #9d2c2c;
  --warn: #8a5a12;
  --warn-bg: #f4e2c4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    rgba(120, 90, 50, 0.08) 28px
  );
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC",
    "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  line-height: 1.45;
}

.sheet {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px 32px;
  border-left: 3px solid rgba(157, 44, 44, 0.55);
}

.login-sheet {
  width: 100%;
  max-width: 460px;
  margin-top: 8vh;
}

h1, h2 { font-weight: 650; letter-spacing: 0; }
h1 { margin: 8px 0; font-size: 1.8rem; line-height: 1.3; }
h2 { margin: 0 0 8px; font-size: 1rem; line-height: 1.35; }

.lede { margin-top: 0; max-width: 42rem; }
.fine { color: var(--muted); font-size: 0.86rem; margin: 6px 0; }
.stamp {
  display: inline-block;
  margin: 0;
  border: 2px solid var(--stamp);
  color: var(--stamp);
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 2px 8px;
  transform: rotate(-6deg);
  white-space: nowrap;
  line-height: 1.4;
}

.mast {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}
.mast > div { flex: 1 1 auto; min-width: 12rem; }
.logout { flex: 0 0 auto; margin: 0; }

label { display: block; margin-top: 12px; font-size: 0.92rem; line-height: 1.4; }
input, button {
  font: inherit;
  color: inherit;
}
input {
  display: block;
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 2px;
  line-height: 1.4;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 16px;
  padding: 8px 16px;
  background: var(--ink);
  color: #fbf7ef;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  word-break: keep-all;
}
button:hover { background: #3a3128; }
.logout button {
  margin-top: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

/* A row flex here shrinks CJK to one character per line. Keep fields stacked. */
.login-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
.login-form .field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
.login-form label {
  width: max-content;
  max-width: 100%;
  margin: 14px 0 0;
  white-space: nowrap;
}
.login-form input {
  width: 100%;
  max-height: 44px;
  margin-top: 6px;
}
.login-form button {
  align-self: flex-start;
  min-width: 7.5rem;
  height: 44px;
  margin-top: 18px;
  padding: 0 18px;
}

.conn, .banner {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--card);
}
.conn[data-state="open"] { border-color: var(--up); }
.conn[data-state="retry"], .conn[data-state="stale"], .banner { border-color: var(--warn); background: var(--warn-bg); }
.conn[data-state="error"], .banner.warn { border-color: var(--stamp); }

.panel, .card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px 14px;
  margin-top: 14px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(9rem, 1fr));
  gap: 12px;
}
.card { margin-top: 0; }
.num {
  margin: 0;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.num.missing { color: var(--muted); font-size: 1rem; }
.num.up { color: var(--up); }
.num.down { color: var(--down); }
.num.flat { color: var(--ink); }
.halt-on { color: var(--stamp); font-weight: 700; }

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(9rem, 1fr));
  gap: 10px 14px;
  margin: 0;
}
.facts div { margin: 0; }
.facts dt { color: var(--muted); font-size: 0.78rem; }
.facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }

.warnings { margin: 12px 0 0; padding-left: 1.1rem; }
.warnings li { margin: 4px 0; }
.empty { color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.table-wrap { overflow-x: auto; }
.st-confirmed { color: var(--up); }
.st-partial, .st-unknown, .st-missing { color: var(--warn); }
.st-not { color: var(--muted); }

svg { width: 100%; height: auto; display: block; background: transparent; }
#curve { min-height: 120px; }

:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

@media (max-width: 900px) {
  .cards, .facts { grid-template-columns: 1fr 1fr; }
  .mast { flex-direction: column; }
}
@media (max-width: 560px) {
  .sheet { padding-left: 16px; }
  .cards, .facts { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
}
