:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c2330;
  --muted: #6b7585;
  --accent: #3b5bdb;
  --accent-weak: #edf0fd;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --err: #c92a2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
header h1 { margin: 0; font-size: 17px; font-weight: 600; }
header .sub { color: var(--muted); font-size: 13px; }

.layout { flex: 1; display: flex; min-height: 0; }

/* Sidebar */
.sidebar {
  width: 290px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.panel h2 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.panel input, .panel select, .panel button { width: 100%; margin-bottom: 8px; }
input, select, textarea, button { font-size: 13px; }
input[type="text"], select {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text);
}
input[type="file"] { font-size: 12px; color: var(--muted); }

button {
  cursor: pointer; border: none; border-radius: 7px; padding: 8px 14px;
  background: var(--accent); color: #fff; font-weight: 500;
}
button:hover { background: #2f4cc4; }

/* Table list */
.table-list { overflow-y: auto; flex: 1; }
.table-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.thead { padding: 8px 10px; background: var(--accent-weak); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.thead:hover { background: #e2e8fb; }
.thead .tn { font-weight: 600; font-size: 13px; }
.thead .tmeta { font-size: 11px; color: var(--muted); }
.app-cols { padding: 4px 10px 8px; }
.app-col { display: flex; justify-content: space-between; padding: 2px 0; font-size: 12px; }
.app-col .cname { font-family: var(--mono); }
.app-col .ctype { color: var(--muted); font-size: 11px; }

/* Main — note: classes are app-prefixed so they can't collide with Monaco's
   own generic class names (e.g. Monaco's suggest row uses .main). */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 14px; gap: 12px; }
.app-editor { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
#editor { width: 100%; height: 200px; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); }
.toolbar .hint { font-size: 11px; color: var(--muted); }
.status { margin-left: auto; font-size: 12px; color: var(--muted); }
.status.err { color: var(--err); }

/* Results */
.results { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: auto; min-height: 0; }
.results .empty { color: var(--muted); padding: 22px; font-size: 13px; }
.results .error { color: var(--err); padding: 16px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; margin: 0; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #f1f3f6; text-align: left; padding: 7px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
th .th-type { display: block; font-weight: 400; font-size: 10px; color: var(--muted); text-transform: none; }
tbody td { padding: 6px 12px; border-bottom: 1px solid #f0f2f4; font-family: var(--mono); white-space: nowrap; }
tbody tr:hover { background: #fafbfe; }
