/* =====================================================
   FinTrack v17.7 | Expense Tracker
   ===================================================== */

@import url("https://fonts.googleapis.com/css2?family=SUSE:wght@100..800&display=swap");

/* =====================================================
   LIGHT THEME
   ===================================================== */
:root,
[data-theme="light"] {
  --bg: #eef2f9;
  --surface: #ffffff;
  --surface2: #f5f8fd;
  --surface3: #edf3fb;
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #e3f0fb;
  --primary-mid: #1976d2;
  --primary-glow: rgba(21, 101, 192, 0.18);
  --text: #0f1923;
  --text2: #4a5568;
  --text3: #8899a8;
  --border: #dce6f0;
  --border2: #c5d8ed;
  --danger: #d32f2f;
  --danger-bg: #ffebee;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --warning: #e65100;
  --warning-bg: #fff3e0;
  --header-bg: linear-gradient(135deg, #1565c0 0%, #1a78d2 50%, #1565c0 100%);
  --header-text: #ffffff;
  --tab-active-bg: #e8f1fb;
  --stat-today-bg: linear-gradient(135deg, #1565c0 0%, #1976d2 100%);
  --shadow-sm: 0 1px 4px rgba(21, 101, 192, 0.07);
  --shadow: 0 2px 12px rgba(21, 101, 192, 0.1);
  --shadow-lg: 0 8px 32px rgba(21, 101, 192, 0.13);
  --shadow-xl: 0 16px 48px rgba(21, 101, 192, 0.16);
  --pin-overlay-bg: rgba(10, 25, 50, 0.5);
  --toggle-bg: rgba(255, 255, 255, 0.14);
  --toggle-border: rgba(255, 255, 255, 0.24);
  --toggle-btn-color: rgba(255, 255, 255, 0.55);
  --toggle-btn-active: #ffffff;
  --toggle-slider: rgba(255, 255, 255, 0.22);

  /* Animation easing tokens */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.18s;
  --dur-base: 0.28s;
  --dur-slow: 0.42s;
}

/* =====================================================
   DARK THEME
   ===================================================== */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #1c2230;
  --surface2: #232c3e;
  --surface3: #1e2736;
  --primary: #4d9fec;
  --primary-dark: #3b8ad4;
  --primary-light: #1e2f45;
  --primary-mid: #5aaef5;
  --primary-glow: rgba(77, 159, 236, 0.22);
  --text: #e6edf5;
  --text2: #99aabb;
  --text3: #586779;
  --border: #2a3549;
  --border2: #354460;
  --danger: #f07070;
  --danger-bg: #2c1515;
  --success: #5fc97a;
  --success-bg: #122318;
  --warning: #f5a444;
  --warning-bg: #2b1d0a;
  --header-bg: linear-gradient(135deg, #111927 0%, #16263d 50%, #111927 100%);
  --header-text: #e6edf5;
  --tab-active-bg: #1a2640;
  --stat-today-bg: linear-gradient(135deg, #193154 0%, #1e3a62 100%);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.42);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
  --pin-overlay-bg: rgba(0, 0, 0, 0.78);
  --toggle-bg: rgba(255, 255, 255, 0.07);
  --toggle-border: rgba(255, 255, 255, 0.12);
  --toggle-btn-color: rgba(255, 255, 255, 0.35);
  --toggle-btn-active: #e6edf5;
  --toggle-slider: rgba(77, 159, 236, 0.3);
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition-property: background-color, border-color, color, box-shadow;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: "SUSE", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* Inline flex helper for icon fonts */
.fa-solid,
.fa-regular,
.fa-brands {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

/* Remove tap highlights on interactive elements */
a,
button,
input,
select,
textarea,
[role="button"],
[tabindex] {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Hide scrollbars globally */
::-webkit-scrollbar {
  display: none;
}
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* =====================================================
   GLOBAL THEME TRANSITIONS
   Only transition visual properties, not layout ones
   ===================================================== */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.25s;
  transition-timing-function: var(--ease-in-out);
}

/* Override for elements that need custom transitions */
.cat-btn,
.btn-record,
.stat-card,
.pin-key,
.period-btn,
.mbtn,
.exp-edit,
.exp-delete,
.icon-btn,
.about-link,
.expense-item,
.insight-card,
.timer-seg,
.tab-btn,
.sort-btn,
.theme-btn {
  transition-property:
    background-color, border-color, color, transform, box-shadow, opacity;
  transition-duration: var(--dur-fast);
  transition-timing-function: var(--ease-out);
}

/* =====================================================
   APP SHELL
   ===================================================== */
.app-shell {
  width: 100%;
  max-width: 900px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 901px) {
  body {
    padding: 28px 0;
  }
  .app-shell {
    min-height: unset;
    border-radius: 20px;
    box-shadow:
      0 0 0 1px var(--border),
      var(--shadow-xl);
    overflow: hidden;
  }
  .tab-panels-wrapper {
    min-height: 560px;
  }
  .tab-nav {
    width: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: 900px;
    bottom: 20px;
    padding: 8px 12px;
  }
}

/* =====================================================
   HEADER
   ===================================================== */
.app-header {
  height: 64px;
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  position: sticky;
  top: 0;
  z-index: 2000;
  flex-shrink: 0;
  overflow: hidden;
  /* Load animation */
  animation: headerSlideDown 0.4s var(--ease-out) both;
}

@keyframes headerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shimmer sweep on load */
.app-header::after {
  content: "";
  position: absolute;
  inset-block: 0;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.07),
    transparent
  );
  transform: translateX(-200%);
  animation: headerSweep 0.9s ease 0.5s forwards;
  pointer-events: none;
}

@keyframes headerSweep {
  from {
    transform: translateX(-200%);
  }
  to {
    transform: translateX(300%);
  }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.header-logo {
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--header-text);
}

.header-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--header-text);
  letter-spacing: -0.3px;
  display: block;
  white-space: nowrap;
}

.header-tagline {
  font-size: 9.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: block;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 8px;
}

.header-chip {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 22px;
  padding: 5px 13px;
  text-align: center;
  white-space: nowrap;
}

.chip-label {
  display: block;
  font-size: 8.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  line-height: 1;
}

.chip-amount {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--header-text);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Flash when value updates */
@keyframes chipGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  40% {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

.header-chip.updated {
  animation: chipGlow 0.55s ease forwards;
}

/* =====================================================
   TAB NAVIGATION
   ===================================================== */
.tab-nav {
  display: flex;
  align-items: center;
  height: 68px;
  background: var(--surface);
  position: fixed;
  border: 1px solid var(--border);
  border-radius: 34px;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 420px;
  z-index: 8999;
  padding: 10px;
  box-shadow:
    0 4px 24px rgba(21, 101, 192, 0.13),
    0 1px 8px rgba(21, 101, 192, 0.07);
  /* Load animation */
  animation: tabNavUp 0.55s var(--ease-spring) 0.1s both;
}

@keyframes tabNavUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(80px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

[data-theme="dark"] .tab-nav {
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}
.tab-nav.elevated {
  box-shadow: 0 -4px 30px rgba(21, 101, 192, 0.15);
}
[data-theme="dark"] .tab-nav.elevated {
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  outline: none;
  transition-property: color;
  transition-duration: 0.22s;
}

/* Pill highlight around the icon */
.tab-btn-icon-wrap {
  width: 52px;
  height: 44px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition:
    background var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-spring);
}

.tab-btn .fa-solid {
  font-size: 18px;
  transition:
    transform var(--dur-base) var(--ease-spring),
    color 0.22s ease;
  position: relative;
  z-index: 1;
}

.tab-btn.active {
  color: var(--primary);
}
.tab-btn.active .tab-btn-icon-wrap {
  background: var(--primary-light);
  transform: scale(1.06);
}
.tab-btn.active .fa-solid {
  transform: scale(1.15) translateY(-1px);
}

.tab-btn:hover:not(.active) .tab-btn-icon-wrap {
  background: var(--surface2);
  transform: scale(1.03);
}
.tab-btn:hover:not(.active) {
  color: var(--primary-mid);
}
.tab-btn:active .tab-btn-icon-wrap {
  transform: scale(0.88);
}

/* =====================================================
   TAB PANELS
   ===================================================== */
.tab-panels-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-panel {
  width: 100%;
  overflow-y: auto;
}

.tab-panel.tab-slide-in-right {
  animation: tabSlideInRight 0.32s var(--ease-out) forwards;
}
.tab-panel.tab-slide-in-left {
  animation: tabSlideInLeft 0.32s var(--ease-out) forwards;
}
.tab-panel.tab-slide-out-left {
  animation: tabSlideOutLeft 0.16s ease-in forwards;
  pointer-events: none;
  position: absolute;
  width: 100%;
}
.tab-panel.tab-slide-out-right {
  animation: tabSlideOutRight 0.16s ease-in forwards;
  pointer-events: none;
  position: absolute;
  width: 100%;
}

@keyframes tabSlideInRight {
  from {
    opacity: 0;
    transform: translateX(24px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
@keyframes tabSlideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
@keyframes tabSlideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-16px);
  }
}
@keyframes tabSlideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

.tab-inner {
  padding: 22px 22px 36px;
}

.tab-page-header {
  margin-bottom: 22px;
}
.tab-page-header h2 {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
}
.tab-page-header p {
  font-size: 13px;
  color: var(--text3);
  margin-top: 3px;
}

/* =====================================================
   STATS STRIP
   ===================================================== */
.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 14px 14px 10px;
  animation: fadeUpIn 0.4s var(--ease-out) 0.18s both;
}

.stat-card {
  background: var(--surface2);
  border-radius: 16px;
  padding: 14px 10px 13px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  /* Override global transition for custom one */
  transition:
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-fast) ease !important;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card:active {
  transform: scale(0.97);
}

.stat-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(-5deg);
}

