:root {
  --navy: #0b1f33; --navy-2: #13314f; --gold: #b8955a; --gold-soft: #e9dcc3;
  --ink: #1a2633; --muted: #6b7684; --line: #e6e1d8; --bg: #faf8f4; --card: #ffffff;
  --green: #2f7d5b; --green-soft: #e3f1ea; --red: #b4483c; --red-soft: #f7e4e1;
  --amber: #b07a1c; --amber-soft: #f6ecd7;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif; font-size: 16px; line-height: 1.5;
  min-height: 100dvh; padding-bottom: calc(76px + var(--safe-b));
}
body.no-nav { padding-bottom: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; }
.top .sub { color: var(--gold-soft); font-size: 13px; font-weight: 400; display: block; }
.top .icon-btn { color: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; }
.top .icon-btn:active { background: var(--navy-2); }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* ---------- bottom nav ---------- */
nav.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding: 6px 8px calc(6px + var(--safe-b));
}
nav.tabs a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px;
  padding: 6px 0; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a.on { color: var(--navy); font-weight: 600; }
nav.tabs a.on svg { color: var(--gold); }

/* ---------- common ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }
h2 { font-size: 16px; margin: 20px 0 10px; color: var(--navy); }
h2:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 12px; font-weight: 600; background: var(--navy); color: #fff; min-height: 48px;
}
.btn:active { background: var(--navy-2); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red-soft); }
.btn.wa { background: #1f9d55; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

.seg { display: flex; background: #efeae0; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 15px; }
.seg button.on { background: var(--card); color: var(--navy); box-shadow: 0 1px 3px rgba(11,31,51,.12); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 15px; color: var(--ink); min-height: 40px;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=month], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; min-height: 48px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--navy); font-weight: 600; }
.badge.navy { background: var(--navy); color: #fff; }

/* ---------- attendance ---------- */
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 18px; color: var(--navy); }
.datebar .datebox { flex: 1; position: relative; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-height: 44px; }
.datebar .datebox b { display: block; font-size: 15px; color: var(--navy); }
.datebar .datebox small { color: var(--muted); font-size: 12px; }
.datebar .datebox input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

.tally { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.tally span { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: #efeae0; }
.tally .p { background: var(--green-soft); color: var(--green); }
.tally .a { background: var(--red-soft); color: var(--red); }
.tally .l { background: var(--amber-soft); color: var(--amber); }

.att { padding: 12px; }
.att .name { font-weight: 600; font-size: 16px; }
.status { display: flex; gap: 6px; margin-top: 10px; }
.status button {
  flex: 1; padding: 10px 4px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 15px; color: var(--muted);
  min-height: 46px;
}
.status button.p.on { background: var(--green); border-color: var(--green); color: #fff; }
.status button.a.on { background: var(--red); border-color: var(--red); color: #fff; }
.status button.l.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.att.marked-p { border-inline-start: 4px solid var(--green); }
.att.marked-a { border-inline-start: 4px solid var(--red); }
.att.marked-l { border-inline-start: 4px solid var(--amber); }

.stars { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.stars .srow { display: flex; align-items: center; justify-content: space-between; padding: 2px 0; }
.stars .srow > span { font-size: 14px; color: var(--muted); width: 64px; }
.stars .set { display: flex; }
.stars .set button { width: 40px; height: 38px; font-size: 24px; line-height: 1; color: #d9d2c4; }
.stars .set button.on { color: var(--gold); }

/* ---------- swimmers ---------- */
.sw { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: var(--gold-soft); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.avatar.learn { background: var(--gold-soft); color: var(--navy); }
.sw .count { text-align: center; min-width: 48px; }
.sw .count b { display: block; font-size: 20px; color: var(--navy); }
.sw .count small { font-size: 11px; color: var(--muted); }
.fab {
  position: fixed; inset-inline-start: 16px; bottom: calc(88px + var(--safe-b)); z-index: 25;
  background: var(--gold); color: #fff; border-radius: 999px; padding: 14px 20px; font-weight: 600; box-shadow: 0 6px 18px rgba(11,31,51,.25);
}

/* ---------- profile ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; }
.stat small { color: var(--muted); font-size: 12px; }
.stat.p b { color: var(--green); } .stat.a b { color: var(--red); } .stat.l b { color: var(--amber); }
.progress { height: 8px; background: #efeae0; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.datechips { display: flex; flex-wrap: wrap; gap: 6px; }
.datechips span { font-size: 13px; padding: 4px 10px; border-radius: 8px; }
.datechips .p { background: var(--green-soft); color: var(--green); }
.datechips .a { background: var(--red-soft); color: var(--red); }
.datechips .l { background: var(--amber-soft); color: var(--amber); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.t tr:last-child td { border-bottom: 0; }
.best { color: var(--gold); font-weight: 600; }
.down { color: var(--green); font-size: 12px; } .up { color: var(--red); font-size: 12px; }
.x { color: var(--muted); padding: 4px 8px; font-size: 18px; }
.event-title { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; font-weight: 600; color: var(--navy); }
.event-title:first-child { margin-top: 0; }

.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }

/* ---------- sheet (modal) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(11,31,51,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(16px + var(--safe-b)); max-height: 92dvh; overflow-y: auto;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grip { width: 40px; height: 4px; background: var(--line); border-radius: 9px; margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; color: var(--navy); font-size: 18px; }
.timebox { display: flex; gap: 8px; direction: ltr; align-items: flex-end; }
.timebox label { flex: 1; text-align: center; }
.timebox label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.timebox input { text-align: center; font-size: 22px; font-weight: 600; }
.timebox .sep { font-size: 22px; padding-bottom: 10px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .mark { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px; display: block; }
.login h1 { text-align: center; color: var(--navy); margin: 0 0 4px; font-size: 22px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 24px; }
.err { color: var(--red); font-size: 14px; margin: -6px 0 12px; min-height: 20px; }

/* ---------- toast + sync ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 60;
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(11,31,51,.25); transition: opacity .2s;
}
.sync { font-size: 12px; color: var(--gold-soft); }

/* ---------- payment status ---------- */
.badge.due { background: var(--amber-soft); color: var(--amber); }
.badge.late { background: var(--red); color: #fff; }
.card.pay-due { background: #fffaf0; border-color: #ecd9b0; }
.card.pay-late { background: #fdf3f1; border-color: #eec3bc; }
.sw .badge { margin-top: 4px; }
.att .row .badge + .badge { margin-inline-start: 4px; }
