:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #64726d;
  --line: #dfe7e3;
  --accent: #177b65;
  --accent-dark: #0d5d4a;
  --warn: #b42318;
  --shadow: 0 14px 40px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}

button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.metrics div {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
}

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

.metrics strong {
  font-size: 24px;
  line-height: 1.1;
  word-break: break-word;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 12px;
}

.search {
  width: min(420px, 100%);
  display: grid;
  gap: 6px;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  outline-color: var(--accent);
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 36px 0 12px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  outline-color: var(--accent);
}

#statusText {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.data-wrap table {
  min-width: 1200px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf4f1;
  color: #31423b;
  font-size: 13px;
  font-weight: 800;
}

td {
  color: #22302a;
}

tbody tr:hover td {
  background: #f8fbfa;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.table-link {
  color: var(--accent-dark);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.compact-control {
  width: 180px;
}

.table-meta {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.data-wrap td {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.num {
  white-space: nowrap;
  text-align: right;
}

.empty {
  height: 160px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.error {
  color: var(--warn);
}

@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: fit-content;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.button-link.secondary {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-dark);
}

.log-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 380px) 180px 180px auto 1fr;
  align-items: end;
}

.log-toolbar #logStatusText {
  justify-self: end;
}

.log-table-wrap td {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-table-wrap td.log-error-info {
  min-width: 320px;
  max-width: 640px;
  overflow: visible;
  text-overflow: clip;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
}

#pageInfo {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 900px) {
  .topbar-actions {
    justify-content: flex-start;
  }

  .log-toolbar {
    grid-template-columns: 1fr;
  }

  .log-toolbar #logStatusText {
    justify-self: start;
  }
}

.schema-shell {
  width: min(1900px, calc(100% - 24px));
}

.schema-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  transition: grid-template-columns 160ms ease;
}

.schema-layout.is-collapsed {
  grid-template-columns: 58px minmax(0, 1fr);
}

.schema-sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.schema-sidebar-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-toggle {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  justify-content: center;
  padding: 0;
  font-size: 24px;
}

.sidebar-body {
  padding: 12px;
}

.sidebar-search {
  width: 100%;
  margin-bottom: 10px;
}

.schema-table-list {
  max-height: calc(100vh - 164px);
  overflow-y: auto;
  display: grid;
  gap: 5px;
}

.schema-table-button {
  width: 100%;
  min-height: 52px;
  display: grid;
  gap: 3px;
  justify-items: start;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.schema-table-button:hover {
  background: #f2f8f5;
}

.schema-table-button.active {
  border-color: #a9d2c7;
  background: #e4f2ed;
  color: var(--accent-dark);
}

.schema-table-button span {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.schema-table-button small {
  color: var(--muted);
  font-weight: 500;
}

.sidebar-message {
  margin: 18px 4px;
  color: var(--muted);
  font-size: 13px;
}

.schema-layout.is-collapsed .sidebar-title,
.schema-layout.is-collapsed .sidebar-body {
  display: none;
}

.schema-layout.is-collapsed .schema-sidebar-head {
  justify-content: center;
  padding: 10px;
  border-bottom: 0;
}

.schema-content {
  min-width: 0;
}

.schema-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.schema-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 3vw, 32px);
}

#schemaStatusText {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.schema-metrics {
  grid-template-columns: repeat(6, minmax(125px, 1fr));
}

.schema-metrics strong {
  font-size: 18px;
}

.schema-comment {
  margin: 14px 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.schema-fields-table {
  min-width: 2850px;
}

.schema-fields-table th,
.schema-fields-table td {
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.schema-fields-table td {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .schema-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .schema-layout,
  .schema-layout.is-collapsed {
    grid-template-columns: 1fr;
  }

  .schema-sidebar {
    position: static;
    max-height: none;
  }

  .schema-table-list {
    max-height: 320px;
  }

  .schema-layout.is-collapsed .schema-sidebar {
    width: 58px;
  }

  .schema-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .schema-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
