/* Wallio — aplicația utilizatorului. Design system: neutre reci, accent violet,
   roșu-coral pt. cheltuieli, auriu pt. economii. Grilă de spațiere 4px. */

:root {
  --paper: #f6f4fb;
  --surface: #ffffff;
  --surface-2: #faf8ff;
  --panel: #efeaf9;
  --ink: #1c1830;
  --ink-2: #423c5c;
  --muted: #79728f;
  --rule: #e6e1f2;
  --rule-strong: #d7cfec;

  --violet: #6d28d9;
  --violet-strong: #5b21b6;
  --violet-soft: #efe6fd;
  --violet-ink: #ffffff;

  --coral: #e0435f;
  --coral-strong: #c92e4d;
  --coral-soft: #fbe8ec;
  --coral-ink: #ffffff;

  --gold: #eab308;
  --gold-strong: #ca8a04;
  --gold-soft: #fdf3d0;
  --gold-ink: #3a2c02;

  --danger: #c93b3b;
  --danger-soft: #fbeceb;
  --ok: #2f9e5a;
  --ok-soft: #e6f7ed;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(28, 20, 48, .05);
  --sh-2: 0 1px 3px rgba(28, 20, 48, .06), 0 8px 24px -14px rgba(28, 20, 48, .18);
  --sh-3: 0 2px 6px rgba(28, 20, 48, .08), 0 22px 48px -20px rgba(28, 20, 48, .30);
  --sh-violet: 0 10px 24px -10px rgba(109, 40, 217, .55);
  --sh-coral: 0 10px 24px -10px rgba(224, 67, 95, .5);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --t: .18s var(--ease);
  --tap: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14121f;
    --surface: #1c1930;
    --surface-2: #211d38;
    --panel: #262140;
    --ink: #f1eefb;
    --ink-2: #cdc6e6;
    --muted: #9990b8;
    --rule: #2d2749;
    --rule-strong: #3b3260;

    --violet: #9060f0;
    --violet-strong: #a986f5;
    --violet-soft: #2c2350;
    --violet-ink: #180f33;

    --coral: #ef6a80;
    --coral-strong: #f5899b;
    --coral-soft: #3a1d24;
    --coral-ink: #23090f;

    --gold: #f2c94c;
    --gold-strong: #f5d876;
    --gold-soft: #362a0c;
    --gold-ink: #241a02;

    --danger: #ef6a5c;
    --danger-soft: #2a1512;
    --ok: #74c98c;
    --ok-soft: #12291b;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .35);
    --sh-2: 0 1px 3px rgba(0, 0, 0, .4), 0 10px 28px -16px rgba(0, 0, 0, .65);
    --sh-3: 0 2px 8px rgba(0, 0, 0, .45), 0 24px 52px -20px rgba(0, 0, 0, .75);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--violet-soft); }

.hidden { display: none !important; }

/* ---- shell ---- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 8px;
  background: var(--paper);
}
.topbar h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  border: none;
  background: var(--surface);
  box-shadow: var(--sh-1);
  cursor: pointer;
  color: var(--ink-2);
  transition: transform var(--t), background var(--t);
}
.icon-btn:active { transform: scale(.92); }

main.screen {
  flex: 1;
  padding: 4px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- bottom tab bar ---- */
.tab-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -6px 24px -18px rgba(28, 20, 48, .3);
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: var(--r-sm);
  cursor: pointer;
  min-height: var(--tap);
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn span { font-size: 10.5px; font-weight: 600; }
.tab-btn.activ { color: var(--violet); }
.tab-btn:active { transform: scale(.95); }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 18px;
}
.card + .card { margin-top: 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--r-pill);
  border: none;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), opacity var(--t);
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-violet { background: var(--violet); color: var(--violet-ink); box-shadow: var(--sh-violet); }
.btn-coral { background: var(--coral); color: var(--coral-ink); box-shadow: var(--sh-coral); }
.btn-ghost { background: var(--panel); color: var(--ink); box-shadow: none; }
.btn-outline { background: transparent; color: var(--ink-2); border: 1.5px solid var(--rule-strong); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; width: auto; }
.btn-danger-text { background: none; color: var(--danger); box-shadow: none; font-weight: 600; width: auto; }

