﻿:root {
  --bg-1: #020b28;
  --bg-2: #07205a;
  --bg-3: #0b3a8a;
  --ink: #f4f6ff;
  --muted: #9aa9d0;
  --panel: rgba(4, 16, 46, 0.9);
  --panel-strong: rgba(3, 15, 44, 0.96);
  --panel-solid: #04102e;
  --border: rgba(245, 197, 66, 0.24);
  --accent-yellow: #f5c542;
  --accent-yellow-strong: #ffde75;
  --accent-blue: #132e66;
  --accent-blue-soft: #1b3f87;
  --income: #4ade80;
  --expense: #f87171;
  --net: #60a5fa;
  --total: #f5c542;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--panel-solid);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  overflow-x: hidden;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background: var(--panel-solid);
  overscroll-behavior: none;
  overflow-x: hidden;
  padding: 0;
  touch-action: manipulation;
}

.bg-wrap {
  display: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(3px);
  opacity: 0.35;
}

.blob-a {
  width: 260px;
  height: 260px;
  background: rgba(65, 126, 255, 0.28);
  top: -110px;
  left: -70px;
}

.blob-b {
  width: 360px;
  height: 360px;
  background: rgba(30, 90, 255, 0.26);
  top: 35%;
  right: -170px;
}

.blob-c {
  width: 300px;
  height: 300px;
  background: rgba(86, 140, 255, 0.22);
  bottom: -150px;
  left: 30%;
}

.page {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px;
  position: relative;
  z-index: 2;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}

.auth-panel {
  width: min(560px, 100%);
  margin: 30px auto;
  padding: 22px;
}

.lead {
  margin: 10px 0 20px;
  color: var(--muted);
}

