/* =========================================================
   Cuib - buget lunar
   Design: light, coerent, identitate verde.
   Principii Apple HIG aplicate: grid de spatiere 8pt, scara
   tipografica clara (fara fractiuni), raze de colt consecvente,
   umbre subtile (deferenta), tinte de atingere generoase.
   ========================================================= */

:root {
  /* ---- Culori ---- */
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface-2: #f1f2f5;
  --surface-3: #e8e9ee;
  --border:    #e6e7ec;
  --border-2:  #d4d6de;

  --ink:   #101114;
  --ink-2: #585a63;
  --ink-3: #9095a0;

  --accent:      #0d9f5a;   /* verde - identitatea */
  --accent-deep: #0a7f48;
  --accent-soft: #e6f6ee;

  --need:    #2f76d6;   /* albastru */
  --want:    #e0851e;   /* chihlimbar */
  --savings: #0d9f5a;   /* verde */
  --danger:  #dc2626;
  --danger-soft: #fdecec;
  --need-ink: #2568c4;
  --want-ink: #b56b12;

  /* ---- Spatiere: grid 8pt (jumatati de pas la 4) ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --gutter: var(--sp-4);   /* margine laterala constanta a ecranului */

  /* ---- Tipografie: scara clara, fara fractiuni ---- */
  --fs-hero: 34px;
  --fs-title: 22px;
  --fs-xl:   20px;
  --fs-lg:   17px;
  --fs-md:   15px;
  --fs-base: 14px;
  --fs-sm:   13px;
  --fs-xs:   12px;
  --fs-2xs:  11px;

  /* ---- Raze: imbricare coerenta ---- */
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-xs: 8px;
  --radius-pill: 999px;
  --radius:    var(--r-lg);   /* alias retro-compat */
  --radius-sm: var(--r-md);   /* alias retro-compat */

  --shadow-sm: 0 1px 2px rgba(16,17,20,0.04), 0 1px 3px rgba(16,17,20,0.05);
  --shadow:    0 12px 32px rgba(16,17,20,0.12);

  --sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --maxw: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;   /* nu lasa fereastra sa se miste stanga-dreapta pe telefon */
}

body { min-height: 100vh; min-height: 100dvh; }

/* ---------- Shell ---------- */
.app {
  width: 100%; max-width: var(--maxw);
  height: 100vh; height: 100dvh;   /* 100dvh urmareste bara browserului pe mobil */
  margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg);
  /* respecta zonele sigure (notch) in landscape */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
