:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #1b2320;
  --muted: #66706c;
  --line: #d9dfdc;
  --line-strong: #bcc6c1;
  --green: #16784b;
  --green-dark: #105c3a;
  --green-soft: #e7f5ed;
  --amber: #9a6100;
  --amber-soft: #fff3d6;
  --red: #a93232;
  --red-soft: #fdeaea;
  --charcoal: #202825;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input { font: inherit; letter-spacing: 0; }

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  background: var(--charcoal);
  color: #fff;
  border-bottom: 3px solid var(--green);
}
.brand { font-size: 17px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; align-self: stretch; align-items: stretch; gap: 2px; flex: 1; }
.topbar nav a { display: flex; align-items: center; padding: 0 16px; color: #cfd7d3; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -3px; white-space: nowrap; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; background: #2b3531; border-color: #55b887; }

.page { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 48px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: 25px; line-height: 1.25; }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.health { display: flex; align-items: center; gap: 8px; color: var(--green-dark); font-weight: 600; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #29a566; box-shadow: 0 0 0 3px #cfeede; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 28px; }
.metric { padding: 21px 24px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }

.section { margin-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; min-height: 38px; margin-bottom: 8px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading span { color: var(--muted); }
.text-link, .back-link, .mono-link { color: var(--green-dark); text-decoration: none; }
.text-link:hover, .back-link:hover, .mono-link:hover { text-decoration: underline; }
.mono, .mono-link, code { font-family: Consolas, "SFMono-Regular", monospace; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: #4e5b56; background: #f0f3f1; font-size: 13px; font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty { height: 100px; color: var(--muted); text-align: center; }
.ck-cell { min-width: 320px; max-width: 600px; }
.ck-cell code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.button, .icon-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 13px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.button:hover, .icon-button:hover { border-color: #8e9d96; background: #f7f9f8; }
.button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.button.secondary { color: var(--green-dark); border-color: #7db99a; background: var(--green-soft); }
.button.quiet { background: transparent; }
.topbar .button.quiet { color: #dce2df; border-color: #5d6964; }
.button.full { width: 100%; }
.icon-button { min-height: 29px; padding: 4px 9px; font-size: 12px; }

.filterbar { display: flex; gap: 8px; margin-bottom: 14px; }
.filterbar input { width: min(520px, 100%); min-height: 36px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 7px 10px; background: #fff; }
.filterbar input:focus, .login-form input:focus { outline: 2px solid #86c8a7; outline-offset: 1px; border-color: var(--green); }

.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.success { color: var(--green-dark); background: var(--green-soft); }
.tag.warning { color: var(--amber); background: var(--amber-soft); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 18px; color: var(--muted); }
.details-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.details-grid div { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.details-grid div:nth-child(4n) { border-right: 0; }
.details-grid div:nth-last-child(-n+4) { border-bottom: 0; }
.details-grid dt { color: var(--muted); margin-bottom: 6px; }
.details-grid dd { margin: 0; word-break: break-all; }

.login-page { min-height: 100vh; width: 100%; padding: 0; display: grid; place-items: center; background: #eef2f0; }
.login-panel { width: min(400px, calc(100% - 32px)); background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 6px; padding: 30px; box-shadow: 0 10px 35px rgba(20, 35, 28, 0.08); }
.login-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 25px; }
.login-heading h1 { margin: 0; font-size: 22px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 6px; color: #46514c; font-weight: 600; }
.login-form input { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 8px 10px; margin-bottom: 5px; }
.login-form button { margin-top: 10px; }
.notice { width: min(600px, 100%); padding: 10px 12px; margin-bottom: 14px; border-radius: 5px; }
.notice.error { color: var(--red); background: var(--red-soft); border: 1px solid #efb8b8; }

@media (max-width: 850px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 10px 14px 0; gap: 8px 12px; }
  .topbar > form { grid-column: 2; grid-row: 1; justify-self: end; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; width: auto; min-width: 0; min-height: 42px; margin: 0 -14px; padding: 0 8px; overflow-x: auto; overflow-y: hidden; }
  .topbar nav a { flex: 0 0 auto; min-height: 42px; padding: 0 12px; margin-bottom: 0; }
  .page { width: min(100% - 20px, 1500px); padding-top: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .details-grid { grid-template-columns: repeat(2, 1fr); }
  .details-grid div:nth-child(2n) { border-right: 0; }
  .details-grid div:nth-last-child(-n+4) { border-bottom: 1px solid var(--line); }
  .details-grid div:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 520px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .filterbar { flex-wrap: wrap; }
  .filterbar input { flex: 1 0 100%; }
  .details-grid { grid-template-columns: 1fr; }
  .details-grid div { border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .details-grid div:last-child { border-bottom: 0 !important; }
}
