/* Budget Bot — Custom Styles */
[x-cloak] { display: none !important; }
/* Telegram CSS variable fallbacks */
:root {
  --tg-theme-bg-color:          #FAFAF8;
  --tg-theme-text-color:        #141414;
  --tg-theme-hint-color:        #8A8A8A;
  --tg-theme-link-color:        #2D6A5E;
  --tg-theme-button-color:      #2D6A5E;
  --tg-theme-button-text-color: #FFFFFF;
  --tg-theme-secondary-bg-color:#F2F2EF;
  --tg-theme-header-bg-color:   #FAFAF8;
  --tg-theme-accent-text-color: #2D6A5E;
  --tg-theme-section-bg-color:  #FFFFFF;
  --tg-theme-section-separator-color: #E5E5E0;

  /* Design tokens */
  --accent:        #2D6A5E;
  --accent-light:  #EBF3F1;
  --accent-dim:    #3D8A7A;
  --danger:        #D94F4F;
  --danger-light:  #FAEAEA;
  --success:       #3D9E6E;
  --success-light: #E8F5EE;
  --warning:       #C47E2A;
  --warning-light: #FDF3E3;

  --text-primary:   var(--tg-theme-text-color);
  --text-secondary: var(--tg-theme-hint-color);
  --bg-primary:     var(--tg-theme-bg-color);
  --bg-secondary:   var(--tg-theme-secondary-bg-color);
  --bg-card:        var(--tg-theme-section-bg-color);
  --border:         var(--tg-theme-section-separator-color);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --radius-full: 999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  :root {
    --tg-theme-bg-color:          #1C1C1E;
    --tg-theme-text-color:        #F2F2F2;
    --tg-theme-hint-color:        #8E8E93;
    --tg-theme-secondary-bg-color:#2C2C2E;
    --tg-theme-section-bg-color:  #2C2C2E;
    --tg-theme-section-separator-color: #3A3A3C;
    --accent-light:  #1A3A34;
    --danger-light:  #3A1A1A;
    --success-light: #1A3A28;
    --warning-light: #3A2810;
  }
}

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg-primary);
  color: var(--text-primary);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* Number display */
.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Hero amount */
.hero-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-primary);
}

/* Category chip */
.cat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 64px;
  flex-shrink: 0;
}

.cat-chip:active, .cat-chip.selected {
  background: var(--accent-light);
  border-color: var(--accent);
}

.cat-chip .emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.cat-chip .label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.cat-chip.selected .label {
  color: var(--accent);
}

/* Currency chip */
.cur-chip {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
}

.cur-chip.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Date chips */
.date-chip {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
}

.date-chip.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Amount input */
.amount-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  color: var(--text-primary);
  caret-color: var(--accent);
}

.amount-input::placeholder {
  color: var(--border);
}

/* Primary button */
.btn-primary {
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  padding: 15px 24px;
  width: 100%;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
}

.btn-primary:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 14px 20px;
  width: 100%;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:active {
  opacity: 0.8;
}

/* Expense row */
.expense-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  transition: background 0.1s;
}

.expense-row:active {
  background: var(--bg-secondary);
}

.expense-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Bottom bar */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 100;
}

/* Tab bar */
.tab-bar {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.tab-item {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-full);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.tab-item.active {
  background: white;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Trend badge */
.trend-up {
  color: var(--danger);
  background: var(--danger-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.trend-down {
  color: var(--success);
  background: var(--success-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Category bar */
.cat-bar-track {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stats table */
.stats-table td, .stats-table th {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.stats-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-table tr:last-child td {
  border-bottom: none;
}

/* Receipt upload area */
.receipt-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.receipt-zone:hover, .receipt-zone:active {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Scrollbar hide */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Section divider */
.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Donut legend dot */
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Filter chip */
.filter-chip {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Swipe action hint */
.swipe-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: right;
  padding: 0 16px 8px;
}

/* Input field */
.field-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

/* iOS Safari forces intrinsic width on date/time inputs unless we
   neutralize the default control rendering. */
.field-input[type="date"],
.field-input[type="time"],
.field-input[type="datetime-local"] {
  display: block;
  min-height: 44px;
  text-align: left;
}
.field-input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-width: 0;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.field-input::placeholder {
  color: var(--text-secondary);
}

/* Page header */
.page-header {
  padding: 16px 16px 12px;
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
}

/* Animation */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-up {
  animation: slideUp 0.3s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.2s ease forwards;
}

/* Month switcher */
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  border: none;
}

.month-nav-btn:active {
  background: var(--accent-light);
  color: var(--accent);
}

/* Separator line */
.sep {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

/* Big add button */
.add-btn {
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  flex: 1;
}

.add-btn:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.stats-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.stats-btn:active {
  opacity: 0.8;
}

/* ── Loading primitives ── */
.tg-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--tg-theme-hint-color, #8A8A8A);
  border-top-color: var(--tg-theme-button-color, #2D6A5E);
  border-radius: 50%;
  animation: tg-spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes tg-spin { to { transform: rotate(360deg); } }

.tg-skeleton {
  background: linear-gradient(
    90deg,
    var(--tg-theme-secondary-bg-color, #f0f0f0) 25%,
    var(--tg-theme-bg-color, #fff) 50%,
    var(--tg-theme-secondary-bg-color, #f0f0f0) 75%
  );
  background-size: 200% 100%;
  animation: tg-shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes tg-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error banner */
.tg-error-banner {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border-left: 3px solid var(--danger, #D94F4F);
  font-size: 0.8rem;
  color: var(--tg-theme-destructive-text-color, var(--danger, #D94F4F));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tg-error-banner button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0;
  flex-shrink: 0;
}
