:root {
  --paper: #f4f7fb;
  --card: #ffffff;
  --ink: #10243f;
  --muted: #5c6b80;
  --line: #d5deea;
  --sage: #104890;
  --sage-deep: #0b3268;
  --sand: #e7eef8;
  --sand-ink: #10243f;
  --late: #c9840a;
  --late-bg: #fff3cc;
  --absent: #e31820;
  --absent-bg: #ffe4de;
  --sky: #7ec8e3;
  --leaf: #3cbe86;
  --sun: #ffd15c;
  --shadow: 0 10px 28px rgba(16, 72, 144, 0.10);
  --sans: "Avenir Next", "Segoe UI", "Myanmar Text", "Pyidaungsu", sans-serif;
  --serif: "Iowan Old Style", Georgia, "Myanmar Text", serif;
}

body {
  background:
    radial-gradient(circle at 0% 0%, #d9e6f7 0, transparent 32%),
    radial-gradient(circle at 100% 8%, #d5f3ff 0, transparent 28%),
    radial-gradient(circle at 90% 100%, #f8d6d8 0, transparent 26%),
    var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.logo-btn {
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
  border-radius: 14px;
}
.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: white;
  border-radius: 12px;
  border: 2px solid #104890;
  padding: 4px;
  flex: 0 0 auto;
}
.kicker { color: #e31820; font-weight: 700; }
h1 { font-size: 1.7rem; }

.top-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  position: relative;
  z-index: 8;
}
.tool-row { display: flex; align-items: center; gap: 0.35rem; }
.lang-toggle { display: flex; gap: 0.3rem; }
.flag, .menu-btn {
  min-height: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
}
.flag { width: 46px; opacity: 0.38; }
.flag.on { opacity: 1; border-color: #104890; background: white; }
.flag svg { width: 30px; height: 20px; display: block; border-radius: 2px; }
.menu-btn { width: 40px; border-color: var(--line); background: white; color: #104890; }
.menu-back { position: fixed; inset: 0; z-index: 6; }
.menu-panel {
  position: absolute;
  z-index: 8;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 220px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(62, 44, 24, 0.16);
  padding: 0.35rem;
}
.menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 12px;
  min-height: 46px;
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-weight: 700;
}
.menu-panel button.on { background: #e7eef8; color: #104890; }
.menu-panel svg { width: 20px; height: 20px; }
body.lang-th { font-family: "Thonburi", "Sukhumvit Set", "Noto Sans Thai", "Avenir Next", "Segoe UI", sans-serif; }
.lang {
  display: flex;
  gap: 0.25rem;
}
.lang button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  min-height: 32px;
  padding: 0.15rem 0.65rem;
  font-weight: 700;
}
.lang button.on { background: #7ec8e3; border-color: #7ec8e3; color: #12323c; }

.solid { background: #104890; color: white; }
.pill.on, .filters button.on, .mark.on { background: #7ec8e3; color: #12323c; border-color: #7ec8e3; }
.nav button.on { color: #104890; background: #e7eef8; }

.level.on-1 { background: #7ec8e3; color: #12323c; border-color: #5eb6d6; }
.level.on-2 { background: #ffd15c; color: #5c4300; border-color: #f0c14b; }
.level.on-3 { background: #3cbe86; color: white; border-color: #2ea874; }
.mark.present.on { background: #3cbe86; color: white; border-color: #2ea874; }
.mark.late.on { background: #ffd15c; color: #5c4300; border-color: #f0c14b; }
.mark.absent.on { background: #ffe4de; color: #a33b2e; border-color: #f3c2b8; }

.work-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.22rem 0.45rem 0.22rem 0.28rem;
  margin: 0 0 0.32rem;
  box-shadow: none;
}
.work-line .levels {
  display: flex;
  gap: 0.18rem;
  margin: 0;
  grid-template-columns: none;
  flex: 0 0 auto;
}
.work-line .level {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 9px;
  font-size: 0.82rem;
}
.work-name {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.15rem 0;
  font-size: 0.95rem;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.group-label { margin: 0.7rem 0 0.28rem; }

.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: visible;
}
.nav button {
  flex: none;
  font-size: 0.68rem;
}
.nav svg { width: 18px; height: 18px; }

.flow-wrap {
  overflow: auto;
  max-height: 68vh;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.flow {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
}
.flow th, .flow td {
  padding: 0.28rem 0.3rem;
  border-bottom: 1px solid #f6e6da;
  font-weight: 500;
  font-size: 0.82rem;
  text-align: center;
  background: white;
}
.flow th:first-child, .flow td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  min-width: 8.5rem;
  max-width: 11rem;
  background: #fffaf6;
}
.flow thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff1d6;
  font-size: 0.75rem;
}
.flow thead th:first-child { z-index: 3; }
.flow-group td {
  background: #e7f7fb;
  color: #1d5f73;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}
.dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #eadfce;
  background: white;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 700;
}
.dot.lv1 { background: #7ec8e3; border-color: #5eb6d6; color: #12323c; }
.dot.lv2 { background: #ffd15c; border-color: #f0c14b; color: #5c4300; }
.dot.lv3 { background: #3cbe86; border-color: #2ea874; color: white; }

.report-head {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.8rem;
}
.report-head img {
  width: 92px;
  height: 92px;
  object-fit: contain;
}
.report table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 1rem;
  background: white;
}
.report th, .report td {
  border: 1px solid #f0d3c2;
  padding: 0.35rem 0.45rem;
  text-align: left;
  font-size: 0.92rem;
  vertical-align: top;
}
.report th { background: #fff1d6; }
.report h3 { margin: 0.8rem 0 0.3rem; }
.letter {
  margin: 1.3rem 0 0;
  padding-top: 1rem;
  border-top: 2px solid #d5deea;
}
.letter h2 { font-size: 1.35rem; margin-top: 0.2rem; }
.letter p { margin: 0.35rem 0 0.65rem; }
.report textarea {
  width: 100%;
  min-height: 7.5rem;
  margin: 0.2rem 0 0.8rem;
}
.print-only { display: none; white-space: pre-wrap; }
.hint { font-size: 0.85rem; color: var(--muted); }
.nav { background: rgba(255, 246, 238, 0.96); }
.bar { background: #ffe7d4; }
.bar .s1 { background: #7ec8e3; }
.bar .s2 { background: #ffd15c; }
.bar .s3 { background: #3cbe86; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.35rem 0 0.8rem;
}
.stat {
  border-radius: 14px;
  padding: 0.55rem 0.35rem;
  text-align: center;
  border: 1px solid var(--line);
}
.stat strong { display: block; font-size: 1.35rem; line-height: 1.1; }
.stat span { font-size: 0.75rem; color: var(--muted); }
.stat.sky { background: #e7f7fb; }
.stat.sun { background: #fff6d8; }
.stat.leaf { background: #e5f8ef; }
.stat.coral { background: #ffe4de; }
.share-url { font-size: 1.2rem; font-weight: 700; word-break: break-all; }
.share-url a { color: #104890; }
.class-pick { display: block; margin-top: 0.45rem; font-size: 0.85rem; color: var(--muted); }
.class-pick select { margin-left: 0.35rem; font: inherit; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.7rem; }
.ready-pill, .ext-tag { display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; background: #e7eef8; color: #104890; }
.ext-tag { background: #f8e8ea; color: #9d1820; }
.sheet-back {
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem calc(var(--nav) + 0.75rem);
  z-index: 30;
}
.sheet {
  width: min(520px, 100%);
  max-height: min(72vh, 640px);
  margin: 0;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(16, 36, 63, 0.28);
}
.sheet .handle { display: none; }
.steps { margin: 0.2rem 0 0.8rem; padding-left: 1.2rem; }
.steps li { margin: 0.28rem 0; }
.check-row { display: flex; gap: 0.6rem; align-items: flex-start; width: 100%; text-align: left; margin: 0.35rem 0; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.check-row.on { border-color: #104890; background: #e7eef8; }
.tick { width: 1.1rem; height: 1.1rem; border: 1px solid #104890; border-radius: 4px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.qr-box { display: grid; place-items: center; background: #fff; padding: 0.6rem; }
.qr-box svg { width: min(280px, 78vw); height: auto; background: #fff; }
.note, .parent-work { padding: 0.35rem 0 0.8rem; }
.parent-page .main { padding-bottom: calc(6.4rem + env(safe-area-inset-bottom)); }
.tab-title { margin: 0.1rem 0 0.85rem; font-size: 1.45rem; }
.parent-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.15rem;
  background: #fff;
  border-top: 1px solid #d5deea;
  padding: 0.3rem 0.2rem calc(0.35rem + env(safe-area-inset-bottom));
}
.parent-nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #5c6b80;
  font-size: 0.62rem;
  line-height: 1.15;
  padding: 0.35rem 0.05rem 0.4rem;
}
.parent-nav svg { width: 22px; height: 22px; }
.parent-nav button.on { color: #104890; background: #e7eef8; }
.parent-nav .dot, .nav-dot {
  position: absolute;
  top: 0.28rem;
  right: calc(50% - 18px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e31820;
}
.nav button, .menu-panel button { position: relative; }
.nav .nav-dot { top: 0.15rem; right: 22%; }
.menu-panel .nav-dot { top: 0.45rem; right: 0.55rem; }
.cal-switch { margin-bottom: 0.55rem; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.2rem; text-align: center; }
.cal-head span { font-size: 0.68rem; color: #5c6b80; padding-bottom: 0.2rem; }
.cal-grid .cal-day, .cal-grid .cal-empty {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.cal-grid button.cal-day {
  border: 1px solid transparent;
  background: transparent;
  color: #10243f;
  padding: 0;
  position: relative;
}
.cal-day.past { color: #b0b8c4; }
.cal-day.today { font-weight: 700; }
.cal-day.on { background: #104890; color: #fff; border-color: #104890; }
.cal-day.focus { box-shadow: inset 0 0 0 2px #e31820; }
.cal-day.focus.on { box-shadow: inset 0 0 0 2px #fff; }
.cal-event {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e31820;
  bottom: 4px;
}
.cal-day.on .cal-event { background: #fff; }
.chosen-days { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.75rem 0 0; }
.chosen-days span { background: #104890; color: #fff; border-radius: 999px; padding: 0.28rem 0.65rem; font-size: 0.85rem; }
.parent-note { padding: 0.55rem 0; border-top: 1px solid #e7eef8; }
.parent-note.from-school { background: #f4f7fb; border-radius: 12px; padding: 0.55rem 0.7rem; margin-top: 0.45rem; }
.parent-days, .parent-choice { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.45rem 0 0.8rem; }
.parent-days button, .parent-choice button {
  border: 1px solid #d5deea;
  border-radius: 999px;
  background: #fff;
  color: #10243f;
  padding: 0.45rem 0.75rem;
}
.parent-days button.on, .parent-choice button.on { background: #104890; color: #fff; border-color: #104890; }
.parent-sent { padding: 0.45rem 0; border-top: 1px solid #e7eef8; }
.parent-sent .ghost { flex: 0 0 auto; }
.family-plan {
  background: #fff6e8;
  border: 1px solid #e6d0ad;
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  margin: 0 0 0.85rem;
}
.family-plan ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.family-plan li { margin: 0.2rem 0; }

@media (min-width: 900px) {
  .shell { flex-direction: column; }
  .nav {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    width: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-right: 0;
    border-top: 1px solid #f6e6da;
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
  }
  .nav button { flex: none; font-size: 0.85rem; text-align: center; padding: 0.35rem 0.1rem 0.25rem; }
  .nav svg { display: block; width: 18px; height: 18px; margin: 0 auto 0.12rem; }
  .main { padding: 1.6rem 1.4rem calc(var(--nav) + 1.4rem); }
  .flow-wrap { max-height: calc(100vh - 220px); }
}

@media print {
  .nav, .parent-nav, .top-tools, .sync, .banner, .no-print, .sheet-back { display: none !important; }
  .print-only { display: block !important; }
  body { background: white !important; }
  .main { padding: 0 !important; max-width: none !important; width: auto; }
  .shell { display: block; }
  .report, .report table, .report th, .report td { box-shadow: none; }
}

.age-note { display: block; font-weight: 400; margin-top: 0.15rem; }
.mark-letter { font-weight: 700; }
.mark-letter.present { color: #1f7a4d; }
.mark-letter.late { color: #b86e00; }
.mark-letter.absent { color: #a33b32; }
.attend-grid th .texty { font-size: 0.75rem; padding: 0; }
.today-work {
  background: #e7eef8;
  border: 1px solid #104890;
}
.today-work h2 { color: #0b3268; }
.balance-row {
  display: grid;
  grid-template-columns: minmax(5.6rem, 7.4rem) 1fr 1.6rem;
  gap: 0.45rem;
  align-items: center;
  margin: 0.42rem 0;
}
.balance-name { font-size: 0.82rem; line-height: 1.2; }
.balance-track {
  height: 14px;
  border-radius: 99px;
  background: #e7eef8;
  overflow: hidden;
}
.balance-fill { display: flex; height: 100%; }
.balance-fill i { display: block; height: 100%; }
.balance-fill .s1, .balance-legend .s1 { background: #7ec8e3; }
.balance-fill .s2, .balance-legend .s2 { background: #ffd15c; }
.balance-fill .s3, .balance-legend .s3 { background: #3cbe86; }
.balance-count { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.82rem; color: var(--muted); }
.balance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.balance-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.balance-legend .swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 99px;
}