@media (min-width: 520px) {
  body { padding: var(--sp-8) 0; }
  .app {
    height: calc(100vh - 64px);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 24px 56px rgba(16,17,20,0.08);
  }
}

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--sp-4) + env(safe-area-inset-top)) var(--gutter) var(--sp-2);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: var(--fs-md);
}
.brand-name { font-weight: 800; font-size: var(--fs-xl); letter-spacing: -0.02em; }
.reset-btn {
  background: transparent; border: 1px solid var(--border-2); color: var(--ink-2);
  font-family: inherit; font-size: var(--fs-xs); font-weight: 600;
  min-height: 32px; padding: 0 var(--sp-3); border-radius: var(--radius-pill); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.reset-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.header-actions { display: flex; align-items: center; gap: var(--sp-2); }
.icon-round { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; background: transparent; border: 1px solid var(--border-2); border-radius: 50%; color: var(--ink-2); cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.icon-round:hover { border-color: var(--ink-3); color: var(--ink); }
.icon-round--lang { font-size: 11px; font-weight: 800; letter-spacing: 0.02em; }

/* Navigatie segmentata */
.nav {
  display: flex; gap: var(--sp-1); margin: var(--sp-1) var(--gutter) var(--sp-2); padding: var(--sp-1);
  background: var(--surface-2); border-radius: var(--radius-pill);
}
.nav-tab {
  flex: 1; text-align: center; text-decoration: none;
  min-height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.is-active { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(13,159,90,0.28); }

.view { flex: 1 1 auto; overflow-y: scroll; scrollbar-gutter: stable; padding: var(--sp-2) var(--gutter) calc(var(--sp-6) + env(safe-area-inset-bottom)); }

/* Footer discret cu link catre codul sursa (in interiorul zonei derulabile, jos de tot) */
.app-footer { display: grid; place-items: center; margin-top: var(--sp-6); padding-top: var(--sp-4); }
.source-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); text-decoration: none; font-size: var(--fs-2xs); font-weight: 600; transition: color 0.15s; }
.source-link:hover { color: var(--ink); }
.source-link svg { flex: 0 0 auto; }

/* ---------- Primitive de ecran ---------- */
/* Animatia de intrare ruleaza DOAR la schimbarea de ecran, nu la fiecare click. */
.view.is-switching .screen { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.screen-head { margin: var(--sp-2) 0 var(--sp-4); }
.screen-head--center { text-align: center; }
.screen-title { font-size: var(--fs-title); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.screen-sub { color: var(--ink-2); font-size: var(--fs-sm); margin: var(--sp-1) 0 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-2xs); font-weight: 700; color: var(--ink-3); margin: 0; }
.hint { margin-top: var(--sp-5); text-align: center; color: var(--ink-3); font-size: var(--fs-xs); line-height: 1.5; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: var(--sp-5) 0 var(--sp-3); }
.section-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); font-weight: 700; margin: 0; }
.section-meta { font-size: var(--fs-md); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.empty { list-style: none; text-align: center; color: var(--ink-3); font-size: var(--fs-base); padding: var(--sp-6) var(--sp-3); }

.stack { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.stack--lg { gap: var(--sp-3); }

/* ---------- Card + primitive ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }

.icon-box { display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); font-size: var(--fs-lg); }
.icon-box--md { width: 34px; height: 34px; font-size: var(--fs-md); }
/* Iconita ca text (nu emoji): scalata dupa lungime ca sa incapa in patratel */
.icon-box--text { color: var(--ink); font-weight: 700; line-height: 1; letter-spacing: -0.03em; max-width: 100%; padding: 0 2px; }
.icon-box--text.len-1 { font-size: var(--fs-md); }
.icon-box--text.len-2 { font-size: 13px; }
.icon-box--text.len-3 { font-size: 10px; }
.icon-box--text.len-4 { font-size: 8px; }

.money { font-variant-numeric: tabular-nums; }
.money--big { font-size: var(--fs-hero); font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; display: block; }

.meter { height: 8px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; display: flex; }
.meter-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; border-radius: var(--radius-pill); }
.meter--brand   .meter-fill { background: var(--accent); }
.meter--need    .meter-fill { background: var(--need); }
.meter--want    .meter-fill { background: var(--want); }
.meter--savings .meter-fill { background: var(--savings); }
.meter--over    .meter-fill { background: var(--danger); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot--need { background: var(--need); }
.dot--want { background: var(--want); }
.dot--save { background: var(--savings); }

.chip { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-2); font-weight: 500; }

/* Butoane */
.btn { font-family: inherit; font-weight: 700; font-size: var(--fs-sm); border-radius: var(--radius-pill); cursor: pointer; border: 1px solid transparent; min-height: 40px; padding: 0 var(--sp-4); }
.btn--primary { background: var(--accent); color: #fff; transition: background 0.15s; }
.btn--primary:hover { background: var(--accent-deep); }
.btn--add { padding: 0 var(--sp-4); white-space: nowrap; }
/* Buton "Adauga" discret pt zona de sub-cheltuieli: contur verde subtil, nu bloc verde */
.btn--sub { min-height: 36px; padding: 0 var(--sp-3); font-size: var(--fs-xs); background: transparent; color: var(--accent-deep); border: 1px solid rgba(13,159,90,0.28); }
.btn--sub:hover { background: var(--accent-soft); border-color: transparent; }

.icon-btn { border: none; background: transparent; cursor: pointer; font-size: var(--fs-xl); line-height: 1; color: var(--ink-3); min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; padding: 0; border-radius: var(--r-xs); transition: background 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Campuri */
.field { font-family: inherit; font-size: var(--fs-base); font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: var(--sp-3); width: 100%; }
.field::placeholder { color: var(--ink-3); font-weight: 400; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,159,90,0.14); }
.field--num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.unit { color: var(--ink-3); font-size: var(--fs-sm); font-weight: 500; }

/* Pastila de categorie */
.pill { flex: 0 0 auto; border: none; border-radius: var(--r-xs); font-family: inherit; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.01em; padding: 3px var(--sp-2); cursor: pointer; transition: background 0.15s, color 0.15s; }
.pill--need { background: rgba(47,118,214,0.13); color: var(--need-ink); }
.pill--want { background: rgba(224,133,30,0.16); color: var(--want-ink); }
.pill--save { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- Home: venit (hero verde) ---------- */
.month-row { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.month-line { display: flex; align-items: center; gap: var(--sp-2); }
.month-input { flex: 1 1 auto; min-width: 0; font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.02em; color: var(--ink); background: transparent; border: none; border-bottom: 1px solid transparent; padding: 0 0 1px; cursor: text; }
.currency-select { flex: 0 0 auto; font-family: inherit; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); background-color: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-pill); padding: 6px 26px 6px var(--sp-3); cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5l4 4 4-4' stroke='%239095a0' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 11px; }
.currency-select:hover { border-color: var(--ink-3); color: var(--ink); }
.currency-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,159,90,0.14); }
.month-input:hover { border-bottom-color: var(--border-2); }
.month-input:focus { outline: none; border-bottom-color: var(--accent); }

.hero { background: var(--accent); border: none; border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3); color: #fff; box-shadow: 0 6px 16px rgba(13,159,90,0.18); }
.hero .hero-label { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-2xs); font-weight: 700; color: rgba(255,255,255,0.75); margin-bottom: var(--sp-1); }
.hero .money--big { color: #fff; font-size: var(--fs-hero); }

.people { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-4); }
.person { display: flex; align-items: center; gap: var(--sp-2); background: rgba(255,255,255,0.13); border-radius: var(--r-xs); padding: var(--sp-2) var(--sp-3); }
.swatch { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; border: 2px solid rgba(255,255,255,0.7); cursor: pointer; padding: 0; }
.person-name { flex: 1; min-width: 0; background: transparent; border: none; color: rgba(255,255,255,0.92); font-family: inherit; font-size: var(--fs-sm); font-weight: 600; padding: 0; }
.person-name:focus { outline: none; color: #fff; }
.person-del { background: transparent; border: none; color: rgba(255,255,255,0.6); font-size: var(--fs-lg); line-height: 1; cursor: pointer; min-width: 28px; min-height: 28px; display: grid; place-items: center; padding: 0; }
.person-del:hover { color: #fff; }
.person-add { align-self: flex-start; margin-top: var(--sp-1); background: rgba(255,255,255,0.14); border: none; border-radius: var(--radius-pill); color: #fff; font-family: inherit; font-size: var(--fs-xs); font-weight: 600; min-height: 32px; padding: 0 var(--sp-3); cursor: pointer; transition: background 0.15s; }
.person-add:hover { background: rgba(255,255,255,0.24); }
.partner-amount { display: flex; align-items: baseline; gap: var(--sp-1); flex: 0 0 auto; }
.partner-input { background: transparent; border: none; color: #fff; font-family: inherit; font-size: var(--fs-md); font-weight: 700; padding: 0; text-align: right; box-shadow: none; width: 74px; letter-spacing: -0.01em; }
.partner-input:focus { outline: none; box-shadow: none; }
.person .unit { color: rgba(255,255,255,0.6); }

/* ---------- Split ---------- */
.split { padding: var(--sp-4); margin-bottom: var(--sp-1); }
.split-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--sp-3); }
.split-title { font-weight: 700; font-size: var(--fs-md); letter-spacing: -0.01em; }
.split-hint { font-size: var(--fs-2xs); color: var(--ink-3); }
.split-bar { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-3); gap: 2px; }
.split-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-3); }
.split-item { display: flex; align-items: center; gap: var(--sp-2); }
.split-name { font-size: var(--fs-xs); color: var(--ink-2); font-weight: 500; }
.split-amount { font-size: var(--fs-sm); font-weight: 700; margin-left: 2px; font-variant-numeric: tabular-nums; }
.split-amount.is-over { color: var(--danger); }
.split-warn { margin-top: var(--sp-2); font-size: var(--fs-xs); font-weight: 600; color: var(--danger); display: flex; align-items: center; gap: var(--sp-2); }
.split-warn::before { content: '!'; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; flex: 0 0 auto; }

