/* ══════════════════════════════════════════════════════════════════════════════
   Mshari's Portal — Design System & Styles
   ══════════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg: #F8F9FE;
  --surface: #FFFFFF;
  --surface-2: #F1F3F8;
  --surface-3: #E8ECF4;
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-lighter: #DDD6FE;
  --primary-dark: #5A4BD1;
  --secondary: #00CEC9;
  --accent: #FD79A8;
  --success: #00B894;
  --success-light: #D1FAE5;
  --warning: #FDCB6E;
  --warning-light: #FEF3C7;
  --danger: #FF7675;
  --danger-light: #FEE2E2;
  --text: #1A1A2E;
  --text-secondary: #636E72;
  --text-tertiary: #B2BEC3;
  --border: #E8ECF4;
  --overlay: rgba(0, 0, 0, 0.4);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 40px -5px rgba(0, 0, 0, 0.08);
  --shadow-primary: 0 4px 14px rgba(108, 92, 231, 0.25);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 100px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.45, 0, 0.55, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);

  /* Layout */
  --tab-bar-height: 80px;
  --header-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Category Colors */
  --cat-entertainment: #6C5CE7;
  --cat-productivity: #0984E3;
  --cat-gaming: #00B894;
  --cat-health: #E17055;
  --cat-shopping: #F39C12;
  --cat-communication: #00CEC9;
  --cat-education: #6C5CE7;
  --cat-finance: #2D3436;
  --cat-other: #636E72;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ─── App Container ──────────────────────────────────────────────────────── */
#app {
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
}

/* ─── Lock Screen ────────────────────────────────────────────────────────── */
.lock-screen {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 50%, #DDD6FE 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.lock-screen.hidden {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
  visibility: hidden;
}

.lock-screen__logo {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.lock-screen__title {
  color: white;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.lock-screen__subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 15px;
  margin-bottom: 48px;
}

.lock-screen__time {
  color: white;
  font-size: 56px;
  font-weight: 200;
  letter-spacing: -2px;
  margin-bottom: 4px;
}

.lock-screen__date {
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  margin-bottom: 60px;
}

/* PIN Input */
.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.pin-label {
  color: white;
  font-size: 15px;
  font-weight: 500;
}

.pin-dots {
  display: flex;
  gap: 12px;
}

.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  transition: all 0.2s var(--ease-spring);
}

/* Lockout overlay */
.pin-lockout {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 10px 20px;
  background: rgba(255, 71, 87, 0.25);
  border-radius: 12px;
  margin-top: -8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pin-lockout__timer {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.pin-attempts-left {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 400;
}

.pin-dot.filled {
  background: white;
  border-color: white;
  transform: scale(1.2);
}

.pin-dot.error {
  border-color: #FF7675;
  background: #FF7675;
  animation: pinShake 0.5s var(--ease-out);
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 16px;
}

.pin-key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 28px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pin-key:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.92);
}

