/* ==========================================================================
   FLUVIO RUTA v1.0 — Design System (Apple / Uber Driver / Linear Craft)
   Mobile-First + Safe Areas + Bottom Sheets + Desktop Owner Sidebar + Dark Mode
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --brand: #0b4f9e;
  --brand-vivid: #1d64d8;
  --brand-soft: #eff6ff;
  --brand-ink: #0b4f9e;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: #ecfdf5;
  --emerald-ink: #047857;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-ink: #b45309;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-ink: #b91c1c;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 24px 48px rgba(2, 6, 23, 0.2);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --sidebar-w: 256px;
  --topbar-h: 62px;
  --font-head: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

body.theme-dark {
  --bg: #080e1a;
  --surface: #0f172a;
  --surface-2: #162238;
  --surface-hover: #1a2740;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --brand: #2563eb;
  --brand-vivid: #38bdf8;
  --brand-soft: rgba(37, 99, 235, 0.18);
  --brand-ink: #93c5fd;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: rgba(16, 185, 129, 0.16);
  --emerald-ink: #6ee7b7;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --amber-ink: #fcd34d;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --danger-ink: #fca5a5;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(780px 340px at 12% -6%, rgba(14, 165, 233, 0.11), transparent 64%),
    radial-gradient(640px 300px at 92% 4%, rgba(16, 185, 129, 0.09), transparent 62%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.theme-dark {
  background-image:
    radial-gradient(780px 380px at 14% -4%, rgba(37, 99, 235, 0.2), transparent 64%),
    radial-gradient(640px 320px at 90% 6%, rgba(16, 185, 129, 0.13), transparent 62%);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

.num {
  font-variant-numeric: tabular-nums;
}

.is-hidden {
  display: none !important;
}

/* ==========================================================================
   ONBOARDING / PLANT SELECTOR SCREEN
   ========================================================================== */
.onboarding-screen {
  min-height: 100svh;
  min-height: 100dvh;
  background:
    radial-gradient(760px 460px at 80% 10%, rgba(29, 100, 216, 0.22), transparent 60%),
    radial-gradient(520px 380px at 15% 85%, rgba(16, 185, 129, 0.12), transparent 65%),
    #080e1a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}

.onboarding-card {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: center;
}

.onb-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.onb-brand-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.onb-brand-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.onb-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin-bottom: 14px;
}

.onb-sub {
  color: #cbd5e1;
  font-size: 0.98rem;
  max-width: 46ch;
  margin-bottom: 24px;
}

.onb-panel {
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.onb-panel h2 {
  font-family: var(--font-head);
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.onb-panel p {
  font-size: 0.86rem;
  color: #94a3b8;
  margin-bottom: 16px;
}

.onb-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: 0.76rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.onb-divider::before,
.onb-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.18);
}

.onb-saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.onb-saved-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #ffffff;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}

.onb-saved-item:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.45);
}

.onb-saved-item small {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
}

/* ==========================================================================
   APP SHELL (MOBILE TOPBAR + BOTTOM DOCK / DESKTOP SIDEBAR)
   ========================================================================== */
.app-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* Desktop Sidebar (Hidden on mobile) */
.desktop-sidebar {
  display: none;
}

/* Mobile Topbar */
.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(248, 250, 252, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.theme-dark .mobile-topbar {
  background: rgba(8, 14, 26, 0.88);
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-brand-text {
  min-width: 0;
}

.top-brand-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--emerald-soft);
  color: var(--emerald-ink);
  white-space: nowrap;
}

.sync-pill.is-offline {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

/* Main Content Workspace */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px calc(108px + env(safe-area-inset-bottom));
}

.view-panel {
  display: none;
  animation: fadeSlide 180ms ease;
}

.view-panel.is-active {
  display: block;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.view-head h1 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.32rem, 2.5vw, 1.72rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.view-head p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Mobile Floating Bottom Navigation */
.mobile-dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 70;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
}

body.theme-dark .mobile-dock {
  background: rgba(15, 23, 42, 0.94);
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  transition: background 150ms ease, color 150ms ease;
}

