:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #131a22;
  --panel-2: #18212b;
  --line: #263241;
  --text: #eef4fb;
  --muted: #91a0af;
  --accent: #46d7b6;
  --accent-2: #f2c14e;
  --danger: #ff6b6b;
  --warn: #ffb454;
  --info: #6db8ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

button {
  height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--accent);
  color: #07110f;
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

input, select {
  width: 100%;
  height: 40px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0f151d;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

.hidden { display: none !important; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 15%, rgba(70, 215, 182, .18), transparent 28%),
    linear-gradient(135deg, #0d1117, #101923 55%, #111317);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: rgba(19, 26, 34, .9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand h1, .brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.15;
}

.brand p {
  color: var(--muted);
  margin-top: 3px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #07110f;
  font-weight: 900;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.error {
  min-height: 20px;
  color: var(--danger);
  margin: 0;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #0f151d;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
}

.compact h1 {
  font-size: 18px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.meta {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h2, .topbar p, .table-head h3, .table-head p {
  margin: 0;
}

.topbar h2 {
  font-size: 28px;
}

.topbar p, .table-head p {
  color: var(--muted);
  margin-top: 4px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
}

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

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px minmax(180px, .7fr);
  gap: 10px;
  margin-bottom: 14px;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-entry {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
}

.log-entry header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.level {
  min-width: 74px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 800;
  color: #07110f;
}

.ERROR, .CRITICAL { background: var(--danger); }
.WARNING { background: var(--warn); }
.INFO { background: var(--info); }
.DEBUG { background: var(--accent); }

.message {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #dce7f2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.db-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

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

.tables {
  padding: 12px;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 128px);
  overflow: auto;
  position: sticky;
  top: 24px;
}

.table-button {
  width: 100%;
  min-height: 42px;
  height: auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 9px 10px;
}

.table-button.active {
  background: #1e2b36;
  border-color: var(--accent);
}

.table-button small {
  color: var(--muted);
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 320px);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 245px);
}

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

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  max-width: 360px;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  background: #16202a;
  z-index: 1;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav {
    grid-template-columns: 1fr 1fr;
  }
  .filters, .db-layout, .table-head {
    grid-template-columns: 1fr;
  }
  .tables {
    position: static;
    max-height: 260px;
  }
}