.pin-key--action {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.pin-key--biometric {
  background: transparent;
  border: none;
  font-size: 28px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* PIN Setup */
.pin-setup {
  text-align: center;
}

.pin-setup__title {
  color: white;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.pin-setup__desc {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  margin-bottom: 32px;
}

/* ─── Main App ───────────────────────────────────────────────────────────── */
.main-app {
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.main-app.visible {
  opacity: 1;
}

/* ─── Views Container ────────────────────────────────────────────────────── */
.views-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 20px);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  pointer-events: none;
  overscroll-behavior: contain;
}

.view.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.view-padding {
  padding: 0 24px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.view-header {
  padding: calc(var(--safe-top) + 16px) 24px 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.view-header__greeting {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.view-header__title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-top: 2px;
}

.view-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.view-header__actions {
  display: flex;
  gap: 8px;
}

.view-header__btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.view-header__btn:active {
  transform: scale(0.92);
  background: var(--surface-2);
}

/* ─── Summary Cards ──────────────────────────────────────────────────────── */
.summary-cards {
  display: flex;
  gap: 14px;
  padding: 16px 28px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-scroll-padding: 0 28px;
  scroll-padding: 0 28px;
}

.summary-cards::-webkit-scrollbar {
  display: none;
}

.summary-card {
  flex: 0 0 85%;
  min-width: 250px;
  padding: 24px;
  border-radius: var(--radius-xl);
  scroll-snap-align: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast);
}

.summary-card:first-child {
  margin-left: 0;
}

.summary-card:active {
  transform: scale(0.98);
}

.summary-card--total {
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
  color: white;
}

.summary-card--upcoming {
  background: linear-gradient(135deg, #00CEC9 0%, #55EFC4 100%);
  color: white;
}

.summary-card--overdue {
  background: linear-gradient(135deg, #FF7675 0%, #FD79A8 100%);
  color: white;
}

.summary-card__pattern {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.summary-card__pattern-2 {
  position: absolute;
  bottom: -30px;
  right: 40px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.summary-card__label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.summary-card__amount {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 2px;
}

.summary-card__amount span {
  font-size: 18px;
  font-weight: 500;
  opacity: 0.8;
  margin-left: 4px;
}

.summary-card__sub {
  font-size: 13px;
  opacity: 0.7;
}

.summary-card__icon {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  opacity: 0.6;
}

/* ─── Section ────────────────────────────────────────────────────────────── */
.section {
  padding: 0 24px;
  margin-bottom: 24px;
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.section__action {
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}

/* ─── Subscription Cards ─────────────────────────────────────────────────── */
.sub-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.sub-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

.sub-card--due {
  border-left: 3px solid var(--warning);
}

.sub-card--overdue {
  border-left: 3px solid var(--danger);
}

.sub-card--paid {
  opacity: 0.6;
}

.sub-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sub-card__info {
  flex: 1;
  min-width: 0;
}

.sub-card__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-card__meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sub-card__right {
  text-align: right;
  flex-shrink: 0;
}

.sub-card__amount {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.sub-card__amount span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.sub-card__status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  margin-top: 4px;
  display: inline-block;
}

.sub-card__status--due {
  background: var(--warning-light);
  color: #92400E;
}

.sub-card__status--overdue {
  background: var(--danger-light);
  color: #991B1B;
}

.sub-card__status--paid {
  background: var(--success-light);
  color: #065F46;
}

.sub-card__status--upcoming {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

/* Swipe actions */
.sub-card__actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.sub-card__action-btn {
  width: 72px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.sub-card__action-btn--pay {
  background: var(--success);
}

.sub-card__action-btn--delete {
  background: var(--danger);
}

/* ─── Quick Pay Button ───────────────────────────────────────────────────── */
.quick-pay-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--success);
  color: white;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.quick-pay-btn:active {
  transform: scale(0.95);
  background: #00A884;
}

/* ─── Filter Chips ───────────────────────────────────────────────────────── */
.filter-chips {
  display: flex;
  gap: 8px;
  padding: 8px 24px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition-fast);
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-xs);
}

.filter-chip.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

.filter-chip:active {
  transform: scale(0.95);
}

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-bar {
  margin: 0 24px 12px;
  position: relative;
}

.search-bar__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-bar__input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
}

.search-bar__input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.search-bar__input::placeholder {
  color: var(--text-tertiary);
}

/* ─── Bottom Tab Bar ─────────────────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 100;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
}

.tab-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  position: relative;
  min-width: 56px;
}

.tab-bar__item:active {
  transform: scale(0.9);
}

.tab-bar__icon {
  font-size: 24px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.tab-bar__label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

.tab-bar__item.active .tab-bar__icon {
  color: var(--primary);
  transform: scale(1.1);
}

.tab-bar__item.active .tab-bar__label {
  color: var(--primary);
  font-weight: 600;
}

/* FAB - Add button */
.tab-bar__fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  transition: all var(--transition-fast);
  margin-top: -16px;
}

.tab-bar__fab:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

/* ─── Modal / Bottom Sheet ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: 201;
  transition: transform 0.4s var(--ease-out);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bottom-sheet.active {
  transform: translateX(-50%) translateY(0);
}

.bottom-sheet__handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  margin: 10px auto;
  flex-shrink: 0;
}

.bottom-sheet__header {
  padding: 8px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.bottom-sheet__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.bottom-sheet__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
}

.bottom-sheet__body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-select {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  color: var(--text);
  transition: all var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23636E72' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* ─── Icon / Emoji Picker ────────────────────────────────────────────────── */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.emoji-option {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
  background: var(--surface-2);
}

.emoji-option.selected {
  border-color: var(--primary);
  background: var(--primary-lighter);
  transform: scale(1.1);
}

.emoji-option:active {
  transform: scale(0.9);
}

/* ─── Color Picker ───────────────────────────────────────────────────────── */
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.color-option.selected {
  border-color: var(--text);
  transform: scale(1.15);
}

.color-option.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.color-option:active {
  transform: scale(0.9);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn--primary:active {
  background: var(--primary-dark);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  background: var(--danger-light);
  color: #991B1B;
}

.btn--success {
  background: var(--success);
  color: white;
}

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn--small {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

/* ─── Detail View ────────────────────────────────────────────────────────── */
.detail-header {
  text-align: center;
  padding: 20px 0 24px;
}

.detail-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
}

.detail-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.detail-category {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-top: 12px;
}

.detail-amount span {
  font-size: 16px;
  color: var(--text-secondary);
}

.detail-info {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.detail-info__row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}

.detail-info__row:last-child {
  border-bottom: none;
}

.detail-info__label {
  font-size: 14px;
  color: var(--text-secondary);
}

.detail-info__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

/* ─── Payment History ────────────────────────────────────────────────────── */
.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
}

.payment-item:last-child {
  border-bottom: none;
}

.payment-item__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.payment-item__check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--success-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--success);
}

.payment-item__date {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.payment-item__amount {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ─── Settings ───────────────────────────────────────────────────────────── */
.settings-group {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 4px 0;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  transition: background var(--transition-fast);
}

.settings-item:active {
  background: var(--surface-2);
}

.settings-item + .settings-item {
  border-top: 0.5px solid var(--border);
}

.settings-item__left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.settings-item__label {
  font-size: 16px;
  color: var(--text);
}

.settings-item__desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.settings-item__right {
  color: var(--text-tertiary);
  font-size: 16px;
}

/* Toggle Switch */
.toggle {
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--surface-3);
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.toggle.active {
  background: var(--success);
}

.toggle__knob {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px;
  left: 2px;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast);
}

.toggle.active .toggle__knob {
  transform: translateX(20px);
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 40px;
}

.empty-state__icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.9;
}

.empty-state__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state__desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(-200%);
  max-width: 380px;
  width: calc(100% - 40px);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: var(--text);
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 1500;
  transition: transform 0.4s var(--ease-spring), opacity 0.4s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  pointer-events: none;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast--success {
  background: var(--success);
}

.toast--error {
  background: var(--danger);
}

.toast--warning {
  background: #92400E;
}

.toast__icon {
  font-size: 18px;
}

/* ─── Confetti ───────────────────────────────────────────────────────────── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 600;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2.5s var(--ease-out) forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100px) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

/* ─── Animated Counter ───────────────────────────────────────────────────── */
.counter {
  display: inline-block;
}

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  position: absolute;
  top: -2px;
  right: 4px;
}

/* ─── Skeleton Loading ───────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 80px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
}

.skeleton-summary {
  height: 140px;
  border-radius: var(--radius-xl);
  flex: 0 0 calc(100% - 40px);
}

/* ─── Notification Settings ──────────────────────────────────────────────── */
.reminder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-lighter);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 500;
  margin-right: 6px;
  margin-bottom: 6px;
}