/* ---------- Randuri cheltuieli ---------- */
.row-wrap { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); transition: border-color 0.15s ease; }
.row-wrap:hover { border-color: var(--border-2); }
.row-wrap.is-open { border-color: var(--accent); }
.row-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); min-height: 52px; cursor: pointer; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
/* Numele poate curge pe max 2 randuri (nu mai e taiat brutal); pastila sta dedesubt */
.row-name { flex: 0 1 auto; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: var(--fs-base); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
/* Numele + indicatorul de parti (3p) stau impreuna pe primul rand; pastila dedesubt */
.row-title { display: flex; align-items: center; gap: var(--sp-2); max-width: 100%; min-width: 0; }
.parts-count { flex: 0 0 auto; font-size: 10px; font-weight: 700; color: var(--ink-3); background: var(--surface-2); padding: 1px var(--sp-2); border-radius: var(--radius-pill); }
.row-amount { flex: 0 0 auto; display: flex; align-items: baseline; gap: var(--sp-1); }
.amount-input { width: 72px; border: none; background: transparent; box-shadow: none; padding: var(--sp-1); font-size: var(--fs-md); font-weight: 700; color: var(--ink); border-radius: var(--r-xs); }
.amount-input:hover { background: var(--surface-2); }
.amount-input:focus { outline: none; box-shadow: none; background: var(--surface-2); }
.amount-sum { font-size: var(--fs-md); font-weight: 700; font-variant-numeric: tabular-nums; }
/* In zona sumei editabile, moneda se comporta ca parte din camp (tap = editezi valoarea) */
.row-amount--edit { cursor: text; }
.row-amount--edit .unit { cursor: text; }
/* Sageata de deschidere: tinta de atingere generoasa (usor de nimerit cu unghii).
   Zona clicabila e ~40x48px, trasa spre marginea dreapta, separata de campul de suma. */
.chev { flex: 0 0 auto; width: 40px; height: 48px; margin: 0 -4px 0 -2px; display: grid; place-items: center; color: var(--ink-3); font-size: var(--fs-xl); line-height: 1; transition: transform 0.2s ease; }
.row-wrap.is-open .chev { transform: rotate(180deg); color: var(--accent); }

.icon-box--btn { border: none; cursor: pointer; padding: 0; transition: background 0.15s; }
.icon-box--btn:hover { background: var(--surface-3); }

/* Bulina de proprietar */
.owner-dot { width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--border-2); cursor: pointer; padding: 0; transition: border-color 0.15s; }
.owner-dot:hover { border-color: var(--ink-3); }
.owner-dot--sub { width: 13px; height: 13px; margin-left: var(--sp-3); }
/* Cercul din randul de adaugare in mod individual: doar marcaj, neinteractiv */
.owner-dot--static { cursor: default; pointer-events: none; }

