:root {
  --navy: #1a3866; --navy-2: #24497d; --gold: #c9a24a; --gold-2: #e6c77a; --cream: #f7f2e7;
  --ink: #14213a; --muted: #6b7690; --line: #e4dccb; --ok: #1f8a4c; --bad: #c0392b; --warn: #d68910;
  --radius: 18px; --tabs-h: 74px; --hdr-h: 60px;
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--cream); color: var(--ink); }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; background: var(--cream); }

/* Header: big logo overlapping the bottom edge */
.hdr { position: sticky; top: 0; z-index: 20; height: calc(var(--hdr-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  background: #fff; box-shadow: 0 4px 14px rgba(26,56,102,.08); display: flex; align-items: center; justify-content: space-between;
  padding-inline: 14px; border-bottom: 3px solid var(--gold); }
.brand { position: absolute; left: 50%; transform: translateX(-50%); bottom: -58px; display: flex; align-items: center; justify-content: center; }
.brand img { height: 112px; width: auto; filter: drop-shadow(0 3px 6px rgba(26,56,102,.18)); }
.logo-text { display: none; font-weight: 800; font-size: 34px; color: var(--navy); }
.back { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--navy); color: var(--gold-2); font-size: 30px; line-height: 1; cursor: pointer; }
.back span { display: inline-block; transform: translateY(-2px); }
[dir=rtl] .back span { transform: scaleX(-1) translateY(-2px); }
.back.hide { visibility: hidden; }
.avatar { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--gold); background: var(--navy); overflow: visible;
  display: flex; align-items: center; justify-content: center; color: var(--gold-2); font-weight: 800; font-size: 20px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: none; }
.avatar img.on { display: block; }
.dot { position: absolute; top: -2px; inset-inline-end: -2px; width: 16px; height: 16px; border-radius: 50%; background: #e53935; border: 2px solid #fff; }

.view { padding: 72px 14px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
.view.auth { padding-bottom: 40px; }
h1, h2, h3 { text-align: center; margin: 10px 0 14px; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* Bottom tabs */
.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 30;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); box-shadow: 0 -6px 20px rgba(14,33,64,.08); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.tabs a .ti { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.tabs a.on { color: var(--navy); }
.tabs a.on .ti { background: var(--navy); color: var(--gold-2); }

/* Sliding cards */
.slider { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; padding: 4px 2px 10px; scrollbar-width: none; }
.slider::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 88%; scroll-snap-align: center; min-height: 190px; border-radius: var(--radius); color: #fff; position: relative; overflow: hidden;
  background: var(--navy); box-shadow: 0 10px 24px rgba(14,33,64,.18); }
.slide .bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .55; }
.slide .shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(14,33,64,.95), rgba(14,33,64,.25)); }
.slide .in { position: relative; padding: 16px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-height: 190px; }
.slide .tag { position: absolute; top: 12px; inset-inline-start: 12px; background: var(--gold); color: var(--navy); font-weight: 800; font-size: 12px; padding: 4px 10px; border-radius: 99px; }
.slide .big { font-size: 22px; font-weight: 800; }
.slide .osm { position: absolute; bottom: 4px; inset-inline-end: 8px; font-size: 9px; opacity: .7; }
.dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #cfc5ae; }
.dots i.on { background: var(--navy); width: 20px; border-radius: 6px; }

