/* ===========================================================================
   MetaConnector — hoja de estilos del panel
   ---------------------------------------------------------------------------
   Un solo fichero, sin dependencias. Los colores salen de variables para que
   el tema claro y el oscuro compartan estructura: se cambian los tokens y
   todo lo demás sigue igual.

   El tema sale de la preferencia del sistema y se puede forzar con
   data-theme="light" | "dark" en <html>, que es lo que hace el conmutador.
   =========================================================================== */

:root {
  /* Superficies, de la más al fondo a la más elevada */
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef1f5;
  --line: #e2e6ec;
  --line-soft: #edf0f4;

  --text: #16202b;
  --text-dim: #5b6875;
  --text-faint: #6c7885;

  /* Verde de WhatsApp como color de marca.
     En claro el acento va bastante oscuro a propósito: es el fondo del botón
     principal y del texto de las etiquetas verdes, y con el #25d366 de la
     marca el texto blanco encima solo llegaba a 3.4 de contraste, por debajo
     del 4.5 que pide WCAG AA. El verde vivo se reserva para lo decorativo
     (el punto de la marca, las barras del gráfico), donde no hay texto. */
  --accent: #0d8040;
  --accent-bright: #25d366;
  --accent-soft: #e7f8ee;
  --btn-fg: #ffffff;

  --blue: #1a5cc0;
  --blue-soft: #e8f0fd;
  --amber: #8a5600;
  --amber-soft: #fdf3e2;
  --red: #b8232e;
  --red-soft: #fdecee;

  --shadow-sm: 0 1px 2px rgba(16, 26, 38, 0.05);
  --shadow-md: 0 4px 12px -3px rgba(16, 26, 38, 0.09), 0 1px 3px rgba(16, 26, 38, 0.05);
  --shadow-lg: 0 18px 44px -12px rgba(16, 26, 38, 0.22), 0 4px 12px -4px rgba(16, 26, 38, 0.1);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;
  --radius: var(--r-md); /* nombre antiguo, se mantiene por compatibilidad */

  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 13.5px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --sidebar-w: 244px;
}

/* --- Tema oscuro ---------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #1a212b;
    --surface-3: #222b36;
    --line: #2a333f;
    --line-soft: #212a34;

    --text: #e6edf3;
    --text-dim: #9aa7b4;
    --text-faint: #7d8b9b;

    --accent: #25d366;
    --accent-bright: #3ce77c;
    --accent-soft: rgba(37, 211, 102, 0.13);
    --btn-fg: #06210f;

    --blue: #6ba6ff;
    --blue-soft: rgba(107, 166, 255, 0.13);
    --amber: #f0b429;
    --amber-soft: rgba(240, 180, 41, 0.13);
    --red: #ff6b73;
    --red-soft: rgba(255, 107, 115, 0.13);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px -3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme='dark'] {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1a212b;
  --surface-3: #222b36;
  --line: #2a333f;
  --line-soft: #212a34;

  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #7d8b9b;

  --accent: #25d366;
  --accent-bright: #3ce77c;
  --accent-soft: rgba(37, 211, 102, 0.13);
  --btn-fg: #06210f;

  --blue: #6ba6ff;
  --blue-soft: rgba(107, 166, 255, 0.13);
  --amber: #f0b429;
  --amber-soft: rgba(240, 180, 41, 0.13);
  --red: #ff6b73;
  --red-soft: rgba(255, 107, 115, 0.13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px -3px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, 0.6);
}

/* --- Base ---------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

/* Un solo estilo de foco para todo lo que se puede recorrer con el teclado */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection {
  background: var(--accent-soft);
}

/* Barras de desplazamiento discretas, del color del tema */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Acceso -------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Dos manchas de color muy suaves, para que la pantalla de entrada no sea
   un rectángulo gris en medio de la nada. */
.login::before,
.login::after {
  content: '';
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
}

.login::before {
  background: var(--accent);
  top: -180px;
  left: -140px;
  opacity: 0.16;
}

.login::after {
  background: var(--blue);
  bottom: -200px;
  right: -160px;
  opacity: 0.12;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  font-size: var(--fs-xl);
  font-weight: 680;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-sub {
  margin: -10px 0 10px;
  color: var(--text-dim);
  font-size: var(--fs-base);
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: var(--fs-sm);
  min-height: 18px;
}

.login-card .btn.primary {
  margin-top: 4px;
  padding: 10px 16px;
  font-size: var(--fs-base);
}

/* Punto verde, se sigue usando en otros sitios */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex-shrink: 0;
}

