* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #42a5f5;
  --accent: #00c853;
  --danger: #e53935;
  --warn: #ff9800;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #212121;
  --text-secondary: #757575;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ====== LOGIN ====== */
.login-container {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}
.login-logo {
  width: 90px; height: 90px;
  background: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.login-logo .material-icons { font-size: 48px; color: var(--primary); }
.login-title { color: white; font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: rgba(255,255,255,0.8); font-size: 0.9rem; margin-bottom: 32px; }
.login-card {
  background: white; border-radius: 16px; padding: 32px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-card h2 { font-size: 1.2rem; margin-bottom: 24px; text-align: center; color: var(--primary-dark); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border);
  border-radius: 10px; font-size: 1rem; transition: border-color 0.2s;
  background: #fafafa; appearance: none; -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); background: white; }
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }

/* ====== BUTTONS ====== */
.btn {
  width: 100%; padding: 14px; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; display: flex; align-items: center;
  justify-content: center; gap: 8px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:active { background: #00a844; transform: scale(0.98); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:active { background: #c62828; transform: scale(0.98); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:active { background: var(--primary); color: white; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; width: auto; border-radius: 8px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; min-width: 40px; }

/* ====== APP SHELL ====== */
.app-container { display: none; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app-container.active { display: flex; }

.app-header {
  background: var(--primary); color: white;
  padding: 12px 16px; padding-top: calc(12px + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header h1 { font-size: 1.15rem; font-weight: 700; }
.app-header .subtitle { font-size: 0.75rem; opacity: 0.85; }
.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-right .btn-icon { background: rgba(255,255,255,0.15); color: white; border: none; cursor: pointer; }
.header-right .btn-icon:active { background: rgba(255,255,255,0.3); }

.app-content {
  flex: 1; padding: 16px; padding-bottom: calc(80px + var(--safe-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}

/* ====== BOTTOM NAV ====== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; display: flex;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 4px; cursor: pointer; transition: color 0.2s;
  color: var(--text-secondary); border: none; background: none;
  font-size: 0.65rem; font-weight: 500; gap: 2px;
}
.nav-item.active { color: var(--primary); }
.nav-item .material-icons { font-size: 24px; }

/* ====== CARDS ====== */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 1rem; font-weight: 700; }

/* ====== STATS ====== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.warn .stat-value { color: var(--warn); }

/* ====== LAVADA ITEM ====== */
.lavada-item {
  background: white; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.lavada-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: #e3f2fd; color: var(--primary); flex-shrink: 0;
}
.lavada-icon .material-icons { font-size: 22px; }
.lavada-info { flex: 1; min-width: 0; }
.lavada-placa { font-size: 1rem; font-weight: 700; letter-spacing: 1px; }
.lavada-detail { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lavada-price { text-align: right; flex-shrink: 0; }
.lavada-price .amount { font-size: 1rem; font-weight: 700; color: var(--accent); }
.lavada-price .time { font-size: 0.7rem; color: var(--text-secondary); }
.lavada-item.cancelada { opacity: 0.5; }
.lavada-item.cancelada .lavada-placa { text-decoration: line-through; }

/* ====== MODAL ====== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.modal h3 { font-size: 1.1rem; margin-bottom: 20px; text-align: center; }

/* ====== CATEGORY SELECTOR ====== */
.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.category-btn {
  background: #f5f5f5; border: 2px solid transparent;
  border-radius: var(--radius); padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer; transition: all 0.2s;
  font-size: 0.85rem; font-weight: 600; color: var(--text);
}
.category-btn .material-icons { font-size: 32px; color: var(--primary); }
.category-btn.selected { border-color: var(--primary); background: #e3f2fd; }
.category-btn:active { transform: scale(0.96); }

/* ====== SERVICE SELECTOR ====== */
.service-list { margin-bottom: 16px; }
.service-item {
  padding: 14px 16px; border: 2px solid var(--border);
  border-radius: 10px; margin-bottom: 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  transition: all 0.2s;
}
.service-item.selected { border-color: var(--primary); background: #e3f2fd; }
.service-item:active { transform: scale(0.98); }
.service-name { font-size: 0.9rem; font-weight: 600; }
.service-price { font-size: 1rem; font-weight: 700; color: var(--accent); }

/* ====== PAGO LAVADOR ====== */
.pago-card {
  background: white; border-radius: var(--radius);
  margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.pago-header {
  padding: 14px 16px; display: flex; align-items: center;
  justify-content: space-between; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.pago-nombre { font-weight: 700; font-size: 1rem; }
.pago-total { font-size: 1.1rem; font-weight: 800; color: var(--accent); }
.pago-count { font-size: 0.75rem; color: var(--text-secondary); }
.pago-detalle { padding: 0 16px; max-height: 0; overflow: hidden; transition: max-height 0.3s; }
.pago-detalle.open { max-height: 1000px; padding: 12px 16px; }
.pago-line {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 0.8rem; border-bottom: 1px solid #f5f5f5;
}

/* ====== TABS ====== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: #f0f0f0; border-radius: 10px; padding: 3px; }
.tab {
  flex: 1; padding: 10px; text-align: center; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  border: none; background: transparent; color: var(--text-secondary);
  transition: all 0.2s;
}
.tab.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ====== LIST ITEM (users, categories) ====== */
.list-item {
  background: white; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
}
.list-item-info { display: flex; align-items: center; gap: 12px; }
.list-item-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #e3f2fd; display: flex; align-items: center;
  justify-content: center; color: var(--primary); flex-shrink: 0;
}
.list-item-name { font-weight: 600; font-size: 0.95rem; }
.list-item-sub { font-size: 0.75rem; color: var(--text-secondary); }
.list-item-actions { display: flex; gap: 4px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
}
.badge-admin { background: #fce4ec; color: #c62828; }
.badge-coordinador { background: #e3f2fd; color: #1565c0; }
.badge-lavador { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #f5f5f5; color: #9e9e9e; }

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-secondary);
}
.empty-state .material-icons { font-size: 64px; color: var(--border); margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ====== FAB ====== */
.fab {
  position: fixed; bottom: 80px; right: 16px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: white; border: none;
  box-shadow: 0 4px 12px rgba(0,200,83,0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 50; transition: transform 0.2s;
  bottom: calc(80px + var(--safe-bottom));
}
.fab:active { transform: scale(0.9); }
.fab .material-icons { font-size: 28px; }

/* ====== TOAST ====== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: #323232; color: white; padding: 12px 24px;
  border-radius: 8px; font-size: 0.85rem; z-index: 300;
  animation: fadeInUp 0.3s ease;
  bottom: calc(100px + var(--safe-bottom));
}
@keyframes fadeInUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ====== QR SECTION ====== */
.qr-display { text-align: center; padding: 20px; }
.qr-display img { max-width: 250px; border-radius: 12px; margin-bottom: 16px; }

/* ====== SECTION TITLE ====== */
.section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;
  padding-left: 4px;
}

/* ====== RESPONSIVE ====== */
@media (min-width: 500px) {
  .app-content { max-width: 500px; margin: 0 auto; }
  .modal { max-height: 80vh; border-radius: 20px; margin-bottom: 20px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ====== SPINNER ====== */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%; border-top-color: white;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; flex-direction: column; gap: 12px; color: var(--text-secondary);
}
.loading-screen .spinner { border-color: var(--border); border-top-color: var(--primary); width: 32px; height: 32px; }

/* Date picker */
.date-picker-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.date-picker-row input[type="date"] {
  flex: 1; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: 10px; font-size: 0.9rem;
}