/* Cards & lists */
.card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(14,33,64,.06); border: 1px solid var(--line); }
.card.navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 10px; }
.thumb { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: linear-gradient(135deg, var(--navy), var(--navy-2)); flex: 0 0 auto;
  display: grid; place-items: center; color: var(--gold-2); font-weight: 800; font-size: 12px; overflow: hidden; text-align: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ring { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .5px; direction: ltr; unicode-bidi: embed; }
.title { font-weight: 800; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--cream); border: 1px solid var(--line); }
.chip.gold { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.chip.ok { background: #e3f4ea; color: var(--ok); border-color: #bfe3cd; }
.chip.bad { background: #fbe7e5; color: var(--bad); border-color: #f2c2bd; }
.chip.warn { background: #fdf0dc; color: var(--warn); border-color: #f4d6a6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--cream); border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }

/* Segmented tabs */
.seg { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 14px; gap: 4px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--navy); color: var(--gold-2); }

/* Forms */
label { display: block; font-weight: 700; font-size: 14px; margin: 10px 0 6px; }
.field { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-size: 16px; color: var(--ink); }
.field:focus { outline: none; border-color: var(--gold); }
.pw { position: relative; }
.pw .field { padding-inline-end: 52px; }
.pw .eye { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: transparent; font-size: 20px; cursor: pointer; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 14px; border: 0; background: var(--navy); color: var(--gold-2); font-weight: 800; font-size: 16px; cursor: pointer; text-align: center; margin-top: 12px; }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn.bad { background: var(--bad); color: #fff; }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .5; }
.big-btn { padding: 22px; font-size: 20px; border-radius: 20px; }

/* Map & photos */
.map { width: 100%; height: 180px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #dde3ea; position: relative; }
.map iframe { width: 100%; height: 100%; border: 0; }
.photo-pick { display: block; width: 100%; aspect-ratio: 16/9; border-radius: 16px; border: 2px dashed var(--gold); background: #fff center/cover no-repeat;
  display: grid; place-items: center; color: var(--navy); font-weight: 800; cursor: pointer; overflow: hidden; }
.photo-pick input { display: none; }
.hero-photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); background: var(--navy); display: block; }

/* Clock screen */
.clock-face { text-align: center; background: var(--navy); color: var(--gold-2); border-radius: 22px; padding: 18px; margin-bottom: 14px; }
.clock-face .t { font-size: 46px; font-weight: 800; direction: ltr; font-variant-numeric: tabular-nums; }
.bird-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border-radius: 18px; border: 2px solid var(--navy); background: #fff; margin-bottom: 10px; cursor: pointer; text-align: start; }
.bird-btn.done { border-color: var(--ok); background: #eef8f2; }

/* Results table */
.res { width: 100%; border-collapse: collapse; background: #fff; border-radius: 16px; overflow: hidden; font-size: 14px; }
.res th { background: var(--navy); color: var(--gold-2); padding: 10px 6px; font-size: 12px; }
.res td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: center; }
.res tr.me td { background: #fbf4e2; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; background: var(--cream); }
.medal.m1 { background: #e6c35c; } .medal.m2 { background: #cfd4dc; } .medal.m3 { background: #d9a273; }

/* Pedigree */
.ped { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; align-items: center; }
.ped .col { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; height: 100%; }
.pnode { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px; font-size: 11px; text-align: center; min-height: 54px; display: flex; flex-direction: column; justify-content: center; }
.pnode.cock { border-color: #8aa6d6; } .pnode.hen { border-color: #d99ab5; }
.pnode.root { background: var(--navy); color: #fff; border-color: var(--gold); }
.pnode.empty { color: #bbb; border-style: dashed; }
.pnode .ring { font-size: 10px; }

/* Store */
.prod { display: flex; gap: 12px; }
.prod .thumb { width: 88px; height: 88px; }
.price { font-weight: 800; color: var(--navy); }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.qty button { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--navy); background: #fff; font-weight: 800; font-size: 18px; cursor: pointer; }
.cart-bar { position: fixed; bottom: calc(var(--tabs-h) + 10px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: calc(100% - 28px); max-width: 532px; z-index: 25; }

/* More menu */
.menu a, .menu button.mi { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 16px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; margin-bottom: 10px; font-weight: 700; font-size: 16px; color: var(--ink); cursor: pointer; text-align: start; }
.menu .arrow { color: var(--gold); font-size: 22px; }
[dir=rtl] .menu .arrow { transform: scaleX(-1); }
.switch { width: 52px; height: 30px; border-radius: 99px; background: #ccc; position: relative; transition: .2s; flex: 0 0 auto; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { inset-inline-start: 25px; }

.toast { position: fixed; bottom: calc(var(--tabs-h) + 20px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 14px; z-index: 100; font-weight: 700; max-width: 90%; text-align: center; box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; margin: 40px auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { background: #fdf0dc; border: 1px solid #f4d6a6; border-radius: 14px; padding: 12px; font-size: 14px; margin-bottom: 12px; }

@media print {
  .hdr, .tabs, .noprint, .toast { display: none !important; }
  .view { padding: 0 !important; }
  body, .app { background: #fff; }
  .ped { gap: 4px; }
  .pnode { font-size: 10px; }
}