/* Marca: dos nodos unidos dentro de un cuadrado verde */
.logo {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent-bright), var(--accent));
  box-shadow: 0 2px 6px -1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.logo svg {
  width: 19px;
  height: 19px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.login-brand .logo svg {
  width: 23px;
  height: 23px;
}

/* --- Estructura ---------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 670;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 8px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

nav a {
  position: relative;
  color: var(--text-dim);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-base);
  transition: background 0.13s ease, color 0.13s ease;
}

/* Los iconos son SVG de trazo: se tiñen con el color del texto */
nav a svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}

nav a:hover {
  background: var(--surface-3);
  color: var(--text);
}

nav a.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 570;
}

nav a.active svg {
  color: var(--accent);
  opacity: 1;
}

/* Marca de posición a la izquierda de la entrada activa */
nav a.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 17px;
  border-radius: 0 var(--r-full) var(--r-full) 0;
  background: var(--accent);
}

nav .nav-sep {
  margin: 14px 10px 5px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  padding: 0 6px;
  word-break: break-word;
}

.user strong {
  display: block;
  color: var(--text);
  font-weight: 570;
}

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

.foot-actions .btn:first-child {
  flex: 1;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 660;
  letter-spacing: -0.015em;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.content {
  padding: 24px 26px 72px;
  min-width: 0;
  animation: view-in 0.22s ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Botón del menú en móvil: oculto en escritorio */
.menu-toggle {
  display: none;
}

/* --- Botones ------------------------------------------------------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 520;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.13s ease, border-color 0.13s ease, box-shadow 0.13s ease,
    transform 0.08s ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--text-faint);
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--btn-fg);
  font-weight: 600;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn.primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.btn.danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 32%, var(--line));
}

.btn.danger:hover {
  background: var(--red-soft);
  border-color: var(--red);
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.btn.small {
  padding: 4px 9px;
  font-size: var(--fs-xs);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Botón cuadrado para iconos, como el del tema */
.btn.icon {
  padding: 6px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.btn.icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Tarjetas de cifras -------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Filo de color arriba: verde normalmente, ámbar o rojo si hay que mirarlo */
.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
  opacity: 0.55;
}

.card:has(.value.warn)::before {
  background: var(--amber);
  opacity: 1;
}

.card:has(.value.bad)::before {
  background: var(--red);
  opacity: 1;
}

.card .label {
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 580;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card .value {
  font-size: 27px;
  font-weight: 670;
  line-height: 1.15;
  margin-top: 5px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.card .value.warn {
  color: var(--amber);
}

.card .value.bad {
  color: var(--red);
}

.card-hint {
  margin-top: 3px;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* Icono de fondo, arriba a la derecha: ayuda a reconocer la tarjeta de un
   vistazo sin robarle protagonismo a la cifra. */
.card-ico {
  position: absolute;
  top: 13px;
  right: 13px;
  line-height: 0;
  color: var(--text-faint);
  opacity: 0.45;
}

.card-ico svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tarjetas que llevan a la vista donde se puede actuar sobre esa cifra */
.card.link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card.link:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.card.link:hover .card-ico {
  color: var(--accent);
  opacity: 0.9;
}

/* --- Paneles ------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 640;
  letter-spacing: -0.005em;
}

.panel-body {
  padding: 16px;
}

.panel-body p {
  margin: 0 0 10px;
}

.panel-body p:last-child {
  margin-bottom: 0;
}

/* --- Tablas -------------------------------------------------------------- */

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}

th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 580;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
}

/* Aquí NO va `position: sticky`. El .table-wrap necesita overflow-x para las
   tablas anchas, y en cuanto un eje deja de ser visible el navegador calcula
   el otro como auto: el contenedor pasa a ser el ancla del sticky, no la
   página. Como el contenedor no tiene altura limitada, nunca scrollea y la
   cabecera se iría igual al bajar. Comprobado: con scroll de 400 px el th
   pasaba de 153 a -247. Para que funcionase habría que limitar la altura del
   contenedor y meter un segundo scroll dentro del panel. */

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

/* La primera columna es la que identifica la fila: algo más de peso */
tbody td:first-child {
  font-weight: 520;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions .btn {
  margin-left: 5px;
}

/* --- Texto y etiquetas --------------------------------------------------- */

.mono {
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.dim {
  color: var(--text-dim);
}

.truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 570;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

/* Punto de color delante del texto: se distingue sin depender del color */
.tag.ok::before,
.tag.warn::before,
.tag.bad::before,
.tag.info::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.tag.ok {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-soft);
}

.tag.warn {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 30%, transparent);
  background: var(--amber-soft);
}

.tag.bad {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
  background: var(--red-soft);
}

.tag.info {
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 30%, transparent);
  background: var(--blue-soft);
}

/* --- Sitios vacíos ------------------------------------------------------- */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty svg {
  width: 34px;
  height: 34px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.35;
}

.empty strong {
  color: var(--text);
  font-weight: 580;
  font-size: var(--fs-md);
}

.empty p {
  margin: 0;
  max-width: 46ch;
  font-size: var(--fs-base);
}

.empty .btn {
  margin-top: 6px;
}

/* --- Formularios --------------------------------------------------------- */

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: var(--fs-base);
  font-family: inherit;
  width: 100%;
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  padding-right: 30px;
  /* La flechita va en el fondo para no depender del control del sistema */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236c7885' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 540;
  color: var(--text-dim);
  margin-bottom: 2px;
}

label input,
label select,
label textarea {
  margin-top: 5px;
  color: var(--text);
  font-weight: 400;
}

/* Casillas y radios: tamaño cómodo y del color de la marca */
input[type='checkbox'],
input[type='radio'] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: 4px;
  line-height: 1.45;
}

