/* ════════════════════════════════════════════════
   فلوسي — التصميم
   هوية: فحمي مزرّق هادئ + نعناعي للدخل + كهرماني للديون
   ════════════════════════════════════════════════ */

:root {
  --bg:        #13171C;   /* خلفية — فحمي مزرق دافئ */
  --surface:   #1B2128;   /* بطاقات */
  --surface-2: #232B34;   /* عناصر مرفوعة */
  --line:      #2E3742;   /* حدود */
  --mint:      #3DD9A0;   /* الدخل / الادخار — نعناعي */
  --mint-dim:  #2A9D77;
  --amber:     #F2B544;   /* الديون / تنبيه — كهرماني */
  --amber-dim: #C18E2E;
  --rose:      #F2715E;   /* مصروف / خروج — وردي دافئ */
  --sky:       #5BA8E0;   /* معلومات */
  --text:      #EEF2F6;   /* نص رئيسي */
  --muted:     #94A2B2;   /* نص ثانوي */
  --faint:     #5C6975;   /* نص باهت */

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 30px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
::-webkit-scrollbar { width: 0; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }

/* ───────── Screen ───────── */
.screen { padding: 24px 18px 120px; min-height: 100vh; min-height: 100dvh; }

.screen-head { margin-bottom: 22px; }
.greeting { font-size: 14px; color: var(--muted); font-weight: 600; }
.screen-title { font-size: 27px; font-weight: 900; letter-spacing: -0.6px; margin-top: 2px; }
.week-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; background: var(--surface-2); padding: 5px 12px; border-radius: 20px; margin-top: 10px; }

