:root {
  --bg: #f3efe5;
  --surface: #fffdf8;
  --surface-2: #faf7ef;
  --ink: #16211f;
  --ink-2: #43514e;
  --muted: #7b8783;
  --line: rgba(22, 33, 31, 0.09);
  --teal: #0e6f63;
  --teal-2: #0a5a50;
  --teal-soft: #e3f1ee;
  --gold: #d9a521;
  --gold-2: #a9790d;
  --gold-soft: #fbf0cf;
  --danger: #b4442f;
  --danger-soft: #f8e5e0;
  --shadow: 0 12px 34px rgba(22, 33, 31, 0.09);
  --shadow-sm: 0 2px 10px rgba(22, 33, 31, 0.06);
  --r: 18px;
  --max: 1080px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Heebo", "Assistant", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(1100px 560px at 85% -10%, #fbf3d9 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 18%, #e7f2ee 0%, transparent 56%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

.app {
  min-height: 100dvh;
}

.topbar {
  position: relative;
  padding: calc(14px + env(safe-area-inset-top)) 18px 16px;
  color: #f7f2e7;
  background: linear-gradient(160deg, #17332e 0%, #0d211e 58%, #1a3832 100%);
  border-radius: 0 0 26px 26px;
  box-shadow: 0 18px 40px rgba(10, 30, 27, 0.18);
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  bottom: -130px;
  width: 270px;
  height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 165, 33, 0.3), transparent 66%);
  pointer-events: none;
}

.brand-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #2a2108;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(145deg, #f3cb63, #c9931c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 6px 14px rgba(0, 0, 0, 0.22);
}

.brand-text {
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 15.5px;
  letter-spacing: 0.01em;
}

.brand-text > span {
  display: block;
  margin-top: 2px;
  color: rgba(247, 242, 231, 0.62);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid rgba(246, 211, 124, 0.28);
  border-radius: 999px;
  color: #f6d37c;
  background: rgba(246, 211, 124, 0.14);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.chip.parent {
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(247, 242, 231, 0.85);
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #f7f2e7;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.main {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 18px 16px calc(104px + env(safe-area-inset-bottom));
}

body.parent-mode .main {
  max-width: 560px;
  padding-bottom: calc(34px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 24px), var(--max));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(22, 33, 31, 0.16);
}

