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

:root {
  --color-samim: #6D5BD0;
  --color-samim-2: #8B7CF7;
  --color-hamas: #FF7EB3;
  --color-hamas-2: #FFA5C8;
  --profile-accent: #6D5BD0;
  --profile-accent-2: #8B7CF7;

  --surface: #ffffff;
  --surface-alt: #F7F6FC;
  --text: #201F33;
  --text-muted: #6E6C87;
  --border: #EBE9F6;
  --danger: #E5484D;
  --danger-bg: #FDEBEC;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-soft: 0 16px 40px rgba(65, 48, 140, 0.16);
  --shadow-card: 0 2px 10px rgba(32, 31, 51, 0.06);
  --shadow-pop: 0 20px 50px rgba(32, 31, 51, 0.25);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-alt);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ---------- Background decor ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
}
.blob-1 {
  width: 480px; height: 480px;
  background: linear-gradient(135deg, #6D5BD0, #8B7CF7);
  top: -160px; left: -120px;
}
.blob-2 {
  width: 420px; height: 420px;
  background: linear-gradient(135deg, #FF7EB3, #FFB4A2);
  bottom: -160px; right: -100px;
}
.blob-3 {
  width: 300px; height: 300px;
  background: linear-gradient(135deg, #A0C4FF, #BDB2FF);
  top: 40%; left: 60%;
  opacity: 0.3;
}

/* ---------- App / screens ---------- */
#app { position: relative; z-index: 1; min-height: 100vh; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: fadeIn .35s ease; }

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

/* ---------- Profile screen ---------- */
#screen-profiles.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profiles-wrap { text-align: center; max-width: 520px; width: 100%; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-samim);
  margin-bottom: 12px;
}
.headline {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  margin-bottom: 8px;
}
.subtext { color: var(--text-muted); font-size: 15px; margin-bottom: 44px; }

.profile-cards {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  transition: opacity .2s ease;
}
.profile-cards.is-loading { opacity: 0.5; pointer-events: none; }
.profile-card {
  --accent: #6D5BD0;
  --accent-2: #8B7CF7;
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  width: 200px;
  box-shadow: var(--shadow-card);
  transition: transform .25s ease, box-shadow .25s ease;
  font-family: inherit;
}
.profile-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: var(--shadow-soft); }
.profile-card:active { transform: translateY(-2px) scale(0.99); }

.profile-avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-size: 32px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(65, 48, 140, 0.3);
}
.profile-avatar.small { width: 42px; height: 42px; font-size: 17px; box-shadow: none; }
.profile-name { font-size: 18px; font-weight: 700; }

/* ---------- Dashboard ---------- */
#screen-dashboard.active { display: flex; flex-direction: column; min-height: 100vh; }

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.dash-title { display: flex; align-items: center; gap: 12px; }
.dash-title .profile-avatar.small { background: linear-gradient(135deg, var(--profile-accent), var(--profile-accent-2)); }
.dash-name { font-weight: 800; font-size: 17px; }
.dash-sub { font-size: 12px; color: var(--text-muted); }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: transform .2s ease, background .2s ease;
  flex-shrink: 0;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--surface-alt); }
.icon-btn:active { transform: translateY(0); }

.dash-body { flex: 1; max-width: 640px; margin: 0 auto; width: 100%; padding: 0 20px 110px; }

.total-card {
  background: linear-gradient(135deg, var(--profile-accent), var(--profile-accent-2));
  border-radius: var(--radius-lg);
  color: white;
  padding: 26px 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}
.total-label { font-size: 13px; opacity: 0.85; margin-bottom: 6px; font-weight: 600; }
.total-amount { font-size: clamp(26px, 6vw, 36px); font-weight: 800; letter-spacing: -0.02em; word-break: break-all; }
.total-count { font-size: 13px; opacity: 0.9; font-weight: 600; white-space: nowrap; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 6px 0 4px;
}
.month-label {
  font-size: 17px;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
  display: inline-block;
}

.link-btn {
  display: block;
  margin: 0 auto 20px;
  border: none;
  background: none;
  color: var(--color-samim);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

.calendar-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1;
  border: none;
  background: var(--surface-alt);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: transform .15s ease, background .15s ease;
  padding: 2px;
  min-width: 0;
}
.cal-cell.empty { visibility: hidden; cursor: default; }
.cal-cell:not(.empty):hover { transform: scale(1.06); }
.cal-day { font-size: 12px; font-weight: 600; }
.cal-amount {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--profile-accent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-cell.has-expense { background: #EEECFB; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--profile-accent); }
.cal-cell.is-selected { background: linear-gradient(135deg, var(--profile-accent), var(--profile-accent-2)); }
.cal-cell.is-selected .cal-day,
.cal-cell.is-selected .cal-amount { color: white; }

.section-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}
.section-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

.cat-summary-list { display: flex; flex-direction: column; gap: 14px; }
.cat-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.cat-row-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.cat-row-label { flex: 1; font-weight: 700; font-size: 13.5px; }
.cat-row-amount { font-weight: 800; font-size: 13.5px; flex-shrink: 0; }
.cat-row-track { height: 6px; border-radius: 3px; background: var(--surface-alt); overflow: hidden; }
.cat-row-fill { height: 100%; border-radius: 3px; }

.hint-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 10px 24px;
}

.list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.list-header h2 { font-size: 16px; font-weight: 800; }
.chip-clear {
  border: none;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.expense-list { display: flex; flex-direction: column; }
.day-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  padding: 12px 4px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  border-radius: 8px;
}
.day-item-row:first-child { border-top: none; }
.day-item-row:hover { background: var(--surface-alt); }
.day-item-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.day-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.day-item-label { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.day-item-amount { font-weight: 800; font-size: 14px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 50px 20px;
  background: var(--surface);
  border-radius: var(--radius-md);
}

.alltime-total-label { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.alltime-total-amount { font-size: 28px; font-weight: 800; color: var(--profile-accent); margin: 4px 0 2px; letter-spacing: -0.02em; }
.alltime-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.month-table { display: flex; flex-direction: column; }
.month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
}
.month-row:first-child { border-top: none; }
.month-row:hover { background: var(--surface-alt); }
.month-row-label { font-weight: 600; font-size: 14px; }
.month-row-amount { font-weight: 800; font-size: 14px; }
.month-row.is-current .month-row-label,
.month-row.is-current .month-row-amount { color: var(--profile-accent); }

.fab {
  position: fixed;
  right: 24px;
  bottom: 28px;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--profile-accent), var(--profile-accent-2));
  color: white;
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  z-index: 10;
  transition: transform .2s ease;
}
.fab:hover { transform: scale(1.06); }
.fab:active { transform: scale(0.96); }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 31, 51, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 100;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-pop);
  transform: translateY(40px);
  transition: transform .3s ease;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 10px; }
.modal-header h3 { font-size: 18px; font-weight: 800; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input,
.field select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-alt);
}
.field input:focus,
.field select:focus { outline: none; border-color: var(--profile-accent); }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--profile-accent), var(--profile-accent-2)); color: white; }
.btn-danger { background: var(--danger-bg); color: var(--danger); flex: 0 0 auto; }

.settings-note { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
  .profile-card { width: 150px; padding: 28px 20px; }
  .profile-avatar { width: 68px; height: 68px; font-size: 26px; }
}