.stat-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.5px;
  text-align: center;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 9.5px;
  color: var(--text3);
  margin-top: 4px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

/* Number pop on value update */
@keyframes numPop {
  0% {
    transform: translateY(5px) scale(0.95);
    opacity: 0.5;
  }
  60% {
    transform: translateY(-1px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
.stat-value.num-updated {
  animation: numPop 0.38s var(--ease-out) forwards;
}

/* Stat card color variants */
.stat-total .stat-icon {
  background: #e3f2fd;
  color: #1565c0;
}
[data-theme="dark"] .stat-total .stat-icon {
  background: #1a2f45;
  color: #4d9fec;
}

.stat-today {
  background: var(--stat-today-bg);
  border: none;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.28);
}
[data-theme="dark"] .stat-today {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
.stat-today .stat-label {
  color: rgba(255, 255, 255, 0.7);
}
.stat-today .stat-value {
  color: #fff;
}
.stat-today .stat-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.stat-today .stat-sub {
  color: rgba(255, 255, 255, 0.6);
}
.stat-today:hover {
  transform: translateY(-2px);
}

.stat-avg .stat-icon {
  background: #e8eaf6;
  color: #283593;
}
[data-theme="dark"] .stat-avg .stat-icon {
  background: #1a2040;
  color: #7986cb;
}

/* =====================================================
   BUDGET BAR
   ===================================================== */
.budget-bar-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px 7px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.budget-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--primary);
  transition:
    width 0.6s var(--ease-out),
    background 0.3s ease;
}
.budget-fill.budget-warn {
  background: #f59e0b;
}
.budget-fill.budget-over {
  background: var(--danger);
  animation: budgetPulse 1.4s ease-in-out infinite;
}

@keyframes budgetPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

.budget-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 160px;
}
.budget-label-warn {
  color: #d97706;
}
.budget-label-over {
  color: var(--danger);
}

