/* APROVIVA Operations Suite - mobile-first stylesheet */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #1e3a8a;
  --primary-soft: #dbeafe;
  --accent: #0ea5e9;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 12px 32px -16px rgba(15,23,42,0.18);
  --radius: 14px;
  /* Space reserved for fixed bottom nav on narrow viewports */
  --nav-bottom-h: 3.25rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: rgba(30, 58, 138, 0.12);
}

/* ── App shell ── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--primary);
  color: white;
  padding: calc(0.65rem + var(--safe-top)) calc(0.85rem + var(--safe-right)) 0.65rem calc(0.85rem + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
}

.app-header-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.app-header-subline {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.app-header .building {
  font-size: 0.78rem;
  opacity: 0.8;
  font-weight: 400;
  margin-left: 0.5rem;
}

.app-header-date {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
}

.role-badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
}
.role-badge.role-junta { background: var(--accent); border-color: var(--accent); }
.role-badge.role-conserje { background: rgba(255,255,255,0.2); }
.role-badge.role-supervisor { background: rgba(96, 165, 250, 0.35); border-color: rgba(147, 197, 253, 0.6); }
.role-badge.role-gerencia { background: rgba(34, 197, 94, 0.35); border-color: rgba(134, 239, 172, 0.55); }
/** @deprecated session.role staff (use conserje) */
.role-badge.role-staff { background: rgba(255,255,255,0.2); }

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 0.45rem 0.85rem;
  min-height: 44px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 500;
  touch-action: manipulation;
}
.btn-logout:hover { background: rgba(255,255,255,0.12); }

/* ── Nav (tablet/desktop: sticky under header) ── */
.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  padding: 0.4rem calc(0.5rem + var(--safe-left)) 0.4rem calc(0.5rem + var(--safe-right));
  gap: 0.2rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.nav-link {
  padding: 0.55rem 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
}
.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.nav-ico {
  font-size: 1rem;
  line-height: 1;
}

.nav-label {
  line-height: 1.1;
}