.reminder-chip__remove {
  font-size: 14px;
  opacity: 0.7;
  cursor: pointer;
}

/* ─── Progress Ring ──────────────────────────────────────────────────────── */
.progress-ring {
  width: 60px;
  height: 60px;
  position: relative;
}

.progress-ring__circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s var(--ease-out);
}

.progress-ring__bg {
  stroke: var(--surface-3);
}

.progress-ring__fill {
  stroke: var(--success);
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.progress-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ─── Preset Cards ───────────────────────────────────────────────────────── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.preset-card {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.preset-card.selected {
  border-color: var(--primary);
  background: var(--primary-lighter);
}

.preset-card:active {
  transform: scale(0.95);
}

.preset-card__icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.preset-card__name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

/* ─── Notification View ──────────────────────────────────────────────────── */
.notif-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.notif-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.notif-card__content {
  flex: 1;
}

.notif-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.notif-card__body {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.notif-card__time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 431px) {
  body {
    background: #E8ECF4;
  }

  #app {
    box-shadow: var(--shadow-xl);
    border-radius: 0;
    height: 100vh;
  }
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.anim-fade-in-up {
  animation: fadeInUp 0.4s var(--ease-out) both;
}

.anim-fade-in {
  animation: fadeIn 0.3s var(--ease-out) both;
}

.anim-scale-in {
  animation: scaleIn 0.3s var(--ease-spring) both;
}

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* ─── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .tab-bar, .lock-screen, .modal-overlay, .bottom-sheet {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════════════════════════════ */
:root.dark {
  --bg: #0D0D1A;
  --surface: #1A1A2E;
  --surface-2: #232340;
  --surface-3: #2D2D4A;
  --text: #EEEEF5;
  --text-secondary: #9898B8;
  --text-tertiary: #5A5A78;
  --border: #2D2D4A;
  --overlay: rgba(0, 0, 0, 0.65);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.35);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.2);
}

:root.dark body {
  background: var(--bg);
}

:root.dark .tab-bar {
  background: rgba(26, 26, 46, 0.92);
  border-top-color: rgba(255, 255, 255, 0.06);
}

:root.dark .form-input, :root.dark .form-select {
  background: var(--surface-2);
  border-color: var(--surface-3);
  color: var(--text);
}

:root.dark .search-bar__input {
  background: var(--surface-2);
  border-color: var(--surface-3);
  color: var(--text);
}

:root.dark .sub-card--paid {
  opacity: 0.5;
}

:root.dark .preset-card {
  background: var(--surface-2);
}

:root.dark .emoji-option {
  background: var(--surface-2);
}

@media (min-width: 431px) {
  :root.dark body {
    background: #080810;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BUDGET PROGRESS
   ═══════════════════════════════════════════════════════════════════════════════ */
.budget-section {
  padding: 0 24px;
  margin-bottom: 20px;
}

.budget-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.budget-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.budget-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.budget-card__amount {
  font-size: 13px;
  font-weight: 600;
}

.budget-bar {
  height: 10px;
  border-radius: 5px;
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 6px;
}

.budget-bar__fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s var(--ease-out);
}

.budget-card__footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ANALYTICS
   ═══════════════════════════════════════════════════════════════════════════════ */
.analytics-section {
  padding: 0 24px;
  margin-bottom: 24px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.analytics-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.analytics-card--full {
  grid-column: 1 / -1;
}

.analytics-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.donut-chart {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto 12px;
}

.donut-chart__hole {
  position: absolute;
  width: 66px;
  height: 66px;
  background: var(--surface);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.donut-chart__total {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.donut-chart__label {
  font-size: 9px;
  color: var(--text-secondary);
}

.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.analytics-legend__item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}

.analytics-legend__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 90px;
  padding-top: 8px;
}

.bar-chart__bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.bar-chart__fill {
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
  transition: height 0.5s var(--ease-out);
}

.bar-chart__amount {
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 600;
}

.bar-chart__label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   STREAK
   ═══════════════════════════════════════════════════════════════════════════════ */
.streak-section {
  padding: 0 24px;
  margin-bottom: 20px;
}

.streak-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card);
}

.streak-icon {
  font-size: 36px;
  line-height: 1;
}

.streak-info {
  flex: 1;
}

.streak-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.streak-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.streak-badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CALENDAR
   ═══════════════════════════════════════════════════════════════════════════════ */
.calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar__nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text);
}

.calendar__nav:active {
  transform: scale(0.9);
  background: var(--surface-3);
}

.calendar__month {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar__weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 6px 0;
}

.calendar__day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  position: relative;
  gap: 1px;
  transition: background var(--transition-fast);
}

.calendar__day:active {
  background: var(--surface-2);
}

.calendar__day--today {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.calendar__day--other {
  color: var(--text-tertiary);
}

.calendar__day--has-bill {
  font-weight: 700;
}

.calendar__dots {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 3px;
}

.calendar__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.calendar__bills {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FREE TRIAL BADGE
   ═══════════════════════════════════════════════════════════════════════════════ */
.trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #DBEAFE;
  color: #1D4ED8;
  font-size: 10px;
  font-weight: 600;
}

:root.dark .trial-badge {
  background: #1E3A5F;
  color: #93C5FD;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CURRENCY INDICATOR
   ═══════════════════════════════════════════════════════════════════════════════ */
.currency-tag {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}
