:root {
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #6e7681;
  --faint: #8c959f;
  --border: #e3e6ea;
  --row-hover: #fafbfc;
  --ok: #3ba55c;
  --minor: #f0a500;
  --major: #e5534b;
  --stopped: #8c959f;
  --nodata: #c9ced6;
  --link: #2f6fde;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 850px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header ---------- */

.masthead { padding: 40px 0 36px; }
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }

.masthead-actions { display: flex; gap: 8px; }
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f6f8fa; text-decoration: none; }
.btn-primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn-primary:hover { background: #32383f; }

/* ---------- banner ---------- */

.banner {
  border-radius: 6px;
  padding: 18px 22px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.banner.operational { background: var(--ok); }
.banner.degraded { background: var(--minor); }
.banner.outage { background: var(--major); }
.banner small { font-size: 13px; font-weight: 500; opacity: 0.9; }

.notice {
  margin-top: 12px;
  border: 1px solid #f3d38a;
  background: #fff8e6;
  color: #7a5200;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
}

.uptime-caption {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  margin: 36px 0 8px;
}

/* ---------- components ---------- */

.components {
  border: 1px solid var(--border);
  border-radius: 6px;
}

.group + .group,
.component + .component { border-top: 1px solid var(--border); }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
  cursor: pointer;
  user-select: none;
}
.group-head:hover { background: var(--row-hover); }
.group-toggle {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  flex: none;
}
.group-name { font-weight: 600; flex: 1; }
.group-count { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.group-body { border-top: 1px solid var(--border); }
.group:not(.open) .group-body { display: none; }

.component { padding: 18px 22px 14px; }
.group-body .component { padding-left: 50px; }

.component-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.component-name { font-weight: 600; overflow-wrap: anywhere; }
.component-meta { color: var(--faint); font-size: 12px; font-weight: 400; margin-left: 6px; }
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: 1px;
}

.status-text { font-size: 14px; white-space: nowrap; }
.status-operational { color: var(--ok); }
.status-degraded { color: #c98900; }
.status-outage { color: var(--major); }
.status-stopped, .status-unknown { color: var(--stopped); }

.bars {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 10px;
}
.bars rect { cursor: pointer; }
.bars rect:hover { opacity: 0.7; }

.bars-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
  margin-top: 6px;
}
.bars-legend .rule { flex: 1; height: 1px; background: var(--border); }

.errors {
  margin-top: 10px;
  font-size: 13px;
}
.errors summary {
  cursor: pointer;
  color: var(--muted);
  list-style: none;
}
.errors summary::-webkit-details-marker { display: none; }
.errors summary::before { content: "▸ "; }
.errors[open] summary::before { content: "▾ "; }
.log {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}
.log time { color: var(--faint); margin-right: 8px; }

/* ---------- incidents ---------- */

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 56px 0 8px;
}

.incident-day { padding: 18px 0 6px; }
.incident-day + .incident-day { border-top: 0; }
.incident-date {
  font-weight: 700;
  font-size: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.no-incidents { color: var(--muted); font-size: 14px; }

.incident { margin-bottom: 22px; }
.incident-title { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.incident-title.outage { color: var(--major); }
.incident-title.degraded { color: #c98900; }
.incident-title.resolved { color: var(--text); }
.incident-update { margin: 4px 0; font-size: 14px; }
.incident-update strong { margin-right: 4px; }
.incident-time { color: var(--faint); font-size: 12px; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 10;
  width: 260px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.12);
  padding: 12px 14px;
  font-size: 13px;
  pointer-events: none;
}
.tooltip-date { font-weight: 700; margin-bottom: 6px; }
.tooltip-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- login ---------- */

.login {
  max-width: 360px;
  margin: 40px auto 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}
.login h1 { font-size: 18px; margin: 0 0 4px; }
.login p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login input {
  width: 100%;
  font: inherit;
  font-size: 18px;
  letter-spacing: 0.3em;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.login input:focus { outline: 2px solid var(--link); outline-offset: -1px; }
.login .btn { width: 100%; padding: 10px; font-size: 14px; }
.login-error { color: var(--major); font-size: 13px; min-height: 20px; margin-bottom: 4px; }

/* ---------- footer ---------- */

.footer {
  color: var(--faint);
  font-size: 12px;
  padding-top: 40px;
  padding-bottom: 48px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.loading { color: var(--muted); padding: 60px 0; text-align: center; }

@media (max-width: 600px) {
  .masthead { padding: 24px 0 20px; }
  .banner { font-size: 17px; padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 2px; }
  .component, .group-head { padding-left: 14px; padding-right: 14px; }
  .group-body .component { padding-left: 24px; }
}
