:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --border: #2d3a4a;
  --text: #e8eef5;
  --muted: #8b9cb3;
  --accent: #3d9eef;
  --accent-dim: #2a6fad;
  --danger: #e85d5d;
  --ok: #4ecf8a;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

.site-top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.api-warning {
  padding: 0.65rem 1.25rem;
  background: #3a2828;
  border-bottom: 1px solid var(--danger);
  color: #fdd;
  font-size: 0.85rem;
}

.api-origin-hint {
  opacity: 0.85;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.header-actions .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@keyframes help-instructions-blink {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 transparent;
  }
  50% {
    opacity: 0.55;
    box-shadow:
      0 0 0 2px #e6c84a,
      0 0 16px rgba(230, 200, 74, 0.65);
  }
}

#help-instructions-btn.help-instructions--pulse {
  animation: help-instructions-blink 1s ease-in-out 15;
}

@media (prefers-reduced-motion: reduce) {
  #help-instructions-btn.help-instructions--pulse {
    animation: none;
    opacity: 1;
    box-shadow: 0 0 0 2px #e6c84a;
  }
}

.help-header {
  align-items: center;
}

.help-main {
  width: 98%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  display: grid;
  gap: 1rem;
}

.help-section h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.help-section p {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.help-list {
  margin: 0;
  padding-left: 1.35rem;
  color: var(--text);
  font-size: 0.95rem;
}

.help-list li {
  margin-bottom: 0.5rem;
}

.help-list li:last-child {
  margin-bottom: 0;
}

/* [hidden] debe ocultar del todo: .auth-screen tenía display:flex y anulaba el atributo */
.auth-screen[hidden],
.app-root[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
}

.auth-card h1 {
  margin-bottom: 0.35rem;
}

.auth-hint {
  margin-top: 0;
  margin-bottom: 1rem;
}

.auth-form {
  gap: 0.85rem;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 36rem;
}

.health {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.health.ok .dot {
  color: var(--ok);
}

.health.warn .dot {
  color: #e6c84a;
}

.layout {
  width: 98%;
  max-width: 100%;
  padding: 1.25rem 1.5rem 2.5rem;
  display: grid;
  gap: 1.25rem;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(260px, 0.38fr) minmax(0, 1.62fr);
  }

  .cancel-card {
    grid-column: 1 / -1;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.form {
  display: grid;
  gap: 0.75rem;
}

.form.compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  align-items: end;
}

.form.compact .full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

input,
select,
textarea {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 3rem;
}

.coords {
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.coords legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.btn {
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

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

.btn.danger {
  border-color: #a33;
  background: #3a2222;
  color: #fcc;
}

.btn.danger:hover {
  background: #522828;
}

.btn.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-with-icon .btn-ic {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
  opacity: 0.92;
}

.btn-with-icon:hover .btn-ic {
  opacity: 1;
}

.btn-with-icon--danger {
  border-color: #6a3535;
  color: #f0c4c4;
}

.btn-with-icon--danger:hover {
  border-color: #a34545;
  background: #3a2228;
}

.card-nested {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.import-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.import-row label {
  min-width: 10rem;
  flex: 1 1 140px;
}

.import-file input[type="file"] {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  max-width: 100%;
}

.import-result {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  overflow-x: auto;
  max-height: 220px;
}

.list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.list-header h2 {
  margin: 0;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.hint code {
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

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

/* CSS Grid: el borde va en cada .transfer-row → una sola línea recta en todo el ancho */
.transfer-sheet {
  width: 100%;
  font-size: 0.8rem;
}

.transfer-row {
  display: grid;
  grid-template-columns:
    2.75rem
    minmax(4rem, 0.45fr)
    3.25rem
    minmax(4rem, 0.5fr)
    minmax(6rem, 2fr)
    10.5rem
    minmax(11rem, 1.2fr)
    18rem;
  column-gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.transfer-row--head {
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.th-sort-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  border-radius: 4px;
  padding: 0.1rem 0.2rem;
  margin: -0.1rem -0.2rem;
  box-sizing: border-box;
}

.th-sort-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.th-sort-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.th-sort-btn--active {
  color: var(--text);
  font-weight: 600;
}

.th-sort-btn .th-sort-ind {
  display: inline-block;
  min-width: 1.35em;
  text-align: center;
  font-weight: 600;
  font-size: 1.12em;
  color: var(--accent);
  flex-shrink: 0;
  padding-inline: 0.1em;
}

.transfer-row:not(.transfer-row--head):hover {
  background: rgba(255, 255, 255, 0.03);
}

.transfer-cell {
  min-width: 0;
}

.transfer-cell--check {
  text-align: center;
}

.transfer-cell--pickup {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.transfer-cell--time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.transfer-cell--actions-head {
  text-align: right;
}

.col-send {
  min-width: 0;
}

.send-cell {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem 0.65rem;
}

.send-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-icon {
  font-size: 0.65rem;
  opacity: 0.95;
}

.badge-pending {
  color: var(--muted);
  background: rgba(139, 156, 179, 0.12);
  border-color: rgba(139, 156, 179, 0.35);
}

.badge-ok {
  color: #b8f0d0;
  background: rgba(78, 207, 138, 0.15);
  border-color: rgba(78, 207, 138, 0.45);
}

.badge-error {
  color: #ffc9c9;
  background: rgba(232, 93, 93, 0.18);
  border-color: rgba(232, 93, 93, 0.5);
}

.cell-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.cell-actions .btn {
  flex-shrink: 0;
}

.result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
  overflow-x: auto;
  max-height: 200px;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  max-width: min(90vw, 360px);
  z-index: 50;
}

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

.toast.ok {
  border-color: var(--ok);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.72);
  backdrop-filter: blur(3px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  max-width: min(90vw, 22rem);
  text-align: center;
}

.loading-spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.7s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-message {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.4;
}