/* =====================================================
   FORM CARD
   ===================================================== */
.form-card {
  margin: 4px 14px 14px;
  background: var(--surface);
  border-radius: 18px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: fadeUpIn 0.4s var(--ease-out) 0.26s both;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease !important;
}

.form-card:focus-within {
  border-color: var(--border2);
  box-shadow:
    0 0 0 1px var(--border2),
    var(--shadow);
}

/* Editing state highlights the whole card */
.form-card.editing-mode {
  border-color: var(--primary);
  box-shadow:
    0 0 0 2px var(--primary-glow),
    var(--shadow);
}
.form-card.editing-mode .form-card-header {
  background: var(--primary);
}
.form-card.editing-mode .form-card-header-left {
  color: #fff;
}

.form-card-header {
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--primary);
}

.form-card form {
  padding: 14px 16px 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-input {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  overflow: visible;
  /* Custom transition - don't use the global one */
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    transform 0.2s var(--ease-out) !important;
}

.field-input:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px var(--primary-glow),
    0 2px 8px rgba(21, 101, 192, 0.08);
  background: var(--surface);
  transform: translateY(-1px);
}

.field-input::placeholder {
  color: var(--text3);
}
.field-input.input-valid {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}
[data-theme="dark"] .field-input.input-valid {
  box-shadow: 0 0 0 3px rgba(95, 201, 122, 0.1);
}

input[type="date"].field-input::-webkit-datetime-edit {
  color: var(--text);
}
input[type="date"].field-input::-webkit-calendar-picker-indicator {
  opacity: 0.45;
  cursor: pointer;
}
[data-theme="dark"]
  input[type="date"].field-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Description character counter */
.desc-counter {
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  margin-left: auto;
  letter-spacing: 0.3px;
  transition: color 0.2s ease;
  font-variant-numeric: tabular-nums;
}
.desc-counter.near-limit {
  color: var(--warning);
}
.desc-counter.at-limit {
  color: var(--danger);
  animation: counterPulse 0.35s ease;
}

@keyframes counterPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.28);
  }
}

/* =====================================================
   CATEGORY PICKER
   ===================================================== */
.cat-section {
  margin-bottom: 12px;
}

.cat-section-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.cat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px 4px 4px;
  height: 34px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  /* Custom spring transition */
  transition:
    background var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-fast) ease !important;
}

.cat-btn-icon {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}

.cat-btn-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  line-height: 1;
  transition: color var(--dur-fast) ease;
}

.cat-btn:hover {
  border-color: var(--primary-mid);
  background: var(--primary-light);
  transform: translateY(-1px);
}
.cat-btn:hover .cat-btn-label {
  color: var(--primary);
}

.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px var(--primary-glow);
}
.cat-btn.active .cat-btn-label {
  color: #fff;
}
.cat-btn.active .cat-btn-icon {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #fff !important;
}
.cat-btn:active {
  transform: scale(0.92) !important;
}

/* Active dot indicator */
.cat-btn.active::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--primary);
  animation: checkDotPop 0.28s var(--ease-spring) forwards;
  pointer-events: none;
}

@keyframes checkDotPop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.35);
    opacity: 1;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Icon animation when newly selected */
.cat-btn.just-selected .cat-btn-icon {
  animation: catIconPop 0.38s var(--ease-spring);
}

@keyframes catIconPop {
  0% {
    transform: scale(1) rotate(0deg);
  }
  35% {
    transform: scale(1.35) rotate(-12deg);
  }
  65% {
    transform: scale(0.92) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* =====================================================
   RECORD BUTTON
   ===================================================== */
.btn-record {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.2px;
  box-shadow: 0 3px 12px var(--primary-glow);
  position: relative;
  overflow: hidden;
  transition:
    background var(--dur-fast) ease,
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-fast) ease !important;
}

.btn-record:hover {
  background: var(--primary-mid);
}
.btn-record:active {
  transform: scale(0.97) translateY(1px) !important;
}

/* Hover shimmer sweep */
.btn-record::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 60%
  );
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-record:hover::after {
  opacity: 1;
  animation: btnShimmer 1.2s linear infinite;
}

@keyframes btnShimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

/* =====================================================
   HISTORY SECTION
   ===================================================== */
.history-section {
  padding: 0 14px 28px;
  animation: fadeUpIn 0.4s var(--ease-out) 0.34s both;
}

/* Sticky header + filter so they stay visible on scroll */
.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 10px 0 6px;
}

.history-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

/* =====================================================
   SEARCH FIELD
   ===================================================== */
.search-field {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  gap: 7px;
  flex-shrink: 0;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.search-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-field .fa-solid {
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
  transition: color 0.2s ease !important;
}
.search-field:focus-within .fa-solid {
  color: var(--primary);
}

.search-field input {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 160px;
}
.search-field input::placeholder {
  color: var(--text3);
}

#search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background-color: var(--text3);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  cursor: pointer;
  opacity: 0.5;
}

