:root {
  --bg: #0b1220;
  --surface: #142033;
  --surface-2: #1c2c44;
  --line: #27384f;
  --text: #e8eef6;
  --muted: #93a4ba;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --amber: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  padding-bottom: calc(64px + var(--safe-b));
  min-height: 100vh;
}

[dir="rtl"] { font-family: "Noto Naskh Arabic", "Noto Sans Arabic", -apple-system, "Segoe UI", Roboto, sans-serif; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(15,118,110,0.25), transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark { font-size: 22px; }
.lang-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}

.view { padding: 16px; max-width: 720px; margin: 0 auto; }

.view-title { font-size: 22px; font-weight: 700; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.section { margin-bottom: 22px; }

/* Cards / stats */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-value.in { color: var(--ok); }
.stat-value.out { color: var(--amber); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row .amount { font-weight: 700; white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin-inline-start: 6px;
}
.badge.paid { background: rgba(34,197,94,0.18); color: var(--ok); }
.badge.partial { background: rgba(251,191,36,0.18); color: var(--amber); }
.badge.unpaid { background: rgba(239,68,68,0.18); color: var(--danger); }
.dir-in { color: var(--ok); }
.dir-out { color: var(--amber); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; }
.fab {
  position: fixed;
  inset-inline-end: 16px;
  bottom: calc(76px + var(--safe-b));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 26px;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 15;
}

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { outline: 2px solid var(--brand-2); }
textarea.input { min-height: 120px; resize: vertical; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-weight: 600; cursor: pointer;
}
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Nav */
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 20;
}
.nav-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 11px;
}
.nav-btn .nav-ico { font-size: 20px; }
.nav-btn.is-active { color: var(--brand-2); }

/* Toast */
.toast {
  position: fixed;
  inset-inline: 0;
  bottom: calc(80px + var(--safe-b));
  margin: 0 auto;
  max-width: 420px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 30;
  padding: 0;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--line);
  padding: 18px 16px calc(18px + var(--safe-b));
  max-height: 92vh;
  overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }

/* Photo */
.photo-thumb {
  width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line);
}
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-box {
  position: relative; width: 96px; height: 96px;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.photo-box .del {
  position: absolute; top: -6px; inset-inline-end: -6px;
  background: var(--danger); color: #fff; border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 13px; cursor: pointer;
}

.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
}
.empty .big { font-size: 40px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 14px;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.scroll-x { overflow-x: auto; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.summary-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; white-space: pre-wrap;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
}

/* Trial banner */
.trial-banner {
  text-align: center;
  background: rgba(251,191,36,0.16);
  color: var(--amber);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
}
.trial-banner[hidden] { display: none; }

/* Trial lock screen */
body.is-locked .bottom-nav,
body.is-locked .fab,
body.is-locked .trial-banner { display: none !important; }
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lock-card {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; text-align: center;
  box-shadow: var(--shadow);
}
.lock-emoji { font-size: 40px; }
.lock-card h2 { margin: 6px 0 10px; font-size: 20px; }
.lock-contact {
  text-align: start; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin: 14px 0; font-size: 15px;
}
.lock-contact a { color: var(--brand-2); }
.lock-err { color: var(--danger); min-height: 18px; margin: 6px 0; font-size: 14px; }

