:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --ink: #18212b;
  --muted: #65717f;
  --line: #dce3ea;
  --panel: #ffffff;
  --accent: #166a6f;
  --accent-soft: #e6f3f2;
  --danger: #a93434;
  --danger-soft: #f8e8e8;
  --ok: #28784d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav a,
.actions a,
.button-link,
button,
.nav-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 14px;
}

nav a.active,
button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button {
  cursor: pointer;
}

nav form {
  margin: 0;
}

.nav-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

.metric,
.panel,
.account {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric span,
.kv span,
.run span,
.meta-row,
.section-head p {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.metric.danger strong {
  color: var(--danger);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 20px;
  font-size: 13px;
}

.account {
  margin-top: 18px;
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head p {
  margin: 5px 0 0;
  word-break: break-all;
}

.pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  background: #eef1f4;
}

.pill.ok {
  color: var(--ok);
  background: #e9f5ee;
}

.pill.muted {
  color: var(--muted);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.panel {
  min-width: 0;
  padding: 14px;
}

.span-2 {
  grid-column: span 2;
}

.panel h3,
.panel-title h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h3 {
  margin-bottom: 0;
}

.panel-title a,
.panel-title span {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.panel-title a:hover {
  color: var(--accent);
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #edf1f4;
}

.kv:first-of-type {
  border-top: 0;
}

.good {
  color: var(--ok);
}

.quiet,
.empty {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-top: 1px solid #edf1f4;
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td {
  max-width: 320px;
  word-break: break-word;
}

.run {
  padding: 9px 0;
  border-top: 1px solid #edf1f4;
}

.run:first-of-type {
  border-top: 0;
}

.run p {
  margin: 4px 0 0;
  word-break: break-word;
}

.notice {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.notice.success {
  background: #e9f5ee;
  color: var(--ok);
}

.notice.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.config-form textarea {
  width: 100%;
  min-height: 68vh;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font: 13px/1.5 Consolas, "Courier New", monospace;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.filter-bar label,
.login-panel label {
  display: grid;
  gap: 5px;
}

.filter-bar span,
.login-panel span {
  color: var(--muted);
  font-size: 12px;
}

.filter-bar input,
.login-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--ink);
  background: #fff;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.filter-actions a {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 14px;
}

.login-wrap {
  min-height: 60vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.login-panel h2 {
  margin: 0;
  font-size: 20px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font-size: 13px;
}

.tabs a.active {
  background: var(--accent-soft);
  border-color: #b9d9d7;
  color: var(--accent);
}

.detail-panel {
  margin-top: 12px;
}

.pagination {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.pagination a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
}

@media (max-width: 980px) {
  .summary-grid,
  .account-grid,
  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .topbar,
  .meta-row,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .account-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