/* =====================================================
   FILTER BAR
   ===================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 48px;
  z-index: 9;
  background: var(--bg);
  padding-bottom: 8px;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: fit-content;
  overflow: hidden;
  transition:
    background var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-fast) ease !important;
}

.sort-btn .fa-solid:first-child {
  font-size: 11px;
}

.sort-icon {
  font-size: 10px;
  transition: transform 0.3s var(--ease-spring) !important;
}

.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px var(--primary-glow);
  transform: translateY(-1px);
}

.sort-btn:hover:not(.active) {
  border-color: var(--primary-mid);
  color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}
.sort-btn:active {
  transform: scale(0.95) translateY(0) !important;
}

/* Category dropdown */
.cat-filter-wrap {
  position: relative;
  flex-shrink: 0;
}

.cat-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  z-index: 100;
  min-width: 165px;
  box-shadow: var(--shadow-lg);
  animation: dropdownIn 0.2s var(--ease-out);
  transform-origin: top left;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: scaleY(0.88) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: scaleY(1) translateY(0);
  }
}

.cat-drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s,
    color 0.15s;
}

.cat-drop-item .fa-solid {
  font-size: 11px;
  color: var(--text3);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.cat-drop-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.cat-drop-item:hover .fa-solid {
  color: var(--primary);
}
.cat-drop-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
}
.cat-drop-item.active .fa-solid {
  color: var(--primary);
}

/* =====================================================
   EXPENSE LIST
   ===================================================== */
.expense-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.expense-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 13px;
  animation: expSlideIn 0.3s var(--ease-out) both;
  transition:
    box-shadow var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-base) var(--ease-spring),
    background var(--dur-fast) ease !important;
  animation-fill-mode: both;
}

/* Staggered entrance delays */
.expense-item:nth-child(1) {
  animation-delay: 0s;
}
.expense-item:nth-child(2) {
  animation-delay: 0.04s;
}
.expense-item:nth-child(3) {
  animation-delay: 0.08s;
}
.expense-item:nth-child(4) {
  animation-delay: 0.12s;
}
.expense-item:nth-child(5) {
  animation-delay: 0.16s;
}
.expense-item:nth-child(6) {
  animation-delay: 0.2s;
}
.expense-item:nth-child(n + 7) {
  animation-delay: 0.24s;
}

@keyframes expSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
  60% {
    opacity: 1;
    transform: translateY(2px) scale(1.002);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.expense-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--border2);
  transform: translateY(-2px) scale(1.003);
}

.expense-item.being-edited {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary-glow);
  opacity: 0.75;
}

/* New-item border flash */
@keyframes newItemFlash {
  0% {
    border-color: var(--primary);
    box-shadow:
      0 0 0 4px var(--primary-glow),
      var(--shadow-lg);
  }
  60% {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 2px var(--primary-glow);
  }
  100% {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
  }
}
.expense-item.new-flash {
  animation: newItemFlash 1s var(--ease-out) forwards;
}

/* Remove animation */
.expense-item.removing {
  overflow: hidden;
  animation: expRemove 0.32s ease-in forwards;
}

@keyframes expRemove {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
    max-height: 80px;
    margin-bottom: 7px;
    padding-block: 10px;
    border-width: 1px;
  }
  35% {
    opacity: 0.5;
    transform: translateX(12px) scale(0.99);
  }
  100% {
    opacity: 0;
    transform: translateX(48px) scale(0.96);
    max-height: 0;
    margin-bottom: 0;
    padding-block: 0;
    border-width: 0;
  }
}

.exp-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}
.expense-item:hover .exp-icon {
  transform: scale(1.1);
}

.exp-body {
  flex: 1;
  min-width: 0;
}

.exp-desc {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-meta {
  font-size: 10.5px;
  color: var(--text3);
  margin-top: 3px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.exp-cat-badge {
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.exp-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.exp-amount {
  font-size: 14px;
  font-weight: 800;
  color: var(--danger);
  display: block;
  white-space: nowrap;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

/* Amount pop when newly added */
@keyframes amountPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.15);
    color: #ff5252;
  }
  100% {
    transform: scale(1);
  }
}
.exp-amount.just-added {
  animation: amountPop 0.45s var(--ease-spring);
}

.exp-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.expense-item:hover .exp-actions {
  opacity: 1;
}

.exp-edit,
.exp-delete {
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.15s,
    background 0.15s,
    transform 0.15s;
}
.exp-edit:hover {
  color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.1);
}
.exp-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
  transform: scale(1.1);
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text3);
}

.empty-icon-wrap {
  width: 68px;
  height: 68px;
  background: var(--surface2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  color: var(--text3);
  opacity: 0.5;
  animation: emptyFloat 3s ease-in-out infinite;
}

@keyframes emptyFloat {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-6px) rotate(4deg);
    opacity: 0.7;
  }
}

.empty-state p {
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 4px;
}
.empty-state small {
  font-size: 12px;
}

/* =====================================================
   CATEGORY COLORS - Icon backgrounds
   ===================================================== */
.cat-food {
  background: #fff8e1;
  color: #e65100;
}
.cat-travel {
  background: #e3f2fd;
  color: #1565c0;
}
.cat-shopping {
  background: #f3e5f5;
  color: #6a1b9a;
}
.cat-health {
  background: #e8f5e9;
  color: #2e7d32;
}
.cat-entertainment {
  background: #fce4ec;
  color: #c62828;
}
.cat-bills {
  background: #e0f2f1;
  color: #00695c;
}
.cat-education {
  background: #e8eaf6;
  color: #283593;
}
.cat-other {
  background: #f5f5f5;
  color: #424242;
}

