:root {
  --bg-top: #111722;
  --bg-bottom: #0b1018;
  --panel: rgba(17, 24, 36, 0.94);
  --panel-soft: rgba(10, 17, 29, 0.9);
  --panel-border: rgba(138, 180, 255, 0.16);
  --panel-strong: rgba(138, 180, 255, 0.28);

  --text-main: #eef4ff;
  --text-muted: #b7c5d9;
  --text-faint: #8a9ab0;

  --accent: #8ab4ff;
  --accent-soft: rgba(138, 180, 255, 0.14);

  --success-soft: rgba(84, 208, 154, 0.14);
  --success-text: #8de4bc;

  --warning-soft: rgba(255, 181, 76, 0.16);
  --warning-text: #ffd28f;

  --danger-soft: rgba(255, 108, 108, 0.16);
  --danger-text: #ff9e9e;

  --shadow-lg: 0 18px 38px rgba(0, 0, 0, 0.34);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(138, 180, 255, 0.08), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  padding: 28px;
}

.lists-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.surface-toolbar,
.kpi-strip,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.surface-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  margin: 18px 0;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.toolbar-right {
  display: flex;
  align-items: center;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 180px;
}

.toolbar-field span,
.toolbar-check span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toolbar-field input,
.toolbar-field select,
.toolbar-button {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--panel-strong);
  background: rgba(8, 13, 21, 0.82);
  color: var(--text-main);
  padding: 0 14px;
  font-size: 14px;
}

.toolbar-field input:focus,
.toolbar-field select:focus,
.toolbar-button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 180, 255, 0.16);
}

.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 6px;
}

.toolbar-check input {
  width: 16px;
  height: 16px;
}

.toolbar-button {
  cursor: pointer;
  background: linear-gradient(180deg, rgba(138, 180, 255, 0.2), rgba(138, 180, 255, 0.08));
  font-weight: 600;
}

.result-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 110px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-strong);
  background: rgba(10, 16, 26, 0.88);
}

.pill-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pill-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 16px;
  padding: 18px;
  margin-bottom: 18px;
}

.kpi-card {
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 26, 38, 0.94), rgba(11, 17, 27, 0.9));
  border: 1px solid rgba(138, 180, 255, 0.12);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
}

.table-panel {
  padding: 20px 22px 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0 0 6px 0;
  font-size: 24px;
  font-weight: 700;
}

.panel-head p {
  margin: 0;
  color: var(--text-muted);
}

.load-warning {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 181, 76, 0.28);
  background: var(--warning-soft);
  color: var(--warning-text);
}

.hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: rgba(7, 12, 20, 0.72);
}

.lists-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.lists-table col.col-expand { width: 56px; }
.lists-table col.col-name { width: 35%; }
.lists-table col.col-db { width: 21%; }
.lists-table col.col-user { width: 18%; }
.lists-table col.col-refresh { width: 12%; }
.lists-table col.col-type { width: 14%; }

.lists-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 14px 12px;
  background: rgba(18, 26, 38, 0.95);
  border-bottom: 1px solid var(--panel-border);
  vertical-align: middle;
}

.lists-table tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(138, 180, 255, 0.08);
  vertical-align: middle;
}

.col-toggle {
  text-align: center;
}

.lists-table thead th.num,
.lists-table tbody td.num,
.num {
  text-align: right;
}

.list-name,
.list-db,
.list-user,
.list-refresh {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-name {
  font-weight: 700;
}

.list-db,
.list-user,
.list-refresh {
  color: var(--text-muted);
}

.expand-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--panel-strong);
  border-radius: 10px;
  background: rgba(138, 180, 255, 0.08);
  color: var(--text-main);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.expand-btn:hover {
  border-color: var(--accent);
  background: rgba(138, 180, 255, 0.16);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.type-sql {
  background: var(--success-soft);
  color: var(--success-text);
}

.badge.type-text {
  background: var(--warning-soft);
  color: var(--warning-text);
}

.badge.type-alias {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.type-unknown {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.sql-row {
  display: none;
}

.sql-row.open {
  display: table-row;
}

.sql-cell {
  padding: 0 !important;
  background: rgba(8, 12, 19, 0.9);
}

.sql-panel {
  padding: 18px 20px 20px;
  border-top: 1px solid rgba(138, 180, 255, 0.08);
}

.sql-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.sql-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sql-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.sql-code {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(138, 180, 255, 0.14);
  background: linear-gradient(180deg, rgba(14, 21, 32, 0.96), rgba(8, 13, 21, 0.96));
  color: #dfe8f8;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.detail-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid rgba(138, 180, 255, 0.14);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 21, 32, 0.96), rgba(8, 13, 21, 0.96));
}

.detail-grid col.col-display { width: 50%; }
.detail-grid col.col-alias { width: 50%; }

.detail-grid thead th {
  text-align: left;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  padding: 10px 12px 6px;
  border-bottom: 1px solid rgba(138, 180, 255, 0.08);
  background: transparent;
}

.detail-grid tbody td {
  padding: 10px 12px 12px;
  color: var(--text-main);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  border-bottom: none;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 38px 20px;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 1200px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    padding: 16px;
  }

  .surface-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    justify-content: flex-start;
  }

  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .sql-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }
}