/* FinKeeper — User PWA. Айдентика «Изумрудный сейф»:
   глубокий зелёно-чёрный фон, мятное свечение, золото для сумм. */

:root {
  --bg: #0b1512;
  --bg-card: #10201a;
  --bg-card2: #132620;
  --line: #1d3a30;
  --mint: #6ee7b7;
  --mint-dim: #34d399;
  --gold: #e8c268;
  --text: #e7f3ed;
  --muted: #7fa393;
  --danger: #f87171;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 40% at 50% -5%, rgba(110, 231, 183, .10), transparent 70%),
    radial-gradient(40% 30% at 85% 100%, rgba(232, 194, 104, .06), transparent 70%);
}

.hidden { display: none !important; }
.view { position: relative; z-index: 1; }
.view-center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }

/* ---------- login ---------- */
.login-card {
  width: 100%; max-width: 400px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.brand { margin-bottom: 10px; }
.brand-gem { filter: drop-shadow(0 0 18px rgba(110, 231, 183, .35)); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.brand-name { font-size: 2.1rem; letter-spacing: .5px; font-weight: 700; margin-top: 10px; }
.brand-name span { color: var(--mint); }
.brand-tag { color: var(--muted); font-size: .95rem; margin-top: 4px; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text);
  padding: 10px 16px; font-size: 1rem; cursor: pointer;
  transition: transform .08s ease, box-shadow .2s ease, background .2s;
}
.btn:hover { background: var(--bg-card2); }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, #17a06a, #128a58);
  border-color: transparent; color: #06130d; font-weight: 700;
  box-shadow: 0 4px 24px rgba(52, 211, 153, .25);
}
.btn-primary:hover { background: linear-gradient(135deg, #2cc584, #17a06a); }
.btn-lg { padding: 15px 20px; font-size: 1.1rem; }
.btn-ghost { background: transparent; }
.btn-tiny { padding: 4px 10px; font-size: .8rem; border-radius: 8px; }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.key-ico { color: inherit; margin-right: 6px; }

.input {
  background: #0d1a15; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 11px 13px; font-size: 1rem; width: 100%;
}
.input:focus { outline: 2px solid rgba(110, 231, 183, .5); outline-offset: 0; border-color: var(--mint-dim); }
.input::placeholder { color: #557a6b; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.error { color: var(--danger); font-size: .9rem; }
.muted { color: var(--muted); font-size: .9rem; }

.dev-box { border: 1px dashed #3a5a4c; border-radius: var(--radius); padding: 12px; }
.dev-label { color: var(--gold); font-size: .75rem; letter-spacing: .15em; margin-bottom: 8px; }
.dev-users { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.recovery-details { color: var(--muted); font-size: .9rem; }
.recovery-details summary { cursor: pointer; padding: 4px; }
.recovery-details form { margin-top: 10px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(11, 21, 18, .85); backdrop-filter: blur(10px); z-index: 5;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.05rem; }
.topnav { display: flex; gap: 4px; flex: 1; }
.navbtn {
  background: none; border: none; color: var(--muted); font-size: .95rem;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
.navbtn:hover { color: var(--text); }
.navbtn.active { color: var(--mint); background: rgba(110, 231, 183, .08); }
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }

.tab { max-width: 980px; margin: 0 auto; padding: 26px 22px 60px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 26px 0 8px; position: relative; }
.hero-label { color: var(--muted); text-transform: uppercase; letter-spacing: .2em; font-size: .8rem; }
.hero-amount {
  font-size: clamp(2.6rem, 8vw, 4rem); font-weight: 800; margin-top: 6px;
  color: var(--gold); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(232, 194, 104, .3);
}
.hero-sub { color: var(--muted); font-size: .92rem; margin-top: 8px; }
.hero-sub .neg { color: var(--danger); }
.hero-sub .pos { color: var(--mint); }
.hero-coin {
  width: 14px; height: 14px; border-radius: 50%; margin: 12px auto 0;
  background: radial-gradient(circle at 35% 30%, #ffe9ad, var(--gold));
  opacity: 0; transform: translateY(0);
}
.hero-coin.drop { animation: coindrop .9s ease-out; }
@keyframes coindrop {
  0% { opacity: 1; transform: translateY(-46px) scale(1.4); }
  60% { opacity: 1; transform: translateY(0) scale(1); }
  75% { transform: translateY(-8px); }
  100% { opacity: 0; transform: translateY(0); }
}

/* ---------- cards ---------- */
.card, .add-card {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-card2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.card-title { font-size: 1rem; margin-bottom: 12px; color: var(--mint); font-weight: 600; }
.add-card { display: flex; flex-direction: column; gap: 10px; }
.add-row { display: flex; gap: 10px; }
.input-amount { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.input-cur { max-width: 92px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } .topnav { order: 3; width: 100%; } }

/* ---------- income / expense switch ---------- */
.kind-switch { display: flex; gap: 6px; background: #0d1a15; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 4px; }
.kind-btn {
  flex: 1; background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 9px 12px; border-radius: 10px; font-size: .95rem; font-weight: 600;
  transition: background .18s, color .18s;
}
.kind-btn:hover { color: var(--text); }
.kind-btn.active[data-kind="income"] { background: rgba(52, 211, 153, .16); color: var(--mint); }
.kind-btn.active[data-kind="expense"] { background: rgba(248, 113, 113, .16); color: var(--danger); }
.btn-square { width: 44px; flex-shrink: 0; padding: 10px 0; text-align: center; }

/* expense mode recolors the primary action so the form never lies about
   what it will record */
.add-card.expense .btn-primary {
  background: linear-gradient(135deg, #e05a5a, #b83f3f);
  box-shadow: 0 4px 24px rgba(248, 113, 113, .22);
  color: #1a0808;
}
.add-card.expense .btn-primary:hover { background: linear-gradient(135deg, #f07070, #cc4a4a); }
.add-card.expense .input:focus { outline-color: rgba(248, 113, 113, .5); border-color: var(--danger); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap; }
.card-head .card-title { margin-bottom: 0; }
.seg { display: flex; gap: 2px; background: #0d1a15; border: 1px solid var(--line);
  border-radius: 10px; padding: 3px; }
.seg-btn { background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px 10px; border-radius: 8px; font-size: .8rem; }
.seg-btn.active { background: rgba(110, 231, 183, .12); color: var(--mint); }

/* ---------- ranking lists ---------- */
.rank-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.rank-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.rank-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.rank-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.rank-fill { height: 100%; border-radius: 3px; }
.rank-share { color: var(--muted); font-size: .78rem; min-width: 62px; text-align: right;
  font-variant-numeric: tabular-nums; }

.trend-bar.out { background: linear-gradient(180deg, var(--danger), rgba(248, 113, 113, .25)); }
.trend-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  gap: 1px; height: 100%; }
.trend-legend { color: var(--muted); font-size: .78rem; margin-top: 8px;
  display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-in { background: var(--mint); }
.dot-out { background: var(--danger); margin-left: 8px; }

.earn-amount.out { color: var(--danger); }
.earn-tag { font-size: .72rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 1px 8px; white-space: nowrap; }

/* ---------- earnings list ---------- */
.earn-list, .plain-list { list-style: none; display: flex; flex-direction: column; }
.earn-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid rgba(29, 58, 48, .6);
}
.earn-item:last-child { border-bottom: none; }
.earn-date { color: var(--muted); font-size: .85rem; min-width: 86px; }
.earn-amount { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.earn-comment { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.earn-item { min-width: 0; }
.earn-actions { display: flex; gap: 6px; }

/* ---------- stats ---------- */
.stats-dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.stats-dl dt { color: var(--muted); }
.stats-dl dd { text-align: right; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.trend { display: flex; align-items: flex-end; gap: 2px; height: 64px; margin-top: 16px; }
.trend-bar {
  flex: 1; min-height: 2px; border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--mint), rgba(110, 231, 183, .25));
}
.ro-badge {
  font-size: .7rem; color: var(--gold); border: 1px solid rgba(232, 194, 104, .4);
  padding: 2px 8px; border-radius: 20px; margin-left: 8px; vertical-align: middle;
  letter-spacing: .05em;
}
.big-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.big-stat { background: #0d1a15; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.big-stat .k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.big-stat .v { font-size: 1.4rem; font-weight: 800; color: var(--gold); margin-top: 6px; font-variant-numeric: tabular-nums; }

.codes { background: #0d1a15; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-top: 10px; font-size: .95rem; line-height: 1.7; color: var(--gold); }

/* ---------- dialog / toast ---------- */
dialog {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(4, 10, 8, .7); backdrop-filter: blur(3px); }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card2); border: 1px solid var(--mint-dim); color: var(--text);
  border-radius: 12px; padding: 10px 18px; z-index: 50; box-shadow: 0 6px 30px rgba(0,0,0,.4);
}