body.parent-mode .tabbar {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border-radius: 15px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.tab svg {
  width: 21px;
  height: 21px;
}

.tab.active {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 6px 14px rgba(14, 111, 99, 0.28);
}

.tab:not(.active):hover {
  color: var(--ink-2);
  background: var(--surface-2);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 2px 16px;
}

.page-head h1 {
  margin: 0 0 3px;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 15px;
  border-radius: 12px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 6px 14px rgba(14, 111, 99, 0.22);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  transition: 0.15s;
}

.btn:hover {
  background: var(--teal-2);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn.gold {
  color: #2a2108;
  background: var(--gold);
  box-shadow: 0 6px 14px rgba(217, 165, 33, 0.25);
}

.btn.ghost {
  color: var(--teal);
  background: var(--teal-soft);
  box-shadow: none;
}

.btn.subtle {
  color: var(--ink-2);
  background: #f0ede3;
  box-shadow: none;
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  box-shadow: none;
}

.btn.sm {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-card {
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-card b {
  display: block;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.stat-card.gold b {
  color: var(--gold-2);
}

.stat-card.teal b {
  color: var(--teal);
}

.stat-card.danger b {
  color: var(--danger);
}

.panel {
  margin-bottom: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.progress {
  height: 9px;
  margin: 10px 0 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece6d8;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), #f0c65a);
  transition: width 0.3s;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.quick-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.search {
  flex: 1 1 190px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--muted);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.search:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 111, 99, 0.12);
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.seg {
  flex: none;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.seg.active {
  color: #fff;
  background: var(--teal);
}

.data-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: #fff;
  transition: 0.15s;
}

.data-row:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.data-row .profile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 17px;
}

.data-serial {
  width: 42px;
  flex: none;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  text-align: center;
}

.data-main {
  flex: 1;
  min-width: 0;
}

.data-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 800;
}

.data-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.data-side {
  flex: none;
  text-align: left;
  font-size: 11px;
  color: var(--muted);
}

.data-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: none;
}

.icon-action {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--ink-2);
  background: #f4f1e8;
}

.icon-action:hover {
  background: var(--teal-soft);
  color: var(--teal);
}

.icon-action svg {
  width: 16px;
  height: 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.status.available {
  color: var(--teal);
  background: var(--teal-soft);
}

.status.claimed {
  color: #7a5706;
  background: var(--gold-soft);
}

.status.void {
  color: var(--danger);
  background: var(--danger-soft);
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.02em;
  direction: ltr;
  unicode-bidi: embed;
}

.code {
  font-size: 11px;
  color: var(--muted);
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.family-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.family-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.family-main {
  flex: 1;
  min-width: 0;
}

.family-name {
  font-size: 14.5px;
  font-weight: 800;
}

.family-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.family-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.family-hero {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.family-hero h2 {
  margin: 0 0 4px;
  font-size: 21px;
}

.family-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.family-code {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--gold-soft);
  color: #6a4d05;
  font-size: 12px;
  font-weight: 700;
}

.child-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: #fff;
}

.child-row:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.child-main {
  flex: 1;
  min-width: 0;
}

.child-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
}

.child-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.child-balance {
  flex: none;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.child-detail-hero {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.profile-avatar {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 24px;
  font-weight: 800;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-info h2 {
  margin: 0;
  font-size: 20px;
}

.profile-info p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.balance-big {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.balance-big small {
  color: var(--muted);
  font-size: 14px;
}

.activity {
  display: flex;
  flex-direction: column;
}

.act-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 3px;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}

.act-row:last-child {
  border-bottom: 0;
}

.act-ic {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--teal);
  background: var(--teal-soft);
}

.act-ic.gold {
  color: var(--gold-2);
  background: var(--gold-soft);
}

.act-ic.red {
  color: var(--danger);
  background: var(--danger-soft);
}

.act-ic svg {
  width: 15px;
  height: 15px;
}

.act-main {
  flex: 1;
  min-width: 0;
}

.act-main b {
  font-weight: 800;
}

.act-time {
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 1px;
}

.act-amt {
  white-space: nowrap;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.act-amt.pos {
  color: var(--teal);
}

.act-amt.neg {
  color: var(--gold-2);
}

.voided {
  opacity: 0.45;
  text-decoration: line-through;
}

.btn-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 22px;
  border-radius: 24px;
  color: #f8f3e6;
  background: linear-gradient(145deg, #17332e 0%, #0d211e 58%, #1c3a33 100%);
  box-shadow: 0 24px 50px rgba(10, 30, 27, 0.26);
}

.hero::before {
  content: "";
  position: absolute;
  inset-inline-end: -80px;
  bottom: -130px;
  width: 270px;
  height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 165, 33, 0.32), transparent 66%);
}

.hero-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(248, 243, 230, 0.7);
  font-size: 10.5px;
}

.hero-name {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  font-size: 23px;
  font-weight: 800;
}

.hero-balance {
  position: relative;
  z-index: 1;
  margin-top: 2px;
  color: #fff;
  font-size: 50px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.hero-balance small {
  color: #f6d37c;
  font-size: 22px;
}

.hero-sub {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  color: rgba(248, 243, 230, 0.7);
  font-size: 12px;
}

.child-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.child-card .profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 19px;
}

.child-card-main {
  flex: 1;
  min-width: 0;
}

.child-card-main b {
  display: block;
  font-size: 14.5px;
}

.child-card-main span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.child-card-balance {
  flex: none;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.steps {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px;
  border-radius: 11px;
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.5;
}

.step-num {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #2a2108;
  background: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.inline-form {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}

.inline-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: #fff;
  font-size: 14px;
}

.inline-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 111, 99, 0.12);
}

