:root {
  --ink: #f4f4f5;
  --paper: #0c0c0e;
  --card: #18181b;
  --line: #27272a;
  --muted: #a1a1aa;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

.bg-grid {
  background-image:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.12), transparent 32%),
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}

.hero-card,
.kpi-card,
.chart-card {
  animation: rise 420ms ease both;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-radius: 1.25rem;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8);
}

.kpi-icon {
  display: grid;
  height: 2.25rem;
  width: 2.25rem;
  place-items: center;
  border-radius: 0.85rem;
}

.kpi-icon svg {
  height: 1.05rem;
  width: 1.05rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  word-break: break-all;
}

.period-btn,
.nav-btn,
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #3f3f46;
  background: #18181b;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #d4d4d8;
  transition: 160ms ease;
}

.period-btn.hidden,
.nav-btn.hidden,
.tab-btn.hidden {
  display: none;
}

.period-btn.is-active,
.tab-btn.is-active,
.nav-btn.is-active {
  background: #f4f4f5;
  border-color: #f4f4f5;
  color: #0c0c0e;
}

.nav-btn:hover,
.period-btn:hover,
.tab-btn:hover {
  border-color: #2dd4bf;
  color: #2dd4bf;
}

.tab-btn.is-active:hover,
.period-btn.is-active:hover {
  color: #0c0c0e;
}

.chart-card {
  border-radius: 1.5rem;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 1.1rem 1.1rem 0.5rem;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.8);
}

.chart-title {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.tx-card,
.recurring-card {
  display: grid;
  gap: 0.65rem;
  border-radius: 1.15rem;
  border: 1px solid #27272a;
  background: #101014;
  padding: 0.9rem 1rem;
}

@media (min-width: 768px) {
  .tx-card {
    grid-template-columns: 7.5rem 1fr auto;
    align-items: center;
  }
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end;
}

@media (min-width: 640px) {
  .modal {
    place-items: center;
    padding: 1.5rem;
  }
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.field {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid #3f3f46;
  background: #09090b;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f4f4f5;
  outline: none;
}

.field:focus {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.18);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(32rem, 100%);
  max-height: min(92vh, 44rem);
  overflow-y: auto;
  border-radius: 1.5rem 1.5rem 0 0;
  border: 1px solid var(--line);
  background: #18181b;
  padding: 1.35rem;
  animation: slide-up 280ms ease;
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: 1.5rem;
  }
}

.toast {
  pointer-events: auto;
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  animation: toast-in 220ms ease;
}

.toast-ok {
  background: #0f766e;
}

.toast-err {
  background: #be123c;
}

.spinner {
  height: 1rem;
  width: 1rem;
  border-radius: 999px;
  border: 2px solid rgba(9, 9, 11, 0.25);
  border-top-color: #09090b;
  animation: spin 700ms linear infinite;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
