@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('fonts/tajawal-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --palm: #1e6b4a;
  --palm-d: #134a33;
  --palm-l: #e3f1e9;
  --gold: #c9962b;
  --gold-l: #fbf0d6;
  --date: #7a4a24;
  --sand: #f7f1e3;
  --card: #fffdf8;
  --ink: #23201b;
  --muted: #7b7366;
  --line: #e8dfcc;
  --red: #b23b2e;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--sand);
  background-image:
    radial-gradient(circle at 20px 20px, rgba(201,150,43,.09) 2px, transparent 2.5px),
    radial-gradient(circle at 0 0, rgba(30,107,74,.05) 2px, transparent 2.5px);
  background-size: 40px 40px, 40px 40px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  overscroll-behavior: none;
}
h1, h2, h3, h4 { margin: .2em 0 .4em; line-height: 1.3; }
h1 { font-size: 30px; font-weight: 800; color: var(--palm-d); }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: 10px; }
.grow { flex: 1; }

.center-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: calc(24px + var(--safe-t)) 24px 24px; gap: 6px;
}
.logo-big { font-size: 74px; filter: drop-shadow(0 6px 12px rgba(122,74,36,.25)); }
.logo-mid { font-size: 48px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.login { position: relative; overflow: hidden; }
.login .palms { position: absolute; font-size: 220px; opacity: .07; bottom: -40px; left: -40px; transform: rotate(-12deg); pointer-events: none; }
.lead { font-size: 18px; color: var(--date); font-weight: 500; margin: 0 0 8px; }
.features { list-style: none; padding: 0; margin: 10px 0 22px; text-align: right; display: grid; gap: 8px; }
.features li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 16px; }

