/* Netcloudify Looking Glass — hoja de estilo del frontend público.
   Tema claro. Mobile-first: la barra de herramientas vive abajo en el móvil
   (al alcance del pulgar) y pasa a ser una cabecera en escritorio. */

:root {
  --accent: #0e7490;
  --accent-ink: #ffffff;          /* texto que va encima del color de acento */
  --accent-text: #0e7490;         /* el acento, oscurecido lo justo para leerse sobre blanco */
  --accent-soft: rgba(14, 116, 144, .10);
  --accent-line: rgba(14, 116, 144, .34);
  --bg: #f2f5fa;
  --bg-2: #ffffff;
  --bg-3: #eaeff7;
  --panel: #ffffff;
  --line: rgba(15, 23, 42, .12);
  --line-strong: rgba(15, 23, 42, .24);
  --text: #0f1b2d;
  --muted: #56637c;
  --dim: #8592aa;
  --ok: #0f7a52;
  --ok-soft: rgba(15, 122, 82, .10);
  --warn: #9a5b06;
  --warn-soft: rgba(154, 91, 6, .12);
  --bad: #b42318;
  --bad-soft: rgba(180, 35, 24, .10);
  --info: #1d4ed8;
  --purple: #6d28d9;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 28px rgba(15, 23, 42, .08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .07);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(1100px 520px at 12% -10%, rgba(14, 116, 144, .07), transparent 62%),
    radial-gradient(900px 480px at 96% 0%, rgba(109, 40, 217, .06), transparent 58%);
  background-attachment: fixed;
  padding-bottom: calc(72px + var(--safe-bottom));
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
h1, h2, h3, h4 { margin: 0 0 .4rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p { margin: .3rem 0 .8rem; }
code, pre, .mono { font-family: var(--mono); }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 14px; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 12px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #4f46e5);
  color: #ffffff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(14, 116, 144, .3);
  overflow: hidden;
}
/* El logotipo subido se respeta tal cual: altura fija y ancho proporcional,
   sin recortes ni fondo de color detrás. */
.brand-logo {
  display: block; height: 32px; width: auto; max-width: 190px;
  object-fit: contain; flex: 0 0 auto;
}
@media (max-width: 560px) { .brand-logo { height: 27px; max-width: 130px; } }
.brand-text { min-width: 0; }
.brand-name {
  font-weight: 700; font-size: 1rem; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
/* En un móvil no cabe todo en la cabecera: lo secundario vive en el pie. */
@media (max-width: 720px) { .hide-mobile { display: none !important; } }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2);
  font-size: .74rem; color: var(--muted); white-space: nowrap;
}
.pill.accent { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }
.pill.ok { color: var(--ok); border-color: rgba(15, 122, 82, .35); background: var(--ok-soft); }
.pill.bad { color: var(--bad); border-color: rgba(180, 35, 24, .35); background: var(--bad-soft); }
.pill.warn { color: var(--warn); border-color: rgba(154, 91, 6, .35); background: var(--warn-soft); }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 10px 0 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2);
  color: var(--muted); font-size: .85rem; font-weight: 550;
  transition: all .16s ease;
  box-shadow: var(--shadow-sm);
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--text); border-color: var(--line-strong); }
.tab.active {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(14, 116, 144, .28);
}
.tab.active svg { stroke: var(--accent-ink); }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}
.card.tight { padding: 10px 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 12px; }
.field > label, .flabel {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--muted); margin-bottom: 5px; letter-spacing: .01em;
}
.f-input, .f-select, input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 12px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 16px; /* evita el zoom automático de iOS */
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea, .f-area { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.f-input:focus, .f-select:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.f-input::placeholder { color: var(--dim); }
select, .f-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356637c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  padding-right: 34px;
}
.row { display: grid; gap: 10px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: repeat(3, 1fr); }
.row.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
  .row.c3, .row.c4 { grid-template-columns: 1fr 1fr; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--text);
  font-size: .88rem; font-weight: 600; font-family: inherit;
  transition: transform .12s, filter .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg-3); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 16px rgba(14, 116, 144, .26);
}
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: rgba(180, 35, 24, .4); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--line); }
.btn.ghost:hover { background: var(--bg-3); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: .78rem; }
.btn.icon { padding: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ node chips */
.node-groups { display: flex; flex-direction: column; gap: 10px; }
.node-group.empty { display: none; }
.node-group-title {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px;
}
.node-group-title .dim { text-transform: none; letter-spacing: 0; font-weight: 500; }
.nodes { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.nodes::-webkit-scrollbar { display: none; }
.node-chip {
  flex: 0 0 auto; cursor: pointer; user-select: none;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg-2); padding: 9px 12px; min-width: 132px;
  transition: all .15s ease; position: relative;
  box-shadow: var(--shadow-sm);
}
.node-chip:hover { border-color: var(--line-strong); }
.node-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.node-chip .n-top { display: flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; }
.node-chip .n-flag { font-size: 1rem; line-height: 1; }
.node-chip .n-sub { font-size: .7rem; color: var(--muted); margin-top: 2px; }
.node-chip .n-dot {
  position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim);
}
.node-chip .n-dot.ok { background: var(--ok); }
.node-chip .n-dot.down { background: var(--bad); }
.node-chip input { position: absolute; opacity: 0; pointer-events: none; }