[data-theme="dark"] .cat-food {
  background: #2c1f00;
  color: #ffb74d;
}
[data-theme="dark"] .cat-travel {
  background: #0d1e35;
  color: #64b5f6;
}
[data-theme="dark"] .cat-shopping {
  background: #200a2e;
  color: #ce93d8;
}
[data-theme="dark"] .cat-health {
  background: #0a1f0d;
  color: #81c784;
}
[data-theme="dark"] .cat-entertainment {
  background: #2c0a0a;
  color: #ef9a9a;
}
[data-theme="dark"] .cat-bills {
  background: #001f1d;
  color: #4db6ac;
}
[data-theme="dark"] .cat-education {
  background: #0a0d20;
  color: #9fa8da;
}
[data-theme="dark"] .cat-other {
  background: #1a1a1a;
  color: #bdbdbd;
}

/* Badge pills */
.badge-food {
  background: #fff3cd;
  color: #d4810a;
}
.badge-travel {
  background: #cfe2ff;
  color: #0a58ca;
}
.badge-shopping {
  background: #e9d5f5;
  color: #7b1fa2;
}
.badge-health {
  background: #d1f7da;
  color: #1b5e20;
}
.badge-entertainment {
  background: #fce8ef;
  color: #ad1457;
}
.badge-bills {
  background: #ccf5f1;
  color: #006064;
}
.badge-education {
  background: #dde1f5;
  color: #1a237e;
}
.badge-other {
  background: #eeeeee;
  color: #424242;
}

[data-theme="dark"] .badge-food {
  background: #2c1a00;
  color: #ffb74d;
}
[data-theme="dark"] .badge-travel {
  background: #0c1d30;
  color: #64b5f6;
}
[data-theme="dark"] .badge-shopping {
  background: #1d0828;
  color: #ce93d8;
}
[data-theme="dark"] .badge-health {
  background: #081a0b;
  color: #81c784;
}
[data-theme="dark"] .badge-entertainment {
  background: #260808;
  color: #ef9a9a;
}
[data-theme="dark"] .badge-bills {
  background: #001815;
  color: #4db6ac;
}
[data-theme="dark"] .badge-education {
  background: #080a1a;
  color: #9fa8da;
}
[data-theme="dark"] .badge-other {
  background: #141414;
  color: #bdbdbd;
}

/* =====================================================
   INSIGHTS
   ===================================================== */
.insights-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  animation: insightIn 0.38s var(--ease-out) both;
  transition:
    box-shadow var(--dur-fast) ease,
    border-color var(--dur-fast) ease !important;
}

@keyframes insightIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Non-expandable simple cards */
.insight-card:not(.ins-expandable) {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
}

.insight-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border2);
}

/* Expandable card layout */
.ins-expandable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  /* No transform on the card itself - avoids the shrink issue on expand */
}

.ins-expandable:hover {
  border-color: var(--border2);
}
.ins-expandable:hover .ins-chevron {
  color: var(--primary);
}

.ins-expandable.ins-open {
  border-color: var(--primary);
  box-shadow:
    0 0 0 1px var(--primary-glow),
    var(--shadow);
}
.ins-expandable.ins-open .ins-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

/* Card header row (icon + body) */
.ins-card-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
}

/* Detail panel - collapsed by default */
.ins-detail-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--ease-out);
}
.ins-expandable.ins-open .ins-detail-panel {
  max-height: 1200px;
}

.ins-detail-inner {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  animation: insDetailIn 0.3s var(--ease-out) both;
}

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

.ins-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}
.insight-card:hover .ins-icon {
  transform: scale(1.08) rotate(-5deg);
}

.ins-body {
  flex: 1;
  min-width: 0;
}

.ins-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.ins-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.ins-chevron {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  transition:
    transform 0.32s var(--ease-spring),
    color 0.22s ease !important;
}

.ins-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  margin-top: 4px;
}
.ins-text b {
  color: var(--primary);
  font-weight: 700;
}

.ins-tip {
  font-size: 11.5px;
  color: var(--text3);
  background: var(--surface3);
  border-radius: 8px;
  padding: 5px 9px;
  margin-top: 9px;
  border-left: 3px solid var(--primary-mid);
  line-height: 1.45;
}

/* Detail panel content */
.ins-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.ins-detail-stat-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 8px;
  text-align: center;
  min-width: 0;
}

.idsp-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.idsp-val {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ins-detail-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text3);
  margin-bottom: 8px;
}

.ins-detail-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ins-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  transition:
    border-color 0.18s,
    background 0.18s;
}
.ins-detail-row-highlight {
  border-color: var(--primary);
  background: var(--primary-light);
}

.ins-detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  min-width: 90px;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ins-detail-label .fa-solid {
  font-size: 10px;
  flex-shrink: 0;
  width: 13px;
  text-align: center;
}

.ins-detail-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 40px;
}

.ins-detail-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
  transition: width 0.5s var(--ease-out);
}

.ins-detail-val {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
  min-width: 52px;
}
.ins-detail-pct {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
}

.ins-detail-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text2);
}
.ins-detail-stat-row small {
  font-size: 10px;
  color: var(--text3);
  margin-left: 3px;
}
.ins-detail-stat-row b {
  color: var(--text);
}

