/* ============================================================
   Family Expense — «Εστία» design system
   Ζεστό σκούρο δαμασκηνί φόντο, accent «κάρβουνο» (κεχριμπάρι→κοραλλί→ροδί).
   ============================================================ */

@font-face {
  font-family: 'Commissioner';
  src: url('/fonts/commissioner-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Commissioner';
  src: url('/fonts/commissioner-greek.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF;
}

:root {
  --bg0: #14111C;
  --bg1: #1B1726;
  --bg2: #241E32;
  --card: rgba(255, 255, 255, .045);
  --card-strong: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .09);
  --ink: #F1EDE6;
  --muted: #A99FB6;
  --faint: #6E677D;
  --ember1: #F2A93B;
  --ember2: #E8664B;
  --ember3: #D64B7E;
  --ember: linear-gradient(135deg, var(--ember1), var(--ember2) 55%, var(--ember3));
  --income: #2FBF97;
  --expense: #E97258;
  --danger: #E45B5B;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --nav-h: 66px;
  --pad: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(214, 75, 140, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(242, 169, 59, .05), transparent 55%),
    var(--bg0);
  color: var(--ink);
  font-family: 'Commissioner', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--ember1); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(232, 102, 75, .35); }

.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout shell ---------- */
.app { min-height: 100dvh; }

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px var(--pad) calc(var(--nav-h) + 96px);
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg0) 78%, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.topbar-in {
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad);
}
.topbar .brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.topbar .brand-mini img { width: 30px; height: 30px; }
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--ink); background: var(--card-strong); }
.icon-btn svg { width: 20px; height: 20px; }

.avatar-btn {
  display: inline-flex; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; padding: 3px 4px 3px 3px;
  border-radius: 999px; transition: background .15s;
}
.avatar-btn:hover { background: var(--card-strong); }
.avatar-btn .caret { color: var(--muted); font-size: 12px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #14111C;
  flex: none;
}
.avatar.lg { width: 46px; height: 46px; font-size: 18px; }

/* ---------- Bottom nav (mobile) / sidebar (desktop) ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex; align-items: stretch; justify-content: space-around;
}
.nav a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--faint);
  font-size: 10px; font-weight: 600; letter-spacing: 0;
  transition: color .18s;
}
.nav a span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--ember1); }
.nav a.active svg { filter: drop-shadow(0 0 7px rgba(242, 169, 59, .5)); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 41;
  width: 60px; height: 60px; border-radius: 20px;
  border: none; cursor: pointer;
  background: var(--ember);
  color: #fff;
  box-shadow: 0 8px 28px rgba(232, 102, 75, .45), 0 2px 8px rgba(0, 0, 0, .4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .2s;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 28px; height: 28px; }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .nav {
    position: sticky; top: 0; bottom: auto;
    height: 100dvh; width: 232px; flex: none;
    flex-direction: column; justify-content: flex-start;
    gap: 4px; padding: 18px 12px;
    border-top: none; border-right: 1px solid rgba(255, 255, 255, .06);
  }
  .nav .nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 8px 12px 22px; }
  .nav .nav-brand img { width: 34px; height: 34px; }
  .nav a {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 12px 14px; border-radius: var(--r-md); font-size: 14.5px;
  }
  .nav a.active { background: var(--card-strong); }
  .main { max-width: 760px; padding-bottom: 40px; }
  .topbar-in { max-width: 760px; }
  .fab { right: 34px; bottom: 34px; }
}
@media (max-width: 899.5px) { .nav .nav-brand { display: none; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card + .card, .section + .section { margin-top: 14px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 10px;
}
.section-title h2 { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.section-title a, .section-title button {
  background: none; border: none; cursor: pointer; text-decoration: none;
  font-size: 13.5px; font-weight: 600; color: var(--ember1); padding: 0;
}

/* ---------- Σήμα: η κάρτα-εστία ---------- */
.hearth {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--bg2), var(--bg1) 70%);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 26px;
  padding: 24px 22px 20px;
}
.hearth::before {
  content: '';
  position: absolute; inset: auto -30% -75% -30%; height: 130%;
  background: radial-gradient(closest-side, rgba(242, 169, 59, .34), rgba(232, 102, 75, .18) 45%, transparent 75%);
  pointer-events: none;
  animation: hearth-glow 5s ease-in-out infinite alternate;
}
@keyframes hearth-glow {
  from { opacity: .65; transform: translateY(4%) scale(.98); }
  to   { opacity: 1;   transform: translateY(0) scale(1.03); }
}
.hearth .label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.hearth .balance {
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 800; letter-spacing: -.03em; line-height: 1.1;
  margin: 4px 0 14px;
}
.hearth .balance.neg { color: var(--expense); }
.hearth .flow { display: flex; gap: 10px; position: relative; }
.flow-pill {
  flex: 1; display: flex; align-items: center; gap: 9px;
  background: rgba(20, 17, 28, .55);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--r-md);
  padding: 10px 13px;
}
.flow-pill .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.flow-pill .lbl { font-size: 11.5px; color: var(--muted); display: block; }
.flow-pill .val { font-size: 15.5px; font-weight: 700; }

