:root {
  --fg: #1d1f21;
  --muted: #646a70;
  --line: #e3e5e8;
  --soft: #f5f6f7;
  --bg: #ffffff;
  --bad: #b3261e;
  --bad-soft: #fcf1f0;
  --accent: #1d1f21;
  --accent-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e7e8;
    --muted: #9aa0a6;
    --line: #34373b;
    --soft: #1f2124;
    --bg: #161719;
    --bad: #f2867c;
    --bad-soft: #2a1c1b;
    --accent: #e6e7e8;
    --accent-fg: #161719;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: inherit; text-underline-offset: 2px; }
h1 { font-size: 1.5rem; font-weight: 600; margin: 1.5rem 0 1rem; line-height: 1.3; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 2.25rem 0 .75rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 1.25rem 0 .5rem; color: var(--muted); }
p { margin: .5rem 0; }
pre {
  background: var(--soft);
  padding: 12px;
  border-radius: 6px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
  max-width: 100%;
  white-space: pre;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.bad { color: var(--bad); }
.break, td, dd { overflow-wrap: anywhere; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 3rem; }
footer { padding-bottom: 2rem; }

/* header */
.top { border-bottom: 1px solid var(--line); }
.top-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.top nav { display: flex; flex-wrap: wrap; gap: 2px 14px; order: 3; flex: 1 1 100%; min-width: 0; }
.top nav a { text-decoration: none; color: var(--muted); padding: 4px 0; }
.top nav a[aria-current="page"] { color: var(--fg); border-bottom: 2px solid var(--fg); }
.logout { margin-left: auto; order: 2; }
@media (min-width: 720px) { .top nav { order: 1; flex: 1 1 auto; } }
.banner { background: var(--soft); border-bottom: 1px solid var(--line); font-size: .9rem; padding: 8px 0; }

/* notices and status */
.notice { border: 1px solid var(--line); background: var(--soft); padding: 10px 12px; border-radius: 6px; margin: 1rem 0; }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.status { display: inline-block; font-size: .85rem; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.status.bad { color: var(--bad); border-color: var(--bad); }
.statusbox { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 1rem 0; }
.statusbox.bad { border-color: var(--bad); background: var(--bad-soft); }
.crumb { margin: 1.25rem 0 -0.75rem; font-size: .9rem; color: var(--muted); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 1rem 0 0; }
.stats div { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 0; font-size: 1.5rem; font-weight: 600; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* lists */
ul.alerts, ul.events, ul.plain { list-style: none; padding: 0; margin: 0; }
ul.alerts li, ul.events li { border-bottom: 1px solid var(--line); padding: 10px 0; }
ul.plain li { padding: 4px 0; }
.alert-subject { font-weight: 600; }
.ev-head { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .85rem; }
.ev-level { min-width: 2.5em; }
ul.events li.bad .ev-msg { color: var(--bad); }
details { margin-top: 4px; }
summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

/* tables (cards on narrow screens) */
table.list { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); padding: 8px 10px 8px 0; }
table.list td { border-bottom: 1px solid var(--line); padding: 10px 10px 10px 0; vertical-align: top; }
@media (max-width: 719px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.list td { border: 0; padding: 2px 0; display: flex; gap: 12px; }
  table.list td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: 0 0 6.5em; }
  table.list td[data-label=""]::before { content: none; }
  table.list td > * { min-width: 0; }
}

/* definition lists */
dl.props { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: .5rem 0; }
dl.props dt { color: var(--muted); font-size: .85rem; margin-top: 10px; }
dl.props dd { margin: 0; }
@media (min-width: 720px) {
  dl.props { grid-template-columns: 9em minmax(0, 1fr); }
  dl.props dt, dl.props dd { padding: 8px 0; border-bottom: 1px solid var(--line); margin: 0; }
}

/* forms */
form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.stack.narrow { max-width: 360px; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: 6px; }
label, .label { font-weight: 500; }
input, select, textarea, button, .button { font: inherit; font-size: 16px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; max-width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg);
}
fieldset { border: 0; padding: 0; margin: 8px 0; min-width: 0; }
legend { font-weight: 500; margin-bottom: 6px; padding: 0; }
label.choice { display: block; font-weight: 400; padding: 4px 0; }
.indent { padding-left: 26px; display: flex; flex-direction: column; gap: 4px; }
.hint { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; }
button, .button {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); cursor: pointer; text-decoration: none; line-height: 1.4;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: 0; padding: 0; background: none; color: var(--muted); font-size: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 1rem 0; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.title-row h1 { margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; min-width: 0; flex: 1 1 140px; }
.tokenbox { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 1rem 0; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 2.5rem; }
.login { max-width: 360px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 0; }
pre.wrap-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
footer.footer-narrow { max-width: calc(360px + 32px); text-align: left; }
pre.script { white-space: pre; overflow-x: auto; -webkit-overflow-scrolling: touch; }
