/* ==========================================================================
   Variables
   ========================================================================== */
:root {
  --bg: #0d0f18;
  --ink: #dde1f0;
  --ink-deep: #eef0ff;
  --muted: #6e7491;
  --panel: rgba(18, 21, 35, 0.75);
  --panel-strong: rgba(22, 25, 42, 0.92);
  --line: rgba(130, 120, 255, 0.1);
  --border: rgba(130, 120, 255, 0.18);

  /* Палитра — нестандартные углы, не из Tailwind */
  --accent: #8276ff;        /* 246° — тёплый фиолет, не standard indigo */
  --accent-2: #b998ff;      /* 270° — lavender с насыщением */
  --accent-dark: #6259e8;
  --accent-soft: rgba(130, 118, 255, 0.1);

  --income: #3ecfb2;        /* 168° — персидский тил, холоднее emerald */
  --income-soft: rgba(62, 207, 178, 0.1);
  --expense: #ff6b7a;       /* 354° — тёплый коралловый, не standard red */
  --expense-soft: rgba(255, 107, 122, 0.1);

  --shadow-md: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 48px rgba(130, 118, 255, 0.07);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 11px;
}

/* ==========================================================================
   Reset
   ========================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle, rgba(130, 118, 255, 0.18) 1px, transparent 1px),
    radial-gradient(ellipse at 15% 0%, rgba(130, 118, 255, 0.1) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 5%, rgba(185, 152, 255, 0.07) 0%, transparent 40%),
    var(--bg);
  background-size: 26px 26px, auto, auto;
}

button, input, select { font: inherit; }
option { background: #1c2032; color: var(--ink); }

/* ==========================================================================
   Ambient background layer (responds to balance mood via JS)
   ========================================================================== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(ellipse at 50% -5%, rgba(130, 118, 255, 0.14), transparent 50%);
  transition: background 0.7s ease;
}

body[data-balance-mood="positive"]::before {
  background: radial-gradient(ellipse at 50% -5%, rgba(62, 207, 178, 0.13), transparent 50%);
}

body[data-balance-mood="negative"]::before {
  background: radial-gradient(ellipse at 50% -5%, rgba(255, 107, 122, 0.11), transparent 50%);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 36px 16px 10px; }
.dashboard { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); gap: 14px; margin-bottom: 14px; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  text-align: center;
  margin-bottom: 22px;
  animation: revealIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 12px;
  padding: 7px 14px;
  border: 1px solid rgba(108, 142, 245, 0.22);
  border-radius: 999px;
  background: rgba(108, 142, 245, 0.08);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 20px rgba(0, 0, 0, 0.2);
}

.brand-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(108, 142, 245, 0.8);
}

.brand-badge__text, .site-kicker, .panel__eyebrow, .field__label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-badge__text, .site-kicker { color: var(--accent); }
.site-kicker { margin: 0 0 12px; }

.site-title {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  background: linear-gradient(105deg, var(--ink-deep) 0%, var(--ink-deep) 30%, var(--accent) 65%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-subtitle {
  max-width: 760px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.08rem);
  line-height: 1.55;
}

/* ==========================================================================
   Dashboard — summary cards & flow meter
   ========================================================================== */
.summary-card, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 158px;
  border-radius: var(--radius-lg);
  padding: 20px;
  background: var(--panel);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.4), var(--shadow-glow);
  border-color: rgba(108, 142, 245, 0.22);
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108, 142, 245, 0.08), transparent 70%);
}

.summary-card--balance {
  border-color: transparent;
  background:
    var(--panel) padding-box,
    linear-gradient(135deg, rgba(130, 118, 255, 0.45), rgba(62, 207, 178, 0.15), rgba(185, 152, 255, 0.3)) border-box;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.summary-card--balance:hover {
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.45), 0 0 50px rgba(130, 118, 255, 0.1);
}

.summary-card--income::after {
  background: radial-gradient(circle, rgba(52, 211, 153, 0.1), transparent 70%);
}

.summary-card--expense::after {
  background: radial-gradient(circle, rgba(248, 113, 113, 0.1), transparent 70%);
}

.summary-card__label, .summary-card__hint { margin: 0; color: var(--muted); }
.summary-card__label { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }

.summary-card__value {
  position: relative;
  z-index: 1;
  margin: 10px 0 6px;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1;
  color: var(--ink-deep);
  font-variant-numeric: tabular-nums;
}

.summary-card__value.is-positive { color: var(--income); }
.summary-card__value.is-negative { color: var(--expense); }
.summary-card__hint { font-size: 0.84rem; }

