:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #1c2321;
  --muted: #6b7470;
  --line: #e6e2d9;
  --accent: #0f5f55;
  --accent-2: #e8f2ef;
  --warn: #b45309;
  --warn-bg: #fff6e6;
  --danger: #b42318;
  --kid: #2563eb;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 20px rgba(20, 30, 25, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Plus Jakarta Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

#app { max-width: 760px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 120px; }
.boot { display: grid; place-items: center; height: 70vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* header */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 2px 18px; }
.top .logo { width: 42px; height: 42px; border-radius: 13px; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; }
.top h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
.top p { margin: 1px 0 0; color: var(--muted); font-size: 13px; }
.top .sp { flex: 1; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; overflow: hidden; background: var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* hero */
.hero { background: linear-gradient(135deg, #0f5f55, #134e48 60%, #1d3b37); color: #fff; border-radius: 24px; padding: 20px 20px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -40px; top: -50px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.06); }
.hero .lbl { font-size: 13px; opacity: .8; }
.hero .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 14px; }
.split { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.15); }
.split span { display: block; height: 100%; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12.5px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.legend b { font-weight: 700; }

/* kid switcher */
.kids { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.kid { text-align: left; background: var(--card); border: 2px solid transparent; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); transition: border-color .2s, transform .15s; }
.kid:active { transform: scale(.98); }
.kid.on { border-color: var(--c); }
.kid .row { display: flex; align-items: center; gap: 10px; }
.ini { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; background: var(--c); flex: none; }
.kid .nm { font-weight: 700; font-size: 15px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c, var(--accent)) 12%, white); color: var(--c, var(--accent)); }
.kid .tot { margin-top: 10px; font-weight: 800; font-size: 17px; }
.kid .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* due */
.due { display: flex; align-items: center; gap: 12px; background: var(--warn-bg); border: 1px solid #f6dfb5; border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.due .tx { flex: 1; font-size: 14px; }
.due .tx b { display: block; }
.due .tx small { color: var(--warn); }
.btn { border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 700; background: var(--accent); color: #fff; }
.btn.ghost { background: var(--accent-2); color: var(--accent); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: #fdecea; color: var(--danger); }
.btn:disabled { opacity: .55; }
.btn.sm { padding: 8px 12px; font-size: 13.5px; }

/* class chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 8px 12px; text-align: left; transition: all .15s; }
.chip b { display: block; font-size: 13px; }
.chip small { color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--c); border-color: var(--c); color: #fff; }
.chip.on small { color: rgba(255,255,255,.85); }

/* bars per class */
.bars { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 10px; }
.bars h3, .group h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.bar { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; font-size: 13px; margin: 7px 0; }
.bar .tr { height: 10px; background: #f0ede6; border-radius: 99px; overflow: hidden; }
.bar .fl { height: 100%; background: var(--c); border-radius: 99px; width: 0; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.bar b { font-weight: 700; }

/* timeline */
.group { margin-top: 18px; }
.group h3 { display: flex; justify-content: space-between; padding: 0 4px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 13px 14px; text-align: left; border-top: 1px solid var(--line); animation: rise .35s both; }
.item:first-child { border-top: 0; }
.item:hover { background: #faf9f6; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.item .dt { width: 46px; flex: none; text-align: center; line-height: 1.1; }
.item .dt b { display: block; font-size: 18px; }
.item .dt small { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.item .mid { flex: 1; min-width: 0; }
.item .rm { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.item .amt { font-weight: 700; font-size: 14.5px; text-align: right; }
.clip { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); font-weight: 600; }
.clip.none { color: #b6b0a3; }
.item.plan { background: var(--warn-bg); }
.item.plan .amt { color: var(--warn); font-size: 13px; }

.fab { position: fixed; right: max(18px, calc(50vw - 362px)); bottom: max(20px, env(safe-area-inset-bottom)); border: 0; border-radius: 18px; padding: 15px 20px; background: var(--accent); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 10px 30px rgba(15, 95, 85, .35); display: flex; gap: 8px; align-items: center; z-index: 5; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* login */
.login { min-height: 80vh; display: grid; place-items: center; text-align: center; }
.login .logo { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: #fff; font-size: 30px; font-weight: 800; display: grid; place-items: center; margin: 0 auto 16px; }
.login h1 { margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 22px; }
#gbtn { display: flex; justify-content: center; min-height: 44px; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(15, 20, 18, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 24px; } }
.grab { width: 40px; height: 5px; border-radius: 9px; background: #d6d1c6; margin: 0 auto 12px; }
.sheet h2 { margin: 4px 0 2px; font-size: 20px; letter-spacing: -.01em; }
.sheet .sub { color: var(--muted); font-size: 13.5px; }
.amount-big { font-size: 30px; font-weight: 800; margin: 14px 0 4px; letter-spacing: -.02em; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 14px; background: var(--card); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.files { display: grid; gap: 12px; margin: 14px 0; }
.file { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); position: relative; }
.file img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: #fff; cursor: zoom-in; }
.file .fbar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 12.5px; border-top: 1px solid var(--line); }
.file .fbar .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.file .fbar a, .file .fbar button { border: 0; background: none; color: var(--accent); font-weight: 700; text-decoration: none; padding: 2px 4px; font-size: 12.5px; }
.file .fbar button.x { color: var(--danger); }
.file iframe { width: 100%; height: 70vh; border: 0; display: block; background: #fff; }
.pdfcard { display: flex; align-items: center; gap: 12px; padding: 16px; text-decoration: none; color: inherit; }
.pdfcard .ic { width: 42px; height: 52px; border-radius: 8px; background: #fdecea; color: var(--danger); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: var(--accent-2); color: var(--accent); }
.tag.r { background: #eef2ff; color: #3730a3; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.actions .btn { flex: 1; }
.nofile { background: var(--card); border: 1.5px dashed var(--line); border-radius: 16px; padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* form */
.form { display: grid; gap: 12px; margin-top: 12px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form input, .form textarea, .form select { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; font-size: 16px; color: var(--ink); font-weight: 500; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form .two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px; font-weight: 700; display: flex; align-items: center; gap: 8px; justify-content: center; }
.seg button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); color: var(--c); }
.sugs { display: flex; gap: 6px; flex-wrap: wrap; }
.sugs button { border: 0; background: var(--accent-2); color: var(--accent); border-radius: 99px; padding: 5px 10px; font-size: 12.5px; font-weight: 700; }
.drop { border: 1.5px dashed #c9c2b4; border-radius: 14px; padding: 16px; text-align: center; background: var(--card); color: var(--muted); font-size: 14px; }
.drop b { color: var(--accent); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs div { position: relative; width: 70px; height: 70px; border-radius: 10px; overflow: hidden; background: #fdecea; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--danger); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 1; padding: 0; }

#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: #1c2321; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.menu { position: absolute; right: 16px; top: 64px; background: var(--card); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.15); padding: 6px; z-index: 30; min-width: 200px; }
.menu .who { padding: 8px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu a, .menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px; border-radius: 9px; font-size: 14px; text-decoration: none; color: var(--ink); }
.menu a:hover, .menu button:hover { background: var(--bg); }
