:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #667085;
  --line: #dde2ea;
  --field: #ffffff;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #0a7d3b;
  --bad: #c42b1c;
  --hl: #fff1b8;
  --row-hover: #f6f8fc;
  --label-w: 300px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --panel: #1a1e26;
    --text: #e7eaf0;
    --muted: #9aa5b5;
    --line: #2b3240;
    --field: #12151b;
    --accent: #6c9cff;
    --accent-text: #0b1220;
    --ok: #4cc38a;
    --bad: #ff7b72;
    --hl: #4b4110;
    --row-hover: #20252f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- верхняя панель ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 650; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; flex: 1; min-width: 0; }
.top-actions #xsdName { flex: 1 1 120px; }
.rootsel { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-left: auto; }

/* ---------- элементы управления ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled):not(.disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled):not(.disabled) { filter: brightness(1.08); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn.small { height: 26px; padding: 0 10px; font-size: 13px; }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input[type="text"], input[type="search"], input[type="date"], input[type="time"],
input[type="datetime-local"], select, textarea {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  min-width: 0;
}
select { padding-right: 6px; }
input:disabled, select:disabled { opacity: .55; }

/* ---------- каркас ---------- */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 16px;
}

.searchbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.searchbar input { flex: 1 1 220px; max-width: 420px; }

.panel {
  flex: 1 1 auto;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); background: var(--bg); }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; margin-bottom: -1px; }
.count {
  min-width: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--line); color: var(--muted);
  font-size: 12px; font-weight: 500; text-align: center; line-height: 18px;
}
.tab.active .count { background: var(--accent); color: var(--accent-text); }

.scroller { flex: 1; min-height: 0; overflow: auto; }

/* ---------- строки параметров ---------- */
.rows { position: relative; padding: 6px 0; }
.rows[hidden] { display: none; }
.empty { padding: 18px 16px; color: var(--muted); }

.row {
  display: grid;
  grid-template-columns: var(--label-w) minmax(0, 1fr);
  column-gap: 14px;
  align-items: center;
  padding: 3px 12px;
  content-visibility: auto;
  contain-intrinsic-size: auto 38px;
}
.row:hover { background: var(--row-hover); }
.row.hl, .row.hl:hover { background: var(--hl); }
.row.group-row .lbl { font-weight: 650; }

.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ctl { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctl > input[type="text"], .ctl > select { flex: 1 1 0; }
.ctl > input[type="date"], .ctl > input[type="time"], .ctl > input[type="datetime-local"] { flex: 0 1 220px; }
.ctl input[type="checkbox"] { width: 18px; height: 18px; flex: none; }

.splitter {
  position: absolute;
  top: 0; bottom: 0;
  left: calc(12px + var(--label-w) + 4px);
  width: 6px;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}
.splitter::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 2px; width: 2px;
  background: var(--line);
  transition: background .12s;
}
.splitter:hover::before, .splitter:focus-visible::before, .splitter.drag::before { background: var(--accent); }

/* ---------- действия и вывод ---------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status { flex: 1 1 260px; min-width: 0; font-size: 13px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.status.info { color: var(--muted); }

.output { display: flex; flex-direction: column; gap: 8px; }
.output textarea {
  height: 200px;
  padding: 10px 12px;
  resize: vertical;
  font: 12.5px/1.45 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  white-space: pre;
  overflow: auto;
}
.issues {
  border: 1px solid var(--line);
  border-left: 3px solid var(--bad);
  border-radius: 6px;
  background: var(--panel);
  padding: 8px 12px;
  max-height: 200px;
  overflow: auto;
}
.issues-title { font-weight: 650; margin-bottom: 4px; }
.issues ul { margin: 0; padding-left: 18px; }
.issues li { margin: 2px 0; font-size: 13px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 720px) {
  body { height: auto; }
  main { padding: 10px 10px 14px; }
  .rootsel { margin-left: 0; width: 100%; justify-content: space-between; }
  .panel { min-height: 60vh; }
  .row { grid-template-columns: minmax(0, 1fr); row-gap: 2px; padding: 6px 12px; }
  .lbl { white-space: normal; font-size: 12.5px; color: var(--muted); }
  .row.group-row .lbl { color: var(--text); }
  .splitter { display: none; }
  .ctl > input[type="date"], .ctl > input[type="time"], .ctl > input[type="datetime-local"] { flex: 1 1 0; }
}