.ins-detail-empty {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* =====================================================
   CHARTS
   ===================================================== */
.period-switcher {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
  position: relative;
}

/* Sliding pill behind the active button */
.period-switcher::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 9px;
  background: var(--primary);
  box-shadow: 0 2px 10px var(--primary-glow);
  pointer-events: none;
  z-index: 0;
  left: var(--pill-left, 4px);
  width: var(--pill-width, calc(25% - 4px));
  transition:
    left 0.28s var(--ease-out),
    width 0.28s var(--ease-out);
}

.period-btn {
  flex: 1;
  padding: 7px 4px;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition:
    color 0.22s ease,
    transform var(--dur-base) var(--ease-spring) !important;
}
.period-btn.active {
  color: #fff;
}
.period-btn:hover:not(.active) {
  color: var(--primary);
}
.period-btn:active {
  transform: scale(0.94) !important;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.22s ease !important;
}
.chart-card:hover {
  box-shadow: var(--shadow);
}

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.chart-title-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.18s,
    color 0.18s,
    transform 0.15s;
}
.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.chart-wrap {
  position: relative;
  height: 220px;
}
.chart-wrap-donut {
  height: 200px;
}
canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Empty-state overlay shown inside a chart-wrap when there's no data */
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-align: center;
  padding: 16px;
  pointer-events: none;
  animation: fadeIn 0.3s ease;
}
.chart-empty .fa-solid {
  font-size: 26px;
  color: var(--text3);
  opacity: 0.4;
}
.chart-empty p {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text3);
}

.weekly-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.weekly-stat-pill {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}

.weekly-stat-pill .pill-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  display: block;
  margin-bottom: 4px;
}
.weekly-stat-pill .pill-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  display: block;
}
.weekly-stat-pill.pill-up .pill-val {
  color: var(--danger);
}
.weekly-stat-pill.pill-down .pill-val {
  color: var(--success);
}

.cat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  justify-content: center;
}
.cat-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text2);
  font-weight: 600;
}
.cat-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =====================================================
   SETTINGS
   ===================================================== */
.settings-group {
  margin-bottom: 22px;
}

.settings-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text3);
  margin-bottom: 9px;
  padding: 0 2px;
}

.settings-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.s-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition:
    background 0.18s ease,
    transform 0.18s ease !important;
}
.s-row:last-child {
  border-bottom: none;
}
.s-row:hover {
  background: var(--surface2);
}
.s-row:active:not(.s-row-toggle):not(.s-row-timer) {
  transform: scale(0.99);
}
.s-row-danger:hover {
  background: var(--danger-bg);
}

.s-icon {
  width: 36px;
  height: 36px;
  background: var(--ib, #e3f0fb);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--ic, var(--primary));
  flex-shrink: 0;
  transition: transform var(--dur-base) var(--ease-spring) !important;
}
.s-row:hover .s-icon {
  transform: scale(1.1) rotate(-5deg);
}

.s-content {
  flex: 1;
  min-width: 0;
}
.s-title {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.s-sub {
  display: block;
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.s-arrow {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

/* Theme toggle row */
.s-row-toggle {
  justify-content: space-between;
  align-items: center;
  cursor: default;
}
.s-row-toggle:hover {
  background: transparent;
}
.s-row-toggle .s-icon {
  display: none;
} /* no icon for the toggle row */

/* =====================================================
   THEME TOGGLE
   ===================================================== */
.theme-toggle {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: 30px;
  padding: 3px;
  gap: 2px;
  position: relative;
  flex-shrink: 0;
}

.theme-btn {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text3);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition:
    color 0.25s ease,
    transform 0.25s var(--ease-spring) !important;
}
.theme-btn.active {
  color: var(--primary);
  transform: scale(1.18) !important;
}

.theme-slider {
  position: absolute;
  width: 30px;
  height: 30px;
  background: var(--primary-light);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  pointer-events: none;
  transition: transform 0.3s var(--ease-spring);
}
.theme-toggle[data-active="1"] .theme-slider {
  transform: translateX(0);
}
.theme-toggle[data-active="2"] .theme-slider {
  transform: translateX(32px);
}

/* =====================================================
   INACTIVITY TIMER - Segmented Control
   ===================================================== */
.s-row-timer {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  cursor: default;
}
.s-row-timer:hover {
  background: transparent;
}
.s-row-timer-top {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
}

.timer-segments {
  display: flex;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  width: 100%;
  position: relative;
}

.timer-segments::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 7px;
  background: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
  pointer-events: none;
  z-index: 0;
  left: var(--timer-pill-left, 3px);
  width: var(--timer-pill-width, calc(20% - 2px));
  transition:
    left 0.28s var(--ease-out),
    width 0.28s var(--ease-out);
}

.timer-seg {
  flex: 1;
  padding: 6px 4px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text3);
  cursor: pointer;
  text-align: center;
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  transition:
    color 0.22s ease,
    transform var(--dur-base) var(--ease-spring) !important;
}
.timer-seg.active {
  color: #fff;
}
.timer-seg:hover:not(.active) {
  color: var(--primary);
}

/* =====================================================
   BUDGET INPUT (Settings)
   ===================================================== */
.s-row-budget {
  cursor: default;
  justify-content: space-between;
  gap: 10px;
}
.s-row-budget:hover {
  background: transparent;
}
.s-row-budget .s-icon {
  display: flex;
} /* keep icon visible */

.budget-input-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 8px 0 10px;
  flex-shrink: 0;
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
.budget-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.budget-rupee {
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
}

.budget-field {
  width: 90px;
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  font-family: inherit;
  -moz-appearance: textfield;
}
.budget-field::-webkit-outer-spin-button,
.budget-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* =====================================================
   STORAGE SUMMARY
   ===================================================== */
.usage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
}
.usage-row:last-child {
  border-bottom: none;
}
.u-label {
  font-size: 13.5px;
  color: var(--text2);
  font-weight: 500;
}
.u-value {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
}

