/* Тёмная тема в духе MongoDB Compass */
:root {
  --bg: #001e2b;
  --bg-2: #0b2530;
  --panel: #112733;
  --panel-2: #1c2d38;
  --hover: #1f3440;
  --border: #3d4f58;
  --border-soft: #26404c;
  --text: #e8edeb;
  --muted: #889397;
  --dim: #5c6c75;
  --green: #00ed64;
  --green-2: #00a35c;
  --green-3: #71f6ba;
  --green-bg: #023430;
  --green-bg-2: #00684a;
  --blue: #0498ec;
  --blue-2: #7ecbff;
  --red: #ff6960;
  --red-bg: #3a1a1c;
  --yellow: #ffc010;
  --yellow-bg: #3b2a02;
  --purple: #b45af2;
  /* типы значений */
  --t-key: #c1c7c6;
  --t-string: #71f6ba;
  --t-number: #7ecbff;
  --t-bool: #f7a4e5;
  --t-null: #889397;
  --t-oid: #ffc010;
  --t-date: #f89a6b;
  --t-other: #c3b1fa;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Euclid Circular A", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar: 56px;
  --sidebar: 280px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
a { color: var(--green-3); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
::selection { background: var(--green-bg-2); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a4450; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- элементы управления */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  cursor: pointer; white-space: nowrap; font-weight: 500; user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--hover); border-color: #5c6c75; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--green-bg-2); border-color: var(--green-2); color: #fff; }
.btn.primary:hover { background: #00593f; border-color: var(--green); }
.btn.accent { background: var(--green); border-color: var(--green); color: #001e2b; font-weight: 600; }
.btn.accent:hover { background: var(--green-3); }
.btn.danger { background: var(--red-bg); border-color: #8f2d2a; color: #ffcdc7; }
.btn.danger:hover { background: #52201f; border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(0, 237, 100, .12); }
.input.error, .textarea.error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 105, 96, .12); }
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; tab-size: 2; }
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23889397' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--green); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.hint { color: var(--muted); font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.err-text { color: var(--red); }
.ok-text { color: var(--green); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.badge.green { background: var(--green-bg); color: var(--green); border-color: #0b4a3a; }
.badge.red { background: var(--red-bg); color: var(--red); border-color: #5b2826; }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); border-color: #5a4308; }
.badge.blue { background: #06324a; color: var(--blue-2); border-color: #0d4c6e; }

/* ---------- каркас */
.app { display: grid; grid-template-rows: var(--topbar) 1fr; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--border-soft); min-width: 0;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 22px; height: 22px; }
.logo small { font-weight: 500; color: var(--green); font-size: 12px; border: 1px solid #0b4a3a; background: var(--green-bg); border-radius: 20px; padding: 1px 8px; }
.conn-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 32px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 20px; color: var(--muted); font-size: 13px;
}
.conn-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex: none; }
.conn-chip .dot.warn { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.conn-chip .dot.bad { background: var(--red); box-shadow: 0 0 8px var(--red); }
.conn-chip b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-switch { display: inline-flex; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 20px; padding: 2px; }
.mode-switch button { border: 0; background: transparent; color: var(--muted); height: 28px; padding: 0 12px; border-radius: 16px; cursor: pointer; font-size: 13px; font-weight: 600; }
.mode-switch button.on { background: var(--green-bg-2); color: #fff; }
.user-btn { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green-bg-2); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.burger { display: none; }

.body { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 0; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; min-height: 0;
}
.sidebar .nav { padding: 10px 8px 6px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border-soft); }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; font-weight: 500; border: 0; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.on { background: var(--green-bg); color: var(--green); }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.tree-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; }
.tree-head h4 { margin: 0; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); flex: 1; }
.tree-search { padding: 0 10px 8px; }
.tree-search .input { height: 32px; }
.tree { flex: 1; overflow: auto; padding: 0 6px 16px; }
.tree-db, .tree-coll {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text); white-space: nowrap; min-width: 0;
}
.tree-db:hover, .tree-coll:hover { background: var(--hover); text-decoration: none; }
.tree-db.on, .tree-coll.on { background: var(--green-bg); color: var(--green); }
.tree-db .name, .tree-coll .name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tree-db .caret { width: 14px; height: 14px; transition: transform .15s; color: var(--muted); flex: none; }
.tree-db.open .caret { transform: rotate(90deg); }
.tree-db svg.i, .tree-coll svg.i { width: 15px; height: 15px; color: var(--muted); flex: none; }
.tree-db.on svg.i, .tree-coll.on svg.i { color: var(--green); }
.tree-coll { padding-left: 30px; font-size: 13.5px; }
.tree-db .acts, .tree-coll .acts { display: none; }
.tree-db:hover .acts, .tree-coll:hover .acts { display: flex; }
.acts-in { display: flex; gap: 2px; }
@media (hover: none) { .tree-db .acts { display: flex; } }
.tree-empty { padding: 6px 30px; color: var(--dim); font-size: 13px; }

.main { overflow: auto; min-width: 0; min-height: 0; position: relative; }
.page { padding: 20px 24px 40px; max-width: 1400px; margin: 0 auto; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.page-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; word-break: break-all; }
.page-title .stats { display: flex; gap: 6px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px; }
/* Вертикальные отступы между блоками страницы; внутри сетки отступы задаёт gap */
.card + .card, .grid + .card, .card + .grid, .grid + .grid, .summary-grid + .grid { margin-top: 14px; }
.grid > .card + .card, .docs > .card + .card { margin-top: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- вкладки */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border-soft); margin: 0 -24px 16px; padding: 0 24px;
  overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; color: var(--muted);
  cursor: pointer; white-space: nowrap; font-weight: 500; border: 0; background: transparent;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--green); }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--green); }
