:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  --green: #16a34a;
  --green-light: #dcfce7;
  --yellow: #d97706;
  --yellow-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-lg: 20px;
  --radius-md: 14px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

/* App Container */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  padding: calc(16px + env(safe-area-inset-top)) 20px 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.app-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-icon:active {
  background: var(--primary-light);
}

/* Main */
.app-main {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Gauge Card */
.gauge-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.week-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 999px;
}

.limit-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.gauge-values {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.val-box {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.val-caption {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.val-number {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 2px;
}

.val-remaining {
  color: var(--green);
  text-align: right;
}

.val-divider {
  width: 1px;
  height: 38px;
  background: var(--border);
  margin: 0 16px;
}

/* Progress Track */
.progress-track {
  width: 100%;
  height: 12px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
}

.progress-green {
  background-color: var(--green);
}

.progress-yellow {
  background-color: var(--yellow);
}

.progress-red {
  background-color: var(--red);
}

.gauge-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.gauge-status {
  font-weight: 700;
  color: var(--text-main);
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.cat-icon {
  font-size: 22px;
}

.cat-info {
  display: flex;
  flex-direction: column;
}

.cat-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.cat-total {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

/* Expenses Feed */
.expenses-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.count-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expense-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.25s ease;
}

.exp-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.exp-icon {
  font-size: 20px;
  width: 38px;
  height: 38px;
  background: #f1f5f9;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exp-details {
  display: flex;
  flex-direction: column;
}

.exp-desc {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.exp-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.author-chip {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: #e2e8f0;
}

.author-maria {
  background: #fce7f3;
  color: #be185d;
}

.author-denilson {
  background: #e0f2fe;
  color: #0369a1;
}

.exp-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exp-amount {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.btn-delete {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.btn-delete:active {
  color: var(--red);
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 6px;
  display: block;
}

/* Floating Action Button (FAB) */
.fab-button {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.5);
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.fab-button:active {
  transform: translateX(-50%) scale(0.96);
  background: var(--primary-hover);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-overlay.hidden .modal-sheet {
  transform: translateY(100%);
}

.sheet-drag-handle {
  width: 36px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 999px;
  margin: 0 auto;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-header h3 {
  font-size: 17px;
  font-weight: 800;
}

.btn-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

/* Sheet Form */
.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-amount-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: center;
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin: 4px 0 8px 0;
}

.currency-prefix {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-muted);
  margin-right: 6px;
}

#inputAmount {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-main);
  border: none;
  background: transparent;
  outline: none;
  max-width: 220px;
  text-align: left;
}

.form-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  margin-top: 4px;
}

/* Category Selector Chips */
.category-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.cat-chip {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.cat-chip input {
  position: absolute;
  opacity: 0;
}

.cat-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* Author Selector */
.author-selector {
  display: flex;
  gap: 10px;
}

.btn-author {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-author.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--green);
  color: #ffffff;
  border: none;
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
  transition: transform 0.15s ease, background 0.15s ease;
}

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

/* PIN Modal */
.pin-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 24px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.pin-lock-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}

.pin-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.pin-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.pin-input-group {
  margin-bottom: 16px;
}

#inputPin {
  font-size: 28px;
  letter-spacing: 8px;
  text-align: center;
  width: 160px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 12px;
  outline: none;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.hidden {
  opacity: 0;
  transform: translate(-50%, -20px);
  pointer-events: none;
}

/* User Greeting in Header */
.user-greeting-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 3px;
}

.btn-switch-user {
  background: transparent;
  border: none;
  font-size: 10px;
  text-decoration: underline;
  color: var(--primary);
  cursor: pointer;
  padding: 0 2px;
}

/* Authors Breakdown Inside Gauge Card */
.authors-breakdown {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}

.author-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  flex: 1;
}

.author-stat-maria {
  background: #fdf2f8;
  color: #be185d;
}

.author-stat-denilson {
  background: #f0f9ff;
  color: #0369a1;
}

.author-val {
  margin-left: auto;
  font-weight: 800;
}

/* Filter Chips */
.filter-chips {
  display: flex;
  gap: 6px;
  padding: 2px 0 6px 0;
}

.btn-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-filter.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

/* Profile Selector Cards in Modal */
.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.profile-card {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.profile-card:active, .profile-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.profile-avatar {
  font-size: 38px;
}

.profile-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.pin-prompt-user {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}

.btn-text {
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 12px;
  display: inline-block;
}

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