/* -------------------------------------------------------------- terminal */
.term {
  background: #f6f8fc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  max-height: 62vh; overflow: auto;
  color: #17233a;
  scrollbar-width: thin;
}
.term::-webkit-scrollbar { width: 9px; height: 9px; }
.term::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }
.term .t-info { color: var(--info); }
.term .t-err { color: var(--bad); }
.term .t-ok { color: var(--ok); }
.term .t-dim { color: var(--dim); }
.term .t-hl { color: var(--warn); }
.term a.ipl { color: var(--accent-text); border-bottom: 1px dotted var(--accent-line); }
.term .asn-chip {
  color: var(--purple); cursor: pointer;
  border-bottom: 1px dotted rgba(109, 40, 217, .5);
}

/* --------------------------------------------------------------- results */
.result-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
}
.result-title { font-weight: 650; font-size: .95rem; }
.result-title .rt-target { color: var(--accent-text); font-family: var(--mono); }
.result-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px;
  background: var(--dim);
}
.status-dot.running { background: var(--warn); animation: pulse 1.1s infinite; }
.status-dot.done { background: var(--ok); }
.status-dot.failed, .status-dot.timeout { background: var(--bad); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent-text);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- table */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 8px 9px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2);
  white-space: nowrap;
}
table.tbl td { padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--bg-3); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.tbl td.mono { font-family: var(--mono); font-size: .78rem; }

/* --------------------------------------------------------------- MTR/hop */
.hop-host { font-family: var(--mono); font-size: .8rem; }
.hop-name { color: var(--muted); font-size: .72rem; }
.hop-asn { color: var(--purple); font-size: .7rem; }
.loss-cell { font-weight: 650; }
.loss-0 { color: var(--ok); }
.loss-low { color: var(--warn); }
.loss-high { color: var(--bad); }
.hop-none { color: var(--dim); font-style: italic; }