.tab svg { width: 16px; height: 16px; }

/* ---------- строка запроса */
.querybar { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; }
.qline { display: flex; align-items: flex-start; gap: 8px; }
.qfield { display: flex; align-items: flex-start; flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .12s, box-shadow .12s; }
.qfield:focus-within { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(0, 237, 100, .12); }
.qfield.error { border-color: var(--red); }
.qfield > label { flex: none; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--green); padding: 9px 0 0 10px; min-width: 76px; text-transform: none; }
.qfield textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; resize: none; padding: 8px 10px; min-height: 34px; height: 34px;
  font-family: var(--mono); font-size: 13px; line-height: 18px; overflow: hidden; color: var(--text);
}
.qfield textarea::placeholder { color: var(--dim); }
.qopts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.qopts .qfield.small { flex: none; }
.qerr { color: var(--red); font-size: 12.5px; margin-top: 6px; font-family: var(--mono); white-space: pre-wrap; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--panel-2); color: var(--muted); height: 32px; width: 36px; display: grid; place-items: center; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--green-bg); color: var(--green); }
.seg button svg { width: 16px; height: 16px; }

/* ---------- документы */
.docs { display: flex; flex-direction: column; gap: 10px; }
.doc {
  position: relative; background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 12px 14px 12px 30px; font-family: var(--mono); font-size: 13px; line-height: 1.6; overflow: hidden;
}
.doc.editing { padding-left: 14px; }
.caret-btn { display: grid; place-items: center; width: 18px; height: 22px; margin-left: -4px; flex: none; }
.doc:hover { border-color: var(--border); }
.doc .doc-acts {
  position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 4px; opacity: 0; transition: opacity .12s;
  background: var(--panel); border-radius: var(--radius-sm); padding: 2px;
}
.doc:hover .doc-acts, .doc:focus-within .doc-acts { opacity: 1; }
.doc.editing { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(0, 237, 100, .08); }
.doc.deleting { border-color: var(--red); background: var(--red-bg); }
.doc .edit-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; font-family: var(--sans); flex-wrap: wrap; align-items: center; }
.doc textarea.textarea { min-height: 160px; background: var(--bg); }
.kv { padding-left: 18px; position: relative; word-break: break-word; }
.kv.top { padding-left: 0; }
.kv > .tog {
  position: absolute; left: 0; top: 4px; width: 14px; height: 14px; display: grid; place-items: center; cursor: pointer; color: var(--muted);
  border: 0; background: transparent; padding: 0;
}
.kv.top > .tog { left: -18px; }
.kv > .tog svg { width: 12px; height: 12px; transition: transform .12s; }
.kv.open > .tog svg { transform: rotate(90deg); }
.kv .children { display: none; border-left: 1px dashed var(--border-soft); margin-left: -12px; padding-left: 12px; }
.kv.open > .children { display: block; }
.k { color: var(--t-key); font-weight: 600; }
.v-String { color: var(--t-string); }
.v-Int32, .v-Double, .v-Int64, .v-Decimal128 { color: var(--t-number); }
.v-Boolean { color: var(--t-bool); }
.v-Null, .v-Undefined { color: var(--t-null); font-style: italic; }
.v-ObjectId { color: var(--t-oid); }
.v-Date, .v-Timestamp { color: var(--t-date); }
.v-RegExp, .v-Binary, .v-UUID, .v-MinKey, .v-MaxKey, .v-Code { color: var(--t-other); }
.v-meta { color: var(--muted); }
.more-btn { border: 0; background: none; color: var(--green-3); cursor: pointer; padding: 0; font: inherit; }

