:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #20242a;
  background: #f5f6f8;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 12px;
  color: #eef1f4;
  background: #22272e;
  border-right: 1px solid #11151a;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 8px 20px;
  font-size: 16px;
  font-weight: 700;
}
.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: #db3b2f;
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 0;
}
.navigation { display: grid; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  gap: 10px;
  padding: 8px 10px;
  color: #b9c0c8;
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}
.nav-item:hover, .nav-item.active { color: #fff; background: #343b44; }
.nav-icon {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #d6dbe0;
  font: 13px "Cascadia Code", Consolas, monospace;
  text-align: center;
}
.nav-icon svg, .icon-button svg, .tree-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 10px 0;
  color: #aeb6bf;
  border-top: 1px solid #3b424b;
  font-size: 12px;
}
.status-dot { width: 8px; height: 8px; background: #3fb950; border-radius: 50%; }

.workspace { min-width: 0; padding: 24px 28px 32px; }
.view { display: none; max-width: 1600px; margin: 0 auto; }
.view.active { display: block; }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 58px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 4px;
  color: #6d737c;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 3px; font-size: 15px; letter-spacing: 0; }

.run-button, .secondary-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 650;
}
.run-button {
  min-width: 88px;
  color: #fff;
  background: #167d4e;
  border: 1px solid #116b41;
}
.run-button:hover { background: #116b41; }
.run-button:disabled { cursor: wait; opacity: .65; }
.secondary-button { color: #272c33; background: #fff; border: 1px solid #c9ced5; }
.secondary-button:hover { background: #f2f4f6; }
.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  color: #4d5660;
  background: #fff;
  border: 1px solid #c9ced5;
}
.icon-button:hover { color: #20242a; background: #f2f4f6; }

.editor-panel, .results-panel, .catalog-wrap, .workspace-tree-panel {
  overflow: hidden;
  background: #fff;
  border: 1px solid #d8dce1;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgb(20 26 33 / 5%);
}
.editor-panel { margin-bottom: 18px; }
.panel-toolbar, .results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 9px 14px;
  border-bottom: 1px solid #e1e4e8;
  font-size: 12px;
  font-weight: 650;
}
.muted { color: #727983; font-size: 12px; font-weight: 400; }
.editor-area {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  height: 282px;
  background: #fbfcfd;
}
.line-numbers {
  padding: 16px 12px;
  color: #9aa1aa;
  background: #f4f6f8;
  border-right: 1px solid #e3e6ea;
  font: 13px/1.6 "Cascadia Code", Consolas, monospace;
  text-align: right;
  user-select: none;
}
#sql-editor {
  width: 100%;
  height: 100%;
  padding: 16px;
  resize: none;
  color: #1f2933;
  background: transparent;
  border: 0;
  outline: none;
  font: 13px/1.6 "Cascadia Code", Consolas, monospace;
  tab-size: 2;
}
.results-panel { min-height: 300px; }
.results-header { min-height: 53px; }
.results-content { min-height: 246px; overflow: auto; }
.empty-state {
  display: grid;
  min-height: 246px;
  place-content: center;
  color: #747b84;
  text-align: center;
}
.empty-state p { margin-bottom: 0; font-size: 13px; }
.empty-icon {
  display: grid;
  width: 48px;
  height: 42px;
  place-items: center;
  margin: 0 auto 12px;
  color: #69717b;
  background: #edf0f3;
  border: 1px solid #d5dae0;
  border-radius: 5px;
  font: 12px "Cascadia Code", Consolas, monospace;
}
.error-state {
  padding: 18px;
  color: #8d241e;
  background: #fff6f5;
  border-bottom: 1px solid #f0cfcb;
  font: 13px/1.5 "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
}

.data-table, .catalog-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.data-table th, .catalog-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  color: #4f5660;
  background: #f2f4f6;
  border-bottom: 1px solid #d8dce1;
  font-weight: 650;
  white-space: nowrap;
}
.data-table td, .catalog-table td {
  max-width: 360px;
  padding: 9px 12px;
  overflow: hidden;
  border-bottom: 1px solid #eceef1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover, .catalog-table tbody tr:hover { background: #f1f6f4; }
.catalog-wrap { min-height: 200px; }
.catalog-table td:first-child {
  color: #176a46;
  font-family: "Cascadia Code", Consolas, monospace;
  font-weight: 650;
}
.catalog-empty { padding: 32px; color: #737a83; font-size: 13px; text-align: center; }
.catalog-empty[hidden] { display: none; }

.workspace-tree-panel { min-height: 320px; padding: 10px 8px; }
.workspace-tree { color: #353b43; font-size: 13px; }
.workspace-tree details { margin: 0; }
.workspace-tree summary { list-style: none; }
.workspace-tree summary::-webkit-details-marker { display: none; }
.tree-row {
  display: grid;
  grid-template-columns: 16px 20px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 34px;
  padding: 4px 10px 4px calc(10px + (var(--tree-depth) * 18px));
  border-radius: 4px;
}
.tree-row:hover { background: #f2f4f6; }
.tree-toggle { color: #7a828c; font-size: 11px; transition: transform .12s ease; }
details[open] > summary .tree-toggle { transform: rotate(90deg); }
.tree-icon { display: grid; color: #5d6772; place-items: center; }
.tree-icon.folder { color: #aa6b12; }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-size { padding-left: 18px; color: #858c95; font-size: 11px; }
.tree-empty { padding: 8px 10px 8px calc(46px + (var(--tree-depth) * 18px)); color: #858c95; }

.workflows-view.active { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.workflows-view .page-header { flex: 0 0 auto; }
.workflow-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 560px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d8dce1;
  border-radius: 6px;
}
#workflow-frame { width: 100%; height: 100%; border: 0; }
.frame-status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #737a83;
  background: #fff;
  font-size: 13px;
}
.frame-status[hidden] { display: none; }
.frame-status.error { color: #8d241e; background: #fff6f5; }

@media (max-width: 760px) {
  .app-shell { display: block; min-height: 100vh; }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    height: auto;
    padding: 10px 12px;
  }
  .brand { min-height: 38px; padding: 0; }
  .navigation { display: flex; grid-column: 1 / -1; grid-row: 2; margin-top: 8px; }
  .nav-item { width: auto; }
  .nav-item span:last-child { display: none; }
  .connection-status { margin: 0; padding: 0; border: 0; }
  .workspace { padding: 18px 14px 24px; }
  .page-header { align-items: center; }
  .editor-area { grid-template-columns: 1fr; height: 320px; }
  .line-numbers { display: none; }
  .workflows-view.active { height: calc(100vh - 116px); }
  .workflow-frame-wrap { min-height: 520px; }
}
