/* ===== Tokens ===== */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #16171a;
  --muted: #5f626a;
  --line: #e4e4de;
  /* Contraste WCAG 2.1 AA: todo texto sobre estos colores llega a 4.5:1 o más */
  --accent: #0f766e; /* petróleo Verienza */
  --accent-soft: #e7f4f1;
  --spark: #f59e0b; /* ámbar: la luz del taller (solo decorativo) */
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #e8f7ee;
  --on-ok: #ffffff;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 17, 20, 0.04), 0 8px 24px rgba(16, 17, 20, 0.06);
  --shadow-lg: 0 24px 60px rgba(16, 17, 20, 0.18);
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --surface: #17181b;
    --surface-2: #1f2024;
    --text: #f2f2ef;
    --muted: #9a9ca3;
    --line: #2a2b30;
    --accent: #2dd4bf;
    --accent-soft: #0f2a27;
    --spark: #fbbf24;
    --ok: #34d399;
    --ok-soft: #10261c;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --danger: #f87171;
    --on-accent: #16171a;
    --on-ok: #16171a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, p {
  margin: 0;
}
a {
  color: inherit;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
.muted {
  color: var(--muted);
}
.hidden {
  display: none !important;
}

/* ===== Layout ===== */
.wrap {
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
}
.narrow {
  width: min(560px, 100% - 32px);
  margin-inline: auto;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap,
.topbar .narrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
}
.brand-mark svg {
  width: 18px;
  height: 18px;
}

/* ===== Botones / campos ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn:hover {
  border-color: color-mix(in srgb, var(--text) 25%, var(--line));
}
.btn:active {
  transform: scale(0.97);
}
.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px color-mix(in srgb, var(--text) 25%, transparent);
  border-color: var(--text);
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-accent:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--on-ok);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}
.btn-danger {
  color: var(--danger);
}
.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 10px;
}
.btn-icon {
  width: 40px;
  padding: 0;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.field {
  display: grid;
  gap: 6px;
}
.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea.input {
  height: auto;
  min-height: 84px;
  padding: 12px 14px;
  resize: vertical;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.chip[data-tone='accent'] {
  background: var(--accent-soft);
  color: var(--accent);
}
.chip[data-tone='ok'] {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip[data-tone='warn'] {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip[data-tone='live'] {
  background: var(--ok-soft);
  color: var(--ok);
}
.chip[data-tone='live']::before {
  animation: pulse 1.6s infinite;
}

/* ===== Animaciones ===== */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  70% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 9px transparent;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.rise {
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.shake {
  animation: shake 0.4s;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.center-load {
  display: grid;
  place-items: center;
  min-height: 50vh;
}

/* ===== Toasts ===== */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(420px, 100% - 32px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px;
  font-weight: 500;
  animation: rise 0.45s var(--spring) both;
}
.toast.out {
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0;
  transform: translateY(10px);
}
.toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ===== Modal / drawer ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 10, 12, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade 0.25s both;
}
.overlay.closing {
  transition: opacity 0.25s;
  opacity: 0;
}
.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 51;
  width: min(560px, 100% - 24px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modal-in 0.4s var(--spring) both;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.96);
  }
}
.modal.closing {
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0;
  transform: translate(-50%, -48%) scale(0.97);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  width: min(520px, 100%);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: drawer-in 0.45s var(--ease) both;
}
@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}
.drawer.closing {
  transition: transform 0.3s var(--ease);
  transform: translateX(100%);
}

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

/* ===== Botón de idioma ES | EN ===== */
.lang-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  height: 36px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  flex: none;
  transition: transform 0.25s var(--spring), border-color 0.2s;
}
.lang-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
.lang-toggle:active {
  transform: scale(0.95);
}
.lang-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.lang-toggle span {
  position: relative;
  z-index: 1;
  width: 34px;
  text-align: center;
  color: var(--muted);
  transition: color 0.3s;
}
.lang-toggle i {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: 34px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.4s var(--spring);
}
.lang-toggle[data-lang='en'] i {
  transform: translateX(34px);
}
.lang-toggle[data-lang='es'] span:nth-of-type(1),
.lang-toggle[data-lang='en'] span:nth-of-type(2) {
  color: var(--on-accent);
}
body {
  transition: opacity 0.22s var(--ease), filter 0.22s;
}
body.lang-out {
  opacity: 0;
  filter: blur(4px);
}

/* contenedor del botón de idioma en barras superiores */
.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Accesibilidad ===== */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.input:focus-visible {
  outline: none; /* los campos ya muestran su propio anillo de foco */
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 0.2s;
}
.skip-link:focus {
  transform: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== Pie legal ===== */
.legal-footer {
  padding: 22px 16px 28px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.legal-footer p {
  margin: 0 0 10px;
}
.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
}
.legal-links a {
  color: var(--muted);
  text-underline-offset: 3px;
}
.legal-links a:hover {
  color: var(--text);
}

/* ===== Aviso de almacenamiento ===== */
.storage-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: rise 0.5s var(--ease) 0.6s both;
}
.storage-notice p {
  margin: 0;
  flex: 1;
}
.storage-notice a {
  color: var(--accent);
  font-weight: 650;
}
.storage-notice.out {
  transition: opacity 0.25s, transform 0.25s;
  opacity: 0;
  transform: translateY(12px);
}
@media (max-width: 520px) {
  .storage-notice {
    flex-direction: column;
    align-items: stretch;
  }
}
.biz-missing {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 4px;
  padding: 0 4px;
}

/* ===== Casillas de consentimiento ===== */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}
.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}
.check a,
.login-legal a,
.privacy-line a {
  color: inherit;
  text-underline-offset: 3px;
}
.login-legal {
  margin: 0 !important;
  font-size: 12.5px;
  color: var(--muted);
}
.privacy-line {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}

/* ===== Logo de Verienza (tuerca con palomita) =====
   Claro: símbolo blanco sobre petróleo. Oscuro: petróleo brillante sobre grafito (como app-icon-oscuro.svg). */
:root {
  --brand-bg: #0f766e;
  --brand-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand-bg: #16171a;
    --brand-fg: #2dd4bf;
  }
}
.brand-mark {
  background: var(--brand-bg);
  color: var(--brand-fg);
  border-radius: 22.5%; /* misma curva que el ícono oficial (115/512) */
}
@media (prefers-color-scheme: dark) {
  .brand-mark {
    box-shadow: inset 0 0 0 1px var(--line);
  }
}
.brand-mark .brand-svg,
.brand-mark.big .brand-svg {
  width: 74%;
  height: 74%;
}
.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  margin-left: -8px; /* el SVG trae 8px de margen propio */
}

/* Campo con error: borde rojo (además del mensaje, que leen los lectores de pantalla) */
.input[aria-invalid='true'],
input[aria-invalid='true'] {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 15%, transparent);
}
.check:has(input[aria-invalid='true']) {
  color: var(--danger);
}
