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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* AUTH */
.auth-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  text-align: center;
}
.auth-container h1 { color: #4f46e5; font-size: 2rem; margin-bottom: 4px; }
.subtitle { color: #888; margin-bottom: 24px; }
.auth-form h2 { margin-bottom: 16px; font-size: 1.2rem; }
.auth-form input {
  width: 100%; padding: 12px; margin-bottom: 12px;
  border: 1px solid #ddd; border-radius: 8px; font-size: 1rem;
}
.auth-form button {
  width: 100%; padding: 12px; background: #4f46e5; color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; cursor: pointer;
}
.auth-form button:hover { background: #4338ca; }
.toggle-text { margin-top: 12px; font-size: 0.9rem; }
.toggle-text a { color: #4f46e5; text-decoration: none; }
.error { color: #e53e3e; margin-top: 8px; font-size: 0.9rem; }

/* NAV */
nav {
  background: #fff; padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky; top: 0; z-index: 100;
}
nav h1 { color: #4f46e5; font-size: 1.4rem; }
.nav-right { display: flex; align-items: center; gap: 12px; }
#user-greeting { font-size: 0.9rem; color: #666; }
.nav-btn {
  padding: 8px 16px; border: none; background: #f0f0f0;
  border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.nav-btn.active { background: #4f46e5; color: #fff; }
.btn-logout {
  padding: 8px 16px; border: 1px solid #e53e3e; background: none;
  color: #e53e3e; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.btn-logout:hover { background: #e53e3e; color: #fff; }

/* SECTIONS */
.section { max-width: 1000px; margin: 24px auto; padding: 0 16px; }

/* DASHBOARD */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; padding: 20px; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-align: center;
}
.stat-card h3 { font-size: 0.85rem; color: #888; margin-bottom: 8px; text-transform: uppercase; }
.stat-number { font-size: 1.8rem; font-weight: 700; color: #4f46e5; }
.stat-card.warning .stat-number { color: #e53e3e; }

.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  background: #fff; padding: 20px; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.panel h3 { font-size: 1rem; margin-bottom: 12px; color: #555; }

.expiring-item {
  padding: 10px; border-bottom: 1px solid #f0f0f0;
  display: flex; justify-content: space-between; align-items: center;
}
.expiring-item:last-child { border-bottom: none; }
.days-left { font-weight: 600; font-size: 0.85rem; }
.days-left.urgent { color: #e53e3e; }
.days-left.soon { color: #d97706; }

.category-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.category-row:last-child { border-bottom: none; }
.category-bar {
  height: 8px; background: #e0e0e0; border-radius: 4px; flex: 1; margin: 0 12px;
  align-self: center;
}
.category-bar-fill { height: 100%; background: #4f46e5; border-radius: 4px; }

/* RECEIPTS */
.receipts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.btn-add {
  padding: 10px 20px; background: #4f46e5; color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.btn-add:hover { background: #4338ca; }

.filters { display: flex; gap: 12px; margin-bottom: 16px; }
.filters input, .filters select {
  padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem;
}
.filters input { flex: 1; }

.receipt-card {
  background: #fff; padding: 16px; border-radius: 10px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex; justify-content: space-between; align-items: center;
}
.receipt-info h3 { font-size: 1.05rem; margin-bottom: 4px; }
.receipt-info p { font-size: 0.85rem; color: #888; }
.receipt-meta { text-align: right; }
.receipt-price { font-size: 1.3rem; font-weight: 700; color: #4f46e5; }
.receipt-deadline { font-size: 0.8rem; margin-top: 4px; }
.receipt-actions { margin-top: 8px; }
.receipt-actions button {
  padding: 5px 12px; border: none; border-radius: 5px;
  cursor: pointer; font-size: 0.8rem; margin-left: 4px;
}
.btn-edit { background: #eef2ff; color: #4f46e5; }
.btn-delete { background: #fef2f2; color: #e53e3e; }
.btn-edit:hover { background: #4f46e5; color: #fff; }
.btn-delete:hover { background: #e53e3e; color: #fff; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.75rem; background: #f0f0f0; color: #666; margin-left: 8px;
}

/* MODAL */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: #fff; padding: 32px; border-radius: 12px;
  width: 90%; max-width: 450px; max-height: 90vh; overflow-y: auto;
}
.modal-content h2 { margin-bottom: 16px; }
.modal-content label { font-size: 0.85rem; color: #666; display: block; margin-bottom: 4px; margin-top: 10px; }
.modal-content input, .modal-content select {
  width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem;
}
.modal-buttons { display: flex; gap: 12px; margin-top: 20px; }
.modal-buttons button {
  flex: 1; padding: 10px; border: none; border-radius: 8px;
  cursor: pointer; font-size: 1rem;
}
.modal-buttons button:first-child { background: #4f46e5; color: #fff; }
.btn-cancel { background: #f0f0f0 !important; color: #333 !important; }

/* SCAN SECTION */
.scan-section { text-align: center; margin-bottom: 8px; }
.scan-label { font-size: 0.85rem; color: #888; margin-bottom: 10px; }
.scan-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.btn-scan {
  padding: 10px 18px; background: #eef2ff; color: #4f46e5; border: 1px dashed #4f46e5;
  border-radius: 8px; cursor: pointer; font-size: 0.9rem; transition: 0.2s;
}
.btn-scan:hover { background: #4f46e5; color: #fff; }
.btn-camera { background: #fef3c7; color: #d97706; border-color: #d97706; }
.btn-camera:hover { background: #d97706; color: #fff; }
.scan-preview { margin-top: 10px; }
.scan-preview img { max-width: 100%; max-height: 150px; border-radius: 8px; border: 1px solid #ddd; }
.scan-status { margin-top: 8px; font-size: 0.85rem; color: #4f46e5; }
.scan-status.error { color: #e53e3e; }
.scan-divider { border: none; border-top: 1px solid #eee; margin: 12px 0; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #4f46e5; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* PROFILE */
.profile-container { display: grid; gap: 16px; }
.profile-card {
  background: #fff; padding: 24px; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.profile-card h3 { margin-bottom: 16px; font-size: 1.1rem; color: #333; }
.profile-card label { font-size: 0.85rem; color: #666; display: block; margin-bottom: 4px; margin-top: 12px; }
.profile-card input {
  width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem;
}
.profile-card input:disabled { background: #f9f9f9; color: #999; }
.profile-actions { margin-top: 16px; }
.profile-actions button {
  padding: 10px 24px; background: #4f46e5; color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.profile-actions button:hover { background: #4338ca; }
.profile-msg { margin-top: 8px; font-size: 0.9rem; }
.danger-zone { border: 1px solid #fecaca; }
.danger-zone h3 { color: #e53e3e; }
.danger-zone p { font-size: 0.9rem; color: #888; margin-bottom: 16px; }
.btn-danger {
  padding: 10px 24px; background: #e53e3e; color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 0.95rem;
}
.btn-danger:hover { background: #dc2626; }

.empty-state { text-align: center; padding: 40px; color: #999; }

@media (max-width: 768px) {
  .dashboard-panels { grid-template-columns: 1fr; }
  .nav-right { flex-wrap: wrap; gap: 8px; }
  .receipt-card { flex-direction: column; text-align: left; }
  .receipt-meta { text-align: left; margin-top: 8px; }
}
