/* ==================================================================
   FRPC-EDS — panel de control
   ================================================================== */

:root {
  --bg: #080c11;
  --bg-glow: #0d1620;
  --panel: #101821;
  --panel-2: #141e29;
  --border: #1d2a38;
  --border-strong: #2a3b4e;
  --text: #e8f0f9;
  --muted: #8ba1b9;
  --muted-2: #64798f;
  --accent: #3ddc97;
  --accent-soft: rgba(61, 220, 151, 0.12);
  --info: #5aa9ff;
  --info-soft: rgba(90, 169, 255, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --warn: #ffb454;
  --warn-soft: rgba(255, 180, 84, 0.12);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(61, 220, 151, 0.08), transparent 60%),
    radial-gradient(700px 400px at 10% 0%, rgba(90, 169, 255, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

a {
  color: var(--info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 20, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(61, 220, 151, 0.22), rgba(90, 169, 255, 0.14));
  border: 1px solid rgba(61, 220, 151, 0.35);
  color: var(--accent);
  font-size: 17px;
}

.brand h1 {
  font-size: 15px;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- pills / badges ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pill.ok {
  color: var(--accent);
  border-color: rgba(61, 220, 151, 0.35);
  background: var(--accent-soft);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
  background: var(--danger-soft);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px rgba(139, 161, 185, 0.1);
  flex: 0 0 auto;
}

.dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.16);
}

.dot.offline {
  background: var(--muted-2);
}

.dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.16);
}

.dot.starting,
.dot.stopping {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 180, 84, 0.16);
}

.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px dashed var(--border-strong);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.http,
.badge.https {
  color: var(--info);
  border-color: rgba(90, 169, 255, 0.35);
  background: var(--info-soft);
}

.badge.tcp,
.badge.udp {
  color: var(--warn);
  border-color: rgba(255, 180, 84, 0.35);
  background: var(--warn-soft);
}

.badge.ok {
  color: var(--accent);
  border-color: rgba(61, 220, 151, 0.35);
  background: var(--accent-soft);
}

.badge.off {
  color: var(--muted-2);
  border-color: var(--border);
  background: transparent;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 22px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  padding: 9px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: linear-gradient(180deg, transparent, rgba(61, 220, 151, 0.06));
}

/* ---------- layout ---------- */

main {
  padding: 22px;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.view.active {
  display: flex;
}

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.card-head .sub {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 400;
  margin-left: 8px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-body {
  padding: 16px;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-strong);
}

.stat.accent::after {
  background: var(--accent);
}

.stat.info::after {
  background: var(--info);
}

.stat.warn::after {
  background: var(--warn);
}

.stat .label {
  color: var(--muted-2);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat .value {
  font-size: 24px;
  font-weight: 650;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.stat .value small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- botones ---------- */

.btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #1a2632;
  border-color: #354b62;
}

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

.btn.primary {
  background: linear-gradient(180deg, #43e7a1, #2ec488);
  border-color: #37d195;
  color: #062014;
}

.btn.primary:hover {
  background: linear-gradient(180deg, #4defab, #35cf92);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.3);
  background: var(--danger-soft);
}

.btn.danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

.btn.sm {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 7px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* ---------- tabla ---------- */

.table-wrap {
  overflow-x: auto;
}

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

table.table.wide {
  min-width: 700px;
}

table.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(29, 42, 56, 0.6);
  vertical-align: middle;
}

table.table tr:last-child td {
  border-bottom: 0;
}

table.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.018);
}

.cell-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.cell-sub {
  color: var(--muted-2);
  font-size: 11.5px;
  margin-top: 2px;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.tiny {
  font-size: 11.5px;
}

/* ---------- estados vacíos ---------- */

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted-2);
}

.empty h3 {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 6px;
}

.empty p {
  margin: 0 auto 16px;
  max-width: 460px;
}

/* ---------- formularios ---------- */

.form-grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}

.field .hint {
  font-size: 11.5px;
  color: var(--muted-2);
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #0b121a;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(61, 220, 151, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.12);
}

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

