:root {
  --bg: #fff;
  --nav: #f3f3f3;
  --line: #d0d0d0;
  --ink: #222;
  --muted: #666;
  --link: #235a81;
  --link-hover: #d44917;
  --th: #d3dce3;
  --hover: #fff6d9;
  --ok-bg: #dff0d8;
  --ok-bd: #c3d6b3;
  --ok-fg: #2d6a2d;
  --err-bg: #f2dede;
  --err-bd: #e0b4b4;
  --err-fg: #a94442;
  --warn-bg: #fcf8e3;
  --warn-bd: #f0e1a8;
  --warn-fg: #8a6d3b;
  --menu: #f7f7f7;
  --here: #d6e6f2;
  --blue: #2f628b;
  --shadow: 0 1px 0 rgba(0, 0, 0, .04);
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  font-size: 13px;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
code, .mono, textarea, .sql-echo {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.skip {
  position: absolute; left: -999px; top: 0; background: var(--blue); color: #fff; padding: 8px 12px;
}
.skip:focus { left: 0; z-index: 10; }

#boot, #blocked {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(#eef3f7, #fff 40%);
}
.boot-card, .blocked-card {
  max-width: 640px; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 28px 22px; box-shadow: 0 8px 30px rgba(20, 40, 60, .08);
}
.boot-card h1, .blocked-card h1 { margin: 8px 0 8px; font-size: 1.45rem; color: var(--blue); }
.muted { color: var(--muted); }
.spinner {
  width: 22px; height: 22px; border: 3px solid #d3dce3; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; color: inherit; }
.brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand span { color: var(--muted); font-size: 12px; }
.top-meta { margin-left: auto; text-align: right; color: var(--muted); font-size: 12px; }
.top-meta b { color: var(--ink); font-weight: 600; }

.menu {
  display: flex; flex-wrap: wrap; gap: 0;
  background: var(--menu); border-bottom: 1px solid var(--line); padding: 0 8px;
}
.menu a {
  display: inline-block; padding: 8px 12px; color: var(--link);
  border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px;
}
.menu a:hover { color: var(--link-hover); text-decoration: none; background: #fff; }
.menu a.active {
  background: #fff; border-color: var(--line); color: var(--ink); font-weight: 700;
  border-bottom: 1px solid #fff;
}

.layout { flex: 1; display: flex; min-height: 0; }
#nav {
  width: 272px; flex: none; background: var(--nav);
  border-right: 1px solid var(--line); overflow: auto; padding: 8px 8px 24px;
}
.nav-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 4px 6px; }
.nav-head h2 { margin: 0; font-size: 13px; }
#nav-filter, .content input[type="text"], .content input[type="number"], .content select, textarea {
  width: 100%; border: 1px solid #bbb; border-radius: 2px; padding: 4px 6px; background: #fff;
}
#nav-filter { margin-bottom: 8px; }
.nav-tools { display: flex; gap: 6px; margin-bottom: 8px; }
.nav-tools a, .nav-tools button { font-size: 12px; }

.db-line { display: flex; align-items: center; gap: 2px; }
.twist {
  width: 18px; height: 22px; border: 0; background: transparent; cursor: pointer; color: #444; padding: 0;
}
.db-line > a, .tbl a { display: block; padding: 3px 6px; border-radius: 3px; }
.db-line > a { font-weight: 650; }
.db-line > a.here, .tbl a.here { background: var(--here); }
.tables { list-style: none; margin: 0 0 6px; padding: 0 0 0 22px; }
.tbl a::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  background: #c5ced6; border: 1px solid #9aa7b2; vertical-align: middle;
}
.tbl.view a::before { background: #e7d5f5; border-color: #b79ac8; }
.sys-toggle { display: flex; gap: 6px; align-items: center; margin: 10px 4px; color: var(--muted); font-size: 12px; }

.content { flex: 1; overflow: auto; padding: 12px 16px 40px; min-width: 0; }
.crumb { color: var(--muted); margin: 0 0 8px; }
.crumb a { font-weight: 600; }
h1 { font-size: 1.25rem; margin: 0 0 10px; font-weight: 650; }
h2.section { font-size: 1rem; margin: 18px 0 8px; }

.msg { border: 1px solid; border-radius: 3px; padding: 8px 12px; margin: 0 0 12px; }
.msg.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.msg.err { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-fg); }
.msg.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }
.msg p { margin: 4px 0; }
.msg code { background: rgba(255,255,255,.55); padding: 0 3px; }

.sql-echo {
  background: #f6f6f6; border: 1px solid #e1e1e1; padding: 8px 10px; margin: 0 0 8px;
  white-space: pre-wrap; overflow-x: auto; font-size: 12.5px;
}

.table-wrap { overflow: auto; border: 1px solid #ccc; margin: 0 0 14px; }
table.data { border-collapse: collapse; width: 100%; background: #fff; }
table.data th, table.data td {
  border: 1px solid #ddd; padding: 4px 8px; text-align: left; vertical-align: top;
}
table.data th { background: var(--th); font-weight: 700; white-space: nowrap; }
table.data tbody tr:hover td { background: var(--hover); }
table.data .null { color: #888; font-style: italic; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data a.icon-btn { margin-right: 6px; }

.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.pager select { width: auto; }

button, .btn {
  background: #f3f3f3; border: 1px solid #aaa; border-radius: 3px;
  padding: 4px 10px; cursor: pointer; text-decoration: none; color: var(--ink);
  display: inline-block;
}
button:hover, .btn:hover { background: #fff; color: var(--ink); text-decoration: none; }
button.primary, .btn.primary { background: var(--blue); color: #fff; border-color: #234e70; }
button.primary:hover, .btn.primary:hover { background: #3d78a4; color: #fff; }
button.danger { background: #b94a48; color: #fff; border-color: #8d3533; }
button.danger:hover { background: #c45c5a; color: #fff; }
button:disabled { opacity: .6; cursor: default; }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 8px 0 14px; }
.form-row label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.form-row input, .form-row select { width: auto; min-width: 8rem; font-weight: 400; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }

textarea.sql {
  min-height: 180px; resize: vertical; line-height: 1.45; padding: 8px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.toolbar select { width: auto; max-width: 100%; }

#run-progress {
  background: #e8f1f8; border: 1px solid #b7cfe0; padding: 6px 10px; margin: 0 0 10px;
}

.grid-editor input, .grid-editor select { width: 100%; min-width: 5.5rem; }
.grid-editor .tiny { width: 3.2rem; min-width: 0; }
.check { text-align: center; }

dialog { border: 1px solid #999; border-radius: 6px; padding: 16px 18px; max-width: 480px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 8px; font-size: 1.05rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.dropzone {
  border: 1px dashed #aaa; background: #fafafa; padding: 12px; border-radius: 4px; margin-bottom: 8px;
}
.guides { margin-left: 8px; }
.guides summary { cursor: pointer; color: var(--link); }
.guides a { display: block; padding: 3px 0; }
.limits { margin-top: 8px; }
.try-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.try-list button { text-align: left; }

.statusbar {
  border-top: 1px solid var(--line); background: #f7f7f7; color: var(--muted);
  padding: 4px 12px; font-size: 12px;
}
body.is-busy { cursor: progress; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid #7ab3d9; outline-offset: 2px; }
#main:focus { outline: none; }
.blocked-card a { font-weight: 650; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  #nav { width: auto; max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .top { flex-wrap: wrap; }
  .top-meta { margin-left: 0; text-align: left; }
}
