* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
}

button {
  font: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
}

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

input[type="text"] {
  font: inherit;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: 4px;
  padding: 6px 10px;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

select {
  font: 12px monospace;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--text-table-head);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg);
}

td { color: var(--text); }

pre {
  font: 13px/1.4 "SF Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

details { margin-bottom: 10px; }
details summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 12px;
  background: var(--bg-topbar);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar button {
  background: none;
  font-size: 18px;
  padding: 2px 8px;
  color: var(--text-dim);
}

.topbar button:hover { color: var(--text); }

.topbar-logo {
  height: 28px;
  width: 28px;
  object-fit: cover;
  border-radius: 4px;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
}

.theme-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 12px monospace;
  color: var(--text-dim);
}

/* Layout */
.layout {
  display: flex;
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Sidebars */
.sidebar {
  display: none;
  width: 250px;
  background: var(--bg-sidebar);
  flex-shrink: 0;
  padding: 12px;
  overflow-y: auto;
}

.sidebar.open { display: block; }

.sidebar-right { border-left: 1px solid var(--border); }
.sidebar-left { border-right: 1px solid var(--border); }

.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-heading);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.sidebar h4 {
  font-size: 11px;
  color: var(--text-heading);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Main content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  min-width: 0;
}

/* Query bar */
.query-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.query-bar input[type="text"] { flex: 1; }

.chat-toggle {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* Active filters */
.active-filters { margin-bottom: 10px; }
.filter-label { font-size: 12px; color: var(--text-heading); }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin: 2px;
}

.chip:hover { opacity: 0.8; }
.chip-table { background: var(--chip-table); }
.chip-host { background: var(--chip-host); }

/* Error */
.error-box {
  padding: 10px;
  margin-bottom: 10px;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  border-radius: 4px;
}

/* Chat response */
.chat-response {
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

/* SQL display */
.sql-display {
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--sql-text);
}

/* SQL log */
.sql-log { display: flex; flex-direction: column; gap: 6px; }
.sql-log-entry { border: 1px solid var(--border); border-radius: 4px; padding: 8px; }
.sql-log-header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sql-log-ts, .sql-log-q { font-size: 11px; color: var(--text-dim); }

/* Results table */
.results-wrap { overflow-x: auto; }

.results-table td {
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-count { font-size: 12px; color: var(--text-heading); margin-top: 4px; }

/* Empty state */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-heading); }

/* Filter sections */
.filter-section { margin-bottom: 8px; }

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 200px;
  overflow-y: auto;
}

.filter-list-hosts { max-height: 300px; }

.filter-item {
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.filter-item:hover { background: var(--bg-hover); }
.filter-item.active { background: var(--bg-active); color: #fff; }

.filter-search {
  width: 100%;
  margin: 3px 0;
  font-size: 13px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 3px; }

.history-item {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.history-item:hover { background: var(--bg-hover); }

.history-q { display: block; font-size: 13px; color: var(--text); }
.history-ts { display: block; font-size: 11px; color: var(--text-heading); margin-top: 1px; }

.clear-btn {
  margin-top: 10px;
  width: 100%;
  padding: 5px;
  font-size: 12px;
  background: var(--bg-hover);
  color: var(--text-dim);
}

.clear-btn:hover { background: var(--bg-card); }

.muted { color: var(--text-heading); font-size: 13px; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }
