:root {
  --bg: #e6eef1;
  --card: #ffffff;
  --text: #1b2a32;
  --muted: #5d727c;
  --line: #d3e0e6;
  --accent: #1f7a84;
  --accent-dark: #16656d;
  --danger: #c5363a;
  --ok: #1f8a4c;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* Login y Enrolar Authenticator centrados en el viewport */
#app:has(#view-login:not(.hidden)),
#app:has(#view-mfa-enroll:not(.hidden)),
#app:has(#view-alta:not(.hidden)) {
  max-width: none;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

#app:has(#view-app:not(.hidden)) {
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

#view-login.card,
#view-mfa-enroll.card {
  width: min(420px, 100%);
  margin: 0;
}

#view-alta.card {
  width: min(460px, 100%);
  max-width: 460px;
  margin: 0;
}

#view-alta h1,
.alta-lead {
  text-align: center;
}

.alta-pass {
  display: grid;
  gap: 0.35rem;
}

.alta-pass-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.alta-pass-head .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

label.alta-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  margin: 0.15rem 0 0.25rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}

label.alta-choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

label.alta-choice input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

label.alta-choice strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--text);
  font-size: 0.95rem;
}

label.alta-choice .muted {
  display: block;
  line-height: 1.4;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  display: grid;
  gap: 0.75rem;
  max-width: 420px;
  box-shadow: 0 10px 28px rgba(19, 38, 46, 0.06);
}

/* Bloques anidados dentro de una .card (paso MFA, recuperación…): mismo espaciado que la card. */
.stack {
  display: grid;
  gap: 0.75rem;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

label.remember {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
}

label.remember input,
label.alta-choice input[type="checkbox"] {
  appearance: none;
  width: 46px;
  height: 28px;
  flex: 0 0 46px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: #e5e5ea;
  background-image: radial-gradient(circle 11px at 14px 50%, #fff 98%, transparent 100%);
  background-repeat: no-repeat;
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.2s ease, background-position 0.2s ease;
}

label.remember input:checked,
label.alta-choice input[type="checkbox"]:checked {
  background-color: #34c759;
  background-position: 18px 0;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  background: #fbfcfd;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 132, 0.16);
}

.btn {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn.danger {
  background: transparent;
  color: var(--danger, #d8161e);
  border: 1px solid var(--danger, #d8161e);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(197, 54, 58, 0.08);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  background: #f3f8fa;
}

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

.hidden {
  display: none !important;
}

html.session-pending #view-login {
  display: none !important;
}

#procesandoModal {
  z-index: 80;
}

#confirmAccionModal,
#avisoModal {
  z-index: 70;
}

button[data-busy="1"] {
  cursor: wait;
  opacity: 0.75;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem 1.25rem;
  color: var(--text);
  box-shadow: 0 18px 48px rgba(19, 38, 46, 0.18);
}

.modal h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.modal p {
  margin: 0;
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

/* Error de conexión: tarjeta amable en lugar del texto rojo (ver showError en app.js). */
.error.net-error {
  color: var(--text);
}

.net-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f3f8f9;
  animation: net-card-in 0.25s ease-out;
}

.net-card-icon {
  flex: none;
  width: 88px;
  height: 44px;
  color: var(--muted);
}

.net-card-body {
  display: grid;
  gap: 0.2rem;
}

.net-card-title {
  font-weight: 650;
  color: var(--text);
}

.net-card-text {
  color: var(--muted);
}

.net-card .net-plug {
  transform-box: fill-box;
  animation: net-plug-wiggle 1.6s ease-in-out infinite;
}

.net-card .net-sparks {
  stroke: #e8a317;
  animation: net-sparks-blink 1.6s ease-in-out infinite;
}

@keyframes net-card-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes net-plug-wiggle {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-4px);
  }
}

@keyframes net-sparks-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.15;
  }
}

@media (max-width: 360px) {
  .net-card {
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .net-card,
  .net-card .net-plug,
  .net-card .net-sparks {
    animation: none;
  }
}

.pw-rules {
  list-style: none;
  margin: 0.25rem 0 0.5rem;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.pw-rule {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pw-rule::before {
  content: "○";
  font-size: 0.75rem;
  color: var(--muted);
}

.pw-rule.ok {
  color: var(--ok);
}

.pw-rule.ok::before {
  content: "✓";
  color: var(--ok);
}

.pw-rule.bad {
  color: var(--danger);
}

.pw-rule.bad::before {
  content: "✗";
  color: var(--danger);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.config-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.hijos-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
  background: #fafcfd;
}

.hijos-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.45rem 0.35rem;
  border-radius: 8px;
}

.hijos-row:hover {
  background: #f0f5f7;
}

.hijos-row input {
  margin-top: 0.2rem;
}

.hijos-row-text {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.hijos-row-title {
  font-size: 0.92rem;
  font-weight: 600;
}

.hijos-row-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.hijos-empty {
  padding: 0.65rem 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.config-row {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0.85rem 0.95rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

.config-row:last-child {
  border-bottom: 0;
}

.config-row:hover {
  background: #f3f8fa;
}

.config-row-text {
  display: grid;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}

.config-row-body {
  display: grid;
  gap: 0.55rem;
}

.config-row-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.config-row-sub {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
}

.ios-switch {
  position: relative;
  flex: 0 0 auto;
  margin-top: 0.1rem;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: #c5d0d4;
  transition: background 0.2s ease;
}

.ios-switch.on {
  background: #34c759;
}

.ios-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease;
}

.ios-switch.on .ios-switch-knob {
  transform: translateX(20px);
}

.ios-switch-check {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-52%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
}

.ios-switch.on .ios-switch-check {
  opacity: 1;
}

.enroll-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.enroll-uri {
  font-size: 0.85rem;
}

.enroll-uri summary {
  cursor: pointer;
}



.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-color: var(--accent);
}

a.tab {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tenant-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.tenant-bar label {
  min-width: 220px;
}

.flags {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-weight: 650;
  background: #f6fafb;
}

.tabla-usuarios {
  table-layout: fixed;
}

.tabla-usuarios tbody tr {
  height: 2.85rem;
}

.tabla-usuarios tbody td {
  height: 2.85rem;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.tabla-usuarios td.row-actions {
  white-space: nowrap;
}

.tabla-usuarios td.row-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.85rem;
  min-height: 1.85rem;
  padding: 0 0.65rem;
  line-height: 1;
  vertical-align: middle;
  margin-right: 0.3rem;
}

.tabla-usuarios td.row-actions .btn:last-child {
  margin-right: 0;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-inline input,
.form-inline select {
  min-width: 140px;
}

.tabla-usuarios td.celda-asig {
  min-width: 140px;
  vertical-align: middle;
}

.tabla-usuarios td.celda-asig select {
  width: 100%;
  max-width: 220px;
  min-height: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  box-sizing: border-box;
}

.tabla-usuarios tr.usu-bloqueado td {
  background: #fff4f2;
}

.tabla-usuarios .estado-bloqueado {
  color: #a33b2b;
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  width: 100%;
}

.secret,
pre {
  display: block;
  background: #f6fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  word-break: break-all;
  white-space: pre-wrap;
  font-size: 0.85rem;
}

.break {
  word-break: break-all;
}

.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.job-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.job-light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--line) 70%, transparent);
}

.job-light.up {
  background: var(--ok);
}

.job-light.down {
  background: var(--danger);
}

.job-meta {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.job-meta strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta span {
  font-size: 0.75rem;
  color: var(--muted);
}