/* =====================================================
   ABOUT CARD
   ===================================================== */
.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.about-hero {
  background: var(--header-bg);
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.about-logo-circle {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
}
.about-hero-text .about-name {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}
.about-hero-text .about-ver {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.about-body {
  padding: 16px 18px 18px;
}
.about-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 14px;
}

.about-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.about-feat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
.about-feat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.about-feat-text {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text2);
  line-height: 1.3;
}

.about-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 14px;
}

.about-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.about-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.about-meta-label {
  font-size: 11.5px;
  color: var(--text3);
  font-weight: 500;
}
.about-meta-value {
  font-size: 11.5px;
  color: var(--text);
  font-weight: 700;
}

.about-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--primary);
  border-radius: 22px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  transition:
    background 0.18s,
    transform 0.15s;
  width: 100%;
  justify-content: center;
}
.about-link:hover {
  background: var(--primary-dark);
  color: #fff;
  text-decoration: none;
}

/* =====================================================
   PIN OVERLAY  - z-index 9999
   ===================================================== */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: var(--pin-overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  overflow-y: auto;
  animation: fadeIn 0.22s ease;
}

.pin-box {
  background: var(--surface);
  border-radius: 22px;
  padding: 26px 20px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  flex-shrink: 0;
  animation: scaleIn 0.28s var(--ease-spring);
}

.pin-logo {
  margin-bottom: 6px;
  line-height: 1;
}
.pin-logo .fa-solid {
  font-size: 32px;
  color: var(--primary);
}
.pin-box h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 3px;
}
.pin-sub {
  font-size: 12px;
  color: var(--text3);
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 11px;
  margin: 14px 0 18px;
}

.pin-dots span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--border2);
  transition:
    background 0.2s ease,
    transform 0.28s var(--ease-spring),
    box-shadow 0.2s ease !important;
}

.pin-dots span.filled {
  background: var(--primary);
  transform: scale(1.25);
  box-shadow:
    0 0 0 3px var(--primary-glow),
    0 2px 8px var(--primary-glow);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 260px;
  margin: 0 auto;
}

.pin-key {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.18s var(--ease-spring),
    box-shadow 0.15s !important;
}

.pin-key:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.07);
  box-shadow: 0 4px 12px var(--primary-glow);
}
.pin-key:active {
  transform: scale(0.88) !important;
  box-shadow: none !important;
}
.pin-action .fa-solid {
  font-size: 17px;
}

.pin-error {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 12px;
}
.pin-retry {
  font-size: 11.5px;
  color: var(--warning);
  margin-top: 8px;
}

/* Shake on wrong PIN */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}
.pin-box.shake {
  animation: shake 0.32s ease;
}

/* Flash on success */
@keyframes pinSuccess {
  0% {
    background: var(--surface);
  }
  30% {
    background: rgba(46, 125, 50, 0.1);
    box-shadow: 0 0 0 6px rgba(46, 125, 50, 0.08);
  }
  100% {
    background: var(--surface);
  }
}
.pin-box.success-flash {
  animation: pinSuccess 0.5s ease;
}

/* =====================================================
   MODALS  - z-index 3000
   ===================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--surface);
  border-radius: 22px;
  padding: 28px 24px;
  width: 350px;
  max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: scaleIn 0.26s var(--ease-spring);
}

.modal-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
  margin: 0 auto 13px;
}
.modal-icon-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-box h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 7px;
}
.modal-box p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 22px;
}

.modal-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.mbtn {
  padding: 9px 20px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  overflow: hidden;
  transition:
    background 0.18s,
    color 0.18s,
    transform 0.15s,
    border-color 0.18s !important;
}
.mbtn:hover {
  transform: translateY(-1px);
}
.mbtn:active {
  transform: scale(0.96);
}

.mbtn-outline {
  background: transparent;
  border-color: var(--border2);
  color: var(--text2);
}
.mbtn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.mbtn-primary {
  background: var(--primary);
  color: #fff;
}
.mbtn-primary:hover {
  background: var(--primary-dark);
}
.mbtn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text3);
}
.mbtn-ghost:hover {
  color: var(--text2);
}
.mbtn-danger {
  background: var(--danger);
  color: #fff;
}
.mbtn-danger:hover {
  background: #b71c1c;
}

/* =====================================================
   TOASTS  - z-index 8998
   ===================================================== */
#toast-container {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 8998;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  justify-content: center;
  text-align: center;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border-radius: 25px;
  padding: 11px 18px 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px var(--border);
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  white-space: nowrap;
  animation: toastIn 0.35s var(--ease-spring) forwards;
}

.toast > i.fa-solid {
  font-size: 15px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 100%;
  animation: progressBar 3.8s linear forwards;
}

.toast.success > i.fa-solid {
  color: var(--success);
}
.toast.success .toast-progress {
  background: var(--success);
}
.toast.error > i.fa-solid {
  color: var(--danger);
}
.toast.error .toast-progress {
  background: var(--danger);
}
.toast.info > i.fa-solid {
  color: var(--primary);
}
.toast.info .toast-progress {
  background: var(--primary);
}
.toast.warning > i.fa-solid {
  color: var(--warning);
}
.toast.warning .toast-progress {
  background: var(--warning);
}