.prize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 9px;
}

.prize {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 138px;
  padding: 11px;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.prize-art {
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, #fff);
}

.prize-art svg {
  width: 26px;
  height: 26px;
}

.prize-name {
  display: block;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.25;
}

.prize-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin-top: auto;
  color: var(--muted);
  font-size: 10.5px;
}

.prize-meta b {
  color: var(--ink);
  font-size: 15px;
}

.prize-can {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  font-size: 9.5px;
  font-weight: 800;
}

.prize.is-poor {
  opacity: 0.6;
}

.prize.is-out {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.claim-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 20px;
  border-radius: 22px;
  color: #f8f3e6;
  background: linear-gradient(145deg, #17332e, #0d211e);
  box-shadow: var(--shadow);
}

.claim-hero::before {
  content: "";
  position: absolute;
  inset-inline-end: -60px;
  bottom: -110px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 165, 33, 0.3), transparent 65%);
}

.claim-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  padding: 3px 8px;
  border: 1px solid rgba(246, 211, 124, 0.3);
  border-radius: 999px;
  color: #f6d37c;
  font-size: 10px;
  font-weight: 800;
}

.claim-value {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  color: #fff;
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.claim-value small {
  color: #f6d37c;
  font-size: 20px;
}

.claim-code {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  color: rgba(248, 243, 230, 0.7);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  direction: ltr;
  text-align: right;
}

.claim-note {
  position: relative;
  z-index: 1;
  margin: 12px 0 0;
  color: rgba(248, 243, 230, 0.62);
  font-size: 11.5px;
  line-height: 1.6;
}

.child-pick {
  display: grid;
  gap: 7px;
}

.child-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  text-align: right;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

.child-option.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: 0 0 0 2px rgba(14, 111, 99, 0.1);
}

.child-option .profile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 17px;
}

.child-option-main {
  flex: 1;
  min-width: 0;
}

.child-option-main b {
  display: block;
  font-size: 14px;
}

.child-option-main span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
}

.child-option-balance {
  flex: none;
  font-size: 15px;
  font-weight: 800;
}

.success-panel {
  margin-top: 14px;
  padding: 26px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.success-check {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(14, 111, 99, 0.26);
}

.success-check svg {
  width: 32px;
  height: 32px;
}

.success-panel h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.success-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.success-balance {
  margin: 14px 0;
  color: var(--teal);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.success-balance small {
  font-size: 18px;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 220px);
}

.login-card {
  width: min(100%, 380px);
  padding: 26px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #2a2108;
  background: linear-gradient(145deg, #f3cb63, #c9931c);
  font-size: 26px;
  font-weight: 800;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 23px;
}

.login-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.field {
  display: block;
  margin-top: 10px;
  text-align: right;
}

.field span {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: #fff;
  font-size: 15px;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 111, 99, 0.12);
}

.form-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.print-controls {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.print-base {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.print-base input {
  flex: 1 1 240px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #fff;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  direction: ltr;
}

.print-base input:focus {
  border-color: var(--teal);
}

.print-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.print-help {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(217, 165, 33, 0.35);
  border-radius: 10px;
  color: #6a4d05;
  background: var(--gold-soft);
  font-size: 11.5px;
  line-height: 1.6;
}

.print-sheet {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-bottom: 18px;
}

.sheet-caption {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.print-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 9px;
  min-height: 118px;
  padding: 11px;
  overflow: hidden;
  border: 1.5px dashed #cfc6b2;
  border-radius: 12px;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(217, 165, 33, 0.12) 0%, transparent 55%),
    linear-gradient(135deg, #fffdf8 0%, #fbf6e9 60%, #f5e9cf 100%);
}

.print-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--teal), var(--teal-2));
  box-shadow: inset 0 0 0 1px rgba(217, 165, 33, 0.75);
}