/* ── Narrow screens: bottom tab bar (thumb-friendly) ── */
@media (max-width: 767px) {
  :root { --nav-bottom-h: 4.15rem; }

  body { background: #0f1117; }

  .app-shell--authed {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: #0f1117;
    color: #e8e8ee;
  }

  .app-shell--authed .app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #1a1d27;
    border-bottom: 1px solid #2e3140;
    box-shadow: none;
    padding: calc(0.7rem + var(--safe-top)) calc(0.95rem + var(--safe-right)) 0.55rem calc(0.95rem + var(--safe-left));
  }

  .app-shell--authed .app-header h1 {
    font-size: 1rem;
    color: #e8e8ee;
  }

  .app-shell--authed .app-header .building {
    display: block;
    margin-left: 0;
    margin-top: 0.18rem;
    color: #9ca3af;
    font-size: 0.72rem;
  }

  .app-shell--authed .app-header-subline {
    margin-top: 0.15rem;
  }

  .app-shell--authed .app-header-date {
    color: #9ca3af;
    font-size: 0.72rem;
  }

  .app-shell--authed .role-badge {
    background: rgba(108, 92, 231, 0.2);
    border-color: rgba(108, 92, 231, 0.5);
    color: #c4b5fd;
    font-size: 0.7rem;
  }

  .app-shell--authed .btn-logout {
    min-height: 34px;
    padding: 0.4rem 0.75rem;
    border-radius: 9px;
    border-color: #2e3140;
    color: #9ca3af;
    font-size: 0.74rem;
  }
  .app-shell--authed .btn-logout:hover {
    background: #22252f;
    color: #e8e8ee;
  }

  .app-shell--authed .app-nav {
    position: fixed;
    left: max(0px, calc((100vw - 430px) / 2));
    right: max(0px, calc((100vw - 430px) / 2));
    bottom: 0;
    top: auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 0.1rem;
    padding: 0.35rem calc(0.35rem + var(--safe-right)) calc(0.35rem + var(--safe-bottom)) calc(0.35rem + var(--safe-left));
    border-bottom: 0;
    border-top: 1px solid #2e3140;
    box-shadow: none;
    background: #1a1d27;
    justify-content: flex-start;
    z-index: 60;
  }
  .app-shell--authed .app-nav::-webkit-scrollbar { display: none; }
  .app-shell--authed .app-nav { scrollbar-width: none; -ms-overflow-style: none; }

  .app-shell--authed .nav-link {
    flex: 0 0 74px;
    min-height: 56px;
    justify-content: center;
    flex-direction: column;
    gap: 0.15rem;
    border-radius: 10px;
    padding: 0.35rem 0.25rem;
    color: #6b7280;
    font-size: 0.64rem;
    text-align: center;
  }
  .app-shell--authed .nav-link:hover {
    background: #22252f;
    color: #e8e8ee;
  }
  .app-shell--authed .nav-link.active {
    background: transparent;
    color: #a29bfe;
  }
  .app-shell--authed .nav-link .nav-ico {
    font-size: 1.16rem;
  }
  .app-shell--authed .nav-link .nav-label {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell--authed .app-content {
    max-width: none;
    margin: 0;
    background: transparent;
    padding-top: 1rem;
    padding-bottom: calc(var(--nav-bottom-h) + var(--safe-bottom) + 0.85rem);
    padding-left: calc(0.95rem + var(--safe-left));
    padding-right: calc(0.95rem + var(--safe-right));
  }

  .app-shell--authed .page {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    padding: 0;
  }

  .app-shell--authed .page-title {
    color: #e8e8ee;
    font-size: 1.25rem;
  }

  .app-shell--authed .page-subtitle {
    color: #9ca3af;
  }

  .app-shell--authed .section-title {
    color: #9ca3af;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
  }

  .app-shell--authed .muted {
    color: #9ca3af;
  }

  .app-shell--authed .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .app-shell--authed .kpi-card {
    background: #22252f;
    border: 1px solid #2e3140;
    border-radius: 12px;
    padding: 0.75rem 0.7rem;
  }

  .app-shell--authed .kpi-card .kpi-label {
    color: #6b7280;
    font-size: 0.63rem;
  }

  .app-shell--authed .kpi-card .kpi-value {
    color: #e8e8ee;
    font-size: 1.2rem;
  }

  .app-shell--authed .kpi-card .kpi-sub {
    color: #9ca3af;
  }

  .app-shell--authed .module-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .app-shell--authed .module-card {
    background: #22252f;
    border: 1px solid #2e3140;
    border-radius: 12px;
    box-shadow: none;
    padding: 0.85rem 0.9rem;
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "icon eyebrow"
      "icon title"
      "icon desc";
    column-gap: 0.7rem;
    row-gap: 0.15rem;
  }

  .app-shell--authed .module-card:hover {
    transform: none;
    border-color: #6c5ce7;
    box-shadow: none;
  }

  .app-shell--authed .module-icon {
    grid-area: icon;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1a1d27;
    font-size: 1.2rem;
    line-height: 1;
    margin-top: 0.2rem;
  }

  .app-shell--authed .module-card .card-eyebrow {
    grid-area: eyebrow;
    color: #a29bfe;
  }

  .app-shell--authed .module-card h3 {
    grid-area: title;
    color: #e8e8ee;
    font-size: 0.95rem;
  }

  .app-shell--authed .module-card p {
    grid-area: desc;
    color: #9ca3af;
    font-size: 0.78rem;
  }

  .app-shell--authed .form-field label {
    color: #9ca3af;
  }

  .app-shell--authed .form-field input,
  .app-shell--authed .form-field select,
  .app-shell--authed .form-field textarea,
  .app-shell--authed .mapa-select {
    background: #22252f;
    border-color: #2e3140;
    color: #e8e8ee;
  }
  .app-shell--authed .form-field input:focus,
  .app-shell--authed .form-field select:focus,
  .app-shell--authed .form-field textarea:focus,
  .app-shell--authed .mapa-select:focus {
    border-color: #6c5ce7;
    outline-color: rgba(108, 92, 231, 0.32);
  }

  .app-shell--authed .btn-primary-sm,
  .app-shell--authed .btn-secondary,
  .app-shell--authed .btn-ghost,
  .app-shell--authed .btn-danger {
    border-color: #2e3140;
  }
  .app-shell--authed .btn-secondary,
  .app-shell--authed .btn-ghost {
    background: #22252f;
    color: #9ca3af;
  }
  .app-shell--authed .btn-secondary:hover,
  .app-shell--authed .btn-ghost:hover {
    background: #1a1d27;
    color: #e8e8ee;
  }
  .app-shell--authed .btn-primary-sm {
    background: #6c5ce7;
    color: #fff;
  }
  .app-shell--authed .btn-primary-sm:hover:not(:disabled) {
    background: #a29bfe;
  }

  .app-shell--authed .badge {
    background: #1a1d27;
    border-color: #2e3140;
    color: #9ca3af;
  }
  .app-shell--authed .badge-success { background: rgba(0, 184, 148, 0.15); color: #00b894; border-color: transparent; }
  .app-shell--authed .badge-warning { background: rgba(253, 203, 110, 0.15); color: #fdcb6e; border-color: transparent; }
  .app-shell--authed .badge-danger { background: rgba(225, 112, 85, 0.15); color: #e17055; border-color: transparent; }
  .app-shell--authed .badge-info { background: rgba(108, 92, 231, 0.15); color: #a29bfe; border-color: transparent; }

  .app-shell--authed .loading,
  .app-shell--authed .empty {
    background: #22252f;
    border: 1px solid #2e3140;
    color: #9ca3af;
  }

  .app-shell--authed .table-wrap {
    border: 0;
    overflow: visible;
  }

  .app-shell--authed .data-table thead {
    display: none;
  }

  .app-shell--authed .data-table,
  .app-shell--authed .data-table tbody,
  .app-shell--authed .data-table tr,
  .app-shell--authed .data-table td {
    display: block;
    width: 100%;
  }

  .app-shell--authed .data-table tr {
    background: #22252f;
    border: 1px solid #2e3140;
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.55rem;
  }

  .app-shell--authed .data-table td {
    border-bottom: 1px solid #2e3140;
    padding: 0.45rem 0;
    display: flex;
    justify-content: space-between;
    gap: 0.65rem;
    font-size: 0.8rem;
    color: #e8e8ee;
    text-align: right;
  }

  .app-shell--authed .data-table td:last-child {
    border-bottom: 0;
  }

  .app-shell--authed .data-table td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    text-align: left;
    color: #6b7280;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .app-shell--authed #suite-modal-host:not(:empty) {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.65);
  }

  .app-shell--authed #suite-modal-host:not(:empty) .page {
    width: min(430px, 100vw);
    max-width: none;
    margin: 0;
    border: 1px solid #2e3140;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: #1a1d27;
    padding: 1rem 0.95rem calc(1rem + var(--safe-bottom));
  }
}

/* ── Content ── */
.app-content {
  flex: 1;
  padding: 1rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.page-title {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.page-subtitle {
  margin: 0 0 1rem;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.page-section {
  margin-top: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

/* ── Login ── */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0c1d4f 100%);
  padding: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(1rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}

.login-card {
  background: white;
  border-radius: 18px;
  padding: 2.25rem 1.75rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.4);
  text-align: center;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  color: var(--text);
}

.login-card .login-sub {
  margin: 0 0 1.5rem;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.pin-input {
  /* ≥16px prevents iOS zoom-on-focus */
  font-size: max(1rem, 16px);
  letter-spacing: 0.35em;
  text-align: center;
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.85rem 0.5rem;
  width: 100%;
  font-family: 'Inter', monospace;
  background: var(--surface-soft);
}
.pin-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.btn-primary {
  background: var(--primary);
  color: white;
  border: 0;
  padding: 0.85rem 1.5rem;
  min-height: 48px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 1rem;
  touch-action: manipulation;
}
.btn-primary:hover { background: #1e40af; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--border); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.7rem;
  min-height: 1.1em;
}

.login-hints {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.login-back {
  display: block;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  text-decoration: none;
}
.login-back:hover { color: var(--primary); }

/* ── Forms ── */
.form-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.65rem 0.75rem;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: max(0.92rem, 16px);
  font-family: inherit;
  background: white;
  color: var(--text);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}
.form-field textarea {
  resize: vertical;
  min-height: 88px;
}

.form-field .hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* ── Cards / KPIs ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.kpi-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.95rem 1rem;
}
.kpi-card .kpi-label {
  font-size: 0.74rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.kpi-card .kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.3rem;
  color: var(--text);
}
.kpi-card .kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.data-table th, .data-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.data-table tbody tr:hover { background: var(--surface-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.mapa-registry-wrap {
  margin-top: 0.5rem;
}
.mapa-wp-registry {
  min-width: 880px;
}
.mapa-registry-lead {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
}
.mapa-wp-registry .mapa-registry-obs {
  max-width: 16rem;
  word-break: break-word;
  vertical-align: top;
}
.mapa-wp-registry .mapa-registry-actions {
  white-space: nowrap;
  vertical-align: middle;
}
.mapa-wp-num {
  font-weight: 600;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-neutral { background: var(--surface-soft); color: var(--text-soft); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.95rem;
  min-height: 44px;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary-sm { background: var(--primary); color: white; }
.btn-primary-sm:hover:not(:disabled) { background: #1e40af; }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-soft); }
.btn-danger { background: var(--danger); color: white; }

/* ── Loading / empty / error ── */
.loading {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-soft);
  border-radius: 10px;
  font-size: 0.88rem;
  margin: 0.85rem 0;
}
.error-box {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  font-size: 0.86rem;
}
.error-detail {
  font-size: 0.74rem;
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  font-family: monospace;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translate(-50%, 80%);
  background: var(--text);
  color: white;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 1000;
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* Logged-in mobile: clear fixed bottom nav */
@media (max-width: 767px) {
  .app-shell--authed .toast {
    bottom: calc(var(--nav-bottom-h) + var(--safe-bottom) + 0.65rem);
  }
}
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

/* ── Inicio (home) ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.95rem;
  margin-top: 1rem;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.module-card .card-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--primary);
  text-transform: uppercase;
}
.module-card h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}
.module-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-soft);
}

.module-icon {
  display: none;
}

/* Add to Home Screen hints (PWA) */
.install-section .install-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-top: 0.5rem;
}

/* Leaflet map (recorridos / #/mapa) */
.vv-map-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.vv-map {
  height: min(70vh, 560px);
  min-height: 260px;
  width: 100%;
  z-index: 0;
}
/* Deja espacio para ver el registro tabular sin scroll excesivo */
.mapa-page .vv-map {
  height: min(56vh, 500px);
}
.mapa-registry-jump {
  margin: 0.45rem 0 0;
  padding: 0 0.35rem 0.25rem;
  text-align: center;
  font-size: 0.88rem;
}
.mapa-registry-jump a {
  font-weight: 600;
}
.mapa-registry-section {
  scroll-margin-top: 5.5rem;
}
.mapa-registry-empty-cell {
  vertical-align: top;
  padding: 1rem 0.85rem !important;
}
.leaflet-container { font-family: inherit; }
.mapa-toolbar .muted { align-self: center; }
.mapa-wp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mapa-wp-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.45rem;
  background: var(--surface);
}
.mapa-wp-labelwrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex: 1;
  min-width: 140px;
}
.mapa-wp-label { font-weight: 600; }
.mapa-wp-coord { font-size: 0.78rem; }
/* Numbered route markers (Leaflet divIcon) */
.mapa-wp-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
}
.mapa-wp-marker__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.9);
}
/* Waypoint detail modal (suite-modal-host) */
.mapa-wp-modal .mapa-wp-comments {
  max-height: 220px;
  overflow-y: auto;
  margin: 0.5rem 0 1rem;
}
.mapa-wp-comment {
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.45rem;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}
.mapa-wp-textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-family: inherit;
  font-size: max(0.92rem, 16px);
  resize: vertical;
  min-height: 4rem;
}
.mapa-wp-file {
  font-size: max(0.88rem, 14px);
  max-width: 100%;
}
.mapa-wp-photo {
  margin-top: 0.45rem;
}
.mapa-wp-photo a {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
}
.mapa-wp-photo__img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.map-embed-kind { font-size: 0.8rem; color: var(--text-soft); }
.mapa-select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: max(0.92rem, 16px);
}
.mapa-popup-form .mt-1 { margin-top: 0.65rem; }

/* ── Helpers ── */
.row { display: flex; align-items: center; gap: 0.5rem; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: 0.82rem; }
.right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.alert-row.critical {
  background: var(--danger-soft);
  border-left-color: var(--danger);
}

/* Global modal host (Gemba forms + map hallazgo); filled by JS */
#suite-modal-host:not(:empty) {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(15, 23, 42, 0.48);
  overflow: auto;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--nav-bottom-h, 0px));
  -webkit-overflow-scrolling: touch;
}
#suite-modal-host:not(:empty) .page {
  max-width: 720px;
  margin: 0.5rem auto 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.mapa-layer-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}
.mapa-layer-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

/* ── Inventario (APICS-style helpers) ── */
.inv-apics-help {
  margin-top: 0.65rem;
  max-width: 44rem;
  font-size: 0.86rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  background: var(--surface-soft);
}
.inv-apics-help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-soft);
}
.inv-apics-body {
  padding: 0.5rem 0 0.15rem;
  line-height: 1.45;
}
.inv-delta-neg { color: var(--danger); font-weight: 600; }
.inv-delta-zero { color: var(--warning); font-weight: 600; }
.inv-delta-ok { color: var(--success); }

/* ── Print-friendly reports ── */
@media print {
  .app-header, .app-nav, .btn, button { display: none !important; }
  .page { box-shadow: none; border: 0; padding: 0; }
}
