:root {
  --bg: #0e1117;
  --card: #161b22;
  --card-2: #1c2230;
  --border: #232a36;
  --text: #e6edf3;
  --muted: #7d8590;
  --green: #2ecc8f;
  --green-dim: #1f9d6f;
  --red: #f57b7b;
  --orange: #e3a008;
  --gray: #2b3340;
  --blue: #4d9fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.5;
}

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

.page { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; }
.page-narrow { max-width: 640px; }
.subtle { color: var(--muted); }
.small { font-size: 12px; }

/* Hero */
.hero { text-align: center; padding: 24px 0 28px; }
.hero-compact { padding: 8px 0 20px; }
.hero h1 { font-size: 32px; font-weight: 700; margin: 16px 0 8px; }
.hero-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff;
}
.hero-ok { background: var(--green); }
.hero-minor { background: var(--orange); }
.hero-major { background: var(--red); }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-head h2 { font-size: 15px; font-weight: 600; margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 20px;
  background: var(--card-2);
}
.pill-ok { color: var(--green); }
.pill-ok::before { content: "\2713"; color: var(--green); }
.pill-minor, .pill-major { color: var(--orange); }

/* Service rows */
.service { padding: 16px 0; border-top: 1px solid var(--border); }
.service:first-of-type { border-top: none; }
.service-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.service-name { font-weight: 600; }
.uptime { margin-left: auto; color: var(--green); font-size: 13px; }
.uptime.subtle { color: var(--muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-up { background: var(--green); }
.dot-down { background: var(--red); }
.dot-unknown { background: var(--muted); }

/* Uptime bars */
.bars { display: flex; gap: 2px; height: 34px; align-items: stretch; }
.bar { flex: 1; min-width: 2px; border-radius: 2px; background: var(--gray); }
.bar-up { background: var(--green); }
.bar-down { background: var(--red); }
.bar-partial { background: var(--orange); }
.bar-none { background: var(--gray); }
.bar:hover { filter: brightness(1.25); }
.bars-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

/* Notices on status page */
.notices { padding: 8px 12px; }
.notice {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 8px; color: var(--text);
}
.notice:hover { background: var(--card-2); text-decoration: none; }
.notice-title { flex: 1; font-weight: 500; }
.notice-tag {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 5px;
  background: var(--card-2); color: var(--muted); white-space: nowrap;
}
.tag-incident { background: rgba(245,123,123,.15); color: var(--red); }
.tag-maintenance { background: rgba(77,159,255,.15); color: var(--blue); }

.badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px;
  background: var(--card-2); color: var(--muted); white-space: nowrap;
}
.badge-investigating, .badge-identified { color: var(--orange); background: rgba(227,160,8,.15); }
.badge-monitoring, .badge-in_progress, .badge-scheduled { color: var(--blue); background: rgba(77,159,255,.15); }
.badge-resolved, .badge-completed { color: var(--green); background: rgba(46,204,143,.15); }

/* History list */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; border-top: 1px solid var(--border);
}
.history-list li:first-child { border-top: none; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 14px 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: none; }
.timeline-body { margin: 8px 0 4px; white-space: pre-wrap; }

/* Forms / admin */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 14px; }
.row label { flex: 1; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 9px 11px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
textarea { resize: vertical; }

.btn {
  display: inline-block; cursor: pointer; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); padding: 8px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit;
}
.btn:hover { filter: brightness(1.2); text-decoration: none; }
.btn-primary { background: var(--green-dim); border-color: var(--green-dim); color: #fff; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.link { font-size: 13px; }

.admin-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.admin-bar h1 { font-size: 22px; margin: 0; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.form-inline { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.form-inline input { flex: 1; min-width: 160px; }

/* Flash */
.flashes { max-width: 820px; margin: 12px auto 0; padding: 0 20px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.flash-ok { background: rgba(46,204,143,.15); color: var(--green); }
.flash-error { background: rgba(245,123,123,.15); color: var(--red); }

.foot { text-align: center; margin-top: 24px; font-size: 13px; }

/* Day-count label toggles (wide = full history, narrow = 30) */
.d-narrow { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .page { padding: 20px 14px 48px; }

  .hero { padding: 12px 0 18px; }
  .hero h1 { font-size: 24px; }
  .hero-icon { width: 46px; height: 46px; font-size: 22px; }
  .subtle { font-size: 13px; }

  .card { padding: 16px 16px; border-radius: 10px; }
  .card-head { flex-wrap: wrap; gap: 8px; }

  /* Show only the most recent 30 days; hide the older bars */
  .bars { height: 30px; gap: 2px; }
  .bars .bar:nth-last-child(n+31) { display: none; }
  .d-wide { display: none; }
  .d-narrow { display: inline; }

  /* Notices / history rows stack nicely */
  .notice { flex-wrap: wrap; gap: 8px; }
  .notice-title { flex-basis: 100%; order: 3; }
  .history-list li { flex-wrap: wrap; gap: 4px; }
  .history-list li .small { flex-basis: 100%; }

  /* Forms stack vertically */
  .row { flex-direction: column; gap: 14px; }
  .form-inline { flex-direction: column; }
  .form-inline input { width: 100%; }

  /* Admin */
  .admin-bar h1 { font-size: 19px; }
  .admin-actions { width: 100%; }
  .admin-actions .btn, .admin-actions form { flex: 1; }
  .admin-actions .btn { text-align: center; }

  /* Tables scroll horizontally instead of overflowing */
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Larger touch targets on coarse pointers */
@media (pointer: coarse) {
  .btn { padding: 10px 16px; }
  .bar { min-width: 3px; }
}
