:root {
  --bg: #faf8fe;
  --surface: #ffffff;
  --surface-soft: #f5effc;
  --text: #2c2a36;
  --muted: #615e6a;
  --border: #e8e3ef;
  --lavender: #efe6fb;
  --pink: #fbcfe0;
  --yellow: #fdef81;
  --blue: #b6e2fd;
  --green: #add6ae;
  --primary: #6f4ea0;
  --primary-dark: #56327f;
  --danger: #b93838;
  --good: #3e7a50;
  --warn: #927a1d;
  --info: #2f6f9f;
  --shadow: 0 18px 40px rgba(58, 36, 86, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #ede8f6; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(239, 230, 251, .7), rgba(250, 248, 254, 1) 34%),
    var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(111, 78, 160, .08);
  position: relative;
}

.content {
  padding: 12px 16px calc(92px + env(safe-area-inset-bottom));
}
.content-no-nav { padding-bottom: 28px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(250, 248, 254, .92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(232, 227, 239, .84);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: var(--primary);
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  box-shadow: 0 8px 20px rgba(111, 78, 160, .18);
}
.app-mark.large { width: 56px; height: 56px; font-size: 28px; }
.app-name { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.topbar h1, .login-brand h1 {
  margin: 1px 0 0;
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
}
.avatar-link img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
  box-shadow: 0 6px 16px rgba(44, 42, 54, .12);
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 30px;
  line-height: 1;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 30;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
.bottom-nav a {
  min-height: 56px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav a.active {
  color: var(--primary);
  background: var(--lavender);
}

.login-screen .app-shell {
  background: linear-gradient(180deg, #efe6fb 0%, #faf8fe 46%);
}
.login-panel {
  min-height: 100vh;
  padding: calc(42px + env(safe-area-inset-top)) 20px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }

.hero-card, .summary-card, .card, .form-card, .filter-card, .receipt-card, .article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(44, 42, 54, .07);
}
.hero-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary), #8e5db9);
  color: #fff;
  border: 0;
  box-shadow: var(--shadow);
}
.hero-card h2 { margin: 4px 0; font-size: 26px; letter-spacing: 0; }
.hero-card p { margin: 0; color: rgba(255,255,255,.82); }
.eyebrow { display: block; color: inherit; opacity: .78; font-size: 12px; font-weight: 900; text-transform: uppercase; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}
.quick-grid.two-col { margin-top: 0; }
.quick-card {
  min-height: 94px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.quick-card:nth-child(4n+1) { background: #fff8ca; border-color: #efe18d; }
.quick-card:nth-child(4n+2) { background: #edf8ff; border-color: #cceaff; }
.quick-card:nth-child(4n+3) { background: #fff0f6; border-color: #f7d5e3; }
.quick-card:nth-child(4n+4) { background: #f0f8f0; border-color: #cfe6cf; }
.quick-card strong { font-size: 16px; }
.quick-card span, .muted { color: var(--muted); font-size: 13px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}
.section-head a { color: var(--primary); font-size: 13px; font-weight: 900; }
.section-head.in-form { margin-top: 4px; }
.stack { display: grid; gap: 10px; }

.card { padding: 14px; }
.card h3, .form-card h3 { margin: 0 0 5px; font-size: 15px; letter-spacing: 0; }
.card p, .form-card p, .pay-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.right { text-align: right; display: grid; gap: 5px; justify-items: end; }

.schedule-card { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; }
.time-pill {
  min-height: 58px;
  padding: 8px 6px;
  border-radius: 8px;
  background: var(--lavender);
  color: var(--primary);
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 900;
  font-size: 13px;
}
.time-pill small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }

.child-row, .notice-card, .child-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.child-row img, .child-card > img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--lavender);
  border: 2px solid var(--surface);
}
.child-card { align-items: flex-start; }
.child-card-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
.child-card.disabled { pointer-events: none; opacity: .58; }
.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.metric-strip span {
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row .btn { flex: 1 1 auto; }

.invoice-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.summary-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 12px;
}
.summary-card > div {
  padding: 14px;
  background: var(--surface);
}
.summary-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.summary-card strong { display: block; margin-top: 4px; font-size: 20px; }
.invoice-summary { grid-template-columns: 1fr 1fr; }
.invoice-summary > div:last-child { grid-column: 1 / -1; }

.profile-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.profile-hero img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--lavender);
}
.profile-hero h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: 0; }
.profile-hero p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }

