:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e0e2e6;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 280px;
  background: #151a24;
  color: #e5e7eb;
  padding: 16px 0;
  flex-shrink: 0;
  overflow-y: auto;
}
.brand { font-weight: 700; font-size: 18px; padding: 0 18px 16px; border-bottom: 1px solid #2a3040; margin-bottom: 8px; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: #9ca3af; }
.settings-link { display: block; padding: 10px 18px; color: #e5e7eb; text-decoration: none; font-size: 13px; border-bottom: 1px solid #2a3040; margin-bottom: 8px; }
.settings-link:hover { background: #1f2533; }

.nav-group { margin-bottom: 10px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #7f8694; padding: 8px 18px 4px; }
.nav-link { display: block; padding: 7px 18px; color: #cbd2de; text-decoration: none; font-size: 13.5px; }
.nav-link:hover { background: #1f2533; color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }

main#app { flex: 1; padding: 28px 36px; max-width: 980px; }

.page-header h2 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: var(--muted); margin: 0 0 4px; }
.cmd-name { color: #9ca3af; font-size: 11.5px; font-family: ui-monospace, monospace; margin: 0 0 20px; }

.field { margin-bottom: 14px; }
.field-label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #374151; }
.field-input input[type=text], .field-input input[type=number], .field-input input[type=password],
.field-input input[type=datetime-local], .field-input textarea, .field-input select {
  width: 100%; max-width: 440px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; background: var(--panel); color: var(--text);
}
.field-input textarea { font-family: inherit; }
.field-input input.invalid, .field-input select.invalid { border-color: var(--danger); background: #fef2f2; }
.field-bool .field-input { display: flex; align-items: center; }
.field-bool input[type=checkbox] { width: 18px; height: 18px; }

.help-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: #dbeafe; color: var(--accent-dark);
  font-size: 11px; font-weight: 700; cursor: help; flex-shrink: 0;
}
.help-bubble {
  display: none; position: absolute; left: 20px; top: -4px; z-index: 50;
  width: 260px; background: #111827; color: #f9fafb; padding: 8px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 400; line-height: 1.4; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.help-icon:hover .help-bubble, .help-icon:focus .help-bubble { display: block; }

details.group-box {
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: #fafbfc;
}
details.group-box > summary {
  cursor: pointer; padding: 9px 12px; list-style: none; display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13px; color: #374151;
}
details.group-box > summary::-webkit-details-marker { display: none; }
details.group-box > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.group-box[open] > summary::before { transform: rotate(90deg); }
.group-body { padding: 4px 14px 12px; }

.list-box { border: 1px dashed #c7cbd4; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fcfcfd; }
.list-header { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 8px; color: #374151; }
.list-row { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; background: var(--panel); }
.list-row-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: #f3f4f6; border-radius: 6px 6px 0 0; }
.list-row-index { font-size: 12px; color: var(--muted); font-weight: 600; }
.list-row-body { padding: 10px 12px; }
.btn-remove { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 5px; padding: 3px 9px; font-size: 11.5px; cursor: pointer; }
.btn-remove:hover { background: #fef2f2; }
.btn-add { background: none; border: 1px dashed var(--accent); color: var(--accent-dark); border-radius: 6px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.btn-add:hover { background: #eff6ff; }
.btn-mini { border: 1px solid var(--border); background: #fff; border-radius: 5px; padding: 6px 8px; font-size: 11.5px; cursor: pointer; margin-left: 6px; }

.submit-bar { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 10px 20px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }

.conn-status { font-size: 12.5px; color: var(--muted); }
.conn-status.ok { color: var(--ok); }
.conn-status.warn { color: var(--warn); }
.conn-status.err { color: var(--danger); }

.result-box {
  white-space: pre-wrap; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
  padding: 12px 14px; border-radius: 8px; font-family: ui-monospace, monospace; font-size: 12.5px; margin-top: 14px;
}
.error-box {
  white-space: pre-wrap; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-top: 14px;
}

.settings-form h3 { margin-top: 22px; }