/* Buscador de las listas (tuneles / servidores) */
.search {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #0b121a;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 11px;
  min-width: 230px;
  max-width: 320px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.search::placeholder {
  color: var(--muted-2);
}

.search:focus {
  border-color: rgba(61, 220, 151, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.12);
}

/* ---------- listas de IPs como registros (chips) ---------- */

.iplist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: #0b121a;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 7px 9px;
  min-height: 40px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.iplist:focus-within {
  border-color: rgba(61, 220, 151, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.12);
}

.iplist-chips {
  display: contents;
}

.iplist input[type="text"] {
  flex: 1 1 150px;
  min-width: 130px;
  width: auto;
  border: 0;
  background: transparent;
  padding: 4px 2px;
  font-size: 12px;
}

.iplist input[type="text"]:focus {
  box-shadow: none;
  border-color: transparent;
}

.ip-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--info-soft);
  border: 1px solid rgba(90, 169, 255, 0.35);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  white-space: nowrap;
}

.ip-x {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.ip-x:hover {
  color: var(--danger);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group .suffix {
  display: flex;
  align-items: center;
  padding: 0 11px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-2);
  background: #0e1620;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  white-space: nowrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.is-hidden {
  display: none !important;
}

/* ---------- avisos ---------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  font-size: 13px;
}

.banner.warn {
  border-color: rgba(255, 180, 84, 0.35);
  background: var(--warn-soft);
  color: #ffd9a8;
}

.banner.bad {
  border-color: rgba(255, 107, 107, 0.35);
  background: var(--danger-soft);
  color: #ffc2c2;
}

.banner.ok {
  border-color: rgba(61, 220, 151, 0.3);
  background: var(--accent-soft);
  color: #b6f5d8;
}

/* ---------- logs ---------- */

.log-box {
  margin: 0;
  padding: 14px;
  background: #060a0e;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line {
  display: flex;
  gap: 10px;
}

.log-line time {
  color: #45596d;
  flex: 0 0 auto;
}

.log-line .txt {
  color: #b9cbdc;
}

.log-line.stderr .txt {
  color: #ff9a9a;
}

.log-line.info .txt {
  color: var(--accent);
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 10, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 60;
  overflow-y: auto;
}

.modal {
  background: linear-gradient(180deg, #121b25, #0f1720);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.14s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  font-size: 14.5px;
}

.modal-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 80;
}

.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #121c26;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: slide 0.16s ease-out;
}

.toast.ok {
  border-color: rgba(61, 220, 151, 0.45);
}

.toast.bad {
  border-color: rgba(255, 107, 107, 0.45);
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
}

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.login-card .logo {
  margin: 0 auto 14px;
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.login-card h1 {
  font-size: 17px;
  text-align: center;
}

.login-card .sub {
  text-align: center;
  color: var(--muted-2);
  font-size: 12.5px;
  margin: 6px 0 22px;
}

.login-error {
  color: var(--danger);
  font-size: 12.5px;
  min-height: 18px;
  margin-top: 10px;
}

/* ---------- responsive ---------- */

/* Móvil y tablet en vertical: tablas como tarjetas, sin scroll lateral */
@media (max-width: 820px) {
  main {
    padding: 12px;
  }
  .topbar {
    padding: 10px 14px;
    gap: 10px;
  }
  .tabs {
    padding: 8px 14px 0;
  }
  .brand p {
    display: none;
  }
  .brand h1 {
    font-size: 14px;
    white-space: nowrap;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card-head {
    padding: 12px 14px;
  }
  .card-actions {
    width: 100%;
  }
  .card-actions .search {
    flex: 1 1 100%;
    max-width: none;
  }
  .card-actions .btn {
    flex: 1 1 auto;
  }

  /* Tablas → tarjetas apiladas (sin scroll horizontal) */
  table.table,
  table.table.wide {
    min-width: 0;
  }
  table.table thead {
    display: none;
  }
  table.table tbody tr {
    display: block;
    padding: 10px 4px 12px;
    border-bottom: 1px solid var(--border);
  }
  table.table tbody tr:last-child {
    border-bottom: 0;
  }
  table.table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    border: 0;
    padding: 5px 10px;
    text-align: right;
  }
  table.table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 10.5px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted-2);
    text-align: left;
  }
  table.table td:first-child {
    display: block;
    text-align: left;
    padding-bottom: 8px;
  }
  table.table .row-actions {
    justify-content: flex-start;
  }
  .log-box {
    height: 260px;
  }
}
