/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 650;
  padding: 7px 14px;
  min-height: 36px;
  transition: background 0.18s var(--ease-out), transform 0.12s var(--ease-out), box-shadow 0.18s var(--ease-out), color 0.15s;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px rgba(11, 18, 32, 0.12), 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(11, 18, 32, 0.14), 0 10px 22px color-mix(in srgb, var(--accent) 34%, transparent);
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0) scale(0.98);
}

.btn--success {
  background: var(--green-600);
  color: var(--white);
}

.btn--success:hover {
  background: var(--green-700);
}

.btn--danger {
  background: var(--red-50);
  color: var(--red-700);
}

.btn--danger:hover {
  background: var(--red-100);
}

.btn--ghost {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn--ghost:hover {
  background: var(--gray-200);
}

.btn--outline {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn--outline:hover {
  background: var(--gray-50);
}

.btn--sm {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.btn--lg {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.95rem;
}

.btn--block {
  width: 100%;
}

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

/* Tarjetas */
.card {
  background: var(--surface-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--gray-200) 85%, transparent);
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out), border-color 0.22s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--gray-200));
}

.card__pad {
  padding: 12px 14px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}

.card__title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.kpi-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

.kpi {
  padding: 12px 14px 10px;
  position: relative;
  overflow: hidden;
  animation: ledger-kpi-in 0.42s var(--ease-out) both;
}

.kpi:nth-child(1) { animation-delay: 0.04s; }
.kpi:nth-child(2) { animation-delay: 0.08s; }
.kpi:nth-child(3) { animation-delay: 0.12s; }
.kpi:nth-child(4) { animation-delay: 0.16s; }
.kpi:nth-child(5) { animation-delay: 0.2s; }

@keyframes ledger-kpi-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.85;
  border-radius: 0 2px 2px 0;
}

.kpi__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi__value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-top: 4px;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.kpi__value--green {
  color: var(--green-600);
}

.kpi__value--red {
  color: var(--red-600);
}

.kpi__hint {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.kpi__delta {
  font-size: 0.72rem;
  font-weight: 650;
  margin-top: 4px;
}

.kpi__delta--up {
  color: var(--green-600);
}

.kpi__delta--down {
  color: var(--red-600);
}

.kpi__delta--flat {
  color: var(--gray-400);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.badge--ok {
  background: var(--green-50);
  color: var(--green-700);
}

.badge--warn {
  background: var(--amber-50);
  color: var(--amber-700);
}

.badge--danger {
  background: var(--red-50);
  color: var(--red-700);
}

.badge--info {
  background: var(--blue-50);
  color: var(--blue-700);
}

.badge--muted {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* Formularios */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--gray-600);
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: 38px;
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}

.textarea {
  min-height: 80px;
  resize: vertical;
}

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

.search {
  position: relative;
}

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search .input {
  padding-left: 40px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  border-radius: 999px;
  padding: 4px 10px;
  min-height: 28px;
  font-weight: 650;
  font-size: 0.8rem;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.chip__count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  line-height: 1.35;
}

.chip.is-active .chip__count {
  background: rgba(255, 255, 255, 0.22);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--gray-50);
  border-radius: 8px;
  margin-bottom: 8px;
}

.switch span {
  font-weight: 650;
  color: var(--gray-700);
}

.switch input {
  width: 42px;
  height: 24px;
  appearance: none;
  background: var(--gray-300);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.switch input::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--white);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.15s;
}

.switch input:checked {
  background: var(--blue-600);
}

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

/* Tabla */
.table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.cell-name {
  font-weight: 700;
  color: var(--gray-900);
}

.cell-muted {
  color: var(--gray-500);
  font-size: 0.88rem;
}

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

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.qty button {
  width: 28px;
  height: 28px;
  border: 0;
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 1.1rem;
  font-weight: 700;
}

.qty button:hover {
  background: var(--gray-100);
}

.qty span {
  min-width: 32px;
  text-align: center;
  font-weight: 700;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 10px;
  overflow-y: auto;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  animation: ledger-rise 0.32s var(--ease-out);
  margin: auto;
  border: 1px solid color-mix(in srgb, var(--gray-200) 70%, transparent);
}

.modal--sm {
  max-width: 400px;
}

