/* ==========================================================================
   url-watchdog — hoja de estilos propia
   CSS puro, sin framework, sin build. Tema oscuro base + claro como override.
   ========================================================================== */

/* Tema oscuro: tema base. El tema claro lo sobrescribe más abajo. */
:root {
  --bg: #0b1120;
  --bg-2: #0f172a;
  --page-glow-a: rgba(99, 102, 241, 0.20);
  --page-glow-b: rgba(37, 99, 235, 0.14);

  --surface: rgba(15, 23, 42, 0.74);
  --surface-strong: rgba(15, 23, 42, 0.96);
  --surface-soft: rgba(30, 41, 59, 0.48);
  --surface-hover: rgba(255, 255, 255, 0.035);

  --border: rgba(147, 197, 253, 0.16);
  --border-soft: rgba(255, 255, 255, 0.08);
  --divider: rgba(148, 163, 184, 0.16);
  --rim: rgba(96, 165, 250, 0.20);

  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;
  --heading: #ffffff;

  --blue: #2563eb;
  --indigo: #6366f1;
  --blue-soft: rgba(37, 99, 235, 0.16);
  --blue-text: #7aa2ff;

  --green: #22c55e;
  --green-text: #31f37a;
  --green-soft: rgba(34, 197, 94, 0.14);

  --red: #ef4444;
  --red-text: #ff5b65;
  --red-soft: rgba(239, 68, 68, 0.14);

  --amber: #f59e0b;
  --amber-text: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.14);

  --grey: #94a3b8;
  --grey-soft: rgba(148, 163, 184, 0.14);

  --ring-track: rgba(148, 163, 184, 0.24);

  --shadow: 0 24px 80px rgba(2, 8, 23, 0.38);
  --shadow-soft: 0 10px 34px rgba(2, 8, 23, 0.24);
  --primary-shadow: 0 16px 36px rgba(79, 70, 229, 0.32);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
  --bg: #f8fbff;
  --bg-2: #eef5ff;
  --page-glow-a: rgba(37, 99, 235, 0.10);
  --page-glow-b: rgba(99, 102, 241, 0.08);

  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.98);
  --surface-soft: rgba(248, 250, 252, 0.86);
  --surface-hover: rgba(37, 99, 235, 0.035);

  --border: rgba(37, 99, 235, 0.14);
  --border-soft: rgba(15, 23, 42, 0.08);
  --divider: rgba(37, 99, 235, 0.12);
  --rim: rgba(37, 99, 235, 0.12);

  --text: #0f172a;
  --text-muted: #334155;
  --text-soft: #64748b;
  --heading: #0b1120;

  --blue-soft: rgba(37, 99, 235, 0.10);
  --blue-text: #2563eb;

  --green-text: #0ea54d;
  --green-soft: rgba(34, 197, 94, 0.10);

  --red-text: #ef1f2d;
  --red-soft: rgba(239, 68, 68, 0.10);

  --amber-text: #b45309;
  --amber-soft: rgba(245, 158, 11, 0.12);

  --grey-soft: rgba(148, 163, 184, 0.12);
  --ring-track: rgba(37, 99, 235, 0.14);

  --shadow: 0 24px 80px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.08);
  --primary-shadow: 0 14px 32px rgba(37, 99, 235, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 24% -10%, var(--page-glow-a), transparent 38%),
    radial-gradient(circle at 82% 4%, var(--page-glow-b), transparent 32%),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-block;
  flex: 0 0 auto;
}

/* Layout ------------------------------------------------------------------ */

.app-shell {
  position: relative;
  width: min(1536px, 100%);
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 4px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-width: max-content;
}

.brand-mark {
  display: block;
  width: 70px;
  height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(2, 8, 23, 0.28));
}

.brand-name {
  color: var(--heading);
  font-size: 1.75rem;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

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

.button,
.avatar-button,
.theme-toggle,
.actions button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.button:hover,
.avatar-button:hover,
.theme-toggle:hover,
.actions button:hover {
  transform: translateY(-1px);
  border-color: var(--rim);
  background: var(--surface-strong);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 560;
  white-space: nowrap;
}

.button-primary {
  border-color: rgba(255, 255, 255, 0.20);
  color: #ffffff;
  background: linear-gradient(135deg, var(--indigo), var(--blue));
  box-shadow: var(--primary-shadow);
}

.button-primary:hover {
  background: linear-gradient(135deg, #7375ff, #2f6df4);
}

.button-secondary {
  color: var(--text-muted);
}

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

.button.compact {
  min-height: 44px;
  padding-inline: 18px;
  font-size: 0.95rem;
}

.button.block {
  width: 100%;
}

.avatar-button {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 999px;
  color: var(--text-muted);
}

.avatar-button .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--rim);
}