.dock-btn.is-active {
  background: linear-gradient(135deg, #1d64d8 0%, #0b4f9e 100%);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(11, 79, 158, 0.28);
}

/* Daily Live Pulse Strip on POS */
.pulse-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.pulse-tile {
  border-radius: var(--radius-md);
  padding: 11px 12px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pulse-tile small {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.pulse-tile strong {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  letter-spacing: -0.025em;
}

.pulse-blue {
  background: linear-gradient(135deg, rgba(29, 100, 216, 0.11), rgba(56, 189, 248, 0.08));
  border-color: rgba(29, 100, 216, 0.2);
  color: var(--brand-ink);
}

.pulse-emerald {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), rgba(52, 211, 153, 0.07));
  border-color: rgba(16, 185, 129, 0.22);
  color: var(--emerald-ink);
}

.pulse-sky {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.13), rgba(99, 102, 241, 0.07));
  border-color: rgba(14, 165, 233, 0.22);
  color: #0369a1;
}

body.theme-dark .pulse-sky {
  color: #7dd3fc;
}

/* Product Visual Artwork Squircle */
.prod-left {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.prod-art {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.prod-art.art-blue {
  background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
  color: #1d64d8;
}
.prod-art.art-teal {
  background: linear-gradient(135deg, #ccfbf1 0%, #d1fae5 100%);
  color: #0d9488;
}
.prod-art.art-sky {
  background: linear-gradient(135deg, #e0f2fe 0%, #cffafe 100%);
  color: #0284c7;
}
.prod-art.art-indigo {
  background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
  color: #4f46e5;
}

body.theme-dark .prod-art.art-blue { background: rgba(37, 99, 235, 0.22); color: #60a5fa; border-color: rgba(96, 165, 250, 0.25); }
body.theme-dark .prod-art.art-teal { background: rgba(13, 148, 136, 0.22); color: #2dd4bf; border-color: rgba(45, 212, 191, 0.25); }
body.theme-dark .prod-art.art-sky { background: rgba(2, 132, 199, 0.22); color: #38bdf8; border-color: rgba(56, 189, 248, 0.25); }
body.theme-dark .prod-art.art-indigo { background: rgba(79, 70, 229, 0.24); color: #a5b4fc; border-color: rgba(165, 180, 252, 0.25); }

/* Vibrant Client Avatar Palette (specificity 0,2,0 over .cs-avatar) */
.cs-avatar.av-0 { background: linear-gradient(135deg, #1d64d8, #0ea5e9); color: #ffffff; }
.cs-avatar.av-1 { background: linear-gradient(135deg, #10b981, #0d9488); color: #ffffff; }
.cs-avatar.av-2 { background: linear-gradient(135deg, #6366f1, #3b82f6); color: #ffffff; }
.cs-avatar.av-3 { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #ffffff; }
.cs-avatar.av-4 { background: linear-gradient(135deg, #ec4899, #8b5cf6); color: #ffffff; }
.cs-avatar.av-5 { background: linear-gradient(135deg, #0284c7, #06b6d4); color: #ffffff; }

/* ==========================================================================
   COMMON UI PRIMITIVES (CARDS, BUTTONS, INPUTS, CHIPS, BADGES)
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}

.card-subtle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: transform 140ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, #1d64d8 0%, #0b4f9e 100%);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(11, 79, 158, 0.28);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.3);
}

.btn-emerald:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.btn-amber {
  background: var(--amber);
  color: #ffffff;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-blue { background: var(--brand-soft); color: var(--brand-ink); }
.badge-green { background: var(--emerald-soft); color: var(--emerald-ink); }
.badge-amber { background: var(--amber-soft); color: var(--amber-ink); }
.badge-red { background: var(--danger-soft); color: var(--danger-ink); }
.badge-neutral { background: var(--surface-2); color: var(--muted); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 13px;
}

.field label {
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--ink-2);
}

.onboarding-screen .field label {
  color: #cbd5e1;
}

.input, .select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.onboarding-screen .input,
.onboarding-screen .select {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.25);
  color: #ffffff;
}

.input:focus, .select:focus {
  border-color: var(--brand-vivid);
  box-shadow: 0 0 0 3px rgba(29, 100, 216, 0.16);
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 140ms ease;
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* ==========================================================================
   MODULE 1: POS (VENTA RÁPIDA DE 1 MANO)
   ========================================================================== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.pos-layout > * {
  min-width: 0;
}

.client-selector-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  box-shadow: var(--shadow-xs);
  margin-bottom: 14px;
  transition: border-color 150ms ease;
}

.client-selector-card:hover {
  border-color: var(--brand-vivid);
}

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

.cs-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.cs-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
  font-size: 0.76rem;
  color: var(--muted);
}

.product-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.product-card.has-qty {
  border-color: #1d64d8;
  background: linear-gradient(135deg, var(--surface) 75%, rgba(29, 100, 216, 0.06) 100%);
  box-shadow: 0 6px 20px rgba(29, 100, 216, 0.13);
}

.prod-info {
  min-width: 0;
}

.prod-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.96rem;
  margin-bottom: 2px;
}

.prod-desc {
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.prod-price-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prod-price {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--brand-ink);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 4px;
  flex-shrink: 0;
}

.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: background 120ms ease, color 120ms ease;
}

.step-btn.is-plus {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.step-val {
  min-width: 28px;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
}

/* Checkout Summary Panel */
.checkout-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.returnables-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.returnables-box.has-diff {
  background: var(--amber-soft);
  border-color: rgba(217, 119, 6, 0.35);
}

.pay-segment {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: var(--surface-2);
  padding: 5px;
  border-radius: 14px;
}

@media (min-width: 420px) {
  .pay-segment {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.pay-opt {
  min-height: 40px;
  padding: 4px 6px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  transition: all 140ms ease;
}

.pay-opt.is-active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(11, 79, 158, 0.26);
}

.pay-opt.is-active[data-pay="efectivo"] {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.pay-opt.is-active[data-pay="transferencia"] {
  background: linear-gradient(135deg, #1d64d8, #0b4f9e);
  box-shadow: 0 4px 12px rgba(29, 100, 216, 0.3);
}

.pay-opt.is-active[data-pay="fiado"] {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.pay-opt.is-active[data-pay="anticipo"] {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.pay-helper-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.bill-btn {
  flex: 1 1 auto;
  min-width: 54px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  transition: border-color 140ms ease, background 140ms ease;
}

.bill-btn:hover {
  border-color: var(--brand-vivid);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.change-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--emerald-soft);
  color: var(--emerald-ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.change-readout.is-short {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

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

@media (min-width: 600px) {
  .search-filter-row {
    grid-template-columns: 1.4fr 0.6fr;
  }
}

.receipt-card {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}

.total-amount {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.85rem;
  letter-spacing: -0.04em;
}

/* ==========================================================================
   MODULE 2: RUTA Y MAPA OSRM
   ========================================================================== */
.route-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.route-layout > * {
  min-width: 0;
}

.map-shell {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  height: 310px;
  box-shadow: var(--shadow-sm);
}

#routeMap {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-overlay-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 400;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.map-overlay-top > * {
  pointer-events: auto;
}

.map-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.86);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.route-progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0 14px;
}

.route-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-vivid), var(--emerald));
  border-radius: 999px;
  transition: width 260ms ease;
}

.stop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: opacity 160ms ease, border-color 160ms ease;
}

.stop-card.is-done {
  opacity: 0.68;
  border-color: rgba(16, 185, 129, 0.35);
}

.stop-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.stop-num {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.86rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stop-card.is-done .stop-num {
  background: var(--emerald);
  color: #ffffff;
}

.stop-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-sub {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==========================================================================
   MODULE 3 & 4: CLIENTES & CAMIÓN (KPIS + LISTS)
   ========================================================================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.kpi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid #1d64d8;
  border-radius: var(--radius-md);
  padding: 14px 12px;
  box-shadow: var(--shadow-xs);
}

.kpi-strip .kpi-box:nth-child(2) {
  border-top-color: #10b981;
}

.kpi-strip .kpi-box:nth-child(3) {
  border-top-color: #0ea5e9;
}

#view-clientes .kpi-strip .kpi-box:nth-child(2) {
  border-top-color: #f59e0b;
}

#view-clientes .kpi-strip .kpi-box:nth-child(3) {
  border-top-color: #ef4444;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-val {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  letter-spacing: -0.03em;
  margin-top: 4px;
}

.entity-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.entity-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   MODULE 5: CIERRE DE CAJA & CORTE DE TURNOS OLVIDADOS
   ========================================================================== */
.forgotten-banner {
  background: var(--amber-soft);
  border: 1px solid rgba(217, 119, 6, 0.42);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.forgotten-banner strong {
  color: var(--amber-ink);
  font-family: var(--font-head);
  font-size: 0.96rem;
}

.forgotten-banner p {
  font-size: 0.83rem;
  color: var(--ink-2);
  margin-top: 2px;
}

.cash-hero-card {
  background: linear-gradient(145deg, #0b4f9e 0%, #080e1a 100%);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.cash-hero-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #93c5fd;
  font-weight: 700;
}

.cash-hero-val {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  letter-spacing: -0.04em;
  margin: 6px 0 14px;
}

.cash-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cash-mini-tile {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  padding: 10px 12px;
}

.cash-mini-tile small {
  display: block;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.cash-mini-tile strong {
  font-family: var(--font-head);
  font-size: 1.05rem;
}

.cierre-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.cierre-grid > * {
  min-width: 0;
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.tx-row:last-child {
  border-bottom: none;
}

.tx-row.is-void {
  opacity: 0.48;
  text-decoration: line-through;
}

/* ==========================================================================
   NATIVE-FEEL BOTTOM SHEETS (MOBILE) -> CLEAN CENTERED MODAL (DESKTOP)
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.56);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.is-open {
  display: flex;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 88svh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheetUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetUp {
  from { transform: translateY(32px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-head h3 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.12rem;
}

/* Toast Notification */
.toast-stack {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 380px);
}

.toast {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeSlide 180ms ease;
}

.toast.is-success { border-left: 4px solid var(--emerald); }
.toast.is-warning { border-left: 4px solid var(--amber); }
.toast.is-error { border-left: 4px solid var(--danger); }

/* ==========================================================================
   DESKTOP ENHANCEMENTS (>= 768px & >= 1024px)
   ========================================================================== */
@media (min-width: 768px) {
  .onboarding-card {
    grid-template-columns: 1.05fr 0.95fr;
    gap: 40px;
  }
  .entity-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cash-mini-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .sheet-backdrop {
    align-items: center;
    padding: 20px;
  }
  .sheet {
    border-radius: 22px;
    padding: 22px 24px 24px;
  }
  .sheet-handle {
    display: none;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    flex-direction: row;
  }
  .mobile-topbar,
  .mobile-dock {
    display: none;
  }
  .desktop-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 60;
  }
  .sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 10px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
  }
  .sb-brand-name {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: -0.03em;
  }
  .sb-brand-sub {
    font-size: 0.72rem;
    color: var(--muted);
  }
  .sb-plant-pill {
    width: 100%;
    padding: 10px 12px;
    border-radius: 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    text-align: left;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .sb-plant-pill strong {
    display: block;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sb-plant-pill small {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
  }
  .sb-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sb-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--muted);
    text-align: left;
    transition: background 140ms ease, color 140ms ease;
  }
  .sb-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
  }
  .sb-btn.is-active {
    background: linear-gradient(135deg, #1d64d8 0%, #0b4f9e 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(11, 79, 158, 0.28);
  }
  .sb-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .sb-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .app-main {
    margin-left: var(--sidebar-w);
    padding: 28px 32px 48px;
    max-width: calc(100% - var(--sidebar-w));
  }
  .pos-layout {
    grid-template-columns: 1.25fr 0.75fr;
    align-items: start;
  }
  .checkout-panel {
    position: sticky;
    top: 24px;
  }
  .route-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
  .map-shell {
    height: 540px;
    position: sticky;
    top: 24px;
  }
  .cierre-grid {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }
}

.map-night-filter .leaflet-tile-pane {
  filter: invert(93%) hue-rotate(185deg) saturate(88%) brightness(92%) contrast(94%);
}

/* Isolate Leaflet internal z-index (400-1000) so it never bleeds over sheets/toasts */
.map-shell { position: relative; z-index: 1; isolation: isolate; }
.sheet-backdrop { z-index: 2000; }
.toast-stack { z-index: 2200; }

/* Responsive stop-card stacking on mobile so client names never squeeze */
@media (max-width: 640px) {
  .stop-card { flex-direction: column; align-items: stretch; gap: 10px; }
  .stop-left { width: 100%; }
  .stop-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
}
