/* ============================================================
   My Wallet — Personal Finance Tracker
   Light, airy fintech UI (soft blue / white palette)
   ============================================================ */

/* ---------- Reset & tokens ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* surfaces */
  --bg: #F4F7FC;
  --surface: #FFFFFF;

  /* text */
  --text: #0F1B3D;
  --text-muted: #6B7894;
  --text-soft: #A6B0C4;

  /* brand */
  --primary: #4A8AF4;
  --primary-soft: #E8F0FE;
  --primary-soft-2: #DCE9FD;

  /* semantic */
  --income: #1FCB8B;
  --income-bg: #E5F8F0;
  --expense: #F06464;
  --expense-bg: #FCE9E9;
  --savings: #5BB0F5;
  --savings-bg: #E8F3FE;
  --investments: #8A7BF5;
  --investments-bg: #EFEBFE;

  /* misc */
  --border: #E6EAF2;
  --shadow-sm: 0 2px 6px rgba(15, 27, 61, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 27, 61, 0.06);
  --shadow-lg: 0 10px 30px rgba(74, 138, 244, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 24px 16px 64px;
}

.app {
  max-width: 440px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.greeting h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wave-emoji {
  font-size: 20px;
  display: inline-block;
  transform-origin: 70% 70%;
  animation: wave 1.8s ease-in-out 1;
}

@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6B9CFF 0%, #4A8AF4 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  letter-spacing: 0.5px;
}

/* ---------- Balance card ---------- */
.balance-card {
  position: relative;
  background: linear-gradient(135deg, #4A8AF4 0%, #6B7BF5 100%);
  border-radius: 24px;
  padding: 22px 24px 28px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  margin-bottom: 24px;
  overflow: hidden;
}

.balance-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  letter-spacing: 0.2px;
}

.eye-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.eye-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.balance-amount {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.8px;
  margin-top: 8px;
}

.balance-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.92;
}

.balance-change.negative {
  color: #FFD2D2;
}

.wave-svg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 80px;
  pointer-events: none;
}

/* ---------- Card (shared) ---------- */
.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-bottom: 14px;
}

/* ---------- Quick overview ---------- */
.overview {
  margin-bottom: 20px;
}

.overview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

.overview-header h2 {
  margin-bottom: 0;
}

.period-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.overview-list {
  list-style: none;
  background: var(--surface);
  border-radius: 20px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.overview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  transition: background 0.15s;
}

.overview-row + .overview-row {
  border-top: 1px solid var(--border);
}

.overview-row:hover {
  background: var(--bg);
}

.row-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-income     { background: var(--income-bg);     color: var(--income); }
.icon-expense    { background: var(--expense-bg);    color: var(--expense); }
.icon-savings    { background: var(--savings-bg);    color: var(--savings); }
.icon-investments{ background: var(--investments-bg);color: var(--investments); }

.row-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.row-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

/* ---------- Form ---------- */
.tx-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 138, 244, 0.15);
}

.form-group-btn {
  justify-content: flex-end;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.05s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  margin-top: 22px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(74, 138, 244, 0.3);
}

.btn-primary:hover {
  background: #3B7AE0;
}

/* ---------- History ---------- */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.history-header h2 { margin-bottom: 0; }

.filters {
  display: inline-flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
}

.filter-btn {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.filter-btn:hover { color: var(--text); }

.filter-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 14px;
  border-left: 3px solid transparent;
  transition: transform 0.1s;
}

.tx-item:hover { transform: translateX(2px); }
.tx-item.income  { border-left-color: var(--income); }
.tx-item.expense { border-left-color: var(--expense); }

.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.tx-item.income  .tx-icon { background: var(--income-bg);  color: var(--income); }
.tx-item.expense .tx-icon { background: var(--expense-bg); color: var(--expense); }

.tx-info { flex: 1; min-width: 0; }

.tx-desc {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tx-amount {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.tx-item.income  .tx-amount { color: var(--income); }
.tx-item.expense .tx-amount { color: var(--expense); }

.tx-delete {
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.tx-delete:hover {
  background: var(--expense-bg);
  color: var(--expense);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 0 8px;
  font-size: 13px;
}

.empty-state.hidden { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  body { padding: 16px 12px 48px; }
  .balance-amount { font-size: 30px; }
}

@media (min-width: 768px) {
  body { padding: 32px 24px 80px; }
}

/* ============================================================
   Auth overlay + form
   ============================================================ */

.hidden { display: none !important; }

.auth-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #F4F7FC 0%, #E8F0FE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand .logo {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.auth-brand h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.auth-form h2 {
  font-size: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.auth-form .form-group {
  margin-bottom: 12px;
}

.auth-form .btn {
  margin-top: 8px;
}

.btn-block {
  width: 100%;
  margin-top: 16px !important;
}

.auth-error {
  color: var(--expense);
  font-size: 12px;
  min-height: 16px;
  margin: 4px 0 0;
  text-align: center;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ---------- Header user chip ---------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 4px;
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6B9CFF 0%, #4A8AF4 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

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

.btn-logout:hover {
  background: var(--expense-bg);
  color: var(--expense);
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
  .auth-brand h1 { font-size: 22px; }
}
