:root {
  color-scheme: light;
  background: #f7f8f2;
  color: #202c25;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  --paper: #fff;
  --ink: #202c25;
  --muted: #58685d;
  --green: #245239;
  --green-light: #e5efe6;
  --line: #dde6dc;
  --red: #a5283d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body.dialog-open { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #3e8962; outline-offset: 2px; }
h1, h2, h3, p, dl, dd { margin: 0; }
img { display: block; height: auto; max-width: 100%; }
.shell { max-width: 1040px; margin: 0 auto; padding: env(safe-area-inset-top) 24px max(32px, env(safe-area-inset-bottom)); }
.top { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand, .header-tools { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 15px; border: 1px solid #d8e1d8; }
.brand h1 { font-size: 1.25rem; letter-spacing: .05em; }
.icon-button { min-height: 44px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.icon-button { width: 44px; min-width: 44px; border-radius: 14px; font-size: 1.4rem; display: grid; place-items: center; }
.device-status { border-radius: 999px; padding: 6px 11px; background: #e5efe6; font-size: .875rem; color: var(--green); }
.dashboard, .details { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.overview, .actions, .card, .welcome { background: var(--paper); border: 1px solid var(--line); border-radius: 24px; }
.overview { overflow: hidden; }
.hero { min-height: 212px; position: relative; display: flex; align-items: center; overflow: hidden; background: #234c37; isolation: isolate; }
.hero::before { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at 81% 90%, #527a56 0%, #335c43 35%, transparent 70%); }
.hero-dogs { position: absolute; z-index: -1; width: 55%; height: 110%; max-width: none; object-fit: contain; object-position: right bottom; right: -2%; bottom: -7%; }
.hero-copy { padding: 26px 24px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; color: #fff; }
.hero-label { color: #e0efe1; }
.balance { font-variant-numeric: tabular-nums; line-height: 1.12; font-size: clamp(2.05rem, 5.6vw, 3.65rem); letter-spacing: -.055em; font-weight: 750; }
.balance.long { font-size: clamp(1.4rem, 4.75vw, 2.75rem); }
.available { margin-top: 4px; padding: 5px 11px; border-radius: 24px; background: #e1eddd; color: #254a34; font-size: .875rem; font-weight: 650; }
.available.low { background: #fff0d6; color: #65400d; }
.totals { display: grid; grid-template-columns: .85fr 1fr 1fr; padding: 13px 12px; }
.totals > div { min-width: 0; padding-inline: 12px; }
.totals > div + div { border-left: 1px solid var(--line); }
dt, .muted { color: var(--muted); font-size: .875rem; }
dd { font-weight: 720; font-variant-numeric: tabular-nums; margin-top: 5px; overflow-wrap: anywhere; }
.actions { align-self: stretch; padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.today-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.today-line > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; }
#today-date { color: var(--muted); font-size: .875rem; }
.day-status { font-size: .875rem; white-space: nowrap; padding: 5px 9px; background: #f4efe1; color: #674a22; border-radius: 30px; }
.day-status.done { background: var(--green-light); color: #25523a; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border: 1px solid transparent; border-radius: 13px; padding: 8px 12px; font-weight: 650; color: var(--ink); }
.primary { background: var(--green); color: white; }
.primary:hover { background: #1b412c; }
.secondary { background: #f4f7f1; border-color: var(--line); color: #2e543d; }
.secondary:hover { background: #e9f1e8; }
.danger { background: #a5283d; color: #fff; }
.danger:hover { background: #842033; }
.walk-button { min-height: 58px; justify-content: flex-start; padding: 10px 12px; font-size: 1.1rem; }
.walk-button.done { background: #e5efe6; color: #234b35; border-color: #c5d9c8; }
.walk-button.done:hover { background: #d7e8da; }
.walk-symbol { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #fff3; flex-shrink: 0; }
.done .walk-symbol { background: #cee1d0; }
#walk-fee { margin-left: auto; white-space: nowrap; font-size: .875rem; opacity: .94; }
.secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-icon { font-size: 1.25rem; line-height: 1; }
.calendar-icon { display: inline-block; width: 16px; height: 15px; border: 2px solid currentColor; border-radius: 4px; position: relative; }
.calendar-icon::after { content: ""; position: absolute; top: 3px; left: 0; right: 0; border-top: 1px solid currentColor; }
.details { margin-top: 18px; align-items: start; }
.card { padding: 17px 18px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.section-heading h2 { font-size: 1.08rem; }
.records { list-style: none; margin: 8px 0 0; padding: 0; }
.records li + li { border-top: 1px solid var(--line); }
.record-row { width: 100%; min-height: 57px; display: flex; align-items: center; gap: 10px; background: transparent; color: var(--ink); border: none; text-align: left; padding: 7px 0; }
.record-row:hover .record-name { text-decoration: underline; text-underline-offset: .18em; }
.record-mark { display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px; background: #ebf2e9; color: #315640; font-weight: 700; }
.record-mark.recharge { background: #f4efe1; color: #705322; }
.record-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.record-name { overflow-wrap: anywhere; }
.record-date { font-size: .825rem; color: var(--muted); }
.record-money { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.record-money.recharge { color: #22603d; }
.empty { padding-block: 15px; color: var(--muted); }
.more { margin-top: 8px; width: 100%; background: #f4f7f1; color: var(--green); }
.monthly-card select { margin-top: 12px; }
.month-totals { margin: 12px 0; }
.month-totals div { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; }
.month-totals dd { margin: 0; }
.statement-button { width: 100%; }
.reminder { margin-top: 14px; padding: 3px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #f5efe1; color: #604d2f; font-size: .875rem; border-radius: 13px; }
.reminder button { white-space: nowrap; }
.welcome { max-width: 460px; margin: 22px auto 0; overflow: hidden; }
.welcome-art { background: radial-gradient(ellipse at 53% 80%, #d7e8d8, #eef5eb 66%); height: 196px; display: flex; justify-content: center; align-items: flex-end; overflow: hidden; }
.welcome-art img { width: min(315px, 85%); transform: translateY(18px); }
.welcome-copy { padding: 26px; }
.welcome-copy h2 { font-size: 1.55rem; }
.welcome-copy > p { margin-top: 7px; color: var(--muted); }
label { display: block; font-size: .875rem; font-weight: 650; }
input:not([type=file]), select { width: 100%; min-height: 46px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #b9c9bc; border-radius: 11px; }
input:not([type=file]) { margin-top: 6px; }
.overlay { position: fixed; z-index: 10; inset: 0; padding: 14px; display: grid; align-items: center; justify-items: center; background: #19271ec2; }
.dialog { width: min(100%, 470px); max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow: auto; overscroll-behavior: contain; background: var(--paper); border-radius: 22px; padding: 16px 18px 18px; box-shadow: 0 24px 65px #152b2960; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dialog-header h2 { font-size: 1.25rem; }
.close { font-size: 1.6rem; line-height: 1; }
.dialog p { line-height: 1.55; }
.dialog p + .secondary-actions { margin-top: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.presets > button { flex: 1; }
.full { width: 100%; margin-top: 12px; }
.calendar-nav { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; text-align: center; }
.calendar-week { font-size: .875rem; color: var(--muted); margin: 10px 0 5px; }
.calendar-day { position: relative; padding: 0; min-height: 44px; border-radius: 8px; border: 1px solid transparent; color: var(--ink); background: #f5f7f3; font-size: .95rem; font-weight: 500; }
.calendar-day.weekend { color: #a72d43; font-weight: 600; }
.calendar-day.off { color: #9c2138; background: #fce9eb; font-weight: 800; }
.calendar-day.work { color: #25312a; border-color: #546358; font-size: 1.05rem; font-weight: 900; }
.calendar-day.done { color: #225438; background: #e0f1e4; border-color: #a5ceb1; opacity: 1; font-weight: 700; font-size: .95rem; }
.calendar-day.selected { color: #fff; background: #245239; border-color: #245239; font-weight: 700; }
.day-mark { font-size: .65rem; position: absolute; bottom: 2px; right: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; font-size: .75rem; color: var(--muted); }
.legend span { border-radius: 6px; border: 1px solid transparent; padding: 4px 5px; }
.legend-off { background: #fce9eb; color: #9c2138; }
.legend .legend-work { border-color: #546358; color: #25312a; }
.legend-done { background: #e0f1e4; color: #225438; }
.legend-selection { background: #245239; color: #fff; }
.calendar-total { display: flex; align-items: center; justify-content: space-between; font-size: .9rem; gap: 5px; }
.text-button { color: var(--green); border: none; background: transparent; padding: 4px; min-height: 44px; font-size: .875rem; font-weight: 650; }
.text-button:hover { text-decoration: underline; text-underline-offset: .18em; }
.danger-text, .field-error { color: var(--red); }
.field-error { margin-top: 9px; font-size: .875rem; }
.field-error:empty { display: none; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.settings-fields > label { min-width: 0; }
.settings-backup, .settings-bottom { border-top: 1px solid var(--line); padding-top: 13px; margin-top: 14px; }
.settings-backup h3 { font-size: 1rem; }
.settings-backup p { margin: 4px 0 9px; }
.settings-bottom { display: flex; justify-content: flex-end; }
.toast { position: fixed; z-index: 12; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); border-radius: 12px; padding: 9px 13px; color: white; background: #263c30; box-shadow: 0 5px 20px #0002; font-size: .875rem; pointer-events: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.print-sheet { display: none; }

@media (max-width: 690px) {
  .shell { padding-inline: 14px; }
  .top { min-height: 67px; }
  .brand img { width: 40px; height: 40px; border-radius: 12px; }
  .brand h1 { font-size: 1.12rem; }
  .header-tools, .brand { gap: 7px; }
  .dashboard, .details { grid-template-columns: 1fr; gap: 12px; }
  .overview, .actions, .card { border-radius: 19px; }
  .hero { min-height: 170px; }
  .hero-copy { padding: 18px 15px; }
  .hero-dogs { width: 60%; }
  .balance { font-size: clamp(2.05rem, 8.7vw, 3.4rem); }
  .balance.long { font-size: clamp(1.35rem, 6vw, 3rem); }
  .totals { padding: 11px 5px; }
  .totals > div { padding-inline: 9px; }
  .totals dd { font-size: .98rem; }
  .actions, .card { padding: 12px; }
  .actions { gap: 8px; }
  .details { margin-top: 12px; }
  .welcome { margin-top: 8px; }
}

@media (max-width: 360px) {
  .shell { padding-inline: 10px; }
  .device-status { padding-inline: 8px; font-size: .8rem; }
  .hero-dogs { right: -6%; width: 61%; }
  .totals dd { font-size: .9rem; }
  #walk-fee { font-size: .8rem; }
}

@media print {
  @page { margin: 15mm; }
  body { background: #fff; color: black; }
  .shell, .overlay, .toast { display: none !important; }
  .print-sheet { display: block; font-size: 11pt; }
  .print-sheet h1 { margin-bottom: 8pt; font-size: 20pt; }
  .print-sheet p { margin-bottom: 9pt; }
  .print-sheet table { width: 100%; border-collapse: collapse; margin-top: 14pt; }
  .print-sheet th, .print-sheet td { text-align: left; padding: 6pt 5pt; border-bottom: 1px solid #ccc; }
  .print-sheet th:last-child, .print-sheet td:last-child { text-align: right; }
  .print-sheet tr { break-inside: avoid; }
}