/* Toggle de tema ---------------------------------------------------------- */

.theme-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--text-soft);
}

.switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 8px rgba(2, 8, 23, 0.18);
}

.switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #f8fafc;
  box-shadow: 0 4px 12px rgba(2, 8, 23, 0.30);
  transition: transform 180ms ease;
}

html[data-theme="light"] .switch-thumb {
  transform: translateX(20px);
  background: #334155;
}

html[data-theme="light"] .sun-icon {
  color: var(--blue);
}

html:not([data-theme="light"]) .moon-icon {
  color: #bfdbfe;
}

/* Tarjetas ---------------------------------------------------------------- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card,
.url-card,
.kpi-strip {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.075), transparent 42%),
    var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.stat-card {
  min-height: 176px;
  padding: 20px 24px 16px;
}

.stat-content {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.stat-card h2,
.kpi-item h2 {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 520;
}

.stat-value {
  margin: 10px 0 0;
  color: var(--heading);
  font-size: clamp(2.1rem, 3vw, 2.9rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.stat-caption {
  margin: 10px 0 0;
  font-size: 0.98rem;
  color: var(--text-soft);
}

.icon-box,
.kpi-icon {
  display: grid;
  place-items: center;
  color: var(--blue-text);
  background: var(--blue-soft);
  border: 1px solid var(--border);
}

.icon-box {
  width: 54px;
  height: 54px;
  border-radius: 14px;
}

.icon-box .icon {
  width: 1.65rem;
  height: 1.65rem;
}

.icon-box-green {
  color: var(--green-text);
  background: var(--green-soft);
  border-color: rgba(34, 197, 94, 0.18);
}

.icon-box-red {
  color: var(--red-text);
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.18);
}

.icon-box-neutral {
  color: var(--text-soft);
  background: var(--surface-soft);
}

.text-green { color: var(--green-text) !important; }
.text-red { color: var(--red-text) !important; }
.accent-blue { color: var(--blue-text); }

/* Sparklines -------------------------------------------------------------- */

.sparkline {
  width: 100%;
  height: 56px;
  margin-top: 14px;
  overflow: visible;
}

/* La línea: solo trazo, sin relleno (si se rellena, se ve un bloque). */
.sparkline polyline {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* El punto final: solo relleno, sin trazo. */
.sparkline circle {
  stroke: none;
}

.sparkline-blue polyline {
  stroke: var(--indigo);
  filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.5));
}
.sparkline-green polyline {
  stroke: var(--green);
  filter: drop-shadow(0 0 5px rgba(34, 197, 94, 0.45));
}
.sparkline-red polyline {
  stroke: var(--red);
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.45));
}

.sparkline-blue circle { fill: var(--indigo); }
.sparkline-green circle { fill: var(--green); }
.sparkline-red circle { fill: var(--red); }

.spark-empty {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* Próximo chequeo --------------------------------------------------------- */

.next-check-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.next-check-card .stat-content {
  min-width: 0;
}

/* El anillo de cuenta atrás va centrado verticalmente; el contenido
   (icono incluido) queda arriba, alineado con las otras tarjetas. */
.next-check-card .progress-ring {
  align-self: center;
}

/* Algo de aire alrededor de los ":" de la cuenta atrás (el número grande
   lleva un tracking muy ceñido y se pegan a las cifras). */
.t-colon {
  margin: 0 0.1em;
}

.progress-ring {
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
  padding: 9px;
  border-radius: 999px;
  background: conic-gradient(
    var(--blue) calc(var(--p, 0) * 1%),
    var(--ring-track) 0
  );
  box-shadow: 0 12px 34px rgba(37, 99, 235, 0.18);
  transition: background 0.6s linear;
}

.progress-ring span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--surface-strong);
}

/* Tarjeta de la tabla ----------------------------------------------------- */

.url-card {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--divider);
}

.card-header h1 {
  margin: 0;
  color: var(--heading);
  font-size: 1.45rem;
  letter-spacing: -0.035em;
}

.card-subtitle {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.search-field {
  display: flex;
  width: min(320px, 32vw);
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: var(--text-soft);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.search-field input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-field input::placeholder {
  color: var(--text-soft);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 26px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--divider);
  color: var(--text-muted);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  font-size: 0.95rem;
  font-weight: 540;
}

tbody tr {
  transition: background 140ms ease;
}

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

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

.table-message {
  text-align: center;
  color: var(--text-soft);
  padding: 38px 26px;
}

.project,
.url-link,
.status-line,
.last-check,
.actions {
  display: inline-flex;
  align-items: center;
}

.project {
  gap: 12px;
  max-width: 260px;
  color: var(--text);
  font-weight: 560;
}

.project-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #ffffff;
  border-radius: 9px;
  font-weight: 760;
  flex: 0 0 auto;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.18);
}

