:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5b6877;
  --line: #d5dbe2;
  --accent: #0e6b73;
  --accent-ink: #ffffff;
  --accent-soft: #dcefef;
  --danger: #b3312a;
  --track: #d9dfe5;
  --chip-fg: #ffffff;
  --focus: #0b5fff;

  --ok-bg: #e6f5ea;   --ok-bar: #1e8a4c;
  --perm-bg: #fff3d6; --perm-bar: #9a6700;
  --temp-bg: #e5effe; --temp-bar: #2f6fdb;
  --nf-bg: #fde5e3;   --nf-bar: #c9342b;
  --cli-bg: #ffe9d6;  --cli-bar: #b85a12;
  --srv-bg: #efe6fa;  --srv-bar: #7a3fc2;
  --err-bg: #eceef1;  --err-bar: #5f6b78;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c;
    --surface: #182028;
    --ink: #e6ebf0;
    --muted: #9aa8b6;
    --line: #2c3742;
    --accent: #4fc1c9;
    --accent-ink: #062327;
    --accent-soft: #163338;
    --danger: #ff8d85;
    --track: #2a343e;
    --chip-fg: #0b0f14;
    --focus: #7fb0ff;

    --ok-bg: #14301f;   --ok-bar: #4cc482;
    --perm-bg: #3a2f0e; --perm-bar: #e5b53c;
    --temp-bg: #14284a; --temp-bar: #6fa2f5;
    --nf-bg: #401a18;   --nf-bar: #ff7f76;
    --cli-bg: #3f2410;  --cli-bar: #f0954a;
    --srv-bg: #2c1b45;  --srv-bar: #b58af0;
    --err-bg: #222b34;  --err-bar: #9aa8b6;
  }
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  margin: 26px 0 16px;
}
.tool-form {
	display: flex;
	flex-wrap: wrap;
	padding-top: 15px;
}
.tool-form .input-group {
  width: 100%;
}
.form-input-cols {
	display: flex;
	width: 100%;
	gap: 15px;
}
.form-input-cols .form-input {
	width: calc(50% - 7.5px);
}
.form-input.form-buttons.form-buttons-mr {
	width: 100%;
	padding-top: 15px;
}
.tool-form label {
	margin-top: 0;
	padding: 0 0 5px;
	display: block;
}
.tool-form input + label {
	margin-top: 0;
}
.tool-form input[type="text"], .tool-form input[type="number"] {
	margin: 0;
	padding: 10px 15px 9px 15px;
	width: 100%;
	height: 41px;
	border: 2px solid #282c34;
	background: #282c34;
	border-radius: 4px;
	color: #fff;
	-webkit-box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
	-moz-box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
	box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
	outline: none;
}
.tool-form textarea {
	width: 100%;
	height: 212px;
	margin-bottom: 10px;
	resize: none;
}
.output {
	padding-top: 15px;
}
#outputText {
	height: 212px;
}
.ua-note {
  margin: 6px 0 0;
  color: var(--muted);
  word-break: break-all;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin-top: 16px;
}
.controls .ua { flex: 1 1 320px; min-width: 0; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
/* progress */
.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 600;
}
.progress-head .pct { font-variant-numeric: tabular-nums; }
.track {
  height: 14px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.25s ease;
}
.prep-note { margin: 10px 0 0; color: var(--muted); }
.error-note { margin: 10px 0 0; font-weight: 400; color: var(--danger); }
[hidden] { display: none !important; }

/* summary */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.summary li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

/* table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
td { padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td.num { width: 48px; font-size: 13px;color: var(--muted); font-variant-numeric: tabular-nums; }
td.code { width: 190px; }
.url {
  font-size: 13px;
  line-height: 1;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.url-src { display: block; margin-top: 2px; font: 12px/1.4 var(--mono); color: var(--muted); word-break: break-all; }

.chip {
  display: inline-block;
  min-width: 3.2em;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--row-bar, var(--err-bar));
  color: var(--chip-fg);
  font: 700 13px/1.6 var(--mono);
  text-align: center;
  white-space: nowrap;
}
.code-text { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.chain-line { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.arrow { color: var(--muted); }
details.hops { margin-top: 6px; }
details.hops summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); }
.hop { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; }
.hop .chip { flex: 0 0 auto; }
.chain-warn { margin-top: 6px; font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.dash { color: var(--muted); }

/* row tones */
tr.k-ok   { --row-bg: var(--ok-bg);   --row-bar: var(--ok-bar); }
tr.k-perm { --row-bg: var(--perm-bg); --row-bar: var(--perm-bar); }
tr.k-temp { --row-bg: var(--temp-bg); --row-bar: var(--temp-bar); }
tr.k-nf   { --row-bg: var(--nf-bg);   --row-bar: var(--nf-bar); }
tr.k-cli  { --row-bg: var(--cli-bg);  --row-bar: var(--cli-bar); }
tr.k-srv  { --row-bg: var(--srv-bg);  --row-bar: var(--srv-bar); }
tr.k-err  { --row-bg: var(--err-bg);  --row-bar: var(--err-bar); }
tbody tr[class^="k-"] td { background: var(--row-bg); }
tbody tr[class^="k-"] td:first-child { box-shadow: inset 4px 0 0 var(--row-bar); }
.summary .chip { border-radius: 999px; }
.summary .k-ok   { --row-bar: var(--ok-bar); }
.summary .k-perm { --row-bar: var(--perm-bar); }
.summary .k-temp { --row-bar: var(--temp-bar); }
.summary .k-nf   { --row-bar: var(--nf-bar); }
.summary .k-cli  { --row-bar: var(--cli-bar); }
.summary .k-srv  { --row-bar: var(--srv-bar); }
.summary .k-err  { --row-bar: var(--err-bar); }

tr.pending td { color: var(--muted); }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--track);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 6px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .fill { transition: none; }
}

/* mobile: rows become cards */
@media (max-width: 720px) {
  .wrap { padding: 16px 12px 40px; }
  h1 { font-size: 1.35rem; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border-bottom: 1px solid var(--line); padding: 6px 0; background: var(--row-bg, var(--surface)); box-shadow: inset 4px 0 0 var(--row-bar, transparent); }
  tbody tr:last-child { border-bottom: 0; }
  tbody tr[class^="k-"] td:first-child { box-shadow: none; }
  td { border: 0; padding: 4px 12px 4px 16px; display: flex; gap: 10px; }
  td::before {
    content: attr(data-label);
    flex: 0 0 84px;
    font-size: 0.8rem;
    color: var(--muted);
    padding-top: 2px;
  }
  td.num, td.code { width: 100%; }
  td > div { flex: 1 1 auto; min-width: 0; }
}