/* ───────── Pulse — signature element ───────── */
.pulse-wrap { display: flex; flex-direction: column; align-items: center; margin: 8px 0 28px; }
.pulse {
  position: relative; width: 230px; height: 230px;
  display: grid; place-items: center;
}
.pulse svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.pulse-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.pulse-fill { fill: none; stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.pulse-center { text-align: center; z-index: 2; }
.pulse-label { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.pulse-value { font-size: 34px; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.pulse-cur { font-size: 15px; color: var(--muted); font-weight: 700; margin-top: 5px; }
.pulse-state { font-size: 13px; font-weight: 800; margin-top: 12px; padding: 5px 14px; border-radius: 20px; }

/* ───────── Stat cards ───────── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-bottom: 13px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 17px;
  position: relative; overflow: hidden;
}
.stat-ic { font-size: 19px; margin-bottom: 9px; display: block; }
.stat-lbl { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.stat-val { font-size: 21px; font-weight: 900; letter-spacing: -0.5px; }
.stat-val .c { font-size: 12px; color: var(--muted); font-weight: 700; margin-right: 3px; }
.stat.mint .stat-val { color: var(--mint); }
.stat.amber .stat-val { color: var(--amber); }
.stat.rose .stat-val { color: var(--rose); }
.stat.sky .stat-val { color: var(--sky); }
.stat-sub { font-size: 11.5px; color: var(--faint); font-weight: 600; margin-top: 5px; }

.full-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 19px; margin-bottom: 13px;
}
.fc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.fc-title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.fc-link { font-size: 13px; color: var(--mint); font-weight: 700; }

/* progress bar (savings goal etc) */
.prog { height: 10px; background: var(--surface-2); border-radius: 10px; overflow: hidden; margin: 10px 0; }
.prog-fill { height: 100%; border-radius: 10px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.prog-fill.mint { background: linear-gradient(90deg, var(--mint-dim), var(--mint)); }
.prog-fill.amber { background: linear-gradient(90deg, var(--amber-dim), var(--amber)); }

/* ───────── List items ───────── */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 15px 16px;
  display: flex; align-items: center; gap: 13px;
}
.row-ic {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 21px;
  background: var(--surface-2);
}
.row-mid { flex: 1; min-width: 0; }
.row-name { font-size: 15px; font-weight: 700; }
.row-meta { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.row-amt { font-size: 16px; font-weight: 900; letter-spacing: -0.3px; text-align: left; white-space: nowrap; }
.row-amt.mint { color: var(--mint); }
.row-amt.rose { color: var(--rose); }
.row-amt.amber { color: var(--amber); }
.row-amt .c { font-size: 11px; color: var(--muted); font-weight: 700; }

.row-tap { transition: transform .1s; }
.row-tap:active { transform: scale(.985); }

/* debt row with progress */
.debt-row { flex-direction: column; align-items: stretch; gap: 0; }
.debt-top { display: flex; align-items: center; gap: 13px; }
.debt-prog-line { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-weight: 700; margin-top: 12px; margin-bottom: 6px; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 22px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 800; transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--mint); color: #08231A; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-amber { background: var(--amber); color: #2A1E05; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-rose { background: rgba(242,113,94,0.14); color: var(--rose); border: 1px solid rgba(242,113,94,0.3); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ───────── Tabbar ───────── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: rgba(19,23,28,0.92); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px; color: var(--faint); flex: 1; transition: color .15s;
}
.tab.active { color: var(--mint); }
.tab-ic { font-size: 20px; filter: grayscale(0.3); }
.tab.active .tab-ic { filter: none; }
.tab-lbl { font-size: 10.5px; font-weight: 700; }
.tab-add { flex: 0 0 auto; }
.tab-add-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--mint); color: #08231A;
  font-size: 32px; font-weight: 400; line-height: 1;
  display: grid; place-items: center; margin-top: -22px;
  box-shadow: 0 8px 22px rgba(61,217,160,0.4); transition: transform .12s;
}
.tab-add-btn:active { transform: scale(.9); }

/* ───────── Bottom sheet ───────── */
.sheet-host { position: fixed; inset: 0; z-index: 100; display: none; }
.sheet-host.open { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 20px calc(26px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto; animation: sheetUp .28s cubic-bezier(.4,0,.2,1);
}
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-grip { width: 42px; height: 5px; border-radius: 5px; background: var(--line); margin: 6px auto 18px; }
.sheet-title { font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.sheet-sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 20px; }

/* type picker (income/expense/etc) */
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.type-opt {
  padding: 16px; border-radius: var(--r-md); background: var(--surface-2);
  border: 2px solid transparent; display: flex; flex-direction: column;
  align-items: center; gap: 7px; transition: all .15s;
}
.type-opt .e { font-size: 25px; }
.type-opt .l { font-size: 13.5px; font-weight: 800; }
.type-opt.sel { background: var(--bg); }
.type-opt.sel.t-income { border-color: var(--mint); }
.type-opt.sel.t-expense { border-color: var(--rose); }
.type-opt.sel.t-debt { border-color: var(--amber); }
.type-opt.sel.t-payment { border-color: var(--sky); }

/* form fields */
.field-row { margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; display: block; }
.field {
  width: 100%; padding: 16px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-size: 16px; font-weight: 700; transition: border-color .15s;
}
.field:focus { outline: none; border-color: var(--mint); }
.field::placeholder { color: var(--faint); font-weight: 600; }
.field.amount { font-size: 28px; font-weight: 900; text-align: center; letter-spacing: -0.5px; }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A2B2' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 16px center; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 9px 15px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.chip.sel { background: var(--mint); color: #08231A; border-color: var(--mint); }

/* ───────── Empty state ───────── */
.empty { text-align: center; padding: 50px 20px; color: var(--faint); }
.empty .e { font-size: 50px; margin-bottom: 14px; opacity: .55; }
.empty .t { font-size: 16px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.empty .s { font-size: 13.5px; font-weight: 600; line-height: 1.6; }

/* section label */
.sec-label { font-size: 13px; font-weight: 800; color: var(--muted); margin: 22px 4px 12px; display: flex; align-items: center; justify-content: space-between; }

/* history day group */
.day-group { margin-bottom: 20px; }
.day-head { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 10px; padding: 0 4px; }

/* ───────── Toast ───────── */
.toast-host { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center; width: 100%; max-width: 520px; padding: 0 18px; }
.toast { background: var(--text); color: var(--bg); padding: 14px 22px; border-radius: var(--r-md); font-weight: 800; font-size: 14px; box-shadow: var(--shadow-lg); animation: toastUp .25s; display: flex; align-items: center; gap: 9px; }
.toast.ok { background: var(--mint); color: #08231A; }
.toast.warn { background: var(--amber); color: #2A1E05; }
@keyframes toastUp { from { opacity: 0; transform: translateY(14px); } }

/* misc */
.delete-x { color: var(--rose); font-size: 13px; font-weight: 700; padding: 6px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.tiny-note { font-size: 12px; color: var(--faint); font-weight: 600; text-align: center; line-height: 1.7; margin-top: 14px; }