.modal--lg {
  max-width: 860px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal--lg .modal-header,
.modal--lg .modal-footer {
  flex-shrink: 0;
}

.modal--lg .modal-body {
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 4px;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 750;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: 0;
  background: var(--gray-100);
  border-radius: 8px;
  font-size: 1.3rem;
  color: var(--gray-600);
  line-height: 1;
}

.modal-close:hover {
  background: var(--gray-200);
}

.modal-body {
  padding: 4px 12px 8px;
}

.modal-footer {
  padding: 8px 12px 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--gray-100);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Toasts */
.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  font-weight: 650;
  min-width: 220px;
  animation: ledger-toast-in 0.28s var(--ease-out);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast--success {
  background: var(--green-700);
}

.toast--warning {
  background: var(--amber-700);
}

.toast--error {
  background: var(--red-700);
}

.toast--out {
  animation: ledger-toast-out 0.25s var(--ease-out) forwards;
}

.toast__icon {
  font-weight: 800;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(12px) scale(0.98);
  }
}

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

@keyframes ledger-toast-out {
  to {
    opacity: 0;
    transform: translateX(12px) scale(0.98);
  }
}

.empty-state {
  text-align: center;
  padding: 20px 12px;
  color: var(--gray-500);
}

.empty-state__title {
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.empty-state__text {
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.toolbar .search {
  flex: 1;
  min-width: 200px;
}

.profit {
  color: var(--green-600);
  font-weight: 700;
}

/* Miniatura de producto */
.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--gray-100);
  flex-shrink: 0;
  display: block;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.thumb--sm {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.thumb--lg {
  width: 112px;
  height: 112px;
  border-radius: 12px;
}

.thumb--xl {
  width: 140px;
  height: 140px;
  border-radius: 14px;
}

.thumb--ph {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--blue-700);
  background: var(--blue-50);
  letter-spacing: 0.02em;
}

.thumb--lg.thumb--ph,
.thumb--xl.thumb--ph {
  font-size: 1.35rem;
}

.cell-product {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.image-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 10px;
  border: 1px solid var(--gray-200);
}

.image-picker__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.image-picker__actions .hint {
  margin: 0;
  font-size: 0.78rem;
}

.image-picker input[type="file"] {
  font-size: 0.8rem;
  max-width: 100%;
}

/* Recorte de imagen */
.crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.crop-overlay.is-hidden {
  display: none;
}

.crop-panel {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.crop-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
}

.crop-panel__head h2 {
  margin: 0;
  font-size: 1rem;
}

.crop-panel__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#crop-canvas {
  width: min(100%, 360px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: default;
  touch-action: none;
  background: #0f172a;
  max-width: 100%;
}

.crop-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--gray-500);
  text-align: center;
}

.crop-panel__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--gray-200);
}

body.crop-open {
  overflow: hidden;
}

.image-picker__preview {
  cursor: pointer;
  border-radius: 10px;
  outline: none;
}

.image-picker__preview .thumb--xl {
  object-fit: contain;
  background: var(--gray-50);
}

/* Welcome — brand-first splash before login */
.welcome-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 85% 55% at 20% 0%, color-mix(in srgb, var(--accent) 48%, transparent), transparent 58%),
    radial-gradient(ellipse 70% 50% at 95% 100%, color-mix(in srgb, var(--accent-hover) 30%, transparent), transparent 52%),
    linear-gradient(165deg, #060a12 0%, var(--sidebar-bg) 46%, #101826 100%);
}

.welcome-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 65% 55% at 50% 42%, black, transparent);
  pointer-events: none;
  animation: ledger-shimmer 9s ease-in-out infinite;
}

.welcome-screen__glow {
  position: absolute;
  width: min(640px, 95vw);
  height: min(640px, 95vw);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%);
  filter: blur(10px);
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  animation: welcome-glow 5.5s ease-in-out infinite;
}

.welcome-hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: min(420px, 92vw);
  padding: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.welcome-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(220px, 58vw);
  height: min(220px, 58vw);
  margin-bottom: 22px;
  animation: welcome-logo-in 0.85s var(--ease-out) both;
}

.welcome-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 220px;
  max-height: 220px;
  object-fit: contain;
  object-position: center;
  border-radius: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #fff;
  padding: 18px;
  box-sizing: border-box;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.welcome-logo.is-hidden {
  display: none;
}

.welcome-logo.welcome-logo--wide {
  border-radius: 28px;
  padding: 22px 28px;
}

.welcome-logo.welcome-logo--tall {
  border-radius: 32px;
  padding: 16px;
}

