@import url("./variables.css");

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 34rem),
    linear-gradient(180deg, var(--bg) 0%, #0b1120 100%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[data-theme="light"] body,
body[data-theme="light"] {
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.13), transparent 34rem),
    linear-gradient(180deg, var(--bg) 0%, #e9eef7 100%);
}

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

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) 6.5rem;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--space-5);
}

.auth-card {
  width: min(440px, 100%);
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: white;
  box-shadow: 0 16px 32px rgba(59, 130, 246, 0.28);
}

.brand h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(1.65rem, 6vw, 2.5rem);
  line-height: 1.05;
}

.brand p,
.page-title p,
.muted {
  margin: var(--space-1) 0 0;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  padding: 5px;
  margin-bottom: var(--space-5);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
}

.tab-btn {
  min-height: 44px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 180ms var(--ease);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 12px 26px rgba(59, 130, 246, 0.25);
}

.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--bg-soft);
  color: var(--text);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.textarea {
  min-height: 96px;
  padding-top: var(--space-3);
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 80%, white);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.btn {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  background: var(--card-strong);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), background 160ms var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 14px 30px rgba(59, 130, 246, 0.28);
}

.btn.danger {
  background: color-mix(in srgb, var(--danger) 18%, var(--card));
  color: #fecaca;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.icon-btn {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 15px;
  background: var(--card-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}

.icon-btn:hover,
.nav-link:hover {
  background: color-mix(in srgb, var(--primary) 15%, var(--card));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0 var(--space-5);
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}

.top-actions {
  display: flex;
  gap: var(--space-2);
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.summary-grid {
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: var(--shadow-soft);
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
}

.summary-card.balance {
  min-height: 166px;
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.92), rgba(20, 184, 166, 0.86)),
    var(--primary);
  color: white;
}

.summary-card h2,
.panel-title h2 {
  margin: 0;
  font-size: 0.86rem;
  color: color-mix(in srgb, currentColor 72%, transparent);
  text-transform: uppercase;
}

.money {
  margin: var(--space-3) 0 0;
  font-size: clamp(1.6rem, 8vw, 3rem);
  font-weight: 900;
}

.summary-card .trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: color-mix(in srgb, currentColor 74%, transparent);
  font-size: 0.9rem;
  font-weight: 700;
}

.panel {
  padding: var(--space-5);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.filters .wide {
  grid-column: 1 / -1;
}

.period-custom {
  display: none;
}

.filters.custom-period .period-custom {
  display: block;
}

.transaction-list,
.category-list {
  display: grid;
  gap: var(--space-3);
}

.transaction,
.category-item {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}

.avatar {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 16px;
  color: white;
}

.tone-3b82f6 { background: #3b82f6; }
.tone-22c55e { background: #22c55e; }
.tone-ef4444 { background: #ef4444; }
.tone-f97316 { background: #f97316; }
.tone-8b5cf6 { background: #8b5cf6; }
.tone-14b8a6 { background: #14b8a6; }
.tone-eab308 { background: #eab308; }
.tone-ec4899 { background: #ec4899; }
.tone-64748b { background: #64748b; }
.tone-06b6d4 { background: #06b6d4; }
.tone-a855f7 { background: #a855f7; }
.tone-10b981 { background: #10b981; }

.item-title {
  min-width: 0;
}

.item-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

.amount {
  font-weight: 900;
  text-align: right;
}

.amount.expense {
  color: #fca5a5;
}

.amount.income {
  color: #86efac;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chart-box {
  position: relative;
  height: 260px;
}

.empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: var(--space-6);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.skeleton {
  min-height: 74px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--card-strong), var(--bg-soft), var(--card-strong));
  background-size: 240% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

.fab {
  position: fixed;
  right: max(var(--space-5), calc((100vw - 1120px) / 2 + var(--space-5)));
  bottom: 5.8rem;
  z-index: 30;
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: white;
  box-shadow: 0 20px 36px rgba(37, 99, 235, 0.36);
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  width: min(1120px, calc(100% - 1rem));
  margin: 0 auto var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.nav-link {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: 18px;
  color: var(--muted);
  font-weight: 800;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}

.nav-link.active {
  background: color-mix(in srgb, var(--primary) 16%, var(--card));
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(12px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(560px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
  animation: modalIn 220ms var(--ease);
}

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.modal-head h2 {
  margin: 0;
}

.color-grid,
.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
}

.swatch,
.icon-choice {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 15px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
}

.swatch.active,
.icon-choice.active {
  border-color: white;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.32);
}

.toastify {
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  font-family: var(--font);
  font-weight: 800;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