.flow-meter {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.flow-meter__track {
  position: relative;
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.flow-meter__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 8px rgba(108, 142, 245, 0.5);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.flow-meter__legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

/* ==========================================================================
   Insight strip
   ========================================================================== */
.insight-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0 0 14px;
  border: 1px solid rgba(108, 142, 245, 0.14);
  border-radius: 16px;
  padding: 12px 16px;
  background: rgba(108, 142, 245, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.insight-strip__label {
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent);
  background: rgba(108, 142, 245, 0.12);
  border: 1px solid rgba(108, 142, 245, 0.18);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.insight-strip__text {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

/* ==========================================================================
   Panels
   ========================================================================== */
.panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 22px;
  background: var(--panel);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(130, 118, 255, 0.35), transparent);
  pointer-events: none;
}

.panel__head { margin-bottom: 18px; }
.panel__head--row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel__eyebrow { margin: 0 0 6px; color: var(--accent); }
.panel__title { margin: 0; font-size: 1.16rem; line-height: 1.25; color: var(--ink-deep); }

/* ==========================================================================
   Form fields
   ========================================================================== */
.transaction-form, .controls__grid { display: grid; gap: 12px; }
.transaction-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field--wide { grid-column: span 2; }
.field__label { color: var(--muted); }

.field__control {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field__control::placeholder { color: rgba(123, 130, 160, 0.5); }

.field__control:focus,
.field__control:focus-visible {
  border-color: rgba(108, 142, 245, 0.6);
  box-shadow: 0 0 0 3px rgba(108, 142, 245, 0.12);
  background: rgba(108, 142, 245, 0.05);
}

.field__control:hover:not(:focus):not(.field__control--error) {
  border-color: rgba(108, 142, 245, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

select.field__control { cursor: pointer; }

.field__control:not(:placeholder-shown),
.field__control:has(option:checked) {
  border-color: rgba(108, 142, 245, 0.22);
}

.field__control--error {
  border-color: var(--expense) !important;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.14) !important;
}

.field__error {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--expense);
  padding-left: 2px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

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

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(108, 142, 245, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 12px 32px rgba(108, 142, 245, 0.45);
}

.btn-ghost, .btn-secondary {
  color: var(--accent);
  background: rgba(108, 142, 245, 0.1);
  border: 1px solid rgba(108, 142, 245, 0.16);
}
.btn-ghost:hover, .btn-secondary:hover {
  background: rgba(108, 142, 245, 0.16);
  border-color: rgba(108, 142, 245, 0.28);
}

.btn-danger {
  color: var(--expense);
  background: rgba(255, 107, 122, 0.1);
  border: 1px solid rgba(255, 107, 122, 0.18);
}
.btn-danger:hover {
  background: rgba(255, 107, 122, 0.18);
  border-color: rgba(255, 107, 122, 0.32);
  box-shadow: 0 4px 16px rgba(255, 107, 122, 0.18);
}

.transaction-form .btn-primary { grid-column: span 2; }

/* ==========================================================================
   Transaction preview (receipt)
   ========================================================================== */
.transaction-preview { margin-top: 16px; }

.transaction-preview__label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.transaction-preview__paper {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  overflow: hidden;
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(248, 113, 113, 0.2);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.06) inset;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.transaction-preview__paper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(248, 113, 113, 0.3), transparent);
}

.transaction-preview__paper--income {
  border-color: rgba(52, 211, 153, 0.2);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.06) inset;
}

.transaction-preview__paper--income::before {
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.3), transparent);
}

.transaction-preview__paper:focus-within,
.composer:focus-within .transaction-preview__paper {
  transform: translateY(-2px);
}