/* Panou sub-cheltuieli */
.subs { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--sp-2); }
.sub-row { display: flex; align-items: center; gap: var(--sp-2); }
.sub-name { flex: 1; min-width: 0; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.sub-amount { width: 80px; padding: var(--sp-2); font-size: var(--fs-sm); }
.sub-row .row-amount { align-items: center; }
/* Butonul "+" al randului de adaugare parte: mic, verde, minimalist */
.sub-add-btn { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; background: var(--accent-soft); border: none; border-radius: var(--r-xs); color: var(--accent-deep); font-size: var(--fs-xl); line-height: 1; cursor: pointer; transition: background 0.14s; }
.sub-add-btn:hover { background: rgba(13,159,90,0.24); }
.subs-hint { margin: var(--sp-1) 0 0 var(--sp-4); font-size: var(--fs-2xs); color: var(--ink-3); }

/* Capul panoului deschis: butonul de editare + meniul de actiuni */
.drawer-head { display: flex; align-items: stretch; gap: var(--sp-2); }
.row-menu-btn { flex: 0 0 auto; width: 40px; display: grid; place-items: center; background: var(--surface-2); border: none; border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--fs-lg); line-height: 1; cursor: pointer; transition: background 0.14s, color 0.14s; }
.row-menu-btn:hover { background: var(--surface-3); color: var(--ink); }