/* Undo-action toast (used for delete-with-undo) */
.toast-undo-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: 0.2px;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}
.toast-undo-btn:hover {
  background: var(--primary);
  color: #fff;
}
.toast-undo-btn:active {
  transform: scale(0.94);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.01);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
}
.toast.hiding {
  animation: toastOut 0.22s ease forwards;
}

@keyframes progressBar {
  from {
    transform: scaleX(1);
    transform-origin: left;
  }
  to {
    transform: scaleX(0);
    transform-origin: left;
  }
}

/* =====================================================
   EXPENSE EDITING STATE
   ===================================================== */
.expense-item.being-edited {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary-glow);
  opacity: 0.72;
}

/* =====================================================
   SKELETON LOADER
   ===================================================== */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: 400px 0;
  }
}

.skeleton-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 13px;
  margin-bottom: 7px;
}

.skeleton-block {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface2) 25%,
    var(--surface3) 50%,
    var(--surface2) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 12px;
}
.skeleton-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.skeleton-line-a {
  height: 12px;
  width: 65%;
  border-radius: 6px;
}
.skeleton-line-b {
  height: 9px;
  width: 40%;
  border-radius: 6px;
}
.skeleton-amount {
  width: 52px;
  height: 14px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* =====================================================
   SCROLL-REVEAL
   ===================================================== */
.expense-item.reveal-hidden {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.32s ease,
    transform 0.32s ease;
}
.expense-item.reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================
   SHARED KEYFRAMES
   ===================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeUpIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.92) translateY(8px);
    opacity: 0;
  }
  65% {
    transform: scale(1.01) translateY(-1px);
    opacity: 1;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* =====================================================
   FOCUS-VISIBLE ACCESSIBILITY
   ===================================================== */
.cat-btn:focus-visible,
.btn-record:focus-visible,
.sort-btn:focus-visible,
.period-btn:focus-visible,
.timer-seg:focus-visible,
.tab-btn:focus-visible,
.mbtn:focus-visible,
.s-row:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* =====================================================
   RIPPLE
   ===================================================== */
.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  pointer-events: none;
  z-index: 0;
  animation: rippleAnim 0.5s ease forwards;
}
[data-theme="dark"] .ripple-wave {
  background: rgba(255, 255, 255, 0.12);
}

@keyframes rippleAnim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* =====================================================
   HOME TAB BACKGROUND
   ===================================================== */
#tab-home {
  background: var(--bg);
}

/* =====================================================
   RESPONSIVE - ≤ 600px
   ===================================================== */
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .field-group-desc {
    grid-column: 1 / -1;
  }

  .chip-label {
    display: none;
  }
  .chip-amount {
    font-size: 13px;
    line-height: 1;
  }
  .header-chip {
    padding: 6px 10px;
  }

  #toast-container {
    left: 50%;
    right: auto;
    width: max-content;
    max-width: min(360px, calc(100vw - 32px));
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .stat-value {
    font-size: 15px;
  }
  .stat-sub {
    font-size: 9px;
  }
  .period-btn {
    font-size: 11px;
    padding: 6px 2px;
  }
  .tab-inner {
    padding: 16px 14px 28px;
  }
  .form-card {
    margin: 4px 10px 12px;
  }
  .history-section {
    padding: 0 10px 20px;
  }
  .stats-strip {
    padding: 10px 10px 6px;
    gap: 7px;
  }
  .search-field input {
    width: 100px;
  }

  /* Always show actions on touch devices */
  .exp-actions {
    opacity: 1;
  }

  .s-row-toggle {
    flex-wrap: nowrap;
    align-items: center;
  }

  .about-features {
    grid-template-columns: 1fr;
  }

  .pin-box {
    padding: 20px 14px 20px;
  }
  .pin-logo .fa-solid {
    font-size: 28px;
  }
  .pin-box h2 {
    font-size: 15px;
  }
  .pin-keypad {
    gap: 6px;
    max-width: 230px;
  }
  .pin-key {
    font-size: 18px;
  }
  .pin-action .fa-solid {
    font-size: 15px;
  }

  .sort-btn {
    font-size: 11.5px;
    padding: 5px 10px;
  }
  .cat-filter-wrap:last-child .cat-dropdown {
    left: auto;
    right: 0;
  }

  .ins-detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .ins-detail-label {
    min-width: 72px;
    max-width: 90px;
    font-size: 11px;
  }
  .ins-detail-val {
    font-size: 11px;
    min-width: 44px;
  }
}

/* =====================================================
   RESPONSIVE - ≤ 380px
   ===================================================== */
@media (max-width: 380px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field-group-desc {
    grid-column: 1;
  }
  .filter-bar {
    gap: 5px;
  }
  .sort-btn {
    font-size: 11px;
    padding: 5px 9px;
    gap: 4px;
  }
  .sort-btn span {
    display: none;
  }
  .sort-btn .fa-solid:first-child {
    font-size: 12px;
  }
  .pin-keypad {
    max-width: 200px;
    gap: 5px;
  }
  .pin-key {
    font-size: 16px;
  }
}

/* =====================================================
   RESPONSIVE - ≥ 901px (desktop)
   ===================================================== */
@media (min-width: 901px) {
  .form-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
  .field-group-desc {
    grid-column: 1;
  }
  .cat-grid {
    flex-wrap: nowrap;
  }
  .search-field input {
    width: 220px;
  }
  .filter-bar {
    flex-wrap: nowrap;
  }
  .tab-inner {
    padding: 24px 28px 40px;
  }
  .about-features {
    grid-template-columns: 1fr 1fr;
  }
  .insights-grid {
    gap: 14px;
  }
}