.transaction-preview__type,
.transaction-preview__category,
.transaction-preview__date {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.transaction-preview__amount {
  justify-self: end;
  font-family: "Sora", "Manrope", sans-serif;
  color: var(--ink-deep);
}

.transaction-preview__note {
  grid-column: 1 / -1;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.transaction-preview__date { justify-self: end; }

/* ==========================================================================
   History — transaction list
   ========================================================================== */
.history__counter {
  margin: 0;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--accent);
  background: rgba(108, 142, 245, 0.1);
  border: 1px solid rgba(108, 142, 245, 0.16);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.transaction {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.transaction:hover {
  transform: translateY(-1px);
  border-color: rgba(108, 142, 245, 0.18);
  background: rgba(108, 142, 245, 0.04);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.transaction--income { border-left: 2px solid var(--income); }
.transaction--income:hover { border-color: var(--income); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 20px rgba(52, 211, 153, 0.06); }

.transaction--expense { border-left: 2px solid var(--expense); }
.transaction--expense:hover { border-color: var(--expense); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 20px rgba(248, 113, 113, 0.06); }

.transaction--major {
  background: rgba(248, 113, 113, 0.04);
}

.transaction__main { min-width: 0; }

.transaction__note {
  margin: 0 0 8px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  color: var(--ink-deep);
}

.transaction__note::before {
  content: "#";
  margin-right: 6px;
  color: rgba(108, 142, 245, 0.4);
}

.transaction__meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.78rem; }

.transaction__pill {
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-weight: 700;
}

.transaction__pill[data-category="Еда"]         { background: rgba(251, 191, 36, 0.1);  border-color: rgba(251, 191, 36, 0.16);  color: #fbbf24; }
.transaction__pill[data-category="Транспорт"]   { background: rgba(96, 165, 250, 0.1);  border-color: rgba(96, 165, 250, 0.16);  color: #60a5fa; }
.transaction__pill[data-category="Дом"]         { background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.16); color: #a78bfa; }
.transaction__pill[data-category="Развлечения"] { background: rgba(244, 114, 182, 0.1); border-color: rgba(244, 114, 182, 0.16); color: #f472b6; }
.transaction__pill[data-category="Здоровье"]    { background: rgba(52, 211, 153, 0.1);  border-color: rgba(52, 211, 153, 0.16);  color: #34d399; }
.transaction__pill[data-category="Зарплата"]    { background: rgba(108, 142, 245, 0.1); border-color: rgba(108, 142, 245, 0.16); color: #6c8ef5; }
.transaction__pill[data-category="Подарки"]     { background: rgba(251, 146, 60, 0.1);  border-color: rgba(251, 146, 60, 0.16);  color: #fb923c; }

.transaction__side { display: grid; gap: 8px; justify-items: end; }
.transaction__amount { font-family: "Sora", "Manrope", sans-serif; font-size: 1rem; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.transaction__amount--income { color: var(--income); }
.transaction__amount--expense { color: var(--expense); }
.transaction__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.transaction__actions .btn { min-height: 30px; padding: 5px 10px; font-size: 0.76rem; box-shadow: none; }

.transaction--entering { animation: receiptIn 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.transaction--updated  { animation: receiptPulse 0.42s ease both; }
.transaction--leaving  { pointer-events: none; animation: receiptOut 0.24s ease both; }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 56px 20px 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(108, 142, 245, 0.18);
  border-radius: var(--radius-xl);
  background: rgba(108, 142, 245, 0.03);
}

.empty-state::before {
  content: "";
  position: absolute;
  top: 20px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(108, 142, 245, 0.12);
  border: 1px solid rgba(108, 142, 245, 0.2);
  box-shadow: 0 0 20px rgba(108, 142, 245, 0.1);
}

.empty-state::after {
  content: "";
  position: absolute;
  top: 31px;
  width: 18px;
  height: 12px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.empty-state__title { margin: 0; color: var(--ink-deep); font-weight: 800; }
.empty-state__text { max-width: 480px; margin: 0; line-height: 1.5; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { padding: 22px 12px 30px; color: var(--muted); text-align: center; }

/* ==========================================================================
   Keyframes
   ========================================================================== */
@keyframes revealIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes receiptIn {
  from { opacity: 0; transform: translateY(9px) scale(0.988); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes receiptPulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.012); box-shadow: 0 0 0 2px rgba(108, 142, 245, 0.4), 0 16px 40px rgba(0, 0, 0, 0.3); }
  100% { transform: scale(1); }
}

@keyframes receiptOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(14px) scale(0.985); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  .dashboard,
  .workspace { grid-template-columns: 1fr; }
  .transaction-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .app-shell { padding-top: 24px; }
  .panel, .summary-card { border-radius: 20px; }

  .transaction-form,
  .controls__grid { grid-template-columns: 1fr; }

  .field--wide,
  .transaction-form .btn-primary { grid-column: auto; }

  .transaction { grid-template-columns: 1fr; }
  .transaction__side { justify-items: stretch; }
  .transaction__actions,
  .transaction__actions .btn { width: 100%; }
  .transaction__main { padding-left: 14px; }

  .flow-meter__legend { flex-direction: column; }
  .insight-strip { grid-template-columns: 1fr; }

  .transaction-preview__paper { grid-template-columns: 1fr; }
  .transaction-preview__amount,
  .transaction-preview__date { justify-self: start; }
}

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