/* ---- inputs ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
}
.field textarea { padding: 12px 14px; min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--violet);
}
.field-error { color: var(--danger); font-size: 12.5px; }

.amount-input {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 28px 10px;
}
.amount-input input {
  border: none;
  background: none;
  font-size: 44px;
  font-weight: 800;
  width: 100%;
  text-align: right;
  color: var(--ink);
  letter-spacing: -.02em;
}
.amount-input input:focus { outline: none; }
.amount-input .moneda { font-size: 20px; font-weight: 700; color: var(--muted); }

/* ---- login ---- */
.auth-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 32px 24px;
}
.auth-logo {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--violet), var(--coral));
  display: grid; place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 26px;
  margin: 0 auto 4px;
  box-shadow: var(--sh-violet);
}
.auth-title { text-align: center; font-size: 24px; font-weight: 800; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ---- tabs pill (cheltuieli/venituri) ---- */
.pill-tabs {
  display: flex;
  background: var(--panel);
  border-radius: var(--r-pill);
  padding: 4px;
  gap: 4px;
}
.pill-tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 0;
  border-radius: var(--r-pill);
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
}
.pill-tabs button.activ { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ---- home ---- */
.home-hero {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.home-hero .greeting { font-size: 18px; font-weight: 800; }
.home-hero .sub { color: var(--muted); font-size: 13px; }

.progress-track {
  height: 14px;
  border-radius: var(--r-pill);
  background: var(--panel);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width .5s var(--ease);
}
.progress-fill.violet { background: linear-gradient(90deg, var(--violet), var(--violet-strong)); }
.progress-fill.gold { background: linear-gradient(90deg, var(--gold), var(--gold-strong)); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-row .val { font-size: 16px; font-weight: 800; }
.stat-row .tag {
  display: inline-block; margin-top: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill);
}
.tag-violet { background: var(--violet-soft); color: var(--violet); }
.tag-coral { background: var(--coral-soft); color: var(--coral); }
.tag-gold { background: var(--gold-soft); color: var(--gold-strong); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  color: var(--ink);
}
.link-row:first-child { border-top: none; }
.link-row svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.link-row .lbl { flex: 1; font-weight: 600; font-size: 14px; }
.link-row .chev { color: var(--muted); }

/* ---- category grid ---- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 8px;
}
.cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 4px;
  border-radius: var(--r);
}
.cat-item .ic {
  width: 56px; height: 56px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--panel);
  color: var(--violet);
  transition: transform var(--t), box-shadow var(--t);
}
.cat-item .ic svg { width: 24px; height: 24px; }
.cat-item.tip-cheltuiala .ic { color: var(--coral); }
.cat-item span.lbl { font-size: 11.5px; text-align: center; font-weight: 600; line-height: 1.25; color: var(--ink-2); }
.cat-item.selectat .ic { background: var(--violet); color: #fff; box-shadow: var(--sh-violet); transform: scale(1.06); }
.cat-item.tip-cheltuiala.selectat .ic { background: var(--coral); box-shadow: var(--sh-coral); }

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 4px 2px 0;
}

.date-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1.5px solid var(--rule-strong);
  border-radius: var(--r-sm);
  padding: 0 14px;
  min-height: var(--tap);
  cursor: pointer;
}
.date-field svg { width: 18px; height: 18px; color: var(--muted); }

.bottom-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--paper) 30%);
}

/* ---- transactions list ---- */
.tx-list { display: flex; flex-direction: column; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
.tx-item:first-child { border-top: none; }
.tx-item .ic {
  width: 42px; height: 42px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: var(--panel);
  color: var(--violet);
  flex-shrink: 0;
}
.tx-item .ic svg { width: 20px; height: 20px; }
.tx-item.tip-cheltuiala .ic { color: var(--coral); }
.tx-item .info { flex: 1; min-width: 0; }
.tx-item .cat { font-weight: 700; font-size: 14px; }
.tx-item .nota { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-item .suma { font-weight: 800; font-size: 14.5px; white-space: nowrap; }
.tx-item.tip-venit .suma { color: var(--violet); }
.tx-item.tip-cheltuiala .suma { color: var(--coral); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { width: 44px; height: 44px; opacity: .5; }

.month-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-1);
  padding: 6px 6px 6px 16px;
}
.month-picker .lbl { font-weight: 700; }
.month-picker .nav { display: flex; gap: 2px; }

/* ---- statistici ---- */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.bar-row .ic {
  width: 36px; height: 36px; border-radius: var(--r-pill);
  display: grid; place-items: center; background: var(--panel); color: var(--violet); flex-shrink: 0;
}
.bar-row .ic svg { width: 17px; height: 17px; }
.bar-row .body { flex: 1; min-width: 0; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-row .top .nume { font-weight: 700; }
.bar-row .top .suma { color: var(--muted); }
.bar-track { height: 8px; border-radius: var(--r-pill); background: var(--panel); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--violet); }
.bar-row.tip-cheltuiala .ic { color: var(--coral); }
.bar-row.tip-cheltuiala .bar-fill { background: var(--coral); }

/* ---- avere ---- */
.avere-total { text-align: center; padding: 6px 0 2px; }
.avere-total .val { font-size: 34px; font-weight: 900; letter-spacing: -.02em; }
.avere-total .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }

.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

.asset-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
.asset-item:first-child { border-top: none; }
.asset-item .ic {
  width: 42px; height: 42px; border-radius: var(--r-pill);
  display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-strong); flex-shrink: 0;
}
.asset-item .ic svg { width: 19px; height: 19px; }
.asset-item .info { flex: 1; min-width: 0; }
.asset-item .nume { font-weight: 700; font-size: 14px; }
.asset-item .broker { color: var(--muted); font-size: 12px; }
.asset-item .val { font-weight: 800; font-size: 14.5px; }

.type-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.type-pill {
  padding: 9px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--rule-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-2);
}
.type-pill.selectat { background: var(--violet); border-color: var(--violet); color: #fff; }

/* ---- contul meu ---- */
.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 52px; height: 52px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--violet), var(--coral));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.profile-card .nume { font-weight: 800; font-size: 16px; }
.profile-card .email { color: var(--muted); font-size: 13px; }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 16, 36, .5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  animation: fade .15s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 88vh;
  overflow-y: auto;
  animation: rise .2s var(--ease);
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-sheet h2 { font-size: 18px; font-weight: 800; }
.modal-sheet .close { align-self: flex-end; }

/* ---- toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--sh-3);
  z-index: 200;
  max-width: 90%;
  text-align: center;
  transition: opacity var(--t), transform var(--t);
}
#toast.err { background: var(--danger); color: #fff; }

/* ---- loader ---- */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: var(--muted);
}
.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 3px solid var(--rule-strong);
  border-top-color: var(--violet);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- bară instalare PWA ---- */
.install-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--violet-soft);
  border-bottom: 1px solid var(--rule-strong);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.35;
}
.install-bar span { flex: 1; color: var(--ink-2); }
.install-bar span strong { color: var(--ink); }
.install-bar #install-btn {
  flex: none;
  background: var(--violet);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.install-bar #install-close {
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

@media (min-width: 481px) {
  body { background: var(--panel); }
  #app { min-height: 100vh; box-shadow: var(--sh-3); }
  .install-bar { border-radius: var(--r-sm); margin-top: 8px; box-shadow: var(--sh-1); }
}
