:root {
  --navy: #001d38;
  --navy-2: #0b2540;
  --navy-3: #12314f;
  --gold: #c89b4a;
  --gold-light: #e0b96e;
  --ink: #eef2f6;
  --ink-dim: #a9b7c6;
  --danger: #c0453a;
  --ok: #3a8f5c;
  --border: rgba(255,255,255,0.08);
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--ink);
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, var(--navy) 70%, rgba(0,29,56,0.92));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.topbar img.brand-logo { height: 30px; width: auto; }

.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  flex: 1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: var(--navy-3);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- Content ---------- */
main {
  flex: 1;
  padding: 14px 16px calc(90px + env(safe-area-inset-bottom, 0px));
}

.section-label {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 18px 4px 8px;
  font-weight: 600;
}

/* ---------- Cards ---------- */
.card {
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.project-card:active { background: var(--navy-3); }

.project-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), #a97e33);
  color: var(--navy);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.project-card .info { flex: 1; min-width: 0; }
.project-card .info .name {
  font-weight: 700;
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card .info .meta {
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-top: 2px;
}
.project-card .chev { color: var(--ink-dim); font-size: 20px; }

.empty-state {
  text-align: center;
  color: var(--ink-dim);
  padding: 50px 20px;
  font-size: 14px;
  line-height: 1.9;
}
.empty-state .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn-ghost { background: var(--navy-3); color: var(--ink); }
.btn-danger { background: rgba(192,69,58,0.15); color: #ff8b7f; border: 1px solid rgba(192,69,58,0.4); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

.fab {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  max-width: 560px;
  width: calc(100% - 32px);
  z-index: 25;
}
.fab .btn { width: 100%; box-shadow: var(--shadow); font-size: 15.5px; padding: 15px; }

.action-row { display: flex; gap: 10px; margin-top: 10px; }
.action-row .btn { flex: 1; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar input[type="date"] {
  background: var(--navy-3);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12.5px;
  flex: 1;
  min-width: 110px;
  color-scheme: dark;
}
.filter-bar .sep { color: var(--ink-dim); font-size: 12px; }
.filter-bar .clear-link {
  font-size: 12px;
  color: var(--gold-light);
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Entry list ---------- */
.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.entry-row:last-child { border-bottom: none; }
.entry-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--navy-3);
  border: 1px solid var(--border);
}
.entry-thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim); font-size: 18px;
}
.entry-row .info { flex: 1; min-width: 0; }
.entry-row .info .item-name {
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry-row .info .item-meta {
  font-size: 12px; color: var(--ink-dim); margin-top: 2px;
}
.entry-row .amount {
  font-weight: 700; font-size: 14px; color: var(--gold-light);
  white-space: nowrap;
}

/* ---------- Summary strip ---------- */
.summary-strip {
  display: flex;
  justify-content: space-between;
  background: var(--navy-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.summary-strip .stat { text-align: center; flex: 1; }
.summary-strip .stat .val { font-size: 16px; font-weight: 800; color: var(--gold-light); }
.summary-strip .stat .lbl { font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.summary-strip .divider { width: 1px; background: var(--border); margin: 0 4px; }

/* ---------- Modal / sheet ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--navy);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.sheet-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 0 auto 14px;
}

.sheet h2 { font-size: 17px; margin: 0 0 16px; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; color: var(--ink-dim);
  margin-bottom: 6px; font-weight: 600;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  background: var(--navy-2);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14.5px;
  font-family: inherit;
  color-scheme: dark;
}
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.photo-picker {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-dim);
  font-size: 13px;
  position: relative;
  overflow: hidden;
}
.photo-picker img {
  max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin: 0 auto;
}
.photo-picker .hint { margin-top: 6px; }
.photo-picker input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.photo-remove {
  margin-top: 8px; font-size: 12.5px; color: #ff8b7f; cursor: pointer; text-align: center;
}

.total-preview {
  background: var(--navy-3);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
}
.total-preview .val { font-weight: 800; color: var(--gold-light); font-size: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  background: #1c2b3a;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 30px;
  font-size: 13.5px;
  z-index: 60;
  box-shadow: var(--shadow);
  max-width: 90%;
  text-align: center;
}

/* ---------- Misc ---------- */
.back-row { display: flex; align-items: center; gap: 10px; }
.hidden { display: none !important; }
a { color: inherit; }

::-webkit-scrollbar { width: 0; height: 0; }
