/* =====================================================================
   KidsHub — ส่วนเสริมจาก styles.css ของ ClassHub (ธีมปฐมวัย + ส่วนประกอบใหม่)
   ===================================================================== */
:root {
  --fb-blue: #7C4DFF;
  --fb-blue-hover: #6A3BEF;
  --fb-blue-soft: #F1EBFF;
  --fb-blue-line: #CDB9FF;
  --bg: #F4F1FB;
}
.brand-avatar { background: none !important; box-shadow: 0 4px 10px rgba(124, 77, 255, .3); overflow: hidden; }
.brand-avatar img { width: 100%; height: 100%; display: block; }
img.login-logo { display: block; }
.login-screen { background: radial-gradient(120% 120% at 100% 0%, #EDE4FF 0%, #F4F1FB 55%); }
.seg-btn.active { box-shadow: 0 2px 6px rgba(124, 77, 255, .3); }
.dash-hero { background: linear-gradient(135deg, #8E63FF, #6A3BEF) !important; }

/* ---------- แท็บบันทึกประจำวัน ---------- */
.kseg { flex-wrap: wrap; }
.kseg .seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.kseg .seg-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: #F0A020; }
.kseg .seg-btn .dot.ok { background: #0EA968; }
.kseg .seg-btn.active .dot { box-shadow: 0 0 0 2px #fff; }

/* ---------- แถวรายชื่อเด็ก ---------- */
.kid-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line-light); flex-wrap: wrap; }
.kid-row.away { opacity: .55; }
.kid-name { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.kid-no { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--fb-blue-soft); color: var(--fb-blue); font-size: 12.5px; font-weight: 600; }
.kid-name b { display: block; font-weight: 500; }
.kid-name small { color: var(--ink-soft); font-size: 12px; }
.kid-tag { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: 11px; background: #F2F2F2; color: #666; }
.kid-tag.off { background: #FDECEC; color: #C93439; }
.kid-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.yn-btn { --c: #0EA968; min-width: 88px; min-height: 42px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--c); background: #fff; color: var(--c); font: inherit; font-size: 14px; cursor: pointer; }
.yn-btn.no { --c: #E5484D; }
.yn-btn.on { background: var(--c); color: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.hchip { min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid #0EA968; background: #ECFAF2; color: #0E8A57; font: inherit; font-size: 13px; cursor: pointer; }
.hchip.fail { border-color: #E5484D; background: #E5484D; color: #fff; }
.hchip.unset { border-color: var(--line); background: #fff; color: var(--ink-soft); }
.hremark { min-width: 160px; max-width: 220px; min-height: 38px !important; padding: 6px 10px !important; font-size: 13px !important; }
.daily-count { margin-right: auto; color: var(--ink-soft); font-size: 13.5px; align-self: center; }
.daily-note { padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; background: #FFF7E6; color: #8A5A00; font-size: 13px; }

/* ---------- ตารางน้ำหนัก-ส่วนสูง ---------- */
.growth-table input { width: 84px; min-height: 38px; padding: 6px 8px; text-align: center; font-size: 15px; }
.growth-table td, .growth-table th { white-space: nowrap; }
.nb { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.nb.b0 { background: #FDE2E2; color: #B42323; }
.nb.b1 { background: #FFF1D6; color: #9A6200; }
.nb.b2 { background: #E3F7EC; color: #11744A; }
.nb.b3 { background: #FFF1D6; color: #9A6200; }
.nb.b4 { background: #FFE0C2; color: #A04B00; }
.nb.b5 { background: #FDE2E2; color: #B42323; }
.nb.na { background: #F2F2F2; color: #888; }
.nb.good { background: #0EA968; color: #fff; }
.chg-up { color: #0E8A57; font-size: 11.5px; } .chg-down { color: #C93439; font-size: 11.5px; }

/* ---------- ตารางพัฒนาการ ---------- */
.dev-table td, .dev-table th { text-align: center; white-space: nowrap; }
.dev-table td:nth-child(2), .dev-table th:nth-child(2) { text-align: left; }
.dv { display: inline-flex; gap: 4px; }
.dv button { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.dv button.on.v3 { background: #0EA968; border-color: #0EA968; color: #fff; }
.dv button.on.v2 { background: #F0A020; border-color: #F0A020; color: #fff; }
.dv button.on.v1 { background: #E5484D; border-color: #E5484D; color: #fff; }
.dev-note { min-width: 160px; min-height: 36px !important; padding: 6px 10px !important; font-size: 13px !important; }

/* ---------- หน้าแรก ---------- */
.room-card { border: 1px solid var(--line-light); border-radius: 16px; padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.room-card h4 { margin: 0; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.room-card h4 small { font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.todo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.todo { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid #F3D7A0; background: #FFF9EC; cursor: pointer; text-align: left; font: inherit; min-height: 0; }
.todo.ok { border-color: #BDE8D0; background: #F0FBF5; }
.todo b { font-size: 14px; font-weight: 500; } .todo small { color: var(--ink-soft); font-size: 12px; }
.att-mini { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.att-mini span { padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); }

/* ---------- รายงาน ---------- */
.rep-table th, .rep-table td { text-align: center; white-space: nowrap; }
.rep-table td:nth-child(2), .rep-table th:nth-child(2) { text-align: left; }
.pct-low { color: #C93439; font-weight: 600; }
.health-items-edit .hi-row { display: flex; gap: 8px; margin-bottom: 8px; }
.health-items-edit .hi-row input { flex: 1; }
.nutri-preview { max-height: 240px; overflow: auto; font-size: 12.5px; }

@media (max-width: 700px) {
  .kseg { display: grid !important; grid-template-columns: 1fr 1fr; border-radius: 16px; }
  .kseg .seg-btn { justify-content: center; border-radius: 12px; white-space: nowrap; }
  .kid-row { flex-direction: column; align-items: stretch; }
  .kid-btns { justify-content: flex-start; }
  .yn-btn { flex: 1; }
  .todo-grid { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   มือถือก่อน (≤ 700px) — แถบเมนูล่าง ปุ่มบันทึกติดจอ ตารางกลายเป็นการ์ด
   ===================================================================== */
.remark-btn { min-width: 40px; }
@media (max-width: 700px) {
  /* ช่องกรอกตัวอักษร ≥ 16px กัน iPhone ซูมหน้าเองตอนแตะ */
  input, select, textarea { font-size: 16px !important; }
  .main { padding: 10px 10px calc(84px + env(safe-area-inset-bottom)) !important; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar h1 { font-size: 19px; }
  .top-actions { width: 100%; display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .top-field-wrap select { width: 100%; }
  .tablet-bottom-nav { display: grid !important; height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .tablet-nav-item { font-size: 11.5px; padding: 6px 0; }
  .tablet-toggle-btn { display: none !important; }
  .dash-hero { padding: 16px; border-radius: 16px; }
  .dash-hero h2 { font-size: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi b { font-size: 24px; }
  .dsec { padding: 12px; }
  .tgrid { grid-template-columns: 1fr; }
  .panel { padding: 12px; border-radius: 16px; }
  .toolbar { gap: 8px; margin-bottom: 10px; }
  .toolbar > div { flex: 1 1 100%; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1 1 auto; }
  #dailyDate { width: 100%; }

  /* ปุ่มบันทึกติดขอบล่าง (เหนือแถบเมนู) */
  .bottom-save-bar {
    position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 20;
    margin: 12px -12px -12px; padding: 10px 12px; background: rgba(255,255,255,.96);
    backdrop-filter: blur(6px); border-top: 1px solid var(--line-light); border-radius: 0 0 16px 16px;
  }
  .bottom-save-bar button.primary { flex: 1; min-height: 48px; font-size: 16px !important; }
  .daily-count { flex: 1 1 100%; font-size: 12.5px; }
  .bottom-save-bar { flex-wrap: wrap; }

  /* บันทึกประจำวัน */
  .kid-row { padding: 10px 2px; gap: 8px; }
  .kid-name { min-width: 0; }
  .kid-btns { flex-wrap: nowrap; gap: 4px; }
  .kid-btns .att-btn { flex: 1 1 0; min-width: 0; padding: 8px 2px; min-height: 46px; font-size: 13.5px; }
  .sidebar { z-index: 130 !important; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sidebar-overlay { z-index: 125 !important; }
  .yn-btn { min-height: 48px; font-size: 15px; }
  .kid-row:has(.hchip) .kid-btns, .kid-row:has(.yn-btn) .kid-btns { flex-wrap: wrap; }
  .hchip { min-height: 38px; padding: 5px 10px; font-size: 13px; }
  .hremark { flex: 1 1 100%; max-width: none; }

  /* น้ำหนัก-ส่วนสูง: 1 คน = 1 การ์ด */
  .growth-table, .dev-table { min-width: 0; }
  .growth-table thead, .dev-table thead { display: none; }
  .growth-table, .growth-table tbody, .dev-table, .dev-table tbody { display: block; }
  .growth-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line-light); }
  .growth-table td, .dev-table td { background: transparent !important; }
  .growth-table td, .dev-table td { display: flex; flex-direction: column; gap: 3px; border: 0; padding: 0; white-space: normal; font-size: 13.5px; text-align: left !important; }
  .growth-table td::before, .dev-table td::before { content: attr(data-l); font-size: 11.5px; color: var(--ink-soft); }
  .growth-table td.c-no { display: none; }
  .growth-table td.c-name { grid-column: 1 / -1; font-size: 15px; }
  .growth-table td.c-name::before { display: none; }
  .growth-table td.c-sex, .growth-table td.c-age { flex-direction: row; gap: 6px; align-items: center; }
  .growth-table td.c-sex::before, .growth-table td.c-age::before { content: attr(data-l) ':'; }
  .growth-table td.c-bmi { display: none; }
  .growth-table input { width: 100%; min-height: 48px; font-size: 18px !important; }

  /* พัฒนาการ: 1 คน = 1 การ์ด */
  .dev-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line-light); }
  .dev-table td.c-no { display: none; }
  .dev-table td.c-name, .dev-table td.c-note { grid-column: 1 / -1; }
  .dev-table td.c-name { font-size: 15px; } .dev-table td.c-name::before { display: none; }
  .dv { width: 100%; } .dv button { flex: 1; height: 44px; }
  .dev-note { width: 100%; }

  /* ตารางรายงาน/รายชื่อ: ล็อกคอลัมน์ชื่อไว้ เลื่อนดูด้านข้างได้ */
  .rep-table td:nth-child(2), .rep-table th:nth-child(2), #studentsTable td:nth-child(3), #studentsTable th:nth-child(3) {
    position: sticky; left: 0; background: #fff; z-index: 2; white-space: normal; min-width: 130px; box-shadow: 1px 0 0 var(--line-light);
  }
  .rep-table th:nth-child(2), #studentsTable th:nth-child(3) { background: var(--surface-alt); z-index: 3; }
  .io-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .io-card { padding: 12px; }
  .modal-card { max-height: calc(100vh - 20px); overflow: auto; }
}


.login-form { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 14px; }
.login-form label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: -6px; }
.login-form input { width: 100%; min-height: 46px; font-size: 16px; }
.login-form button.primary { min-height: 48px; font-size: 16px; margin-top: 4px; }
.login-form h3 { margin: 0; font-size: 16px; color: var(--fb-blue); }

