:root {
  --bg: #f6f7fb;
  --bg_tint: rgba(14, 165, 233, 0.05);
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #0ea5e9;
  --ok: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --code_bg: rgba(15, 23, 42, 0.04);
  --code_border: rgba(15, 23, 42, 0.10);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg_tint: rgba(56, 189, 248, 0.06);
  --panel: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1f2a44;
  --accent: #38bdf8;
  --ok: #4ade80;
  --danger: #fb7185;
  --warn: #fbbf24;
  --code_bg: rgba(148, 163, 184, 0.08);
  --code_border: rgba(148, 163, 184, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: linear-gradient(180deg, var(--bg_tint), transparent 240px), var(--bg);
  color: var(--text);
}

a { color: inherit; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav .left {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.3px;
}

.links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.links a {
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.links a:hover {
  color: var(--text);
  background: rgba(14, 165, 233, 0.06);
}

.links a.active {
  border-color: rgba(14, 165, 233, 0.18);
  color: var(--text);
  background: rgba(14, 165, 233, 0.10);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 650;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn.small { padding: 6px 8px; font-weight: 600; }

.btn.primary {
  border-color: rgba(14, 165, 233, 0.25);
  background: var(--accent);
  color: #ffffff;
}

.btn.danger {
  border-color: rgba(239, 68, 68, 0.25);
  background: var(--danger);
  color: #ffffff;
}

.btn:hover {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.10s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.card h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.kv {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}

.kv .k { color: var(--muted); }

.mono { font-family: var(--mono); font-size: 12px; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.table th {
  color: var(--muted);
  font-weight: 700;
  background: rgba(148, 163, 184, 0.06);
}

.table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.04);
}

.table tbody tr:hover {
  background: rgba(14, 165, 233, 0.06);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.table-wrap .table th,
.table-wrap .table td {
  border-bottom: 1px solid var(--border);
}

.watches-table {
  table-layout: fixed;
  min-width: 0;
}

.watches-table th:nth-child(1),
.watches-table td:nth-child(1) { width: 56px; }

.watches-table th:nth-child(2),
.watches-table td:nth-child(2) { width: 86px; }

.watches-table th:nth-child(3),
.watches-table td:nth-child(3) { width: 100px; }

.watches-table th:nth-child(4),
.watches-table td:nth-child(4) { width: 110px; }

.watches-table th:nth-child(6),
.watches-table td:nth-child(6) { width: 160px; }

.watches-table th:nth-child(7),
.watches-table td:nth-child(7) { width: 160px; }

.watches-table th:nth-child(8),
.watches-table td:nth-child(8) { width: 92px; }

.watches-table th:nth-child(9),
.watches-table td:nth-child(9) { width: 90px; }

.watches-table th:nth-child(5),
.watches-table td:nth-child(5) {
  width: auto;
}

.watches-table .params-cell {
  max-width: none;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
}

.badge.ok {
  border-color: rgba(34, 197, 94, 0.30);
  background: rgba(34, 197, 94, 0.10);
  color: var(--ok);
}
.badge.warn {
  border-color: rgba(245, 158, 11, 0.30);
  background: rgba(245, 158, 11, 0.10);
  color: var(--warn);
}
.badge.bad {
  border-color: rgba(239, 68, 68, 0.30);
  background: rgba(239, 68, 68, 0.10);
  color: var(--danger);
}

.input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: rgba(14, 165, 233, 0.40);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.16);
}

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 12px; }

.input.small {
  width: auto;
  padding: 6px 8px;
  font-size: 12px;
}

.label-help {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.label-help > span:first-child {
  flex: 1;
}

.help {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: help;
  position: relative;
  user-select: none;
}

.help::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: 26px;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  max-width: min(320px, 78vw);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
  white-space: normal;
  line-height: 1.35;
  z-index: 50;
}

.help::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid var(--border);
  z-index: 51;
}

.help:hover::after,
.help:focus::after,
.help:hover::before,
.help:focus::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.help:focus {
  outline: 2px solid rgba(66, 211, 146, 0.35);
  outline-offset: 2px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 240px; }

.flash {
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  margin: 12px 0;
  background: rgba(148, 163, 184, 0.06);
}

.flash.error { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.flash.ok { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.flash.warn { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.08); }

.logbox {
  height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--code_bg);
}

.logline { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; }

.switches {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.06);
}

.switch-text {
  flex: 1;
  min-width: 240px;
}

.switch-label {
  font-size: 13px;
  font-weight: 750;
}

.switch-tip {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(148, 163, 184, 0.20);
  border: 1px solid var(--border);
  transition: 0.18s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: 0.18s;
  border-radius: 999px;
}

.switch input:checked + .slider {
  background: rgba(14, 165, 233, 0.25);
  border-color: rgba(14, 165, 233, 0.35);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
  border-color: rgba(14, 165, 233, 0.35);
}

.switch input:focus + .slider {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  outline-offset: 3px;
}

.switch input:disabled + .slider {
  opacity: 0.55;
  cursor: not-allowed;
}

.codebox {
  border: 1px solid var(--code_border);
  background: var(--code_bg);
  border-radius: 12px;
  padding: 10px 12px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.35;
}

details > summary {
  cursor: pointer;
  user-select: none;
}