.print-card::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 5px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 165, 33, 0.75), transparent);
  pointer-events: none;
}

.pcard-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  padding-inline-start: 5px;
}

.pcard-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pcard-photo {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  background-color: #fff;
  background-image: url("assets/abba-vebanim.jpg");
  background-position: center 42%;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 2px rgba(255, 253, 248, 0.95), 0 0 0 3px rgba(14, 111, 99, 0.16);
  clip-path: circle(50%);
}

.pcard-head-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.pcard-brand {
  overflow: hidden;
  color: var(--teal);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard-title {
  display: inline-block;
  margin-top: 3px;
  padding-bottom: 1px;
  border-bottom: 2px solid var(--gold);
  color: var(--teal-2);
  font-size: 13px;
  font-weight: 900;
}

.pcard-value {
  margin-top: 5px;
  color: var(--teal-2);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}

.pcard-cur {
  margin-inline-start: 2px;
  color: var(--gold-2);
  font-size: 0.82em;
}

.pcard-meta {
  margin-top: 5px;
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
}

.pcard-code {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 4px;
  border: 1px solid rgba(14, 111, 99, 0.14);
  border-radius: 4px;
  background: rgba(14, 111, 99, 0.06);
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 9.5px;
  direction: ltr;
  text-align: right;
}

.pcard-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.pcard-name {
  margin-top: auto;
  padding-top: 6px;
  color: var(--teal-2);
  font-size: 9.5px;
}

.pcard-qr {
  width: 78px;
  height: 78px;
  align-self: center;
  padding: 3px;
  border: 1px solid rgba(14, 111, 99, 0.55);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(217, 165, 33, 0.55);
}

.pcard-qr svg {
  width: 100%;
  height: 100%;
}

.qr-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px dashed #c9c0ab;
  border-radius: 5px;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 25, 23, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.18s;
}

.sheet-backdrop[hidden] {
  display: none;
}

.sheet-backdrop.open {
  opacity: 1;
}

.sheet {
  width: min(100%, 520px);
  max-height: 88dvh;
  overflow: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.25);
  transform: translateY(24px);
  transition: transform 0.2s;
}

.sheet-backdrop.open .sheet {
  transform: translateY(0);
}

.sheet-grab {
  width: 42px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #ddd5c3;
}

.sheet h2 {
  margin: 0 0 6px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.sheet p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.sheet-figure {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.sheet-figure .profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 19px;
}

.sheet-figure b {
  display: block;
  font-size: 15px;
}

.sheet-figure span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.link-box {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.link-box input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: #fff;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  direction: ltr;
}

.toast-wrap {
  position: fixed;
  z-index: 95;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 520px);
  pointer-events: none;
}

body.parent-mode .toast-wrap {
  bottom: calc(18px + env(safe-area-inset-bottom));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  color: #f8f3e6;
  background: #152522;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-msg {
  flex: 1;
  line-height: 1.45;
}

.toast button {
  flex: none;
  padding: 6px 9px;
  border-radius: 8px;
  color: #f6d37c;
  background: rgba(246, 211, 124, 0.13);
  font-size: 12px;
  font-weight: 800;
}

.fx {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -14px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  animation: confettiFall 1.3s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.footer-note {
  margin-top: 18px;
  padding: 4px 8px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 10.5px;
  line-height: 1.7;
}

.link-btn {
  padding: 0;
  color: var(--teal);
  background: none;
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--dx, 0), 105vh, 0) rotate(var(--rot, 360deg)); }
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .family-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .print-sheet {
    grid-template-columns: repeat(2, 1fr);
  }

  .sheet-backdrop {
    align-items: center;
    padding: 20px;
  }

  .sheet {
    border-radius: 24px;
    transform: translateY(10px) scale(0.985);
  }

  .sheet-backdrop.open .sheet {
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .child-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .child-row .data-actions {
    width: 100%;
    flex-basis: 100%;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
  }

  .child-row .child-balance {
    margin-inline-start: auto;
  }
}

