/* === NullKit V2 Industrial-Editorial Theme === */
:root {
  --bg: #050508;
  --bg2: #0a0a0f;
  --bg3: #111118;
  --accent: #00ff9f;
  --accent-dim: #00cc7f;
  --text: #e0e0e0;
  --text-dim: #666;
  --text-muted: #444;
  --border: #1a1a24;
  --border-light: #252530;
  --font-mono: 'JetBrains Mono', monospace;
  --font-serif: 'Instrument Serif', serif;
  --radius: 4px;
  --sidebar-w: 260px;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow: hidden;
}

/* Noise overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Buttons */
.btn {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 16px;
  border: 1px solid var(--border-light);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-accent {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 700;
}
.btn-accent:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.btn-icon:hover { color: var(--accent); }

/* === LANDING === */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}
.landing-inner { text-align: center; max-width: 560px; }
.landing-title {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 8px;
}
.landing-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 32px;
}
.dropzone {
  border: 2px dashed var(--border-light);
  border-radius: 8px;
  padding: 48px 24px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(0, 255, 159, 0.03);
}
.dropzone-icon { color: var(--accent); margin-bottom: 12px; }
.dropzone-content p { margin: 4px 0; }
.dropzone-hint { color: var(--text-muted); font-size: 11px; }
.landing-actions { margin-top: 12px; }

/* === WORKSPACE === */
.workspace { display: flex; flex-direction: column; height: 100vh; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-brand { font-family: var(--font-serif); font-size: 18px; color: var(--accent); }
.topbar-file { color: var(--text-dim); font-size: 12px; }
.topbar-right { display: flex; gap: 8px; }

/* Main layout */
.main-layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--bg2);
  overflow-y: auto;
  padding: 12px 0;
  flex-shrink: 0;
}
.sidebar.collapsed { display: none; }
.sidebar-section { margin-bottom: 8px; }
.sidebar-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 4px 16px;
  margin-bottom: 2px;
}
.schema-list { list-style: none; }
.schema-list li {
  padding: 5px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  transition: background 0.1s;
}
.schema-list li:hover { background: var(--bg3); }
.schema-list li.active { background: var(--bg3); color: var(--accent); }
.schema-list .row-count {
  color: var(--text-muted);
  font-size: 10px;
}
.schema-list .item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Content */
.content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.tab {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab panels */
.tab-panel { flex: 1; overflow-y: auto; padding: 16px; }

/* Overview */
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.overview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg2);
}
.overview-card h4 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 12px;
}
.overview-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 12px; }
.overview-card dt { color: var(--text-dim); }
.overview-card dd { color: var(--text); }
.chart-card { min-height: 340px; }

/* Data browser */
.data-header { padding-bottom: 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.data-table-name { font-family: var(--font-serif); font-size: 18px; color: var(--accent); }
.data-row-count { font-size: 11px; color: var(--text-dim); }
.create-stmt {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 11px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Table */
.table-wrap { flex: 1; overflow: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg3);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-dim);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.data-table th:hover { color: var(--accent); }
.data-table th .sort-arrow { font-size: 10px; margin-left: 4px; }
.data-table th .col-type { font-size: 9px; color: var(--text-muted); font-weight: 400; display: block; }
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.cell-null { color: var(--text-muted); font-style: italic; }
.cell-blob { color: var(--accent-dim); font-size: 11px; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.pagination button {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: default; }

/* Query editor */
.query-editor { margin-bottom: 8px; flex-shrink: 0; }
#sql-input {
  width: 100%;
  height: 120px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  outline: none;
}
#sql-input:focus { border-color: var(--accent); }
.query-toolbar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
#query-history-select {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: var(--radius);
  max-width: 300px;
}
.query-error {
  background: rgba(255, 60, 60, 0.1);
  border: 1px solid rgba(255, 60, 60, 0.3);
  color: #ff6b6b;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 8px;
}
.query-info { font-size: 11px; color: var(--text-muted); padding: 4px 0; flex-shrink: 0; }

/* Footer */
.footer {
  text-align: center;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--accent); }

/* === STATIC PAGES === */
.static-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 60px 24px;
}
.static-page h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 400;
}
.static-page h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 12px;
  font-weight: 400;
}
.static-page p, .static-page li {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
}
.static-page ul { padding-left: 20px; }
.static-page code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}
.static-footer {
  max-width: 680px;
  margin: 60px auto 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
.static-footer a { color: var(--text-dim); }
.back-link { display: inline-block; margin-bottom: 24px; font-size: 12px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar.mobile-open { display: block; position: fixed; z-index: 100; left: 0; top: 44px; bottom: 0; width: 260px; }
  .overview-grid { grid-template-columns: 1fr; }
  .landing-title { font-size: 2.5rem; }
}