.welcome-mark-fallback {
  width: min(160px, 42vw);
  height: min(160px, 42vw);
  border-radius: 36px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.welcome-mark-fallback.is-hidden {
  display: none;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 6.5vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-align: center;
  color: #f4f7fb;
  margin: 0 0 18px;
  text-shadow: 0 10px 36px rgba(0, 0, 0, 0.35);
  animation: welcome-title-in 0.9s var(--ease-out) 0.18s both;
}

.welcome-hint {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(236, 242, 248, 0.55);
  animation: welcome-hint-pulse 2.4s ease-in-out 0.9s infinite;
}

.welcome-lang {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  z-index: 2;
}

.welcome-screen.is-leaving {
  animation: welcome-out 0.42s var(--ease-out) forwards;
  pointer-events: none;
}

@keyframes welcome-logo-in {
  from {
    opacity: 0;
    transform: scale(0.86) translateY(18px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes welcome-title-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes welcome-hint-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}

@keyframes welcome-glow {
  0%,
  100% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1.06);
  }
}

@keyframes welcome-out {
  to {
    opacity: 0;
    transform: scale(1.03);
  }
}

.login-back {
  margin-top: 10px;
  color: var(--ink-muted);
}

/* Login — brand-first atmosphere */
.login-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
  background:
    radial-gradient(ellipse 80% 50% at 15% 10%, color-mix(in srgb, var(--accent) 42%, transparent), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 85%, color-mix(in srgb, var(--accent-hover) 28%, transparent), transparent 50%),
    radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.06), transparent 40%),
    linear-gradient(165deg, #070b14 0%, var(--sidebar-bg) 48%, #121a2b 100%);
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
  pointer-events: none;
  animation: ledger-shimmer 8s ease-in-out infinite;
}

.login-screen__glow {
  position: absolute;
  width: min(520px, 90vw);
  height: min(520px, 90vw);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent), transparent 68%);
  filter: blur(8px);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -42%);
  pointer-events: none;
  z-index: 0;
}

body:not(.is-authed) .app,
body:not(.is-authed) .bottom-nav,
body:not(.is-authed) .fab {
  display: none !important;
}

body.is-welcome:not(.is-authed) .welcome-screen {
  display: flex !important;
}

body.is-login:not(.is-authed) .login-screen {
  display: flex !important;
}

body:not(.is-login):not(.is-authed) .login-screen {
  display: none !important;
}

body:not(.is-welcome):not(.is-authed) .welcome-screen {
  display: none !important;
}

body.is-authed .welcome-screen,
body.is-authed .login-screen {
  display: none !important;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: min(300px, 88vw);
  margin: 0 auto 16px;
  min-height: 72px;
}

.login-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 96px;
  object-fit: contain;
  object-position: center;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #fff;
  padding: 10px;
  box-sizing: content-box;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.login-logo.login-logo--wide {
  max-width: 280px;
  max-height: 76px;
  padding: 12px 16px;
}

.login-logo.login-logo--tall {
  max-width: 108px;
  max-height: 148px;
  padding: 12px;
}

.login-logo.is-hidden {
  display: none;
}

.login-mark-fallback {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.login-mark-fallback.is-hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: color-mix(in srgb, var(--white) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.55);
  animation: ledger-rise 0.55s var(--ease-out);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
}

.login-card .cell-muted {
  margin-bottom: 18px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.login-card .btn--primary {
  min-height: 46px;
  font-size: 0.95rem;
  margin-top: 4px;
  border-radius: 12px;
}

.login-error {
  color: var(--red-700);
  background: var(--red-50);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 650;
  margin-bottom: 8px;
}

/* —— Móvil: formularios, modales y herramientas táctiles —— */
@media (max-width: 768px) {
  .welcome-screen {
    padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .welcome-title {
    font-size: clamp(1.7rem, 7vw, 2.2rem);
  }

  .login-screen {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(16px + env(safe-area-inset-bottom, 0px));
    align-items: flex-start;
    padding-top: max(36px, calc(20px + env(safe-area-inset-top, 0px)));
  }

  .login-card {
    max-width: 100%;
    padding: 24px 18px 18px;
  }

  .login-card h1 {
    font-size: 1.35rem;
  }

  .login-logo {
    max-width: min(220px, 72vw);
    max-height: 88px;
  }

  .login-logo.login-logo--wide {
    max-width: min(280px, 88vw);
    max-height: 68px;
  }

  .login-logo.login-logo--tall {
    max-width: 92px;
    max-height: 128px;
  }

  .input,
  .select,
  .textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 8px 14px;
  }

  .btn--sm {
    min-height: 36px;
    padding: 6px 10px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .search {
    min-width: 0;
    width: 100%;
  }

  .toolbar > .btn {
    width: 100%;
  }

  .card__head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .cell-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .cell-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .modal--lg {
    max-width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 16px 16px 0 0;
  }

  .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }

  .modal-close {
    width: 36px;
    height: 36px;
  }
}