@media (max-width: 400px) {
  .brand strong {
    font-size: 14px;
  }

  .brand-text > span {
    font-size: 10px;
  }

  .chip {
    font-size: 9.5px;
    padding: 3px 7px;
  }

  .tab {
    font-size: 9.5px;
  }

  .tab svg {
    width: 19px;
    height: 19px;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .data-row {
    flex-wrap: wrap;
  }

  .data-side {
    order: 3;
  }

  .data-actions {
    margin-inline-start: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 3px solid rgba(14, 111, 99, 0.4);
  outline-offset: 2px;
}

@page {
  size: A4;
  margin: 8mm;
}

@media print {
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .topbar,
  .tabbar,
  .toast-wrap,
  .sheet-backdrop,
  .fx,
  .print-controls,
  .page-head,
  .print-help,
  .sheet-caption,
  .footer-note {
    display: none !important;
  }

  .app,
  .main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-sheet {
    display: grid;
    grid-template-columns: repeat(2, 88mm);
    grid-auto-rows: 52mm;
    gap: 4mm;
    width: 180mm;
    margin: 0 auto;
    break-after: page;
    page-break-after: always;
  }

  .print-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-card {
    width: 88mm;
    height: 52mm;
    min-height: 0;
    padding: 3mm;
    grid-template-columns: minmax(0, 1fr) 24mm;
    gap: 2.5mm;
    overflow: hidden;
    border: 1px dashed #b9ae97;
    border-radius: 2.4mm;
    background:
      radial-gradient(120% 100% at 100% 0%, rgba(217, 165, 33, 0.12) 0%, transparent 55%),
      linear-gradient(135deg, #fffdf8 0%, #fbf6e9 60%, #f5e9cf 100%);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-card::after {
    left: 3.5mm;
    right: 3.5mm;
    bottom: 1.2mm;
    height: 0.35mm;
  }

  .pcard-main {
    height: 100%;
    padding-inline-start: 1.2mm;
  }

  .pcard-head {
    gap: 1.6mm;
  }

  .pcard-photo {
    flex-basis: 14.5mm;
    width: 14.5mm;
    height: 14.5mm;
    border-width: 0.45mm;
    border-radius: 50%;
    box-shadow: 0 0 0 0.6mm rgba(255, 253, 248, 0.95), 0 0 0 1mm rgba(14, 111, 99, 0.16);
    clip-path: circle(50%);
  }

  .pcard-brand {
    font-size: 2.4mm;
    letter-spacing: 0;
  }

  .pcard-title {
    margin-top: 0.8mm;
    padding-bottom: 0.2mm;
    border-bottom-width: 0.4mm;
    font-size: 3.2mm;
  }

  .pcard-value {
    margin-top: 1mm;
    font-size: 7.2mm;
  }

  .pcard-cur {
    margin-inline-start: 0.4mm;
  }

  .pcard-meta {
    margin-top: 1mm;
    font-size: 2.4mm;
  }

  .pcard-code {
    margin-top: 0.5mm;
    padding: 0.25mm 0.9mm;
    border-width: 0.25mm;
    border-radius: 0.8mm;
    font-size: 2.3mm;
  }

  .pcard-note {
    margin-top: 1mm;
    font-size: 2.2mm;
  }

  .pcard-name {
    margin-top: auto;
    padding-top: 1mm;
    font-size: 2.3mm;
  }

  .pcard-qr {
    width: 24mm;
    height: 24mm;
    padding: 0.8mm;
    border: 1px solid rgba(14, 111, 99, 0.55);
    border-radius: 1.8mm;
    box-shadow: 0 0 0 0.7mm #fff, 0 0 0 1.1mm rgba(217, 165, 33, 0.55);
  }

  .print-card::before {
    width: 1.8mm;
  }
}
