:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #172033;
  --muted: #697386;
  --accent: #1f7a5f;
  --accent-dark: #155f49;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

button.secondary:hover {
  background: #eef1f5;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

#status-line {
  color: var(--muted);
  display: inline-block;
  margin-top: 4px;
}

main {
  margin: 0 auto;
  max-width: 1440px;
  padding: 20px 24px 40px;
}

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

.metrics.small {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 16px;
}

.metrics div,
.status-card,
.table-shell,
.detail-panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics div {
  padding: 14px 16px;
}

.metrics span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.metrics strong {
  display: block;
  font-size: 26px;
  margin-top: 4px;
}

.status-card {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  margin: 4px 0 14px;
  overflow: hidden;
}

.status-card div {
  border-right: 1px solid var(--line);
  padding: 12px;
}

.status-card div:last-child {
  border-right: 0;
}

.status-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.status-card strong {
  display: block;
  font-size: 18px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0 12px;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
}

.tab.active {
  background: white;
  border-color: var(--line);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 5px;
}

label.check {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 38px;
}

input,
select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 38px;
  padding: 0 10px;
  width: 100%;
}

.table-shell {
  overflow: auto;
}

.table-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 12px;
}

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-key]:hover {
  color: var(--text);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #edf7f3;
}

.detail-panel {
  margin-top: 14px;
  padding: 16px;
}

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

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.detail-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  text-decoration: none;
}

pre {
  background: #111827;
  border-radius: 8px;
  color: #e5e7eb;
  min-height: 180px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
}

.login-panel p {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.alert {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 6px;
  color: var(--danger);
  margin-bottom: 14px;
  padding: 10px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .metrics,
  .metrics.small,
  .toolbar,
  .status-card,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .status-card div {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .status-card div:last-child {
    border-bottom: 0;
  }

  main {
    padding: 16px;
  }
}