.avatar-0 { background: linear-gradient(135deg, #4f46e5, #3b82f6); }
.avatar-1 { background: linear-gradient(135deg, #7c3aed, #4f46e5); }
.avatar-2 { background: linear-gradient(135deg, #f43f5e, #ef4444); }
.avatar-3 { background: linear-gradient(135deg, #06b6d4, #14b8a6); }
.avatar-4 { background: linear-gradient(135deg, #0ea5e9, #3b82f6); }
.avatar-5 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-6 { background: linear-gradient(135deg, #10b981, #22c55e); }
.avatar-7 { background: linear-gradient(135deg, #8b5cf6, #ec4899); }

.url-link {
  max-width: 320px;
  gap: 9px;
  color: var(--blue-text);
  white-space: nowrap;
  overflow: hidden;
}

.url-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.url-link .lock {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--text-soft);
}

.url-link .external {
  color: var(--text-soft);
}

.status-line,
.last-check {
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.dot.green { background: var(--green); }
.dot.red { background: var(--red); animation: dot-pulse 1.6s ease-in-out infinite; }
.dot.amber { background: var(--amber); animation: dot-pulse-amber 1.6s ease-in-out infinite; }
.dot.blue { background: var(--blue); animation: dot-pulse-blue 1.1s ease-in-out infinite; }
.dot.grey { background: var(--grey); }

@keyframes dot-pulse-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

@keyframes dot-pulse-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0); }
}

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.pill,
.code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 620;
}

.pill-green,
.code-green {
  color: var(--green-text);
  background: var(--green-soft);
  border: 1px solid rgba(34, 197, 94, 0.16);
}

.pill-red,
.code-red {
  color: var(--red-text);
  background: var(--red-soft);
  border: 1px solid rgba(239, 68, 68, 0.16);
}

.pill-amber,
.code-amber {
  color: var(--amber-text);
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.18);
}

.pill-blue {
  color: var(--blue-text);
  background: var(--blue-soft);
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.pill-grey,
.code-grey {
  color: var(--text-soft);
  background: var(--grey-soft);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.actions {
  gap: 8px;
}

.actions button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  color: var(--text-muted);
  border-radius: 9px;
}

.actions button[data-act="edit"]:hover { color: var(--blue-text); }
.actions button[data-act="delete"]:hover { color: var(--red-text); }

/* Franja de métricas ------------------------------------------------------ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
  padding: 26px 28px;
}

.kpi-item {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  padding: 0 30px;
  border-right: 1px solid var(--divider);
}

.kpi-item:first-child { padding-left: 0; }

.kpi-item:last-child {
  padding-right: 0;
  border-right: 0;
}

.kpi-icon {
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  border-radius: 14px;
}

.kpi-icon .icon {
  width: 1.8rem;
  height: 1.8rem;
}

.kpi-item h2 { margin: 0; }

.kpi-item p {
  margin: 8px 0 0;
  color: var(--heading);
  font-size: 1.55rem;
  font-weight: 760;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

/* Paneles laterales (offcanvas) ------------------------------------------- */

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 8, 23, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.panel-backdrop.show {
  opacity: 1;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface-strong);
  border-left: 1px solid var(--border);
  box-shadow: -30px 0 80px rgba(2, 8, 23, 0.45);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel.open {
  transform: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--divider);
}

.panel-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.panel-section + .panel-section {
  margin-top: 26px;
}

.panel-section > h3 {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-soft);
}

.panel-note {
  margin: 0 0 14px;
  font-size: 0.86rem;
  color: var(--text-soft);
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.panel-actions .button-primary {
  flex: 1;
}

/* Ayuda */
.help-about {
  text-align: center;
  padding: 30px 24px 26px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 0%, var(--blue-soft), transparent 62%),
    var(--surface);
}

.help-about-logo {
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(2, 8, 23, 0.32));
}

.help-about h2 {
  margin: 16px 0 6px;
  font-size: 1.55rem;
  font-weight: 760;
  letter-spacing: -0.03em;
  color: var(--heading);
}

.help-about-tag {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 560;
  color: var(--blue-text);
}

.help-about-desc {
  margin: 18px auto 0;
  max-width: 320px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
}

.help-about-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.help-about-meta span {
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 560;
  color: var(--text-soft);
}

.help-block + .help-block {
  margin-top: 18px;
}

.help-block h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--heading);
}

.help-block p,
.help-block li {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.help-block ol,
.help-block ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

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

.field {
  margin-bottom: 16px;
}

.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 560;
  color: var(--text-muted);
}

.input,
.select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 13px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.input:focus,
.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row > .field {
  flex: 1;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  transition: background 150ms ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 8, 23, 0.35);
  transition: transform 180ms ease;
}

.switch input:checked + .switch-ui {
  background: linear-gradient(135deg, var(--indigo), var(--blue));
  border-color: transparent;
}

.switch input:checked + .switch-ui::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-ui {
  box-shadow: 0 0 0 3px var(--blue-soft);
}

/* Modal ------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 8, 23, 0.6);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(460px, 100%);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

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

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--heading);
}

.modal-body {
  padding: 22px 22px 6px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 22px;
}

/* Toasts ------------------------------------------------------------------ */

.toast-stack {
  position: fixed;
  top: 94px;
  right: 22px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  animation: toast-in 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.toast.toast-hide {
  animation: toast-out 0.22s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(40px); }
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 9px;
}

.toast-icon .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.toast-success .toast-icon {
  color: var(--green-text);
  background: var(--green-soft);
}
.toast-danger .toast-icon {
  color: var(--red-text);
  background: var(--red-soft);
}
.toast-warning .toast-icon {
  color: var(--amber-text);
  background: var(--amber-soft);
}
.toast-info .toast-icon {
  color: var(--blue-text);
  background: var(--blue-soft);
}

.toast-body {
  flex: 1;
  padding-top: 5px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text);
}

.toast-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  font-size: 1.15rem;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Login ------------------------------------------------------------------- */

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

.login-card {
  width: min(420px, 100%);
  padding: 36px 34px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.075), transparent 42%),
    var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-head {
  text-align: center;
  margin-bottom: 26px;
}

.login-head .brand-mark {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
}

.login-head h1 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--heading);
  letter-spacing: -0.03em;
}