/* ---------- Λίστες κινήσεων ---------- */
.tx-group-date {
  font-size: 12px; font-weight: 700; color: var(--faint);
  letter-spacing: .05em; text-transform: uppercase;
  margin: 18px 4px 8px;
}
.tx {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 12px; border-radius: var(--r-md);
  background: var(--card); border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tx + .tx { margin-top: 8px; }
.tx:hover { background: var(--card-strong); }
.tx .cat-ico {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.tx .tx-main { flex: 1; min-width: 0; }
.tx .tx-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .tx-sub { font-size: 12.5px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.tx .tx-amount { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.tx .tx-amount.in { color: var(--income); }
.tx .tx-amount.out { color: var(--ink); }
.badge-cam { font-size: 13px; }

/* Εκκρεμείς κάρτες */
.pending-card {
  display: flex; gap: 13px; align-items: center;
  border: 1px dashed rgba(242, 169, 59, .45);
  background: rgba(242, 169, 59, .06);
  border-radius: var(--r-lg); padding: 13px 14px;
  cursor: pointer;
}
.pending-card + .pending-card { margin-top: 9px; }
.pending-card .thumb {
  width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--bg2);
}
.pending-card .thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.pending-card .pc-main { flex: 1; min-width: 0; }
.pending-card .pc-title { font-weight: 650; font-size: 14.5px; }
.pending-card .pc-sub { font-size: 12.5px; color: var(--muted); }
.pending-card .pc-cta {
  font-size: 12.5px; font-weight: 700; color: var(--ember1); white-space: nowrap;
}

/* ---------- Κουμπιά ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; text-decoration: none;
  border-radius: 14px; padding: 13px 20px;
  font-weight: 700; font-size: 15px;
  transition: transform .12s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--ember); color: #fff; box-shadow: 0 4px 18px rgba(232, 102, 75, .30); }
.btn-ghost { background: var(--card-strong); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: rgba(228, 91, 91, .14); color: var(--danger); border: 1px solid rgba(228, 91, 91, .35); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 11px; }

/* ---------- Φόρμες ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  background: rgba(20, 17, 28, .6);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  padding: 13px 14px;
  font: inherit;
  transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--ember1); }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
input[type="date"].input { color-scheme: dark; }

.amount-input {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 6px 0 2px;
}
.amount-input input {
  background: none; border: none; color: var(--ink);
  font-size: 52px; font-weight: 800; letter-spacing: -.02em;
  width: 100%; max-width: 260px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.amount-input input:focus { outline: none; }
.amount-input input::placeholder { color: rgba(241, 237, 230, .18); }
.amount-input .cur { font-size: 30px; font-weight: 700; color: var(--faint); }

/* Segmented */
.seg {
  display: flex; background: rgba(20, 17, 28, .6);
  border: 1px solid var(--line); border-radius: 13px; padding: 4px; gap: 4px;
}
.seg button {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 9px 8px; border-radius: 10px; font-weight: 700; font-size: 14px;
  color: var(--faint);
  transition: background .15s, color .15s;
}
.seg button.active { background: var(--card-strong); color: var(--ink); }
.seg button.active.seg-exp { color: var(--expense); }
.seg button.active.seg-inc { color: var(--income); }

/* Chips κατηγοριών */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px; padding: 8px 14px 8px 10px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip .chip-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.chip.active { border-color: currentColor; background: var(--card-strong); }

/* ---------- Sheet (bottom sheet / dialog) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 8, 15, .6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .18s ease;
}
.sheet {
  width: 100%; max-width: 560px;
  max-height: 92dvh; overflow-y: auto;
  background: var(--bg1);
  border: 1px solid rgba(255, 255, 255, .09);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up .26s cubic-bezier(.32, .9, .4, 1);
}
.sheet .grip { width: 42px; height: 4px; border-radius: 3px; background: var(--faint); opacity: .5; margin: 4px auto 14px; }
.sheet h3 { font-size: 18px; margin-bottom: 16px; }
@media (min-width: 900px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid rgba(255, 255, 255, .09); animation: pop-in .2s ease; }
}
@keyframes sheet-up { from { transform: translateY(60%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg2); border: 1px solid var(--line);
  color: var(--ink); font-size: 14px; font-weight: 600;
  border-radius: 999px; padding: 10px 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  animation: toast-in .22s ease;
}
.toast.err { border-color: rgba(228, 91, 91, .5); color: #F4A9A9; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Auth / onboarding ---------- */
.auth-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px var(--pad) 48px; max-width: 420px; margin: 0 auto;
}
.auth-brand { text-align: center; margin-bottom: 30px; }
.auth-brand img { width: 84px; height: 84px; }
.auth-brand h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 14px; }
.auth-brand h1 .fe-accent { background: var(--ember); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand p { color: var(--muted); font-size: 14.5px; margin-top: 6px; }
.auth-card { width: 100%; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-switch button { background: none; border: none; color: var(--ember1); font-weight: 700; cursor: pointer; padding: 0 4px; }

.invite-code-big {
  font-size: 40px; font-weight: 800; letter-spacing: .3em;
  text-align: center; padding: 10px 0 4px 12px;
  background: var(--ember); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}

/* ---------- Στόχοι ---------- */
.goal-card { padding: 15px 16px; }
.goal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.goal-head .cat-ico { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.goal-head .g-title { font-weight: 650; font-size: 14.5px; flex: 1; min-width: 0; }
.goal-head .g-sub { font-size: 12px; color: var(--faint); }
.progress { height: 9px; border-radius: 6px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; transition: width .5s ease; }
.goal-nums { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 7px; }

/* ---------- Αναφορές ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 13px; }
.kpi .k-lbl { font-size: 11.5px; color: var(--faint); font-weight: 600; }
.kpi .k-val { font-size: 17px; font-weight: 800; margin-top: 2px; }
.chart-box { position: relative; width: 100%; }
.legend-list { margin-top: 4px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-size: 14px; }
.legend-row .lg-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend-row .lg-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-row .lg-val { font-weight: 700; }
.legend-row .lg-pct { color: var(--faint); font-size: 12.5px; width: 44px; text-align: right; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 4px; }
.month-nav button {
  background: none; border: none; cursor: pointer; color: var(--muted);
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px;
}
.month-nav button:hover { background: var(--card-strong); color: var(--ink); }
.month-nav .m-label { font-weight: 700; font-size: 15.5px; min-width: 150px; text-align: center; text-transform: capitalize; }

/* ---------- Μέλη / σπίτι ---------- */
.member-row { display: flex; align-items: center; gap: 13px; padding: 11px 4px; }
.member-row .m-main { flex: 1; }
.member-row .m-name { font-weight: 650; font-size: 15px; }
.member-row .m-role { font-size: 12.5px; color: var(--faint); }
.role-pill {
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 4px 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
}
.role-pill.adult { color: var(--ember1); border-color: rgba(242, 169, 59, .4); }

/* ---------- Διάφορα ---------- */
.empty {
  text-align: center; color: var(--faint); padding: 34px 16px;
  font-size: 14.5px;
}
.empty .e-ico { font-size: 34px; display: block; margin-bottom: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.mt { margin-top: 14px; }
.receipt-full {
  position: fixed; inset: 0; z-index: 90; background: rgba(10, 8, 15, .92);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .15s ease;
}
.receipt-full img { max-width: 100%; max-height: 92dvh; border-radius: 14px; }

.photo-drop {
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  padding: 18px; text-align: center; color: var(--muted); cursor: pointer;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: border-color .15s;
}
.photo-drop:hover { border-color: var(--ember1); }
.photo-drop img.preview { max-height: 120px; border-radius: 10px; }

.view-enter { animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
