:root {
  --paper: #fffaf2;
  --ink: #24334d;
  --muted: #728096;
  --line: #e6dfd5;
  --pink: #ef6680;
  --pink-soft: #fff0f2;
  --blue: #448fc9;
  --blue-soft: #eef7ff;
  --green: #3b9b76;
  --green-soft: #eaf8f2;
  --yellow: #efb33e;
  --yellow-soft: #fff8df;
  --purple: #8d6abb;
  --shadow: 0 8px 24px rgba(43, 50, 68, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(85,125,160,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(85,125,160,.06) 1px, transparent 1px);
  background-size: 24px 24px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding: 0 28px 28px 54px; position: relative; }
.app-shell::before {
  content: ""; position: fixed; left: 18px; top: 0; bottom: 0; width: 18px;
  background: repeating-linear-gradient(to bottom, transparent 0 25px, #28333d 26px 31px, transparent 32px 48px);
  opacity: .75;
}
.topbar {
  height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-bottom: 2px solid rgba(87,64,49,.13);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-flower { color: var(--pink); font-size: 29px; transform: rotate(-10deg); }
.brand h1 { margin: 0; font-size: clamp(23px, 2.4vw, 37px); letter-spacing: .05em; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ghost-button, .primary-button, .quick-button {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px; background: rgba(255,255,255,.78);
  font-weight: 700; box-shadow: 0 2px 0 rgba(41,48,65,.05);
}
.ghost-button:hover { background: white; border-color: #bfc7d1; }
.primary-button { background: var(--pink); color: white; border-color: var(--pink); }
.layout { display: grid; grid-template-columns: 215px minmax(540px, 1fr) 330px; gap: 22px; padding-top: 22px; }
.side { min-width: 0; }
.tape-label {
  display: inline-block; margin: 0 0 12px 8px; padding: 7px 18px;
  background: var(--yellow-soft); border: 1px dashed #e3b75a; transform: rotate(-1deg); font-weight: 800;
}
.child-list { display: grid; gap: 10px; }
.child-button {
  width: 100%; display: grid; grid-template-columns: 46px 1fr 22px; align-items: center; gap: 9px;
  padding: 13px; border-radius: 13px; border: 1.5px solid var(--child); background: var(--childSoft); text-align: left;
}
.child-button.active { outline: 3px solid color-mix(in srgb, var(--child) 25%, transparent); transform: translateX(3px); }
.avatar {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  background: white; border: 1px solid rgba(0,0,0,.08); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.child-name { display: block; font-size: 17px; font-weight: 900; }
.child-grade { display: block; font-size: 12px; margin-top: 3px; color: #6a6070; }
.check { color: var(--child); font-weight: 900; opacity: 0; }
.active .check { opacity: 1; }
.quick-actions { display: grid; gap: 9px; margin-top: 20px; padding-top: 18px; border-top: 1px dashed #cfc5b6; }
.quick-button { text-align: left; background: white; border-width: 1.5px; }
.quick-button[data-action="income"] { border-color: var(--pink); color: #a9324e; }
.quick-button[data-action="expense"] { border-color: var(--blue); color: #245d95; }
.quick-button[data-action="weekly"] { border-color: var(--green); color: #27785a; }
.quick-button[data-action="advance"] { border-color: var(--yellow); color: #8b5c00; }
.note {
  margin-top: 24px; padding: 15px; background: rgba(255,255,255,.8); border: 1px solid #ddd2c5; box-shadow: var(--shadow);
  transform: rotate(-1.2deg); line-height: 1.65; font-size: 13px;
}
.summary-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.9);
  border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.metric { padding: 15px 17px; border-right: 1px dashed var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric span { font-size: 12px; color: var(--muted); font-weight: 700; }
.metric strong { display: block; margin-top: 7px; font-size: clamp(18px, 1.9vw, 27px); white-space: nowrap; }
.metric.balance strong { color: var(--pink); }
.metric.income strong { color: var(--green); }
.metric.expense strong { color: var(--blue); }
.metric.debt strong { color: var(--purple); }
.calendar-panel { background: rgba(255,255,255,.93); border: 2px solid #b9d6eb; border-radius: 17px; box-shadow: var(--shadow); overflow: hidden; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; }
.calendar-head h2 { margin: 0; font-size: 22px; }
.month-nav { border: 1px solid #cbd2dc; background: white; border-radius: 9px; width: 39px; height: 39px; font-size: 20px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-week span { text-align: center; padding: 8px; font-weight: 800; font-size: 13px; }
.calendar-week span:first-child { color: #e34141; }
.calendar-week span:last-child { color: #2878c8; }
.day {
  min-height: 103px; padding: 7px; background: rgba(255,255,255,.5); border-top: 1px solid #d9dde3; border-right: 1px solid #d9dde3;
  overflow: hidden; position: relative;
}
.day:nth-child(7n) { border-right: 0; }
.day.outside { background: rgba(242,243,243,.7); color: #adb3bc; }
.day.today { box-shadow: inset 0 0 0 2px var(--yellow); }
.day-number { font-weight: 800; font-size: 13px; }
.day:nth-child(7n+1) .day-number { color: #df3e3e; }
.day:nth-child(7n) .day-number { color: #2878c8; }
.entry {
  display: block; width: 100%; border: 0; background: transparent; padding: 3px 2px; text-align: left;
  font-size: 11px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 5px;
}
.entry:hover { background: #f1f4f7; }
.entry.income { color: #168157; }
.entry.planned { opacity: .55; border: 1px dashed currentColor; }
.entry.expense { color: #2874bd; }
.entry.advance, .entry.repayment { color: #8056a9; }
.more { color: var(--muted); font-size: 10px; padding-left: 2px; }
.legend { display: flex; gap: 18px; padding: 13px 17px; border-top: 1px solid #d9dde3; font-size: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.right-card {
  background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.right-card h2 { margin: 0 0 13px; font-size: 18px; }
.monthly-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.monthly-row:last-child { border-bottom: 0; }
.monthly-row strong.income { color: var(--green); }
.monthly-row strong.expense { color: var(--blue); }
.monthly-row strong.net { color: var(--pink); }
.transaction-list { display: grid; }
.transaction-row {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 9px; align-items: center; padding: 11px 0;
  border-bottom: 1px solid #ece7df; cursor: pointer;
}
.transaction-row:last-child { border-bottom: 0; }
.transaction-date { font-size: 11px; color: var(--muted); }
.transaction-label { min-width: 0; font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-amount { font-weight: 900; font-size: 13px; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: var(--blue); }
.transaction-amount.advance, .transaction-amount.repayment { color: var(--purple); }
.empty { color: var(--muted); line-height: 1.7; font-size: 13px; padding: 18px 4px; text-align: center; }
.settings { display: grid; gap: 12px; }
.settings label { font-size: 13px; font-weight: 800; }
.settings input { width: 100%; margin-top: 6px; padding: 10px; border: 1px solid #ccd3db; border-radius: 9px; background: white; }
.profile-editor { display: flex; align-items: center; gap: 13px; padding-bottom: 11px; border-bottom: 1px dashed var(--line); }
.profile-preview { width: 68px; height: 68px; border-radius: 50%; object-fit: cover; border: 2px solid white; box-shadow: 0 0 0 1px var(--line); }
.image-picker, .upload-picker { display: inline-block; padding: 8px 11px; border: 0; border-radius: 9px; background: var(--blue-soft); color: #245d95; cursor: pointer; font-size: 12px; font-weight: 800; }
.upload-picker { display: block; width: fit-content; margin-top: 6px; background: var(--green-soft); color: #26785b; }
.upload-picker input { display: none; }
.text-button { display: block; margin-top: 6px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; }
.gallery-lead { margin-top: 10px; }
.avatar-gallery { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin: 16px 0; }
.avatar-option { display: grid; gap: 5px; justify-items: center; padding: 7px 4px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 11px; font-weight: 800; }
.avatar-option:hover, .avatar-option.selected { border-color: var(--pink); background: var(--pink-soft); box-shadow: 0 0 0 2px rgba(239,102,128,.12); }
.avatar-option img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.schedule-status { padding: 10px; border-radius: 9px; background: #f4f4f2; font-size: 12px; line-height: 1.55; }
.schedule-status strong, .schedule-status span { display: block; }
.schedule-status.active { background: var(--green-soft); color: #26785b; }
.auto-row { cursor: default; }
.save-settings { width: 100%; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(32,40,55,.42); padding: 20px; }
.modal { width: min(500px, 100%); max-height: 92vh; overflow: auto; background: var(--paper); border-radius: 18px; padding: 24px; box-shadow: 0 24px 80px rgba(25,30,44,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal h2 { margin: 0; }
.close-button { border: 0; background: transparent; font-size: 24px; }
.form { display: grid; gap: 14px; margin-top: 20px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
.form input, .form select, .form textarea { padding: 11px; background: white; border: 1px solid #cbd1d9; border-radius: 9px; }
.form textarea { min-height: 76px; resize: vertical; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 4px; }
.check-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; justify-content: flex-start; }
.check-label input { width: 18px; height: 18px; margin: 0; }
.schedule-preview { padding: 12px; border-radius: 9px; background: var(--green-soft); color: #26785b; font-size: 13px; font-weight: 800; }
.danger-button { color: #c43f4e; margin-right: auto; }
.hint { margin: -3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.toast { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink); color: white; padding: 12px 19px; border-radius: 999px; box-shadow: var(--shadow); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 190px 1fr; }
  .right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .right-card { margin: 0; }
}
@media (max-width: 760px) {
  .app-shell { padding: 0 12px 20px; }
  .app-shell::before { display: none; }
  .topbar { height: auto; padding: 16px 0; align-items: flex-start; }
  .header-actions .ghost-button:nth-child(-n+2) { display: none; }
  .layout { display: block; padding-top: 14px; }
  .tape-label, .note { display: none; }
  .child-list { grid-template-columns: repeat(3, 1fr); }
  .child-button { display: block; padding: 8px; text-align: center; }
  .avatar { margin: auto; width: 38px; height: 38px; }
  .child-name { font-size: 14px; margin-top: 4px; }
  .check { display: none; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); margin: 12px 0 16px; padding-top: 12px; }
  .quick-button { font-size: 13px; text-align: center; padding: 10px 5px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px dashed var(--line); }
  .day { min-height: 73px; padding: 4px; }
  .entry { font-size: 9px; }
  .calendar-head h2 { font-size: 18px; }
  .right { display: block; }
  .right-card { margin-top: 14px; }
  .avatar-gallery { grid-template-columns: repeat(4, 1fr); }
  .avatar-option img { width: 52px; height: 52px; }
}
