* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #1e1e2a;
  color: #d4d4d8;
  font-size: 14px;
}
.muted { color: #8b8b9a; }
.error { color: #f47174; min-height: 18px; margin-top: 8px; font-size: 13px; }
button {
  background: #3a3a4d; color: #e4e4e8; border: 1px solid #4a4a5f;
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
button:hover { background: #46465c; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  width: 100%; background: #2a2a38; color: #e4e4e8; border: 1px solid #44445a;
  border-radius: 6px; padding: 8px 10px; margin: 6px 0; font-size: 13px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #7c6cf0; }
label { font-size: 12px; color: #9a9aad; display: block; margin-top: 6px; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(10,10,16,.75);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.card { background: #26263400; }
.card { background: #262634; border: 1px solid #38384c; border-radius: 12px; padding: 24px; width: 380px; max-width: 92vw; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
#modal.card { width: 460px; }

/* App layout */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 280px; min-width: 200px; background: #17171f; border-right: 1px solid #2c2c3a;
  display: flex; flex-direction: column;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid #2c2c3a;
}
.brand { font-weight: 600; letter-spacing: .3px; }
.side-actions button { padding: 3px 8px; margin-left: 4px; }
#tree { flex: 1; overflow: auto; padding: 6px 0; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#tabbar {
  height: 40px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: #202028; border-bottom: 1px solid #2c2c3a;
}
#tab-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dirty-dot { color: #e2c08d; }
#editor { flex: 1; }
#welcome {
  position: absolute; inset: 40px 0 0 0; display: flex; align-items: center; justify-content: center;
  text-align: center; background: #1e1e2a;
}

/* Tree */
.node { user-select: none; }
.row {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 0;
  cursor: pointer; white-space: nowrap; border-radius: 4px;
}
.row:hover { background: #23232f; }
.row.selected { background: #2f2f45; }
.row .ico { width: 16px; text-align: center; flex: none; }
.row .lbl { overflow: hidden; text-overflow: ellipsis; }
.row.conn { font-weight: 600; }
.children { display: none; }
.node.open > .children { display: block; }
.spin { color: #7c6cf0; }

/* Context menu */
.ctx {
  position: fixed; background: #2a2a38; border: 1px solid #44445a; border-radius: 8px;
  padding: 4px; min-width: 170px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ctx div {
  padding: 7px 12px; border-radius: 5px; cursor: pointer; font-size: 13px;
}
.ctx div:hover { background: #7c6cf0; color: #fff; }
.ctx .sep { height: 1px; background: #44445a; margin: 4px 2px; padding: 0; cursor: default; }
.ctx .danger:hover { background: #c0392b; }

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.test-result { font-size: 13px; margin-top: 8px; min-height: 18px; }
.ok { color: #6ecb7f; }