.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 14px; padding: 14px 18px; cursor: pointer;
  min-height: 52px; transition: transform .12s, opacity .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ''; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border: 3px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.primary { background: var(--palm); color: #fff; box-shadow: 0 4px 0 var(--palm-d); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--palm-d); border: 2px solid var(--line); }
.btn.link { background: none; color: var(--palm); min-height: 40px; padding: 8px; font-weight: 500; }
.btn.block { display: block; width: 100%; margin-top: 14px; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 10px; box-shadow: none; }
.btn.google { background: #fff; color: #222; border: 2px solid var(--line); display: inline-flex; align-items: center; gap: 12px; font-size: 18px; padding: 14px 26px; box-shadow: 0 6px 18px rgba(0,0,0,.08); }

.icon-btn { border: 0; background: none; color: var(--muted); font-size: 18px; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; }
.icon-btn:active { background: var(--line); }

.page { padding: calc(18px + var(--safe-t)) 16px 40px; max-width: 560px; margin: 0 auto; }
.hello { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 2px 0 rgba(122,74,36,.06); }
.card.warn { border-color: var(--gold); background: var(--gold-l); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
.check-line { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 15px; }
.input { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); min-height: 52px; }
.input:focus { outline: none; border-color: var(--palm); }
.code-input { font-size: 24px; letter-spacing: 4px; text-align: center; font-weight: 800; font-family: monospace; }
.or { text-align: center; position: relative; margin: 6px 0; color: var(--muted); }
.or::before { content: ''; position: absolute; top: 50%; right: 0; left: 0; border-top: 1px dashed var(--line); }
.or span { background: var(--sand); position: relative; padding: 0 12px; }

/* الهيكل الرئيسي */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto; }
.topbar {
  background: linear-gradient(135deg, var(--palm) 0%, var(--palm-d) 100%); color: #fff;
  padding: calc(12px + var(--safe-t)) 16px 14px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 4px solid var(--gold);
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; font-size: 19px; font-weight: 800; }
.brand small { display: block; opacity: .85; font-size: 13.5px; }
.logo-sm { font-size: 34px; background: rgba(255,255,255,.15); border-radius: 14px; width: 50px; height: 50px; display: grid; place-items: center; }
.me { background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 20px; font-size: 14px; }
.content { flex: 1; overflow-y: auto; padding: 14px 14px 24px; -webkit-overflow-scrolling: touch; }

.bottomnav {
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
}
.bottomnav button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; cursor: pointer; border-radius: 12px; }
.bottomnav button.active { color: var(--palm-d); font-weight: 800; background: var(--palm-l); }
.ni { font-size: 25px; position: relative; line-height: 1.2; }
.badge { position: absolute; top: -4px; left: -14px; background: var(--red); color: #fff; font-style: normal; font-size: 11.5px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }

.summary { background: var(--gold-l); border: 1px solid #ead39a; color: var(--date); border-radius: 14px; padding: 10px 14px; margin-bottom: 6px; }
.summary.done { background: var(--palm-l); border-color: #bfe0cd; color: var(--palm-d); }
.group { color: var(--date); font-size: 16px; margin: 18px 4px 8px; display: flex; align-items: center; gap: 6px; }
.group small { background: var(--line); border-radius: 10px; padding: 0 8px; font-size: 12.5px; color: var(--ink); }

.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 10px 6px; margin-bottom: 8px; transition: opacity .3s, transform .3s; }
.item.leaving { opacity: .3; transform: translateX(-30px); }
.item .info { flex: 1; cursor: pointer; min-width: 0; }
.item .name { font-weight: 700; font-size: 18px; }
.qty { background: var(--palm-l); color: var(--palm-d); font-size: 13.5px; border-radius: 8px; padding: 1px 8px; font-weight: 500; }
.note { color: var(--date); font-size: 14.5px; }
.meta { color: var(--muted); font-size: 13px; }
.check { width: 40px; height: 40px; flex: none; border-radius: 12px; border: 3px solid var(--palm); background: #fff; cursor: pointer; position: relative; }
.check.on { background: var(--palm); }
.check.on::after, .check:active::after { content: '✓'; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.check:active { background: var(--palm); }
.item.done { opacity: .75; }
.item.done .name { text-decoration: line-through; text-decoration-color: var(--palm); }
.bought { margin-top: 20px; }
.bought summary { cursor: pointer; font-weight: 700; color: var(--palm-d); padding: 12px 6px; list-style: none; }
.bought summary::before { content: '▾ '; }

.cats { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -14px; padding-inline: 14px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex: none; font: inherit; font-size: 15.5px; border: 2px solid var(--line); background: var(--card); border-radius: 22px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--palm); color: #fff; border-color: var(--palm); font-weight: 700; }
.hint { font-size: 13.5px; color: var(--muted); margin: 2px 4px 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
.tile { font: inherit; font-size: 16.5px; font-weight: 700; min-height: 74px; border: 2px solid var(--line); background: var(--card); border-radius: 16px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 6px; text-align: center; user-select: none; -webkit-user-select: none; transition: transform .1s; }
.tile:active { transform: scale(.95); background: var(--palm-l); }
.tile i { font-style: normal; font-size: 12px; font-weight: 500; color: var(--palm); }
.tile.in { border-color: var(--palm); background: var(--palm-l); }
.tile.plus { border-style: dashed; border-color: var(--gold); color: var(--date); font-size: 28px; }
.tile.plus i { color: var(--date); }

.event { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 7px; }
.event .ei { font-size: 22px; }
.event.bought { border-inline-start: 4px solid var(--palm); }
.event.add { border-inline-start: 4px solid var(--gold); }

.fam-head .count { color: var(--muted); font-size: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--palm)); }
.member { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.member:last-child { border-bottom: 0; }
.member small { color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--palm); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.tag { font-size: 11.5px; background: var(--gold-l); color: var(--date); border-radius: 8px; padding: 1px 7px; margin-inline-start: 4px; }
.tag.me { background: var(--palm-l); color: var(--palm-d); }
.code-card { text-align: center; border: 2px dashed var(--gold); }
.code { font-family: monospace; font-size: 38px; font-weight: 800; letter-spacing: 6px; color: var(--palm-d); background: var(--gold-l); border-radius: 14px; padding: 8px; margin: 6px 0 10px; }

.empty { text-align: center; padding: 50px 20px; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(20,20,15,.0); display: flex; align-items: flex-end; justify-content: center; z-index: 50; transition: background .25s; }
.sheet-wrap.open { background: rgba(20,20,15,.45); }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); transform: translateY(100%); transition: transform .25s ease-out; max-height: 90vh; overflow-y: auto; }
.sheet-wrap.open .sheet { transform: none; }
.sheet .row { margin-top: 16px; }

.toast { position: fixed; top: calc(14px + var(--safe-t)); right: 14px; left: 14px; margin: auto; max-width: 480px; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 14px; z-index: 99; font-weight: 500; box-shadow: 0 10px 24px rgba(0,0,0,.25); transform: translateY(-140%); transition: transform .3s ease; }
.toast.show { transform: none; }
.toast.ok { background: var(--palm-d); }
.toast.err { background: var(--red); }