.bar { height: 6px; border-radius: 4px; background: rgba(15, 23, 42, .10); overflow: hidden; min-width: 46px; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--ok), #0ea5b7); }
.bar.warn > span { background: linear-gradient(90deg, #d97706, #ea580c); }
.bar.bad > span { background: linear-gradient(90deg, var(--bad), #dc2626); }

.spark { display: block; height: 22px; width: 90px; }
.spark path { fill: none; stroke: var(--accent-text); stroke-width: 1.5; }
.spark .area { fill: rgba(14, 116, 144, .12); stroke: none; }

/* ------------------------------------------------------------ multi-ping */
.grid-nodes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pcard {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-2); padding: 11px 12px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.pcard.done { border-color: rgba(15, 122, 82, .4); }
.pcard.failed { border-color: rgba(180, 35, 24, .4); }
.pcard.running::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--warn); animation: pulse 1.1s infinite;
}
.pcard .p-name { font-weight: 620; font-size: .86rem; display: flex; align-items: center; gap: 6px; }
.pcard .p-loc { font-size: .72rem; color: var(--muted); margin-bottom: 8px; }
.pcard .p-metrics { display: flex; gap: 14px; align-items: baseline; }
.pcard .p-rtt { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; }
.pcard .p-unit { font-size: .7rem; color: var(--muted); }
.pcard .p-loss { font-size: .78rem; font-weight: 600; }
.pcard .p-err { font-size: .74rem; color: var(--bad); margin-top: 4px; }
.pcard .p-extra { font-size: .7rem; color: var(--dim); margin-top: 6px; font-family: var(--mono); }

/* ------------------------------------------------------------- bottom nav */
.botnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 16px rgba(15, 23, 42, .06);
}
.botnav a, .botnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 8px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: .64rem; font-family: inherit; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.botnav svg { width: 20px; height: 20px; }
.botnav .active { color: var(--accent-text); }
@media (min-width: 860px) { .botnav { display: none; } body { padding-bottom: 24px; } }

/* ---------------------------------------------------------------- extras */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .84rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: .8rem; word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 9px; border-radius: 999px; font-size: .72rem;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }

.alert {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: .85rem;
  border: 1px solid var(--line); background: var(--bg-2); margin: 10px 0;
}
.alert.error { border-color: rgba(180, 35, 24, .35); color: #8a1b12; background: var(--bad-soft); }
.alert.ok { border-color: rgba(15, 122, 82, .35); color: #0b5c3e; background: var(--ok-soft); }
.alert.warn { border-color: rgba(154, 91, 6, .35); color: #7c4906; background: var(--warn-soft); }
.alert.info { border-color: rgba(29, 78, 216, .3); color: #1a3fa8; background: rgba(29, 78, 216, .08); }

.footer {
  margin-top: 26px; padding: 18px 0 26px; border-top: 1px solid var(--line);
  color: var(--dim); font-size: .78rem;
}
.footer a { color: var(--muted); }

.toast-host {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--safe-bottom)); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: #12203a; border: 1px solid rgba(15, 23, 42, .2); color: #f8fafc;
  padding: 10px 14px; border-radius: 999px; font-size: .82rem; box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
.toast.err { background: #7f1d1d; border-color: rgba(127, 29, 29, .5); color: #fff1f2; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton {
  background: linear-gradient(90deg, rgba(15,23,42,.05), rgba(15,23,42,.11), rgba(15,23,42,.05));
  background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 12px;
}
@keyframes sk { to { background-position: -200% 0; } }

.hist-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--line); font-size: .82rem;
}
.hist-item:last-child { border-bottom: none; }
.hist-item .h-act { color: var(--muted); font-size: .72rem; min-width: 78px; }
.hist-item .h-target { font-family: var(--mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 860px) {
  body { font-size: 15px; }
  .wrap { padding: 0 20px; }
  .card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------- resolución del destino */
.resolve-hint {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: -4px 0 10px; font-size: .74rem; color: var(--muted);
}
.resolve-hint.bad { color: var(--bad); }
.resolve-hint .rh-label { text-transform: uppercase; letter-spacing: .05em; font-size: .66rem; }
.resolve-hint .rh-name { font-family: var(--mono); color: var(--text); }
.resolve-hint .rh-note { color: var(--dim); font-size: .68rem; }
.resolve-hint .rh-ip {
  font-family: var(--mono); font-size: .74rem; cursor: pointer;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  color: var(--accent-text);
}
.resolve-hint .rh-ip:hover { filter: brightness(.95); }
.result-title .rt-resolved { color: var(--muted); font-weight: 500; }
