:root {
  --bg: #171717;
  --bg-sidebar: #1f1f1f;
  --bg-panel: #1f1f1f;
  --bg-hover: #2a2a2a;
  --bg-input: #2e2e2e;
  --border: #2e2e2e;
  --border-light: #3a3a3a;
  --text: #ededed;
  --text-muted: #a1a1a1;
  --text-dim: #707070;
  --brand: #3ecf8e;
  --brand-dim: #248a5c;
  --brand-glow: rgba(62, 207, 142, 0.15);
  --danger: #f56565;
  --warning: #ecc94b;
  --info: #63b3ed;
  --sidebar-w: 240px;
  --topbar-h: 52px;
  --radius: 6px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-screen { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 0%, #1a3d2e 0%, var(--bg) 55%); }
.login-card { width: min(400px, 92vw); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; text-align: center; box-shadow: 0 16px 48px rgba(0,0,0,.45); }
.brand-mark span { display: inline-flex; width: 48px; height: 48px; align-items: center; justify-content: center; background: var(--brand-glow); border-radius: 10px; font-size: 1.5rem; margin-bottom: .75rem; }
.login-card h1 { font-size: 1.5rem; font-weight: 600; }
.subtitle, .page-desc { color: var(--text-muted); font-size: .875rem; margin-top: .35rem; }
.login-card input { width: 100%; margin-top: .65rem; padding: .7rem .85rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); outline: none; }
.login-card input:focus { border-color: var(--brand); }
.error { color: var(--danger); font-size: .8rem; min-height: 1.2em; margin-top: .5rem; }
.link-muted { display: block; margin-top: 1rem; color: var(--text-muted); font-size: .8rem; }

.btn { border: none; border-radius: var(--radius); padding: .55rem 1rem; font-size: .875rem; font-weight: 500; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--brand); color: #0d2b1d; width: 100%; margin-top: 1rem; }
.btn-primary:hover { background: #36b87d; }
.btn-primary.sm { width: auto; margin-top: 0; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: .4rem .75rem; border-radius: var(--radius); cursor: pointer; font-family: inherit; font-size: .8rem; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost.sm { padding: .35rem .65rem; }

.app { display: flex; height: 100vh; overflow: hidden; }
.sb-sidebar { width: var(--sidebar-w); background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sb-org { padding: 1rem; border-bottom: 1px solid var(--border); }
.sb-logo { font-weight: 700; font-size: .95rem; color: var(--brand); }
.sb-project { font-size: .75rem; color: var(--text-dim); margin-top: .15rem; }
.sb-nav { flex: 1; overflow-y: auto; padding: .5rem; }
.sb-section { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: .75rem .65rem .25rem; }
.sb-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .65rem; border: none; background: none; color: var(--text-muted); border-radius: var(--radius); cursor: pointer; font-size: .8125rem; text-align: left; font-family: inherit; text-decoration: none; }
.sb-item .ico { width: 1rem; text-align: center; opacity: .75; font-size: .85rem; }
.sb-item:hover { background: var(--bg-hover); color: var(--text); }
.sb-item.active { background: var(--brand-glow); color: var(--brand); }
.sb-item.link { display: flex; }
.sb-footer { padding: .75rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.user-badge { font-size: .75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.sb-topbar { height: var(--topbar-h); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; background: var(--bg-sidebar); flex-shrink: 0; }
.breadcrumb { font-size: .8125rem; color: var(--text-muted); }
.breadcrumb .sep { margin: 0 .35rem; opacity: .5; }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.pill { font-size: .7rem; padding: .2rem .55rem; border-radius: 999px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pill-ok { background: var(--brand-glow); color: var(--brand); }

.view { display: none; flex: 1; overflow: auto; padding: 1.5rem 1.75rem; }
.view.active { display: block; }
.page-title { font-size: 1.35rem; font-weight: 600; margin-bottom: .25rem; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .85rem; margin: 1.25rem 0; }
.metric-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.metric-card:hover { border-color: var(--border-light); }
.metric-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.metric-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; line-height: 1.1; }
.metric-card.green .metric-value { color: var(--brand); }
.metric-card.blue .metric-value { color: var(--info); }
.metric-card.amber .metric-value { color: var(--warning); }
.metric-sub { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

.panel-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: .85rem; margin-bottom: .85rem; }
@media (max-width: 900px) { .panel-row { grid-template-columns: 1fr; } }
.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .85rem; }
.panel h3 { font-size: .8125rem; font-weight: 600; color: var(--text-muted); margin-bottom: .85rem; }

.bar-chart { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 48px; gap: .65rem; align-items: center; font-size: .78rem; }
.bar-name { color: var(--text-muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-dim), var(--brand)); border-radius: 4px; min-width: 2px; }
.bar-count { text-align: right; color: var(--text-dim); font-family: var(--mono); }

.storage-stats { display: grid; gap: .65rem; }
.storage-row { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.storage-row:last-child { border-bottom: none; font-weight: 600; color: var(--brand); }

.activity-list { display: flex; flex-direction: column; gap: .45rem; }
.activity-item { display: flex; justify-content: space-between; padding: .55rem .65rem; background: var(--bg); border-radius: var(--radius); font-size: .8125rem; }
.activity-item span:first-child { color: var(--text-muted); font-family: var(--mono); }

.view-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: .85rem; }
.select { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); padding: .45rem .7rem; border-radius: var(--radius); font-family: var(--mono); font-size: .8125rem; outline: none; }
.muted { color: var(--text-muted); font-size: .8125rem; }
.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 220px); }
.data-table { width: 100%; border-collapse: collapse; font-size: .8125rem; font-family: var(--mono); }
.data-table th { position: sticky; top: 0; background: #252525; text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 500; white-space: nowrap; z-index: 1; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.data-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.data-table .null { color: var(--text-dim); font-style: italic; }
.placeholder { padding: 2.5rem; text-align: center; color: var(--text-dim); }
.pagination { display: flex; align-items: center; gap: .5rem; padding: .65rem 1rem; border-top: 1px solid var(--border); font-size: .8125rem; color: var(--text-muted); }
.pagination button { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text); padding: .3rem .6rem; border-radius: var(--radius); cursor: pointer; font-size: .8125rem; }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

.sql-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: .65rem; }
.check { display: flex; align-items: center; gap: .35rem; font-size: .8125rem; color: var(--text-muted); }
.hint { margin-left: auto; font-size: .75rem; color: var(--text-dim); }
.sql-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: .85rem; }
.sql-wrap .CodeMirror { height: 180px; font-family: var(--mono); font-size: .875rem; }
.result-panel { padding: 0; }
.result-head { display: flex; justify-content: space-between; padding: .6rem 1rem; border-bottom: 1px solid var(--border); font-size: .8125rem; }
.ok { color: var(--brand); }
.err { color: var(--danger); }

.schema-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .85rem; margin-top: 1rem; }
.schema-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.schema-head { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.schema-head h4 { font-family: var(--mono); font-size: .875rem; color: var(--brand); }
.schema-head span { font-size: .75rem; color: var(--text-dim); }
.schema-col { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; padding: .35rem 1rem; font-size: .78rem; font-family: var(--mono); border-bottom: 1px solid rgba(255,255,255,.03); }
.col-type { color: var(--warning); font-size: .72rem; }
.badge { font-size: .65rem; padding: .1rem .35rem; border-radius: 3px; background: var(--brand-glow); color: var(--brand); }
.code-block { display: block; padding: .85rem 1rem; background: var(--bg); border-radius: var(--radius); font-family: var(--mono); font-size: .8125rem; color: var(--brand); margin-top: .65rem; }