.json-view { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0; overflow: auto; font-size: 13px; line-height: 1.55; white-space: pre; }

.table-wrap { overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--panel); }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th, table.t td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
table.t th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; z-index: 1; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--hover); }
table.t td.mono { font-family: var(--mono); font-size: 12.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.click { cursor: pointer; }

/* ---------- списки коллекций/баз как карточки */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: border-color .12s, transform .12s; display: block; color: var(--text); }
.tile:hover { border-color: var(--green-2); text-decoration: none; }
.tile h4 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; word-break: break-all; }
.tile h4 svg { width: 17px; height: 17px; color: var(--green); flex: none; }
.tile .metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.metric small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.metric b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- агрегации */
.stages { display: flex; flex-direction: column; gap: 12px; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.stage.off { opacity: .55; }
.stage.bad { border-color: var(--red); }
.stage-edit { padding: 10px; border-right: 1px solid var(--border-soft); min-width: 0; }
.stage-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; flex-wrap: nowrap; }
.stage-head .num { font-family: var(--mono); color: var(--muted); font-size: 12px; min-width: 22px; }
.stage-head .select { width: auto; min-width: 0; flex: 0 1 180px; height: 30px; font-family: var(--mono); font-size: 13px; color: var(--green); font-weight: 600; }
.stage-edit textarea.textarea { min-height: 110px; }
.stage-out { padding: 10px; min-width: 0; background: var(--bg-2); max-height: 360px; overflow: auto; }
.stage-out .docs { gap: 6px; }
.stage-out .doc { padding: 8px 10px 8px 26px; font-size: 12px; }
.stage-out .out-head { color: var(--muted); font-size: 12px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.add-stage { border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; color: var(--muted); padding: 12px; cursor: pointer; width: 100%; font-weight: 600; }
.add-stage:hover { border-color: var(--green-2); color: var(--green); }

/* ---------- схема */
.schema-field { border-bottom: 1px solid var(--border-soft); padding: 14px 0; display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.schema-field:last-child { border-bottom: 0; }
.schema-field .fname { font-family: var(--mono); font-weight: 600; word-break: break-all; }
.schema-field .fname small { display: block; color: var(--muted); font-family: var(--sans); font-weight: 400; margin-top: 4px; }
.typebar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--panel-2); margin-bottom: 6px; }
.typebar span { display: block; height: 100%; }
.typelegend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.typelegend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 8px; align-items: center; font-size: 12.5px; cursor: pointer; }
.bar .track { position: relative; height: 22px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--green-bg-2); border-right: 2px solid var(--green); }
.bar .label { position: absolute; left: 8px; right: 8px; top: 0; line-height: 22px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar:hover .fill { background: #00785a; }
.range { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* ---------- explain */
.plan-tree { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 0; }
.plan-node { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; min-width: 220px; max-width: 100%; text-align: center; }
.plan-node .st { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.plan-node.COLLSCAN .st { color: var(--red); }
.plan-node.IXSCAN .st, .plan-node.EXPRESS_IXSCAN .st, .plan-node.IDHACK .st, .plan-node.EXPRESS_CLUSTERED_IXSCAN .st { color: var(--green); }
.plan-node .meta { color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-word; }
.plan-arrow { width: 2px; height: 18px; background: var(--border); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.summary-grid .metric { background: var(--panel-2); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ---------- консоль */
.shell { background: #000f15; border: 1px solid var(--border-soft); border-radius: var(--radius); display: flex; flex-direction: column; height: calc(100dvh - var(--topbar) - 150px); min-height: 320px; }
.shell-out { flex: 1; overflow: auto; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.shell-out .in { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.shell-out .in::before { content: attr(data-prompt); color: var(--green); margin-right: 8px; }
.shell-out .out { white-space: pre-wrap; word-break: break-word; margin: 2px 0 12px; color: #cfd8dc; }
.shell-out .out.err { color: var(--red); }
.shell-out .out.info { color: var(--muted); }
.shell-in { display: flex; align-items: flex-start; gap: 8px; border-top: 1px solid var(--border-soft); padding: 10px 14px; }
.shell-in .prompt { color: var(--green); font-family: var(--mono); font-size: 13px; line-height: 20px; padding-top: 1px; white-space: nowrap; }
.shell-in textarea { flex: 1; border: 0; background: transparent; outline: none; resize: none; font-family: var(--mono); font-size: 13px; line-height: 20px; color: var(--text); height: 22px; max-height: 200px; }
.shell-keys { display: none; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap; }

/* ---------- модальные окна, тосты, меню */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 10, 15, .72); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: pop .14s; }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.modal-h h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-b { padding: 6px 18px 12px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--green); border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: pop .15s; word-break: break-word; }
.toast.err { border-left-color: var(--red); }
.menu { position: fixed; z-index: 150; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; min-width: 200px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: pop .1s; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: var(--text); padding: 8px 10px; border-radius: 4px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--border-soft); margin: 4px 0; }
.menu .mhead { padding: 8px 10px 4px; color: var(--muted); font-size: 12px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; color: var(--dim); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.uri-box { display: flex; gap: 8px; align-items: stretch; }
.uri-box code { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; overflow-x: auto; white-space: nowrap; color: var(--green-3); }
.progress { height: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-2), var(--green)); border-radius: 6px; transition: width .3s; }
.progress.warn > span { background: linear-gradient(90deg, #c58c00, var(--yellow)); }
.progress.bad > span { background: linear-gradient(90deg, #b8423c, var(--red)); }
.snip { position: relative; }
.snip pre { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px; margin: 0; overflow: auto; font-size: 12.5px; line-height: 1.5; }
.snip .btn { position: absolute; top: 6px; right: 6px; }
.alert { border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert > div { min-width: 0; overflow-wrap: anywhere; }
.crumbs svg { width: 14px; height: 14px; flex: none; }
.alert.warn { background: var(--yellow-bg); border-color: #5a4308; color: #ffe29a; }
.alert.bad { background: var(--red-bg); border-color: #5b2826; color: #ffcdc7; }
.alert.info { background: #06324a; border-color: #0d4c6e; color: #cfeaff; }
.alert.good { background: var(--green-bg); border-color: #0b4a3a; color: #c8ffe0; }

/* ---------- вход */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #023a2d 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #03283a 0%, transparent 60%), var(--bg); overflow: auto; }
.login { width: 100%; max-width: 400px; }
.login .logo { justify-content: center; font-size: 22px; margin-bottom: 8px; }
.login .logo svg { width: 30px; height: 30px; }
.login p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }
.login .card { padding: 22px; }
.login .btn { width: 100%; height: 40px; }
.login .input { height: 42px; }

/* ---------- админка */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input, .filters .select { width: auto; min-width: 160px; }
.usage-cell { min-width: 140px; }
.usage-cell .progress { height: 6px; margin-top: 4px; }

/* ---------- мобильная версия */
.scrim { display: none; }
@media (max-width: 900px) {
  :root { --topbar: 52px; }
  .body { grid-template-columns: 1fr; }
  .burger { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; width: min(86vw, 320px); z-index: 60;
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: 10px 0 40px rgba(0, 0, 0, .4);
  }
  body.drawer .sidebar { transform: none; }
  body.drawer .scrim { display: block; position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0, 10, 15, .6); z-index: 55; }
  .page { padding: 14px 12px 60px; }
  .tabs { margin: 0 -12px 12px; padding: 0 8px; }
  .tab { padding: 0 11px; }
  .conn-chip { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .logo span.full { display: none; }
  .user-btn .uname { display: none; }
  .qline { flex-wrap: wrap; }
  .qline > .qfield { flex: 1 1 100%; }
  .qline .qbtns { display: flex; gap: 8px; width: 100%; }
  .qline .qbtns .btn { flex: 1; }
  .qopts { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; }
  .stage-head { flex-wrap: nowrap; gap: 2px; }
  .stage-head .select { min-width: 0; flex: 1 1 auto; }
  .stage-head .spacer { display: none; }
  table.t td.num, table.t td .mono, table.t td.mono { white-space: nowrap; }
  .table-wrap table.t { min-width: 560px; }
  .stage-edit { border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .stage-out { max-height: 260px; }
  .schema-field { grid-template-columns: 1fr; gap: 8px; }
  .doc .doc-acts { opacity: 1; position: static; justify-content: flex-end; margin: -4px -6px 4px 0; background: none; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .modal-f .btn { flex: 1; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .shell { height: calc(100dvh - var(--topbar) - 120px); }
  .shell-keys { display: flex; }
  .page-title h1 { font-size: 19px; }
  .tiles { grid-template-columns: 1fr; }
  .btn { height: 38px; }
  .btn.sm { height: 32px; }
  .input, .select { height: 40px; font-size: 16px; }
  .qfield textarea, .textarea, .shell-in textarea { font-size: 16px; }
  .filters .input, .filters .select { flex: 1 1 140px; min-width: 0; }
  table.t th, table.t td { padding: 8px 10px; }
  .hide-m { display: none !important; }
}
@media (min-width: 901px) { .hide-d { display: none !important; } }
@media (max-width: 1180px) { .hide-t { display: none !important; } }