/* Editarea cheltuielii (nume + tip), aparuta cu butonul creion */
.edit-toggle { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); background: var(--surface-2); border: none; color: var(--ink-2); font-family: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; min-height: 36px; padding: 0 var(--sp-3); border-radius: var(--r-sm); transition: background 0.14s, color 0.14s; }
.edit-toggle svg { flex: 0 0 auto; }
.edit-toggle:hover { color: var(--ink); background: var(--surface-3); }
.edit-toggle.is-active { background: var(--accent-soft); color: var(--accent-deep); }
.sub-edit { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3); margin: 2px 0; background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: var(--r-md); }
.edit-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.edit-cap { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; }
.edit-name { font-weight: 600; }
.cat-select { display: flex; gap: var(--sp-2); }
.cat-opt { flex: 1; text-align: center; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-xs); min-height: 36px; padding: 0 var(--sp-2); font-family: inherit; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.cat-opt:hover { border-color: var(--ink-3); color: var(--ink); }
.cat-opt.is-active { border-color: transparent; }
.cat-opt--need.is-active { background: rgba(47,118,214,0.13); color: var(--need-ink); }
.cat-opt--want.is-active { background: rgba(224,133,30,0.16); color: var(--want-ink); }
.cat-opt--save.is-active { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- Selectoare (modale centrate) ---------- */
.picker-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(16,17,20,0.35); }
.emoji-pop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 61; width: min(340px, calc(100vw - 32px)); max-height: 72vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-3); animation: pop-in 0.15s ease; }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -47%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-cell { border: none; background: transparent; cursor: pointer; font-size: var(--fs-xl); padding: var(--sp-2) 0; border-radius: var(--r-xs); line-height: 1; }
.emoji-cell:hover { background: var(--surface-2); }
.emoji-free-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.emoji-free { flex: 1; }

.owner-pop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 61; width: min(260px, calc(100vw - 32px)); max-height: 72vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-2); animation: pop-in 0.15s ease; }
.owner-pop-title { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; padding: var(--sp-2); }
.owner-option { display: flex; align-items: center; gap: var(--sp-3); width: 100%; background: transparent; border: none; cursor: pointer; font-family: inherit; font-size: var(--fs-base); font-weight: 500; color: var(--ink); min-height: 40px; padding: var(--sp-2); border-radius: var(--r-xs); text-align: left; }
.owner-option:hover { background: var(--surface-2); }
.owner-swatch { width: 14px; height: 14px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--border-2); }
.owner-check { margin-left: auto; color: var(--accent); font-weight: 800; }

/* Meniu de actiuni al randului (muta / duplica / sterge) */
.menu-pop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 61; width: min(280px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-2); animation: pop-in 0.15s ease; }
.menu-pop-title { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; padding: var(--sp-2) var(--sp-2) var(--sp-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: var(--sp-2); width: 100%; background: transparent; border: none; cursor: pointer; font-family: inherit; font-size: var(--fs-base); font-weight: 600; color: var(--ink); min-height: 40px; padding: 0 var(--sp-2); border-radius: var(--r-xs); text-align: left; }
.menu-item:hover { background: var(--surface-2); }
.menu-item:disabled { opacity: 0.38; cursor: default; }
.menu-item:disabled:hover { background: transparent; }
.menu-item--danger { color: var(--danger); }
.menu-item--danger:hover { background: var(--danger-soft); }

/* ---------- Formular adaugare ---------- */
.add-card { display: flex; flex-direction: column; gap: var(--sp-2); background: transparent; border: 1px dashed var(--border-2); border-radius: var(--r-md); padding: var(--sp-3); margin-top: var(--sp-2); }
.add-row { display: flex; align-items: center; gap: var(--sp-2); }
.add-row .field { flex: 1 1 auto; min-width: 0; }
.add-row .field--num { flex: 0 0 96px; }
.add-card .btn--add { width: 100%; }
.add-hint { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; }
/* Selectorul de categorie din formularul de adaugare: eticheta deasupra, segmente dedesubt */
.add-cat { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---------- Defalcare + rest ---------- */
.breakdown { display: flex; flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-3) 2px 0; }

.savings-card { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); background: var(--accent-soft); border: 1px solid rgba(13,159,90,0.25); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-top: var(--sp-3); }
.savings-card .money--big { color: var(--accent-deep); font-size: 28px; }
.savings-label { display: block; text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--fs-2xs); font-weight: 700; color: var(--accent-deep); }
.savings-sub { display: block; font-size: var(--fs-xs); color: var(--ink-2); margin-top: var(--sp-1); }
.savings-card.is-negative { background: var(--danger-soft); border-color: rgba(220,38,38,0.28); }
.savings-card.is-negative .money--big, .savings-card.is-negative .savings-label { color: var(--danger); }