.filters input,
.filters select {
  width: auto;
  min-width: 152px;
}

/* --- Ventanas modales ---------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #0a0e14 62%, transparent);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  animation: fade-in 0.14s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

.modal.wide {
  max-width: 880px;
}

.modal h2 {
  margin: 0 0 4px;
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: -0.015em;
}

.modal-sub {
  color: var(--text-dim);
  font-size: var(--fs-base);
  margin: 0 0 18px;
}

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

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

pre.code {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px;
  overflow: auto;
  max-height: 380px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.kv {
  display: grid;
  grid-template-columns: 178px 1fr;
  gap: 8px 16px;
  font-size: var(--fs-base);
  margin-bottom: 18px;
}

.kv dt {
  color: var(--text-dim);
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-row input {
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

/* --- Asistente de alta --------------------------------------------------- */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.wizard-step:not(:last-child)::after {
  content: '';
  width: 16px;
  height: 1.5px;
  border-radius: var(--r-full);
  background: var(--line);
  margin-left: 5px;
}

.wizard-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 620;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wizard-step.current {
  color: var(--text);
  font-weight: 620;
}

.wizard-step.current .wizard-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wizard-step.done .wizard-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--btn-fg);
}

.wizard-step.done {
  color: var(--text-dim);
}

.wizard-step.done:not(:last-child)::after {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

@media (max-width: 700px) {
  .wizard-label {
    display: none;
  }
}

/* --- Refresco automático ------------------------------------------------- */

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
}

.auto-refresh:hover {
  border-color: var(--text-faint);
}

.auto-refresh input {
  width: auto;
  margin: 0;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* --- Gráfico de barras --------------------------------------------------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 124px;
  padding: 0 2px;
}

.chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  height: 100%;
  position: relative;
}

.chart .bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  min-height: 2px;
  transition: opacity 0.13s ease;
}

.chart .bar.out {
  background: linear-gradient(180deg, var(--blue), color-mix(in srgb, var(--blue) 70%, #000));
}

.chart .bar-col:hover .bar {
  opacity: 0.75;
}

.chart .hour {
  font-size: 9.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-top: 12px;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 6px;
}

/* --- Avisos -------------------------------------------------------------- */

.notice {
  border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--line));
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  padding: 12px 15px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  margin-bottom: 18px;
  color: var(--text-dim);
}

.notice.warn {
  border-color: color-mix(in srgb, var(--amber) 22%, var(--line));
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.notice strong {
  color: var(--text);
}

/* --- Avisos flotantes ---------------------------------------------------- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 11px 15px;
  font-size: var(--fs-base);
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.error {
  border-left-color: var(--red);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}

/* --- Esqueleto de carga -------------------------------------------------- */

/* Se muestra mientras llegan los datos: da menos sensación de parón que un
   «Cargando…» y no descoloca la página cuando aparece el contenido. */
.skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.skeleton-row {
  height: 46px;
  border-radius: var(--r-md);
  background: linear-gradient(
    90deg,
    var(--surface-3) 25%,
    var(--surface-2) 37%,
    var(--surface-3) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* --- Pantallas estrechas ------------------------------------------------- */

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

  .menu-toggle {
    display: inline-grid;
  }

  /* La barra lateral pasa a ser un cajón que se abre desde la izquierda */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 39;
    animation: fade-in 0.14s ease-out;
  }

  .topbar {
    padding: 14px 16px;
    justify-content: flex-start;
    gap: 10px;
  }

  /* El título empuja las acciones a la derecha; el botón del menú se queda
     pegado al borde izquierdo. */
  .topbar h1 {
    flex: 1;
    font-size: var(--fs-md);
  }

  .content {
    padding: 18px 16px 64px;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .kv dt {
    margin-top: 8px;
  }
}
