:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #059669;
  --primary-light: #d1fae5;
  --primary-dark: #047857;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0284c7;
  --info-light: #e0f2fe;
  --whatsapp: #16a34a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  padding-bottom: calc(88px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.page {
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.7);
}

.hero-card {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border: none;
}

.hero-label {
  font-size: 13px;
  opacity: 0.9;
  font-weight: 500;
}

.hero-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 4px 0 12px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.hero-stat-val {
  font-size: 16px;
  font-weight: 700;
}

.hero-stat-lbl {
  font-size: 11px;
  opacity: 0.85;
}

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.quick-btn:active {
  transform: scale(0.97);
}

.quick-btn .q-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.quick-btn.q-ia .q-icon {
  background: var(--info-light);
  color: var(--info);
}

.quick-btn.q-pay .q-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-success { background: var(--primary-light); color: var(--primary-dark); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: #e2e8f0; color: #475569; }

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

.ficha-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.ficha-client {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.ficha-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ficha-balance {
  text-align: right;
  flex-shrink: 0;
}

.ficha-balance-amt {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.ficha-balance-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.ficha-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

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

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

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

.btn-whatsapp {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #fecaca;
}

.btn-icon {
  min-height: 36px;
  width: 36px;
  padding: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--text);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

.textarea {
  min-height: 76px;
  resize: vertical;
}

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

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

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  max-height: 210px;
  overflow-y: auto;
  margin-top: 4px;
}

.autocomplete-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: #f8fafc;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 50;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary);
}

.nav-fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  display: grid;
  place-items: center;
  margin: -18px auto 0;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
  cursor: pointer;
}

/* Modal / Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(22px + var(--safe-bottom));
  animation: slideUp 0.18s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

/* Toast */
#toast-root {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: calc(100% - 32px);
  max-width: 480px;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  margin-bottom: 8px;
}

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

.toast.toast-success {
  background: var(--primary-dark);
}

.loading-screen {
  min-height: 60dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 26px 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.photo-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 8px;
}
