/* Sổ tay Mầm non tự lớn — giao diện mobile-first, chữ to, màu dịu. */

:root {
  color-scheme: light;

  --bg: #f6f4ed;
  --surface: #fffefb;
  --ink: #232a26;
  --muted: #5e6a62;
  --line: #e8e4d8;
  --line-strong: #d6d0c0;

  --brand: #2f6b4f;
  --brand-dark: #24543e;
  --brand-soft: #e6efe6;
  --be: #efe7d6;

  --danger: #9c332c;
  --danger-bg: #fbeeeb;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 0 rgba(35, 42, 38, 0.03);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2,
h3,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Khung trang ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand span {
  font-weight: 400;
  color: var(--muted);
  font-size: 14px;
}

.topbar-gate {
  justify-content: center;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.foot {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  color: var(--muted);
  font-size: 13px;
}

.foot-note {
  margin-top: 4px;
}

/* ---------- Nút ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-secondary:hover {
  background: #f4f1e8;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #efd3cf;
}

.btn-sm {
  min-height: 44px;
  font-size: 15px;
  padding: 0 14px;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.inline {
  display: inline;
  margin: 0;
}

.ic {
  width: 20px;
  height: 20px;
  flex: none;
}

.ic-sm {
  width: 16px;
  height: 16px;
}

.ic-lg {
  width: 26px;
  height: 26px;
}

/* ---------- Cổng vào ---------- */

.gate {
  max-width: 460px;
  margin: 0 auto;
  padding-top: 8px;
}

.gate-title {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 16px;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--be);
  border-radius: var(--radius-sm);
  color: #5d5033;
  font-size: 14px;
}

/* ---------- Thẻ, form ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.form .field:last-of-type {
  margin-bottom: 18px;
}

.field {
  margin-bottom: 16px;
}

.field label,
.field legend {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}

.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
}

.req {
  color: var(--danger);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  appearance: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 23px, calc(100% - 14px) 23px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.14);
}

::placeholder {
  color: #9aa39c;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip span {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
}

.chip input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.chip input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Thông báo ---------- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 15px;
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid #efd3cf;
  color: var(--danger);
}

.alert-ok {
  background: var(--brand-soft);
  border: 1px solid #cadcc9;
  color: var(--brand-dark);
}

/* ---------- Trang chủ ---------- */

.search-hero {
  margin-bottom: 20px;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  font-size: 17px;
  border-radius: 14px;
}

.search-form .btn {
  min-height: 56px;
  padding: 0 16px;
}

.search-form-page {
  margin-bottom: 16px;
}

.block {
  margin-bottom: 24px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.block > h2 {
  margin-bottom: 10px;
}

.card + .block {
  margin-top: 22px;
}

.link {
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.kid-list,
.rec-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.kid-list li + li {
  border-top: 1px solid var(--line);
}

.kid {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--ink);
  min-height: 64px;
}

.kid:hover {
  background: #f7f4ec;
  text-decoration: none;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
  flex: none;
}

.kid-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kid-name {
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kid-meta {
  font-size: 14px;
  color: var(--muted);
}

.chev {
  margin-left: auto;
  color: var(--muted);
  font-size: 22px;
}

.empty-card {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-card .btn {
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  font-size: 15px;
  padding: 12px 2px;
}

.kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kind {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 104px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.kind:hover {
  background: #f9f7f0;
  border-color: var(--line-strong);
  text-decoration: none;
}

.kind .ic {
  color: var(--brand);
  margin-bottom: 8px;
}

.kind-label {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.kind-count {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Sắp tới ---------- */

.upcoming {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.up-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 12px 16px;
}

.up-item + .up-item {
  border-top: 1px solid var(--line);
}

.up-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-dark);
  min-width: 88px;
  font-variant-numeric: tabular-nums;
}

.up-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.up-label {
  font-size: 15px;
}

.up-child {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Mã nhà ---------- */

.house-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.house code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--be);
  color: #4a4230;
}

.house p {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 12px;
}

/* ---------- Trang con, chi tiết ---------- */

.crumbs {
  margin-bottom: 10px;
  font-size: 15px;
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  min-height: 36px;
}

.page-title {
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.action-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.add-label {
  font-size: 14px;
  color: var(--muted);
  margin-right: 2px;
}

.page-title + .block,
.crumbs + .block {
  margin-top: 18px;
}

.filter-note {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---------- Dòng bản ghi ---------- */

.rec + .rec {
  border-top: 1px solid var(--line);
}

.rec-link {
  display: block;
  padding: 14px 16px;
  color: var(--ink);
  min-height: 64px;
}

.rec-link:hover {
  background: #f7f4ec;
  text-decoration: none;
}

.rec-top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.rec-main {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.rec-date {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}

.rec-sub {
  display: block;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.rec-child {
  display: block;
  font-size: 13px;
  color: var(--brand);
  margin-top: 2px;
}

.result-count {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---------- Mô tả chi tiết ---------- */

.dl-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
}

.dl-row + .dl-row {
  border-top: 1px solid var(--line);
}

.dl-row dt {
  font-size: 13px;
  color: var(--muted);
  text-transform: none;
}

.dl-row dd {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.dl-long dd {
  font-size: 16px;
}

.cal .btn-block + .btn-block {
  margin-top: 8px;
}

/* ---------- Quản trị ---------- */

.stat-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.stat-list strong {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-list span {
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Tra cứu trong sách ---------- */

.source-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: linear-gradient(180deg, #fffefb, #f3f0e4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.source-card:hover {
  text-decoration: none;
  border-color: var(--brand);
}

.source-ic {
  width: 34px;
  height: 34px;
  color: var(--brand);
  flex: none;
}

.source-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.source-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.source-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.source-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-quick a {
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
}

.tracuu-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tracuu-tabs a {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 600;
}

.tracuu-tabs a.is-active {
  background: var(--brand);
  color: #fff;
}

.tracuu-tabs a:hover {
  text-decoration: none;
}

.nhom-block {
  margin-bottom: 22px;
}

.nhom-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.benh-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.benh-row + .benh-row {
  border-top: 1px solid var(--line);
}

.benh-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  min-height: 56px;
  color: var(--ink);
}

.benh-link:hover {
  background: #f7f5ee;
  text-decoration: none;
}

.benh-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.benh-name {
  font-size: 17px;
  font-weight: 600;
}

.benh-nhom {
  font-size: 13px;
  color: var(--muted);
}

.benh-page {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.bullet-list {
  padding-left: 20px;
  margin: 0;
}

.bullet-list li {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.bullet-list.tight li {
  margin-bottom: 4px;
}

.warn-block {
  background: #fdf6ee;
  border: 1px solid #ecd9c2;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.warn-list li::marker {
  color: #a8652a;
}

.source-line {
  margin: 18px 0 12px;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

.sach-text {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.sach-text.small {
  font-size: 14px;
  color: var(--muted);
}

.lede-book {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 8px;
}

.crumb-sep {
  color: var(--muted);
  padding: 0 2px;
}

.foot-source {
  padding-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.toolbar {
  margin: 12px 0 16px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.lich-table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 15px;
}

.lich-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: #f7f5ee;
}

.lich-table td,
.lich-table tbody th {
  padding: 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-weight: 400;
}

.lich-age {
  font-weight: 600 !important;
  width: 30%;
  color: var(--ink);
}

.lich-kind {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  margin-right: 6px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.lich-kind-kham {
  background: #efe7d6;
  color: #6b5636;
}

.cal-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}

.lich-src {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.child-picker {
  margin-bottom: 12px;
}

.child-picker label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.picker-row {
  display: flex;
  gap: 8px;
}

.picker-row select {
  flex: 1;
  min-width: 0;
}

.picker-row .btn {
  min-height: 52px;
  flex: none;
}

.std-line {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.check-item:last-child {
  border-bottom: 0;
}

.check-box {
  width: 20px;
  height: 20px;
  margin: 3px 0 0;
  flex: none;
  accent-color: var(--brand);
}

.check-item label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 16px;
  cursor: pointer;
  min-width: 0;
}

.check-text {
  overflow-wrap: anywhere;
}

.check-note {
  font-size: 13px;
  color: var(--muted);
}

.check-group,
.q-group {
  font-size: 16px;
  margin-bottom: 6px;
}

.prep-list {
  padding-left: 22px;
  margin: 0;
}

.prep-list li {
  margin-bottom: 8px;
}

.dh-group {
  font-size: 17px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.dh-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

.dh-sub {
  font-size: 15px;
  margin: 14px 0 6px;
  color: var(--brand-dark);
}

.dh-list {
  padding-left: 20px;
  margin: 0;
}

.dh-list li {
  margin-bottom: 7px;
  overflow-wrap: anywhere;
}

.danger-call {
  font-size: 17px;
  font-weight: 700;
}

/* ---------- In ấn ---------- */

@media (max-width: 620px) {
  .lich-table {
    min-width: 0;
  }

  .lich-table thead {
    display: none;
  }

  .lich-table,
  .lich-table tbody,
  .lich-table tr,
  .lich-table th,
  .lich-table td {
    display: block;
    width: auto;
  }

  .lich-table td,
  .lich-table tbody th {
    border-top: 0;
    padding: 0;
  }

  .lich-row {
    padding: 14px 14px 12px;
    border-top: 1px solid var(--line);
  }

  .lich-row:first-child {
    border-top: 0;
  }

  .lich-age {
    font-size: 15px;
    margin-bottom: 4px;
  }

  .lich-what {
    font-size: 15px;
  }

  .lich-src {
    display: inline-block;
    margin-top: 6px;
  }

  .lich-src::before {
    content: "Nguồn ";
  }
}

@media print {
  .topbar,
  .foot,
  .tracuu-tabs,
  .crumbs,
  .toolbar,
  .child-picker,
  .source-card,
  .source-quick {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 12pt;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  .block,
  .print-block {
    break-inside: avoid;
  }

  .check-box {
    border: 1px solid #555;
  }

  a[href]::after {
    content: '';
  }
}

/* ---------- Màn rộng ---------- */

@media (min-width: 720px) {
  .kind-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .kind {
    min-height: 118px;
  }

  .wrap {
    padding: 24px 24px 40px;
  }

  .gate {
    padding-top: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