.login-head p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* Responsive -------------------------------------------------------------- */

/* Pantallas amplias: el panel ocupa el alto de la ventana, sin scroll de
   página. La tabla de URLs scrollea por dentro si hay demasiadas. */
@media (min-width: 1180px) and (min-height: 640px) {
  .app-shell {
    height: 100vh;
  }

  .topbar,
  .summary-grid {
    flex: 0 0 auto;
  }

  .url-card {
    flex: 1 1 auto;
  }

  .url-card .card-header {
    flex: 0 0 auto;
  }

  .url-card .table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    /* Hueco reservado al final de la lista: ahí "aparca" la franja
       flotante, así nunca tapa una fila. */
    padding-bottom: 132px;
  }

  /* La franja de métricas sale del flujo (la lista ocupa todo el alto) y
     flota sobre el hueco final. Si la lista cabe sin scroll se muestra
     fija; si necesita scroll, se oculta y reaparece al hacer scroll. */
  .kpi-strip {
    position: absolute;
    left: 28px;
    right: 28px;
    bottom: 28px;
    margin-top: 0;
    z-index: 20;
    transform: translateY(150%);
    opacity: 0;
    pointer-events: none;
    transition:
      transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.2s ease;
  }

  .kpi-strip.floating-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 1180px) {
  .topbar,
  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .table-tools {
    justify-content: flex-start;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 26px;
  }

  .kpi-item:nth-child(2) { border-right: 0; }
  .kpi-item:nth-child(3) { padding-left: 0; }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 18px;
  }

  .summary-grid,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .table-tools {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-field {
    width: 100%;
  }

  .kpi-item,
  .kpi-item:nth-child(3) {
    padding: 0;
    border-right: 0;
  }
}

/* Página de historial ------------------------------------------------------ */

/* The history page scrolls normally (no 100vh shell like the dashboard). */
.app-shell.history-shell {
  height: auto;
  min-height: 100vh;
}

/* Undo the gap reserved for the dashboard's floating KPI strip. */
.history-shell .url-card .table-wrap {
  padding-bottom: 0;
}

.history-card {
  flex: 0 0 auto;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 22px 26px;
}

.history-filters .field {
  flex: 1 1 150px;
  max-width: 240px;
  margin-bottom: 0;
}

.history-card .project-name {
  display: inline-block;
  max-width: 280px;
  vertical-align: bottom;
}

.history-loading {
  font-size: 0.92rem;
  color: var(--blue-text);
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s ease; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

.history-summary {
  margin-top: 22px;
}

.avail-strip {
  display: block;
}

.avail-strip rect.ok { fill: var(--green); opacity: 0.85; }
.avail-strip rect.fail { fill: var(--red); }

.cell-error {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted-note {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 16px 26px 22px;
}

.pagination-info {
  color: var(--text-soft);
  font-size: 0.92rem;
}

/* KPI clicable que lleva al historial. */
.kpi-link {
  color: inherit;
  text-decoration: none;
}

.kpi-item .kpi-more {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 560;
  letter-spacing: 0;
  color: var(--blue-text);
}

.kpi-link:hover .kpi-more {
  text-decoration: underline;
}