/* ---------- Rule 50-30-20 ---------- */
.rule-summary { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); margin-bottom: var(--sp-4); }
@media (max-width: 380px) { .rule-summary { flex-direction: column; } }
.donut-wrap { display: grid; place-items: center; flex: 0 0 auto; }
.donut .donut-track { stroke: var(--surface-3); }
.donut .seg-need { stroke: var(--need); }
.donut .seg-want { stroke: var(--want); }
.donut .seg-savings { stroke: var(--savings); }
.donut .seg-left { stroke: var(--surface-3); }
.donut-title { fill: var(--ink); font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.donut-sub { fill: var(--ink-3); font-size: 11px; }

.rule-legend { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; width: 100%; }
.rl-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0; border-bottom: 1px solid var(--border); }
.rl-item:last-of-type { border-bottom: none; }
.rl-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.rl-dot--need { background: var(--need); }
.rl-dot--want { background: var(--want); }
.rl-dot--savings { background: var(--savings); }
.rl-dot--left { background: var(--surface-3); border: 1px solid var(--border-2); }
.rl-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.rl-pct { margin-left: auto; padding-left: var(--sp-2); flex: 0 0 auto; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.rl-val { flex: 0 0 auto; width: 74px; text-align: right; font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rule-verdict { margin-top: var(--sp-2); text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-pill); padding: var(--sp-1) var(--sp-3); }
.rule-verdict.is-good { background: var(--accent-soft); color: var(--accent-deep); }

.rule-card { background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--r-md); box-shadow: var(--shadow-sm); padding: var(--sp-4); }
.rule-card--need    { border-left-color: var(--need); }
.rule-card--want    { border-left-color: var(--want); }
.rule-card--savings { border-left-color: var(--savings); }
.rule-top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.rule-pct { font-size: var(--fs-title); font-weight: 800; letter-spacing: -0.03em; width: 50px; }
.rule-card--need .rule-pct { color: var(--need); }
.rule-card--want .rule-pct { color: var(--want); }
.rule-card--savings .rule-pct { color: var(--savings); }
.rule-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rule-name { font-weight: 700; font-size: var(--fs-md); letter-spacing: -0.01em; }
.rule-desc { color: var(--ink-2); font-size: var(--fs-xs); }
.rule-figures { text-align: right; white-space: nowrap; }
.rule-actual { display: block; font-weight: 700; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.rule-target { display: block; color: var(--ink-3); font-size: var(--fs-2xs); margin-top: 2px; }
.rule-status { font-size: var(--fs-xs); margin-top: var(--sp-3); line-height: 1.4; color: var(--ink-2); font-weight: 500; }
.rule-status--ok { color: var(--accent-deep); }
.rule-status--warn { color: var(--want-ink); }

/* ---------- Dialog in interfata (confirm / alert) ---------- */
.dlg-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--sp-4); background: rgba(16,17,20,0.42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-5); animation: dlg-in 0.15s ease; }
/* Dialogul e centrat cu grid (nu cu translate), deci animatia NU trebuie sa mute pe -50% */
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dlg-title { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; margin-bottom: var(--sp-2); }
.dlg-msg { font-size: var(--fs-base); color: var(--ink-2); line-height: 1.5; }
.dlg-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.dlg-btn { flex: 1; min-height: 42px; font-family: inherit; font-size: var(--fs-sm); font-weight: 700; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; }
.dlg-btn--ghost { background: transparent; color: var(--ink-2); border-color: var(--border-2); }
.dlg-btn--ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.dlg-btn--primary { background: var(--accent); color: #fff; }
.dlg-btn--primary:hover { background: var(--accent-deep); }
.dlg-btn--danger { background: var(--danger); color: #fff; }
.dlg-btn--danger:hover { filter: brightness(0.94); }
.dlg-choices { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.dlg-choice { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: var(--sp-3); font-family: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-md); cursor: pointer; transition: border-color 0.14s, background 0.14s; }
.dlg-choice-label { font-size: var(--fs-base); font-weight: 700; }
.dlg-choice-desc { font-size: var(--fs-xs); font-weight: 500; color: var(--ink-2); line-height: 1.4; }
.dlg-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.dlg-choice:hover .dlg-choice-label { color: var(--accent-deep); }
.dlg-choice--danger:hover { border-color: var(--danger); background: var(--danger-soft); }

/* ---------- Raport de printare (imagine / PDF) ---------- */
/* Ascuns pe ecran; apare doar la printare (vezi @media print mai jos). */
.report-page { display: none; }
.report { max-width: 640px; margin: 0 auto; color: #101114; font-family: var(--sans); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.report-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 2px solid #101114; }
.report-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.report-total { text-align: right; }
.report-total-label { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; font-weight: 700; color: #585a63; }
.report-total-val { font-size: 20px; font-weight: 800; }
.report-section { margin-top: 20px; }
.report-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: #585a63; font-weight: 700; margin: 0 0 6px; }
.report-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid #e6e7ec; font-size: 14px; }
.report-line-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.report-line-right { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-line--total { border-bottom: none; border-top: 2px solid #101114; margin-top: 4px; font-size: 15px; }
.report-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.report-swatch--common { background: #fff; border: 1px solid #9095a0; }
.report-group { margin-bottom: 10px; }
.report-group-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 2px; font-size: 13px; font-weight: 700; color: #101114; border-bottom: 1px solid #cdd0d8; padding-bottom: 3px; }
.report-group-sum { font-variant-numeric: tabular-nums; }
.report-group .report-line { padding: 4px 0 4px 12px; font-size: 13px; }
.report-group .report-line--part { padding: 2px 0 2px 30px; font-size: 12px; color: #585a63; border-bottom: none; }
.report-part-name { position: relative; }
.report-part-name::before { content: '– '; color: #9095a0; }
.report-empty { color: #9095a0; font-size: 14px; padding: 4px 0; }
.report-rule-row { padding: 6px 0; }
.report-rule-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.report-rule-fig { font-variant-numeric: tabular-nums; color: #585a63; }
.report-bar { height: 8px; background: #e8e9ee; border-radius: 999px; overflow: hidden; }
.report-bar-fill { height: 100%; background: #0d9f5a; }
.report-bar-fill--over { background: #dc2626; }
.report-rule-status { font-size: 11px; margin-top: 4px; }
.report-rule-status.is-ok { color: #0a7f48; }
.report-rule-status.is-warn { color: #b56b12; }
.report-warn { font-size: 12px; font-weight: 600; color: #dc2626; padding: 4px 0; }
.report-foot { margin-top: 24px; text-align: center; font-size: 11px; color: #9095a0; }

@media print {
  .app, .dlg-backdrop { display: none !important; }
  .report-page { display: block !important; }
  body { background: #fff; }
  @page { margin: 16mm; }
}

/* Curata sagetile numerice */
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* =========================================================
   TEMA DARK - override peste tokeni. Se activeaza cu
   <html data-theme="dark"> (setat din butonul din header).
   ========================================================= */
:root[data-theme="dark"] {
  --bg:        #14151a;
  --surface:   #1c1e26;
  --surface-2: #23262f;
  --surface-3: #2f333f;
  --border:    #2a2d37;
  --border-2:  #3a3e4a;

  --ink:   #f1f2f5;
  --ink-2: #a7abb8;
  --ink-3: #71768a;

  --accent-deep: #34c47e;
  --accent-soft: rgba(13,159,90,0.18);

  --need-ink: #6ea8ff;
  --want-ink: #e0a052;
  --danger:  #f06d6d;
  --danger-soft: rgba(240,80,80,0.14);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.25);
  --shadow:    0 16px 40px rgba(0,0,0,0.50);

  --glass-bg:     rgba(28,30,38,0.58);
  --glass-strong: rgba(28,30,38,0.74);
  --glass-border: rgba(255,255,255,0.08);
  --glass-hi:     inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Fundal ambiental mai stins pe dark */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(13,159,90,0.16), transparent 58%),
    radial-gradient(900px 680px at 104% 2%, rgba(47,118,214,0.12), transparent 55%),
    radial-gradient(820px 680px at 50% 116%, rgba(224,133,30,0.08), transparent 55%),
    var(--bg);
}
/* Cateva reguli din stratul de sticla au alb fix - le adaptam pe dark */
:root[data-theme="dark"] .nav { background: rgba(255,255,255,0.05); }
:root[data-theme="dark"] .reset-btn { background: rgba(255,255,255,0.04); }
:root[data-theme="dark"] .savings-card { background: rgba(13,159,90,0.14); }
:root[data-theme="dark"] .sub-edit { background: rgba(255,255,255,0.04); }
@media (min-width: 520px) {
  :root[data-theme="dark"] .app { background: rgba(255,255,255,0.03); }
}

/* =========================================================
   STRAT LIQUID GLASS (aero) - override peste designul de baza.
   Reversibil: sterge acest bloc ca sa revii la varianta solida.
   Principiu: sticla pe "chrome" (nav, hero, popup-uri, sumar),
   dar cardurile cu cifre raman aproape opace pt lizibilitate.
   ========================================================= */
:root {
  --glass-bg:      rgba(255,255,255,0.60);
  --glass-strong:  rgba(255,255,255,0.74);
  --glass-border:  rgba(255,255,255,0.65);
  --glass-blur:    saturate(180%) blur(18px);
  --glass-shadow:  0 8px 28px rgba(16,17,20,0.10);
  --glass-hi:      inset 0 1px 0 rgba(255,255,255,0.6);
}

/* Fundal ambiental: tente moi de culoare, ca sticla sa aiba ce dezvalui */
body {
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(13,159,90,0.18), transparent 58%),
    radial-gradient(900px 680px at 104% 2%, rgba(47,118,214,0.12), transparent 55%),
    radial-gradient(820px 680px at 50% 116%, rgba(224,133,30,0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
.app { background: transparent; }
@media (min-width: 520px) {
  .app {
    background: rgba(255,255,255,0.24);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border-color: var(--glass-border);
  }
}

/* Cardurile de continut: usor translucide, dar tin cifrele lizibile */
.row-wrap, .card, .rule-card {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-hi);
}
.add-card {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-2);
}

/* Chrome: sticla mai pronuntata */
.nav {
  background: rgba(255,255,255,0.42);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-hi);
}
.reset-btn {
  background: rgba(255,255,255,0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Hero verde cu luciu de sticla (pastreaza identitatea) */
.hero {
  background: linear-gradient(155deg, rgba(23,182,107,0.94), rgba(11,150,84,0.96));
  box-shadow: 0 10px 30px rgba(13,159,90,0.22), inset 0 1px 0 rgba(255,255,255,0.28);
}
.person { background: rgba(255,255,255,0.16); }

/* Sumar 50-30-20 + rest de alocat: sticla verde subtila */
.rule-summary { background: var(--glass-strong); }
.savings-card {
  background: rgba(230,246,238,0.66);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* Popup-uri: sticla puternica + fundal blurat */
.emoji-pop, .owner-pop {
  background: var(--glass-strong);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  backdrop-filter: saturate(180%) blur(28px);
  border-color: var(--glass-border);
  box-shadow: 0 20px 50px rgba(16,17,20,0.18), var(--glass-hi);
}
.picker-backdrop {
  background: rgba(16,17,20,0.26);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* Panoul de editare nume/tip */
.sub-edit {
  background: rgba(255,255,255,0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* =========================================================
   PRINT - override final (raport PDF).
   Pus INTENTIONAT la finalul fisierului: stratul liquid glass de
   mai sus re-seteaza un fundal verde pe body DUPA primul @media
   print, iar la specificitate egala castiga ultima regula. Deci
   overrideul de print trebuie sa fie ultimul, altfel raportul iese
   cu fundal verde (mai ales pe iPhone). Forteaza alb si ascunde tot
   stratul de sticla / popup-urile, lasand doar documentul raport.
   ========================================================= */
@media print {
  html, body {
    background: #fff !important;
    background-image: none !important;
  }
  .app, .dlg-backdrop, .picker-backdrop,
  .emoji-pop, .owner-pop, .menu-pop { display: none !important; }
  .report-page { display: block !important; background: #fff !important; }
  .report { background: #fff !important; }
}
