/* ============================================================================
   PVC COLLECTION — MOBILE / ANDROID FIELD OFFICER DESIGN SYSTEM
   Shared Tokens with Web Dashboard: Vercel · Linear · Stripe · shadcn/ui
   Principle: Simple, clara, rápida, cómoda con una sola mano, sin exceso de tarjetas.
   ============================================================================ */

:root {
  --bg-primary: #FFFFFF;
  --bg-secondary: #FAFAFA;
  --bg-subtle: #F4F4F5;

  --text-primary: #171717;
  --text-secondary: #737373;
  --text-muted: #A3A3A3;

  --border-color: #E5E5E5;
  --border-strong: #D4D4D4;

  --action-blue: #2563EB;
  --action-blue-hover: #1D4ED8;
  --action-dark: #171717;

  --status-success: #16A34A;
  --status-success-bg: #F0FDF4;
  --status-success-border: #DCFCE7;

  --status-warning: #D97706;
  --status-warning-bg: #FFFBEB;
  --status-warning-border: #FEF3C7;

  --status-error: #DC2626;
  --status-error-bg: #FEF2F2;
  --status-error-border: #FEE2E2;

  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;

  --radius-sm: 6px;
  --radius-md: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  width: 100%;
  height: 100dvh;
}

.hidden {
  display: none !important;
}

.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

svg.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
  flex-shrink: 0;
}

/* Device Frame: Fixed width & height across all 5 tabs — zero layout shift on scroll */
.m-device-frame {
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ============================================================================
   1. AUTH SCREEN
   ============================================================================ */
.m-auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--bg-primary);
}

.m-auth-inner {
  width: 100%;
}

.m-brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.m-auth-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.m-auth-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 24px;
}

.m-auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================================
   2. SHELL: TOPBAR + CONTENT + 5-TAB BOTTOM NAV
   ============================================================================ */
.m-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.m-topbar {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 30;
}

.m-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background-color: var(--text-primary);
}

.m-topbar-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.m-net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.m-net-pill .m-net-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--status-success);
}

.m-net-pill.offline {
  background-color: var(--status-warning-bg);
  border-color: var(--status-warning-border);
  color: var(--status-warning);
}

.m-net-pill.offline .m-net-dot {
  background-color: var(--status-warning);
}

.m-sync-strip {
  padding: 8px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.m-link-btn {
  background: transparent;
  border: none;
  color: var(--action-blue);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.m-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 24px;
}

.m-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.m-view {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================================
   3. TYPOGRAPHY & METRIC BLOCKS
   ============================================================================ */
.m-meta-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.m-page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 2px;
}

.m-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.m-metric-band {
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.m-metric-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.m-metric-hero {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.m-progress-track {
  width: 100%;
  height: 4px;
  background-color: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.m-progress-bar {
  height: 100%;
  background-color: var(--action-blue);
  transition: width 0.25s ease;
}

.m-metric-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.m-metric-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.m-metric-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-metric-cell:first-child {
  border-right: 1px solid var(--border-color);
  padding-right: 12px;
}

.m-metric-cell:last-child {
  padding-left: 12px;
}

.m-metric-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================================
   4. SECTIONS & 1PX DIVIDED LISTS (No Heavy Cards)
   ============================================================================ */
.m-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.m-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.m-mono-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: 4px;
}

.m-next-visit {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background-color: var(--bg-secondary);
  cursor: pointer;
}

/* Divided List (Ruta, Clientes, Recaudos) */
.m-divided-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-color);
}

.m-list-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.m-list-row:active {
  background-color: var(--bg-secondary);
}

.m-row-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.m-visit-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 22px;
  padding-top: 2px;
}

.m-visit-num.overdue {
  color: var(--status-error);
}

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

.m-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.m-row-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.m-row-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.m-row-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Status Badges */
.m-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  white-space: nowrap;
  flex-shrink: 0;
}

.leaflet-tile-pane {
  filter: grayscale(88%) contrast(103%) brightness(103%);
}

.m-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: currentColor;
}

.m-badge-success {
  color: var(--status-success);
  background-color: var(--status-success-bg);
  border-color: var(--status-success-border);
}

.m-badge-warning {
  color: var(--status-warning);
  background-color: var(--status-warning-bg);
  border-color: var(--status-warning-border);
}

.m-badge-error {
  color: var(--status-error);
  background-color: var(--status-error-bg);
  border-color: var(--status-error-border);
}

/* ============================================================================
   5. CLIENT DETAIL & FAST PAYMENT SCREEN
   ============================================================================ */
.m-back-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.m-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.m-detail-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.m-contact-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.m-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 0;
}

.m-detail-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 8px;
}

.m-detail-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.m-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Fast Payment Screen */
.m-pay-balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  margin-bottom: 16px;
}

.m-pay-bal-item {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-pay-bal-item:first-child {
  border-right: 1px solid var(--border-color);
}

.m-pay-bal-val {
  font-size: 17px;
  font-weight: 600;
}

.m-quick-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.m-preset-btn {
  height: 36px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.m-preset-btn.active {
  border-color: var(--action-blue);
  color: var(--action-blue);
  background-color: #EFF6FF;
}

/* Form Controls */
.m-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.m-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.m-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  font-size: 14px;
  color: var(--text-primary);
}

.m-input:focus {
  border-color: var(--text-primary);
  outline: none;
}

.m-input-hero {
  height: 52px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.m-search-box {
  position: relative;
}

.m-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px !important;
  height: 15px !important;
  color: var(--text-secondary);
}

.m-input-search {
  padding-left: 36px;
  background-color: var(--bg-secondary);
}

.m-breakdown {
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.m-breakdown-row {
  display: flex;
  justify-content: space-between;
}

/* Buttons */
.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.m-btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
}

.m-btn-lg {
  height: 46px;
  font-size: 14.5px;
  font-weight: 600;
}

.m-btn-full {
  width: 100%;
}

.m-btn-primary {
  background-color: var(--action-dark);
  color: #FFFFFF;
}

.m-btn-blue {
  background-color: var(--action-blue);
  color: #FFFFFF;
}

.m-btn-secondary {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* Header & Map Segmented */
.m-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.m-segmented {
  display: inline-flex;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.m-seg-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
}

.m-seg-btn.active {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.m-map-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 300px;
}

.m-leaflet-canvas {
  width: 100%;
  height: 100%;
}

/* Profile KV */
.m-kv-group {
  border-top: 1px solid var(--border-color);
}

.m-kv-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
}

/* ============================================================================
   6. BOTTOM NAVIGATION BAR (5 Tabs: Inicio, Ruta, Clientes, Recaudos, Perfil)
   ============================================================================ */
.m-bottom-nav {
  width: 100%;
  height: 60px;
  flex-shrink: 0;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 40;
}

.m-nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.m-nav-item svg.lucide {
  width: 18px;
  height: 18px;
}

.m-nav-item.active {
  color: var(--action-blue);
}

/* Helpers & Toasts */
.text-action { color: var(--action-blue); }
.text-success { color: var(--status-success); }
.text-danger { color: var(--status-error); }

.m-toast-region {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90%;
  max-width: 400px;
}

.m-toast {
  background-color: var(--text-primary);
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