.auth-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid rgba(245, 197, 66, 0.3);
  background: rgba(17, 31, 61, 0.74);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip.active {
  background: linear-gradient(130deg, var(--accent-yellow), #ffe08a);
  border-color: transparent;
  color: #0c1222;
}

.form {
  display: grid;
  gap: 12px;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.form input,
.form select {
  width: 100%;
  border: 1px solid rgba(245, 197, 66, 0.22);
  border-radius: 11px;
  padding: 10px 12px;
  background: rgba(8, 20, 45, 0.95);
  color: var(--ink);
  font-size: 16px;
}

.form input:focus,
.form select:focus {
  outline: 2px solid rgba(245, 197, 66, 0.35);
  outline-offset: 1px;
}

.btn {
  border: 1px solid #2a4f94;
  background: linear-gradient(140deg, #0c2046, #19386f);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.btn.primary {
  background: linear-gradient(130deg, var(--accent-yellow), #ffe08a);
  color: #0c1222;
  font-weight: 800;
  border-color: rgba(255, 222, 117, 0.8);
}

.error {
  min-height: 20px;
  color: #fb7185;
  margin: 8px 0 0;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

a {
  color: #ffe08a;
}

.dashboard {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.overview-tools,
.history-tools {
  padding: 12px 16px;
  margin-top: 12px;
  margin-bottom: 4px;
  overflow: hidden;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.topbar-controls {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}

.month-field {
  display: grid;
  gap: 6px;
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.month-field input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(245, 197, 66, 0.22);
  border-radius: 11px;
  padding: 10px 12px;
  background: rgba(8, 20, 45, 0.95);
  color: var(--ink);
  font-size: 16px;
}

.month-field input:focus {
  outline: 2px solid rgba(245, 197, 66, 0.35);
  outline-offset: 1px;
}

.month-field input::-webkit-calendar-picker-indicator {
  filter: invert(87%) sepia(28%) saturate(793%) hue-rotate(327deg) brightness(104%) contrast(96%);
}

.tabs-nav {
  display: none;
  margin-top: 12px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(10, 20, 44, 0.85);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.tabs-nav-btn,
.mobile-nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  min-height: 42px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tabs-nav-btn.active,
.mobile-nav-btn.active {
  background: linear-gradient(130deg, var(--accent-yellow), #ffe08a);
  color: #0b1327;
  box-shadow: 0 8px 18px rgba(245, 197, 66, 0.24);
}

.dashboard-block {
  margin-top: 12px;
  display: none;
}

.dashboard-block.active {
  display: grid;
  gap: 12px;
  animation: tabFadeIn 0.2s ease;
}

.stats-grid,
.charts-grid,
.lists-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-card {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  right: -54px;
  top: -54px;
  opacity: 0.18;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 5vw, 30px);
  font-family: 'Space Grotesk', sans-serif;
}

.stat-card small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}

.stat-card.income::after {
  background: var(--income);
}

.stat-card.expense::after {
  background: var(--expense);
}

.stat-card.net::after {
  background: var(--net);
}

.stat-card.total::after {
  background: var(--total);
}

.stat-card.subscription::after {
  background: #7dd3fc;
}

.charts-grid {
  margin-top: 0;
}

.chart-card {
  padding: 16px;
  min-height: 280px;
}

.chart-canvas-wrap {
  margin-top: 10px;
  height: 250px;
  position: relative;
}

.chart-filter {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  max-width: 320px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.chart-filter select {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(245, 197, 66, 0.22);
  border-radius: 11px;
  padding: 10px 12px;
  background: rgba(8, 20, 45, 0.95);
  color: var(--ink);
  font-size: 16px;
}

.chart-card canvas {
  margin-top: 10px;
  max-height: 250px;
}

.chart-canvas-wrap canvas {
  margin-top: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: none;
}

.chart-breakdown {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.chart-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(245, 197, 66, 0.14);
  border-radius: 10px;
  background: rgba(8, 20, 45, 0.55);
}

.chart-breakdown-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.chart-breakdown-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-breakdown-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.chart-breakdown-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.chart-breakdown-share {
  font-size: 12px;
  color: var(--muted);
}

.chart-breakdown-empty {
  margin: 2px 0 0;
  font-size: 13px;
}

.lists-grid > article,
.table-section,
.settings-card {
  padding: 16px;
}

.settings-form {
  margin-top: 14px;
  max-width: 560px;
}

.settings-categories {
  margin-top: 12px;
}

.settings-accounts {
  margin-top: 12px;
}

.settings-budget {
  margin-top: 12px;
}

.settings-subscriptions {
  margin-top: 12px;
}

.settings-logout-card {
  margin-top: 12px;
}

.settings-logout-btn {
  width: 100%;
}

.settings-status {
  min-height: 20px;
  margin: 8px 0 0;
}

.history-add-card {
  margin-bottom: 12px;
  overflow: hidden;
}

.history-add-card input[type='date'] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.overview-tools input[type='month'],
.history-tools input[type='month'],
.history-add-card input[type='date'] {
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-balances-panel {
  padding: 16px;
}

.account-balances-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-balance-item {
  border: 1px solid rgba(245, 197, 66, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(8, 20, 45, 0.66);
}

.account-balance-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.account-balance-item strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  font-family: 'Space Grotesk', sans-serif;
}

.list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(245, 197, 66, 0.18);
  background: rgba(8, 20, 45, 0.66);
  font-size: 14px;
}

.category-cloud {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.category-pill {
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.category-group {
  border: 1px solid rgba(245, 197, 66, 0.16);
  border-radius: 14px;
  padding: 12px;
  background: rgba(9, 20, 41, 0.66);
}

.category-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.category-head-meta {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.category-type-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.category-delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  padding: 0;
  flex: 0 0 auto;
}

.category-empty {
  margin-top: 10px;
  font-size: 16px;
}

.subcategory-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subcategory-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  max-width: 100%;
}

.subcategory-pill > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subcategory-delete-btn {
  border-radius: 999px;
  padding: 0;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(9, 20, 41, 0.45);
}

.mobile-card-list {
  margin-top: 10px;
  display: none;
  gap: 10px;
}

.mobile-data-empty {
  border: 1px solid rgba(245, 197, 66, 0.18);
  border-radius: 12px;
  padding: 12px;
  background: rgba(8, 20, 45, 0.66);
}

.mobile-data-card {
  border: 1px solid rgba(245, 197, 66, 0.18);
  border-radius: 12px;
  padding: 12px;
  background: rgba(8, 20, 45, 0.66);
  display: grid;
  gap: 10px;
}

.mobile-data-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mobile-data-title {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.mobile-data-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-data-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mobile-data-label {
  color: var(--muted);
  font-size: 12px;
}

.mobile-data-value {
  min-width: 0;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}

.mobile-data-note {
  font-weight: 500;
  color: var(--ink);
}

.mobile-data-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

thead th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid rgba(245, 197, 66, 0.2);
  padding: 8px;
}

tbody td {
  padding: 11px 8px;
  border-bottom: 1px solid rgba(245, 197, 66, 0.09);
  font-size: 14px;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

.badge {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.badge.income {
  color: #a7f3d0;
  background: rgba(20, 83, 45, 0.6);
}

.badge.expense {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.65);
}

.text-income {
  color: #86efac;
  font-weight: 700;
}

.text-expense {
  color: #fca5a5;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid rgba(245, 197, 66, 0.26);
  background: rgba(12, 27, 54, 0.8);
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}

.mobile-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  border: 1px solid var(--border);
  background: rgba(8, 18, 39, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
}

.quick-fab {
  position: fixed;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 48;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 225, 122, 0.6);
  background: linear-gradient(145deg, var(--accent-yellow), #ffe089);
  color: #0c1222;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45);
}

.quick-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 18, 0.62);
  z-index: 46;
}

.quick-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 47;
  border: 1px solid rgba(245, 197, 66, 0.3);
  background: var(--panel-strong);
  border-radius: 18px;
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.52);
  padding: 14px;
}

.quick-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.quick-form {
  gap: 10px;
}

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

.tx-switch-btn {
  border: 1px solid rgba(245, 197, 66, 0.2);
  border-radius: 10px;
  min-height: 40px;
  background: rgba(10, 23, 49, 0.95);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.tx-switch-btn.active {
  background: linear-gradient(130deg, var(--accent-yellow), #ffe08a);
  color: #0b1327;
  border-color: transparent;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: calc(160px + env(safe-area-inset-bottom));
  background: rgba(9, 16, 30, 0.98);
  color: #fff;
  border: 1px solid rgba(245, 197, 66, 0.28);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  z-index: 60;
}

@keyframes bgShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

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

@media (max-width: 759px) {
  body {
    animation: none;
    background-size: 100% 100%;
  }

  .blob {
    display: none;
  }

  .page {
    padding: 10px;
  }

  .overview-tools,
  .history-tools {
    padding: 10px 12px;
    margin-top: 10px;
    margin-bottom: 2px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .month-field,
  .history-add-card,
  .history-add-card .settings-form,
  .history-add-card .settings-form label {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .history-add-card .settings-form {
    max-width: none;
    gap: 10px;
  }

  .overview-tools input[type='month'],
  .history-tools input[type='month'],
  .month-field input,
  .history-add-card input[type='date'] {
    inline-size: 100%;
    max-inline-size: 100%;
    min-inline-size: 0;
    height: 46px;
    font-size: 15px;
    line-height: 1.2;
    padding: 10px 12px;
    text-align: left;
  }

  .overview-tools input[type='month']::-webkit-date-and-time-value,
  .history-tools input[type='month']::-webkit-date-and-time-value,
  .month-field input::-webkit-date-and-time-value,
  .history-add-card input[type='date']::-webkit-date-and-time-value {
    text-align: left;
    white-space: nowrap;
  }

  .chart-card {
    min-height: auto;
    padding: 14px;
  }

  .chart-filter {
    max-width: none;
  }

  .chart-canvas-wrap {
    height: 214px;
  }

  .chart-breakdown {
    max-height: 220px;
  }

  #section-history .table-wrap,
  #section-subscriptions .table-wrap {
    display: none;
  }

  #section-history .mobile-card-list,
  #section-subscriptions .mobile-card-list {
    display: grid;
  }

  #section-history .table-section,
  #section-subscriptions .table-section,
  .history-add-card,
  .settings-categories {
    padding: 14px;
  }

  .list-item {
    align-items: flex-start;
  }

  .list-item > :last-child {
    flex-shrink: 0;
  }

  .category-group {
    padding: 10px;
    border-radius: 12px;
  }

  .category-pill {
    font-size: 11px;
    padding: 6px 10px;
  }

  .category-type-line {
    font-size: 12px;
  }

  .subcategory-list {
    gap: 8px;
  }

  .subcategory-pill {
    font-size: 13px;
    padding: 6px 9px;
  }

  .mobile-data-actions .ghost-btn,
  .mobile-data-head .ghost-btn {
    min-height: 30px;
    padding: 4px 8px;
  }
}

@media (min-width: 760px) {
  .page {
    padding: 20px;
  }

  .stats-grid,
  .charts-grid,
  .lists-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-card.wide {
    grid-column: 1 / -1;
  }

  .mobile-nav {
    left: 20px;
    right: 20px;
  }

  .quick-sheet {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 40px));
    transform: translateX(-50%);
  }

  .account-balances-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
  }

  .topbar-controls {
    width: auto;
    justify-content: flex-end;
  }

  .stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #section-history.dashboard-block.active {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    align-items: start;
  }

  #section-history .history-tools {
    grid-column: 1 / -1;
  }

  #section-history .history-add-card {
    margin-bottom: 0;
  }

  .account-balances-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1120px) {
  .dashboard {
    padding-bottom: 36px;
  }

  .tabs-nav {
    display: grid;
  }

  #section-settings.dashboard-block.active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  #section-settings > .settings-card:first-child,
  #section-settings .settings-logout-card {
    grid-column: 1 / -1;
  }

  .mobile-nav {
    display: none;
  }

  .quick-fab {
    bottom: 24px;
    right: 24px;
  }

  .quick-sheet {
    bottom: 96px;
  }

  .toast {
    bottom: 24px;
  }
}