.detail-card dl, .pay-card dl, .receipt-card dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 9px 12px;
  margin: 10px 0 0;
  font-size: 14px;
}
dt { color: var(--muted); }
dd { margin: 0; font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.qr-img {
  width: 180px;
  max-width: 100%;
  display: block;
  margin: 12px auto 2px;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.qr-missing {
  margin: 12px auto 2px;
  max-width: 240px;
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.form-card, .filter-card {
  padding: 14px;
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.filter-card.two, .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.filter-card.two .btn { grid-column: 1 / -1; }
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
textarea.input { resize: vertical; min-height: 88px; }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(111, 78, 160, .14);
}
.compact-upload {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 0 0 12px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}
.check-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); }
.check-row small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 3px; }
.service-option {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 10px;
}
.service-option.is-hidden { display: none; }

.cropper-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  gap: 12px;
}
.crop-frame {
  width: min(240px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  border: 4px solid #fff;
  box-shadow: 0 10px 24px rgba(44, 42, 54, .14), 0 0 0 1px var(--border);
  touch-action: none;
  position: relative;
}
.crop-frame img {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}
.crop-frame canvas {
  display: block;
}
.crop-frame img {
  cursor: grab;
}
.crop-frame img:active { cursor: grabbing; }
.crop-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px;
}
.crop-slider span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.crop-slider input {
  width: 100%;
  accent-color: var(--primary);
}

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}
.btn-sm { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-soft { background: var(--lavender); color: var(--primary); }
.btn-light { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.34); }
.btn-danger { background: #ffe8e8; color: var(--danger); margin-top: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.badge-good { background: #e6f4e7; color: var(--good); }
.badge-warn { background: #fff5bd; color: var(--warn); }
.badge-danger { background: #ffe4e4; color: var(--danger); }
.badge-info { background: #e5f5ff; color: var(--info); }
.badge-muted { background: #f0edf3; color: var(--muted); }

.flash {
  padding: 11px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-success { background: #e6f4e7; color: var(--good); border-color: #c7e5ca; }
.flash-error { background: #ffe4e4; color: var(--danger); border-color: #ffc7c7; }
.flash-info { background: #e5f5ff; color: var(--info); border-color: #c7eaff; }

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 12px 0;
}
.day-tabs a {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.day-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.notice-thumb {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
}
.article-card { overflow: hidden; }
.article-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  border: 0;
  background: #111827;
}
.article-body { padding: 16px; }
.article-body h2 { margin: 5px 0 12px; font-size: 24px; letter-spacing: 0; }
.article-text { color: var(--text); line-height: 1.62; font-size: 15px; }
.article-text a { color: var(--primary); font-weight: 800; overflow-wrap: anywhere; }

.receipt-card {
  padding: 22px;
  text-align: center;
}
.receipt-card .app-mark { margin: 0 auto 12px; }
.receipt-card h2 { margin: 0; font-size: 24px; }
.receipt-card p { margin: 6px 0 10px; color: var(--muted); }
.receipt-card > strong { display: block; font-size: 32px; color: var(--primary); margin-bottom: 14px; }

.empty-state {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.empty-state.small { padding: 16px; font-size: 13px; }
.empty-state h2 { margin: 0 0 12px; color: var(--text); font-size: 19px; }
.sticky-actions {
  position: sticky;
  bottom: calc(72px + env(safe-area-inset-bottom));
  padding-top: 6px;
  background: linear-gradient(180deg, rgba(250,248,254,0), var(--bg) 34%);
}

@media (max-width: 360px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .hero-card { align-items: stretch; flex-direction: column; }
  .summary-card { grid-template-columns: 1fr; }
  .filter-card.two, .form-grid { grid-template-columns: 1fr; }
  .schedule-card { grid-template-columns: 1fr; }
  .time-pill { min-height: 44px; display: flex; gap: 8px; justify-content: center; }
}
