/* ============================================
   Personal Finance v2 — Dark Theme
   ============================================ */

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

:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --surface-3: #262626;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #fafafa;
  --text-dim: #8a8a8a;
  --text-faint: #555;
  --income: #4ade80;
  --expense: #f87171;

  --holo-bg:
    radial-gradient(at 20% 20%, rgba(255, 107, 157, 0.95) 0%, transparent 50%),
    radial-gradient(at 80% 0%, rgba(192, 132, 252, 0.95) 0%, transparent 50%),
    radial-gradient(at 100% 80%, rgba(56, 189, 248, 0.95) 0%, transparent 50%),
    radial-gradient(at 0% 100%, rgba(52, 211, 153, 0.85) 0%, transparent 50%),
    #1a1a2e;
}

html, body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-bottom: 90px; /* space for bottom nav */
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* ============================================
   App container
   ============================================ */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ============================================
   Screen system
   ============================================ */
.screen {
  display: none;
  padding: 20px 18px;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

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

/* ============================================
   Home Screen
   ============================================ */
.greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.greeting-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.88rem;
  color: white;
  letter-spacing: 0.02em;
}

.greeting-text {
  display: flex;
  flex-direction: column;
}

.greeting-small {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 400;
}

.greeting-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.icon-btn:hover { background: var(--surface-3); }

/* Holographic balance card */
.balance-card {
  border-radius: 20px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  min-height: 165px;
  background: var(--holo-bg);
  display: flex;
  flex-direction: column;
}

.balance-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25) 0%, transparent 40%);
  pointer-events: none;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: auto;
  position: relative;
  z-index: 1;
}

.card-name {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  color: white;
  cursor: pointer;
}

.toggle {
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle.on { background: rgba(255, 255, 255, 0.4); }
.toggle.on::after { transform: translateX(16px); }
.toggle.off { background: rgba(255, 255, 255, 0.15); }
.toggle.off::after { transform: translateX(0); background: rgba(255,255,255,0.6); }

.balance-info {
  position: relative;
  z-index: 1;
  margin-top: 24px;
}

.balance-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 6px;
  font-weight: 400;
}

.balance-amount {
  font-size: 2.3rem;
  font-weight: 600;
  color: white;
  letter-spacing: -0.025em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.balance-eye {
  position: absolute;
  bottom: 18px;
  right: 18px;
  color: rgba(255, 255, 255, 0.9);
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1;
  padding: 4px;
  display: flex;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}

.action-btn.primary {
  background: white;
  color: #1a1a1a;
  border-color: white;
}

.action-btn.primary:hover { background: #f0f0f0; }

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.view-all {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  cursor: pointer;
}

/* Transaction list */
.txn-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.txn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: slideIn 0.2s ease;
}

.txn-item:last-child { border-bottom: none; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.txn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  background: var(--surface-3);
}

.txn-info { flex: 1; min-width: 0; }
.txn-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.txn-cat {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 1px;
}
.txn-amount {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--expense);
  font-variant-numeric: tabular-nums;
}
.txn-amount.income { color: var(--income); }

.txn-delete {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s ease;
}
.txn-delete:hover { color: var(--expense); }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 20px;
  font-size: 0.9rem;
}
.empty-state.hidden { display: none; }

/* ============================================
   Add Screen
   ============================================ */
.add-top {
  background: var(--holo-bg);
  border-radius: 20px;
  padding: 48px 20px 24px;
  text-align: center;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.add-top::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 40%);
  pointer-events: none;
}

.add-amount-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
}

.add-currency {
  font-size: 1.6rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.add-amount {
  background: transparent;
  border: none;
  color: white;
  font-size: 3.2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
  width: auto;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  min-width: 100px;
  font-family: inherit;
}

.add-amount::placeholder { color: rgba(255, 255, 255, 0.4); }
.add-amount::-webkit-outer-spin-button,
.add-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.change-amount-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.15s ease;
}

.change-amount-btn:hover { background: rgba(255, 255, 255, 0.3); }
.change-amount-btn.hidden { display: none; }

.add-form {
  display: flex;
  flex-direction: column;
}

.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input-wrap {
  position: relative;
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 40px 13px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus { border-color: var(--text-dim); }
.form-input::placeholder { color: var(--text-faint); }

select.form-input {
  background-image: none;
  padding-right: 40px;
  cursor: pointer;
}

select.form-input option {
  background: var(--surface-2);
  color: var(--text);
}

input[type="date"].form-input {
  color-scheme: dark;
}

.form-chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 0.88rem;
  min-height: 95px;
  resize: none;
  line-height: 1.5;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-textarea:focus { border-color: var(--text-dim); }
.form-textarea::placeholder { color: var(--text-faint); }

.add-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
  margin-top: 18px;
}

.add-action {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-action:hover { background: var(--surface-3); }

.add-action.primary {
  background: white;
  color: #1a1a1a;
  border-color: white;
}
.add-action.primary:hover { background: #f0f0f0; }

/* ============================================
   Analytics Screen
   ============================================ */
.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.analytics-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.toggle-pill {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.toggle-pill button {
  padding: 9px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-pill button.active {
  background: white;
  color: #1a1a1a;
}

.analytics-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.analytics-total {
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.period-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
}

.period-select .period-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  min-width: 120px;
  z-index: 10;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.period-select.open .period-menu { display: flex; }

.period-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
}
.period-menu button:hover { background: var(--surface-3); }
.period-menu button.active { color: white; font-weight: 600; }

.chart-container {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 14px 14px;
  margin-bottom: 16px;
  height: 200px;
  position: relative;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.category-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: transform 0.15s ease;
}

.category-card:hover { transform: translateY(-1px); }

.category-name {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.category-amount {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.category-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ============================================
   Settings Screen
   ============================================ */
.settings-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.settings-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 8px;
}

.settings-danger {
  width: 100%;
  background: transparent;
  border: 1px solid var(--expense);
  color: var(--expense);
  padding: 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-danger:hover {
  background: var(--expense);
  color: white;
}

.settings-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 30px;
}

/* ============================================
   Bottom Nav (fixed)
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 452px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 18px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.nav-item:hover { color: var(--text); }

.nav-item.active {
  color: var(--text);
  background: var(--surface-3);
}

.nav-item[data-screen="add"].active {
  color: #1a1a1a;
  background: white;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 768px) {
  .app { max-width: 480px; }
}

@media (max-width: 360px) {
  .balance-amount { font-size: 2rem; }
  .add-amount { font-size: 2.6rem; }
  .analytics-total { font-size: 1.5rem; }
}
