:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --ok: #059669;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* El atributo hidden debe ganar a display:flex/grid de las vistas */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  min-height: 100dvh;
}

.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- LOGIN ---------- */
#view-login {
  position: relative;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, #1e293b 0%, #0f172a 60%);
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-logo {
  width: 140px;
  max-width: 55%;
  height: auto;
  margin-bottom: 24px;
}

.login-card {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}

.brand {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

form {
  display: flex;
  flex-direction: column;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
}

select,
input {
  font-size: 16px; /* evita zoom en iOS */
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink);
  appearance: none;
  width: 100%;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  font-family: inherit;
  cursor: pointer;
}

#login-btn {
  margin-top: 22px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

#login-btn:active {
  background: var(--brand-ink);
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 14px 0 0;
  text-align: center;
}

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  background: var(--bg);
  color: #fff;
}

.topbar-logo {
  height: 30px;
  width: auto;
  flex-shrink: 0;
}

.topbar-label {
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-local {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 700;
}

.detail-head {
  display: flex;
  flex-direction: column;
}

.logout {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
}

.back {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
}

/* ---------- CONTENT ---------- */
.content {
  flex: 1;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.section-title {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin: 6px 2px 12px;
}

/* ---------- LISTA DE RECUENTOS ---------- */
.inv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.inv-item:active {
  transform: scale(0.99);
}

.inv-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  flex-shrink: 0;
  background: #eff6ff;
  color: var(--brand-ink);
  border-radius: 10px;
  padding: 8px 0;
}

.inv-date .day {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.inv-date .mon {
  font-size: 11px;
  text-transform: uppercase;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.inv-main {
  flex: 1;
  min-width: 0;
}

.inv-main .ref {
  font-weight: 700;
  font-size: 15px;
}

.inv-main .meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.chev {
  color: #cbd5e1;
  font-size: 22px;
  flex-shrink: 0;
}

/* ---------- DETALLE ---------- */
.detail-meta {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.detail-meta div {
  font-size: 14px;
}

.detail-meta span {
  color: var(--muted);
}

.lines {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.line:last-child {
  border-bottom: none;
}

.line .name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
}

.line .fam {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.line .qty {
  font-weight: 800;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--muted);
  margin-top: 40px;
}

/* ---------- PIE: CREDITO AVANT ---------- */
.credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px max(20px, env(safe-area-inset-bottom));
  text-align: center;
}

.credit-logo {
  height: 30px;
  width: auto;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
}

.credit-text {
  font-size: 12px;
  color: var(--muted);
}

/* En el login (fondo oscuro) el pie va anclado abajo y con texto claro */
.credit--dark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

.credit--dark .credit-text {
  color: #94a3b8;
}

/* ---------- SPINNER ---------- */
.spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(241, 245, 249, 0.6);
  z-index: 50;
}

.dot {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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