/* ===== โทเคนสี: ธีมสว่างเป็นค่าหลัก ธีมมืดเลือกได้ (html[data-theme=dark]) ===== */
:root {
  --bg: #f7f7f5; --surface: #ffffff; --card: #f3f3f0; --fg: #1d1d1b; --muted: #6b6a66; --line: #e4e3df; --line-strong: #cfcdc7;
  --accent: #d85a30; --accent-ink: #993c1d; --accent-bg: #faece7;
  --good: #2f6f2a; --good-bg: #eaf3de; --bad: #b42525; --bad-bg: #fcebeb; --warn: #8a5300; --warn-bg: #faeeda;
  --radius: 10px; --side-w: 236px;
  font-family: 'IBM Plex Sans Thai', Inter, system-ui, sans-serif; font-size: 14px;   /* เดิม 16.5px · ย่อ 15% ตามที่ผู้ใช้ขอ */
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #141413; --surface: #1c1c1b; --card: #232321; --fg: #ececea; --muted: #a3a29d; --line: #2e2e2c; --line-strong: #44433f;
  --accent: #f0997b; --accent-ink: #f5c4b3; --accent-bg: #4a1b0c;
  --good: #97c459; --good-bg: #173404; --bad: #f09595; --bad-bg: #501313; --warn: #fac775; --warn-bg: #412402;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.6; }
a { color: inherit; }
a.strong { font-weight: 600; }
.ic { flex: none; vertical-align: -3px; }

/* ===== โครงหน้า: เมนูด้านข้าง (คอม) · แถบล่าง + ลิ้นชักเมนู (มือถือ) ===== */
.shell { min-height: 100vh; }
body.has-side .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side { display: none; }
body.has-side .side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.side .brand { display: block; padding: 2px 10px 14px; }
.side .school { font-size: .82rem; color: var(--muted); padding: 0 10px 12px; line-height: 1.4; }
.side a.nav { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .95rem; }
.side a.nav:hover { background: var(--card); color: var(--fg); }
.side a.nav.on { background: var(--card); color: var(--fg); font-weight: 500; }
/* หัวกลุ่มเมนู (แพลตฟอร์มรวม): งบประมาณและแผน · บันทึกข้อความ */
.side .nav-group { margin: 14px 10px 4px; font-size: .72rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: none; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 600; line-height: 18px; text-align: center; }
.bottom .nav-badge { position: absolute; margin: -4px 0 0 18px; }
body .bottom a { position: relative; }   /* หลัง all: unset ของแถบล่าง */
.side .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side .hint { font-size: .75rem; color: var(--muted); padding: 6px 10px; }
.side button.nav { all: unset; display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: .95rem; }
.side button.nav:hover { background: var(--card); color: var(--fg); }
.brand { color: var(--fg); text-decoration: none; font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 24px; }
.top .brand { margin-right: auto; }
.icon-btn { all: unset; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--fg); display: inline-flex; }
.only-mobile { display: none !important; }
main { max-width: 960px; margin: 0 auto; padding: 4px 24px 72px; }
.bottom { display: none; }
.side-scrim { display: none; }
@media (max-width: 760px) {
  body.has-side .shell { display: block; }
  body.has-side .side { position: fixed; z-index: 30; left: 0; top: 0; width: 82vw; max-width: 300px; transform: translateX(-105%); transition: transform .18s ease; }
  body.side-open .side { transform: none; }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
  body.has-side .only-mobile { display: inline-flex !important; }
  .top { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
  main { padding: 12px 16px 96px; }
  body.has-side .bottom { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a, .bottom button { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); text-decoration: none; }
  .bottom .on { color: var(--fg); }
}

/* ===== ส่วนประกอบพื้นฐาน ===== */
h1 { font-size: 1.45rem; font-weight: 600; margin: 8px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; font-weight: 600; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 10px 0; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--line-strong); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { font-weight: 500; color: var(--muted); font-size: .85rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .82rem; background: var(--card); color: var(--muted); }
.error { color: var(--bad); }
button { font: inherit; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; }
button:hover { background: var(--card); }
.tabs { display: none; }
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.form label { display: block; margin: 12px 0; font-size: .92rem; color: var(--muted); }
input, select { font: inherit; width: 100%; padding: 7px 9px; margin-top: 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-bg); border-color: var(--accent); }
input.num { text-align: right; }
.grid3, .funds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .grid3, .funds { grid-template-columns: 1fr; } }
button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
a.button { display: inline-block; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; background: var(--card); color: var(--fg); }
button:disabled { opacity: .5; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
#items td:nth-child(2) { width: 160px; }
#items td:nth-child(3) { width: 44px; }

/* บันทึกข้อความ A4 */
.print-page .side, .print-page .top, .print-page .bottom { display: none !important; }
body.print-page.has-side .shell { display: block; }
.memo { font-family: 'Sarabun', 'IBM Plex Sans Thai', serif; font-size: 16px; color: #000; background: #fff; max-width: 210mm; margin: 0 auto; padding: 25mm 20mm 20mm 30mm; border: 1px solid var(--line); }
.memo p { margin: 6px 0; }
.memo-title { text-align: center; font-size: 26px; margin: 0 0 12px; }
.memo .row2 { display: flex; justify-content: space-between; gap: 16px; }
.memo .indent { text-indent: 2.5em; }
.memo-table { margin: 8px 0; }
.memo-table th, .memo-table td { border: 1px solid #000; padding: 4px 8px; }
.memo .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-top: 20px; }
.memo .sign { text-align: center; }
.memo .sign p { margin: 4px 0; }
.memo-ref { margin-top: 18px !important; font-size: 12px; color: #555; }
/* กระดาษ A4 ขอบตามแบบหนังสือราชการ: บน 2.5 ซม. ล่าง 2 ซม. ซ้าย 3 ซม. ขวา 2 ซม. · เลขหน้ากลางหัวกระดาษตั้งแต่หน้า 2
   (กำหนดช่องหัว/ท้ายกระดาษเองแล้ว เบราว์เซอร์จึงไม่พิมพ์ URL และวันที่ทับ) */
@page { size: A4; margin: 25mm 20mm 20mm 30mm;
  @top-center { content: "- " counter(page) " -"; font-family: 'TH SarabunPSK', 'TH Sarabun New', 'Sarabun', serif; font-size: 15pt; color: #000; }
  @bottom-center { content: ""; } }
@page :first { @top-center { content: ""; } }
@media print {
  .memo, .book { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .noprint, .bar { display: none !important; }
  main { padding: 0; max-width: none; }
  .memo { border: 0; }
}

/* รายงานผล */
textarea { font: inherit; width: 100%; padding: 7px 9px; margin-top: 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--fg); resize: vertical; line-height: 1.7; }
label { display: block; margin: 10px 0; font-size: .92rem; color: var(--muted); }
details summary { cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.thumbs figure { margin: 0; text-align: center; }
.thumbs img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumbs .file { display: inline-block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; max-width: 200px; overflow-wrap: anywhere; }
button.link { background: none; border: 0; padding: 2px; color: var(--bad); font-size: .85rem; }
.upload { display: inline-block; padding: 7px 12px; border: 1px dashed var(--line); border-radius: 8px; cursor: pointer; color: var(--fg); }

/* เล่มรายงาน */
.book .cover { text-align: center; padding: 60mm 0 40mm; }
.book .cover h1 { font-size: 30px; margin: 0 0 8px; }
.book .cover h2 { font-size: 22px; font-weight: 400; margin: 0 0 6px; }
.book .cover .school { font-size: 22px; margin-top: 40mm; }
.book .cover .logo { width: 110px; height: auto; margin-bottom: 18px; }
.book .page h2 { font-size: 20px; margin: 0 0 8px; }
.book .page { padding-top: 6mm; }
.book-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.book-photos img { width: 100%; height: 55mm; object-fit: cover; }
@media print {
  .book .cover, .book .page { break-after: page; }
}

/* แผนงาน / รายรับ / จัดสรร */
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
label.check { display: flex; gap: 8px; align-items: baseline; color: var(--fg); }
label.check input { width: auto; }
.scroll { overflow-x: auto; }
.scroll table input, .scroll table select { min-width: 80px; }
td input[type=checkbox] { width: auto; }
tr.strongrow td { font-weight: 600; }
tr.netrow td { font-weight: 600; border-top: 2px solid var(--fg); }
.sticky { position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 2; }
label.check.inline { display: inline-flex; margin: 2px 10px 2px 0; font-size: .85rem; }
td.roles { min-width: 260px; }
#members input { min-width: 140px; margin-bottom: 4px; }
#who select { width: auto; margin: 0; padding: 4px 8px; font-size: .85rem; }
tr.proj-row td { border-top: 1px solid var(--muted); }
tr.act-row td { color: var(--muted); font-size: .92rem; padding-top: 4px; padding-bottom: 4px; }
tr.act-row td:first-child { padding-left: 18px; color: var(--fg); }
fieldset.align-pick { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 6px 12px; }
fieldset.align-pick legend { font-weight: 600; padding: 0 4px; }
p.align-level { margin: 10px 0 2px; }
ul.align-items { margin: 0 0 6px; }
.doc-head p { margin: 4px 0; }
#steps textarea { min-width: 240px; }
#steps input { min-width: 110px; }
.act-summary { border-left: 3px solid var(--line); padding-left: 12px; margin: 10px 0 16px; }
ol.plain { margin: 2px 0 8px; padding-left: 22px; }
#steps textarea[name=stage] { min-width: 150px; }
table.estimate input, table.estimate select { min-width: 70px; }
table.estimate input[name=item] { min-width: 180px; }
table.estimate input[readonly] { background: var(--card); color: var(--muted); }
table.estimate input[name=amount], table.estimate input[name=unit_price] { min-width: 110px; }

/* ===== งานของฉัน ===== */
.phasebar { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.phasebar span { height: 6px; border-radius: 3px; background: var(--line); }
.phasebar span.done { background: var(--good); }
.phasebar span.now { background: var(--accent); }
.phase-now { font-size: .88rem; color: var(--muted); margin: 8px 0 0; }
.tasks { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
a.task { display: flex; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
a.task:first-child { border-top: 0; }
a.task:hover { background: var(--card); }
.task-ic { color: var(--accent); display: inline-flex; }
.task-ic.done { color: var(--good); }
.task-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.task-title { font-size: .97rem; }
.task-detail { font-size: .82rem; color: var(--muted); }
.task-go { display: inline-flex; gap: 4px; align-items: center; font-size: .85rem; white-space: nowrap; border: 1px solid var(--line-strong); border-radius: 8px; padding: 5px 10px; }
@media (max-width: 760px) { .task-go { display: none; } }

/* ===== หน้าเขียนกิจกรรมแบบแบ่งขั้น ===== */
.alloc-box { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 10px 14px; margin: 14px 0; border-radius: var(--radius); background: var(--card); font-size: .9rem; }
.writer { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.steps-side { position: sticky; top: 12px; }
button.step { all: unset; box-sizing: border-box; cursor: pointer; display: flex; gap: 10px; align-items: center; width: 100%; padding: 7px 8px; border-radius: 8px; font-size: .92rem; color: var(--muted); }
button.step:hover { background: var(--card); }
button.step.on { color: var(--fg); font-weight: 500; background: var(--card); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; border: 1px solid var(--line-strong); flex: none; }
.step-dot.ok { background: var(--good-bg); color: var(--good); border-color: transparent; }
button.step.on .step-dot:not(.ok) { border: 1.5px solid var(--accent); color: var(--accent-ink); }
.step-of { margin: 0 0 2px; font-size: .82rem; }
.step-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
a.button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
@media (max-width: 760px) {
  .writer { grid-template-columns: minmax(0, 1fr); }
  .steps-side { position: static; }
  #stepList { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  button.step { width: auto; white-space: nowrap; }
}

/* ===== ประมาณการบนมือถือ: ตาราง → การ์ดทีละรายการ ===== */
@media (max-width: 760px) {
  table.estimate thead { display: none; }
  table.estimate, table.estimate tbody, table.estimate tr, table.estimate td { display: block; width: 100%; }
  table.estimate tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; background: var(--surface); }
  table.estimate td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: center; text-align: left; }
  table.estimate td::before { content: attr(data-label); font-size: .8rem; color: var(--muted); }
  table.estimate td:not([data-label]) { display: block; }
  table.estimate td:not([data-label])::before { content: none; }
  table.estimate td.num { text-align: left; }
  table.estimate input, table.estimate select { margin: 0; min-width: 0 !important; }
  table.estimate tr.total-row { display: flex; justify-content: space-between; background: var(--card); }
  table.estimate tr.total-row td { display: inline; width: auto; }
  table.estimate .actions-cell { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }
}

/* เอกสารโครงการ (รายกิจกรรม) ตามแบบฟอร์มโรงเรียน */
.doc h3 { font-size: 17px; margin: 14px 0 4px; }
.doc .doc-head { text-align: center; font-weight: 700; margin: 0 0 12px; }
.doc .item { padding-left: 2em; }
.doc .sub { padding-left: 1em; font-weight: 700; }
.doc-fields th, .doc-fields td { border: 0; padding: 2px 6px 2px 0; color: #000; font-size: 16px; }
.doc-fields th { width: 150px; font-weight: 700; white-space: nowrap; }
.doc-steps { font-size: 14px; table-layout: fixed; }
.doc-steps th, .doc-steps td { padding: 4px 5px; }
.doc-steps th { text-align: center; color: #000; }
.doc-budget { width: auto; min-width: 60%; }
.doc-budget td { border: 0; padding: 2px 12px 2px 2em; color: #000; }
.doc-budget .total { text-align: right; font-weight: 700; }
.doc-estimate { font-size: 13.5px; }
.doc-estimate th { text-align: center; color: #000; }
.doc .doc-signs { margin-top: 28px; break-inside: avoid; }
.doc .doc-signs.one { grid-template-columns: 1fr; max-width: 50%; margin-left: auto; }
.doc .page { margin-top: 24px; }
.doc .muted { color: #555; }
@media print {
  .doc .page { break-before: page; margin-top: 0; }
  .doc .sign { break-inside: avoid; }
}
.memo th { color: #000; }
.doc .sign-line { white-space: nowrap; }
.doc .doc-signs:not(.one) .sign:last-child:nth-child(odd) { grid-column: 1 / -1; }
#signers input[type=text], #signers input:not([type]), #signers select { min-width: 150px; }
#signers input[name=position]:not([type]) { min-width: 220px; }
.doc .doc-logo { display: block; width: 26mm; height: auto; margin: 0 auto 6mm; }
.doc .doc-head { break-after: avoid; }
.doc h3 { break-after: avoid; }
.doc-steps tr, .memo-table tr { break-inside: avoid; }
.logo-field { display: flex; gap: 16px; align-items: center; margin: 10px 0; }
.logo-preview { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; flex: none; }
.logo-preview.empty { display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); text-align: center; }
.doc .keep { break-inside: avoid; }
/* ตัวชี้วัดในหน้าเขียนกิจกรรม */
.writer .ind { margin: 10px 0; }
.writer .ind label { margin: 6px 0; }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; }
.ind-target { display: flex; gap: 6px; }
.ind-target select { width: auto; flex: none; }
.ind-target input { min-width: 0; }

/* แถบแจ้งการใช้บริการ (ทดลองใช้ / ใกล้หมดอายุ / หมดอายุ) */
.sub-notice { margin: 0 24px 8px; padding: 8px 14px; border-radius: 8px; background: var(--card); color: var(--muted); font-size: .9rem; }
.sub-notice.warn { background: var(--warn-bg); color: var(--warn); }
.sub-notice.bad { background: var(--bad-bg); color: var(--bad); font-weight: 500; }
.sub-notice[hidden] { display: none; }
@media (max-width: 760px) { .sub-notice { margin: 8px 16px 0; } }
.print-page .sub-notice { display: none !important; }

/* มือถือ: ช่องกรอกต้อง 16px ขึ้นไป ไม่อย่างนั้น iPhone ซูมหน้าเองทุกครั้งที่แตะช่อง */
@media (max-width: 760px) { input, select, textarea { font-size: 16px; } }
.link-plain { background: none; border: 0; padding: 0 2px; color: var(--accent-ink); text-decoration: underline; font-size: inherit; cursor: pointer; }
/* วางหลายข้อในหน้าตั้งค่าความสอดคล้อง */
details.paste { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.paste summary { color: var(--accent-ink); font-size: .92rem; }
.paste-preview textarea { margin-top: 0; }
/* รอบแผนในหน้าตั้งค่า */
fieldset.period { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 2px; margin: 0 0 12px; }
fieldset.period legend { padding: 0 4px; font-weight: 600; }
fieldset.period [hidden] { display: none; }
/* ดูรอบเก่า: แถบแจ้ง + ตัวเลือกรอบในเมนูข้าง */
.sub-notice.period-notice { background: var(--warn-bg); color: var(--warn); }
.side .school select { margin-top: 4px; width: 100%; padding: 4px 6px; font-size: .85rem; }
/* ลิงก์เชิญในหน้าตั้งค่า */
.invite { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invite input { flex: 1 1 320px; min-width: 0; font-family: ui-monospace, monospace; }
#joinReqs td input { margin-bottom: 2px; }
#members td select[name=learning_area], #joinReqs td select[name=learning_area] { margin-top: 4px; width: 100%; }
.hint-box { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: .9rem; }
/* ===== ภาพรวมโรงเรียน (dashboard) ===== ชุดสีกราฟ: ช่อง 1 น้ำเงิน · ช่อง 2 ส้ม (ตรวจ CVD/คอนทราสต์ผ่านทั้งสองธีม) */
:root { --series-1: #2a78d6; --series-2: #eb6834; }
html[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 1.7rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .85rem; font-weight: 400; color: var(--muted); }
.kpi-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.viz h2 { margin-top: 0; }
.viz-group { margin: 12px 0 4px; font-weight: 600; }
.viz-legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.viz-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.viz-bars { display: grid; gap: 8px; }
.viz-row { display: grid; grid-template-columns: minmax(120px, 30%) minmax(0, 1fr); gap: 10px; align-items: center; }
.viz-label { font-size: .9rem; line-height: 1.35; }
.viz-label span { display: block; font-size: .78rem; color: var(--muted); }
.viz-track { display: grid; gap: 2px; border-left: 1px solid var(--line-strong); padding-left: 0; }
.viz-line { display: flex; align-items: center; gap: 6px; min-height: 14px; }
.viz-bar { display: block; height: 12px; border-radius: 0 4px 4px 0; }
.viz-val { font-size: .8rem; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.s1, .viz-legend i.s1 { background: var(--series-1); }
.s2, .viz-legend i.s2 { background: var(--series-2); }
@media (max-width: 760px) { .viz-row { grid-template-columns: 1fr; gap: 2px; } }
/* โครงสร้างรายรับ: ตัวเลือกช่วงชั้น/รอบเก็บค่าบำรุงไม่ให้ตัดคำ */
#levels select[name=band] { min-width: 96px; }
#levels select[name=fee_terms] { min-width: 150px; }
#levels input[name=name] { min-width: 70px; }
#programs td.prog-levels { min-width: 230px; }
#programs .prog-levels .check.inline { display: inline-flex; align-items: center; gap: 4px; margin: 2px 10px 2px 0; white-space: nowrap; }
#programs .prog-levels input[type=checkbox] { width: auto; min-width: 0; margin: 0; }
#programs select { min-width: 140px; }
#programs input[name=name] { min-width: 200px; }
#students .term-head { text-align: center; border-bottom: 1px solid var(--line); }
#students .prog-head { font-weight: 500; font-size: .8rem; max-width: 140px; white-space: normal; }
#students td.prog-cell { background: var(--card); }
#students input { min-width: 80px; }
#students th:first-child, #students td:first-child { white-space: nowrap; }
/* จัดสรรงบ */
#groupSum input { min-width: 110px; }
table.alloc tr.proj-row td { background: var(--card); }
/* จัดสรรงบ: แผนภูมิข้างตาราง (จอกว้างติดด้านขวา · จอแคบอยู่ด้านบนตาราง) */
:root { --series-3: #1baf7a; } html[data-theme="dark"] { --series-3: #199e70; }
.s3, .viz-legend i.s3 { background: var(--series-3); }
/* จอคอม: แผนภูมิอยู่ในแถบเมนูซ้ายใต้ "จัดสรรงบ" · มือถือ (ไม่มีแถบซ้าย): กล่องอยู่ด้านบนตาราง */
.alloc-layout { display: flex; flex-direction: column; gap: 16px; }
.alloc-viz { display: none; margin: 0; order: -1; }
@media (max-width: 760px) { .alloc-viz { display: block; } }
.nav-panel { margin: 2px 4px 8px 14px; padding: 6px 8px 8px; border-left: 2px solid var(--line-strong); font-size: .78rem; }
.nav-panel-toggle { all: unset; cursor: pointer; display: flex; justify-content: space-between; width: 100%; font-weight: 600; color: var(--fg); padding: 2px 0 4px; }
.nav-panel-toggle:focus-visible { outline: 2px solid var(--accent); }
.np-title { margin: 8px 0 4px; color: var(--muted); font-weight: 600; }
.np-item { margin-bottom: 7px; }
.np-head { display: flex; justify-content: space-between; gap: 6px; color: var(--fg); }
.np-head span:last-child, .np-val { font-variant-numeric: tabular-nums; }
.np-val { color: var(--muted); font-size: .72rem; }
.np-track { height: 5px; background: var(--card); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.np-track .viz-bar { height: 5px; border-radius: 0 3px 3px 0; }
.np-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); margin-bottom: 4px; }
.np-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.alloc-viz .viz-row { grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; }
.meter-head span:last-child { font-variant-numeric: tabular-nums; }
.meter-track { height: 10px; background: var(--card); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.meter-track .viz-bar { height: 10px; border-radius: 0 4px 4px 0; }
/* เอกสารโครงการ: เนื้อหา 15 (เทียบ TH Sarabun 15 pt) · ตารางคงขนาดเดิม · ช่องลงชื่อจัดชื่อให้ตรงเส้น */
.memo.doc { font-size: 15px; }
.doc .doc-fields th, .doc .doc-fields td { font-size: 15px; }
.doc h3 { font-size: 16px; }
.doc .sign-line { display: flex; justify-content: center; align-items: flex-end; gap: 5px; white-space: nowrap; }
.doc .sign-pre, .doc .sign-as { flex: none; }
.doc .sign-dots { flex: 0 1 34mm; min-width: 14mm; border-bottom: 1px dotted #000; height: 1em; margin-bottom: .3em; }
.doc .sign p.sign-under { margin: 4px auto; }   /* ชนะ .memo .sign p (margin 4px 0) เพื่อให้กล่องอยู่กลางช่องก่อนเลื่อน */
.doc .sign-under .nobr { white-space: nowrap; }
/* บันทึกข้อความขอจัดกิจกรรม แบบ ผ 01 (หน้าเดียว A4) */
.memo.p01 { font-size: 13.5px; line-height: 1.45; }
.p01 p { margin: 2px 0; }
.p01-top { display: grid; grid-template-columns: 30mm 1fr 30mm; align-items: center; }
.p01-top h1 { text-align: center; font-size: 22px; margin: 0; }
.p01-logo { width: 22mm; height: auto; }
.p01-code { text-align: right; font-weight: 700; align-self: start; }
.p01-row { display: flex; gap: 40mm; }
.p01-rule { border-bottom: 1.5px solid #000; padding-bottom: 4px; }
.p01-indent { text-indent: 2.5em; }
.p01-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; margin-top: 6px; }
.p01 .memo-table { margin: 4px 0; width: 100%; }
.p01 .memo-table th, .p01 .memo-table td { padding: 1px 5px; font-size: 12.5px; }
.p01 .memo-table thead th { white-space: nowrap; }
.p01-left .memo-table tbody th { width: 34%; text-align: left; font-weight: 400; }
.p01 .memo-table th { background: #e6e6e6; }
.p01-items td:first-child { width: 8mm; }
.p01-items td:last-child { width: 24mm; }
.p01-items td { height: 1.25em; }
.p01-sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.p01-sigs.one { grid-template-columns: 1fr; width: 60%; margin-left: 15%; }
.p01-sig { text-align: center; break-inside: avoid; }
.p01-sig p:first-child { display: flex; gap: 6px; justify-content: center; align-items: flex-end; margin-top: 10px; }
.p01-dots { display: inline-block; width: 34mm; border-bottom: 1px dotted #000; height: 1em; }
.p01-name { min-height: 1.4em; }
.p01-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid #000; margin-top: 10px; }
.p01-boxes > div { padding: 3px 6px; border-left: 1px solid #000; font-size: 12.5px; }
.p01-boxes > div:first-child { border-left: 0; }
.p01-line { border-bottom: 1px dotted #000; height: 1.2em; }
.p01-director { margin-top: 8px; text-align: left; }
.p01-director .p01-sig { margin-top: 4px; }
.p01-date { text-align: center; }
.p01-note { color: #c00; font-size: 12px; margin-top: 8px !important; }
.p01-boxes .p01-sig p:first-child { margin-top: 6px; }
/* ผ 01 เป็นแบบฟอร์มหน้าเดียว: ขอบบน 1.8 ล่าง 1 ซม. (ซ้าย 3 ขวา 2 ซม. ตามเดิม) แบบฟอร์มเต็มหน้า ชิดล่าง ไม่เหลือที่ว่างล่างมาก
   หน้าจอใช้ขอบเท่ากันให้ตัวอย่างตรงกับที่พิมพ์ · --p01-fit ตั้งโดย fitP01() ใน app.js ย่อเมื่อยาวเกินหน้าเดียว */
@page p01 { size: A4; margin: 18mm 20mm 10mm 30mm; @top-center { content: ""; } }
.memo.p01 { page: p01; padding: 18mm 20mm 10mm 30mm; }
@media print { .memo.p01 { break-inside: avoid; zoom: var(--p01-fit, 1); } }
/* ===== เอกสารพิมพ์ทั้งหมด (บันทึกข้อความ เอกสารโครงการ เล่มรายงาน): TH SarabunPSK ขนาดเป็น pt =====
   ใช้ฟอนต์ที่ติดตั้งในเครื่องก่อน ไม่มีก็โหลดจาก /fonts (ฟอนต์แห่งชาติของ SIPA แจกจ่ายได้) · PDF ที่ส่งเข้า Google Drive จึงได้ฟอนต์เดียวกัน
   font-size-adjust ทำให้ Sarabun (สำรองสุดท้าย) ตัวเล็กลงเท่า TH SarabunPSK (สัดส่วนความสูงตัวอักษร 0.34) เอกสารจึงไม่ล้นหน้า */
@font-face { font-family: 'TH SarabunPSK'; font-weight: 400; font-style: normal; font-display: swap; src: local('TH SarabunPSK'), local('THSarabunPSK'), url('/fonts/THSarabun.ttf') format('truetype'); }
@font-face { font-family: 'TH SarabunPSK'; font-weight: 700; font-style: normal; font-display: swap; src: local('TH SarabunPSK Bold'), local('THSarabunPSK-Bold'), url('/fonts/THSarabun-Bold.ttf') format('truetype'); }
.memo { font-family: 'TH SarabunPSK', 'TH Sarabun New', 'Sarabun', serif; font-size-adjust: ex-height 0.34; font-size: 16pt; line-height: 1.3; }
.memo-title { font-size: 26pt; }
.memo-ref { font-size: 11pt; }
.book .cover h1 { font-size: 30pt; } .book .cover h2, .book .cover .school { font-size: 22pt; } .book .page h2 { font-size: 20pt; }
.memo.doc { font-size: 15pt; }
.doc .doc-fields th, .doc .doc-fields td { font-size: 15pt; }
.doc h3 { font-size: 16pt; }
.doc-steps { font-size: 14pt; }
.doc-estimate { font-size: 13.5pt; }
/* บันทึกข้อความขอจัดกิจกรรม (ผ 01): เนื้อหา 15 pt · ตารางและกล่องความเห็น 13 pt ให้จบหน้าเดียว */
.memo.p01 { font-size: 15pt; line-height: 1.22; }
.p01-top h1 { font-size: 24pt; }
.p01 .memo-table th, .p01 .memo-table td { font-size: 13pt; }
.p01-boxes > div { font-size: 13pt; }
.p01-note { font-size: 12pt; }
.memo.p01 { line-height: 1.15; }
.p01-items td { height: 1.1em; padding-top: 0; padding-bottom: 0; }
.p01-left .memo-table tbody th { width: 42%; white-space: nowrap; }
.p01-sig p:first-child { margin-top: 6px; }
.p01-sigs { margin-top: 0; }
.p01-boxes .p01-line { height: 1.05em; }
.p01-director { margin-top: 4px; }
.p01-code small { display: block; font-weight: 400; font-size: 9pt; color: #555; white-space: nowrap; }   /* เลขที่คำขอในระบบ (อ้างอิงเวลาค้นหา) */
/* บันทึกข้อความใช้ตราครุฑ (เหมือนกันทุกโรงเรียน) สูง 1.5 ซม. ตามระเบียบงานสารบรรณ ไม่ใช้โลโก้โรงเรียน */
.p01-garuda { height: 15mm; width: auto; margin: 0 0 -2mm; }   /* ห้ามดึงขึ้นเกินขอบบน: ส่วนที่ล้นเข้าขอบกระดาษถูกตัดตอนพิมพ์ (ครุฑขาด) */

/* สถานะงบประมาณ: แถบแหล่งเงิน (ใช้แล้ว | รออนุมัติ | คงเหลือ) · ตาราง กลุ่ม → โครงการ → กิจกรรม → คำขอ */
.st-viz { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.st-viz .card { margin: 0; }
.fund-row { margin: 10px 0 12px; }
.stack { display: flex; height: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.stack span { display: block; height: 100%; }
.s-pend, .viz-legend i.s-pend { background: var(--warn); opacity: .55; }
.viz-legend i.s-left { background: var(--card); border: 1px solid var(--line-strong); }
.st-table { font-size: .9rem; }
.st-table th.st-span { text-align: center; border-bottom: 1px solid var(--line); }
.st-table td:first-child { min-width: 260px; }
.st-group td { background: var(--card); font-weight: 600; }
.st-l1 { padding-left: 18px !important; }
.st-l2 { padding-left: 38px !important; }
.st-sub { display: block; font-size: .78rem; padding-left: 26px; }
.st-tg { all: unset; cursor: pointer; display: inline-block; width: 20px; text-align: center; color: var(--muted); }
.st-tg:focus-visible { outline: 2px solid var(--accent); }
.st-sp { display: inline-block; width: 20px; }
.st-act.warn td:first-child { box-shadow: inset 3px 0 var(--warn); }
.st-act.bad td:first-child, .st-group.bad td:first-child { box-shadow: inset 3px 0 var(--bad); }
.st-ent > td { padding: 0 0 6px 64px !important; background: var(--surface); }
.st-entries { width: 100%; font-size: .85rem; margin: 0; }
.st-entries td { padding: 3px 6px; border-bottom: 1px dashed var(--line); }
/* จัดสรรงบ: งบส่วนกลาง */
#centralBox { margin: 14px 0; }
#centralBox h2 small { display: block; font-weight: 400; font-size: .8rem; margin-top: 2px; }
#central input[name=name] { min-width: 220px; }
#central input.num { min-width: 110px; }
#groupSum tr.central-row td { background: var(--card); }
/* ประมาณการ: แถวใหม่ที่พิมพ์ค้างไว้ยังไม่บันทึก */
table.estimate tr.new.pending td { background: var(--warn-bg); }
.pending-note { display: block; font-size: .75rem; color: var(--warn); margin-top: 2px; }
.pending-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--warn); font-size: .9rem; margin: 6px 0 0; }
.pending-bar[hidden] { display: none; }

/* รายงานรายไตรมาส: หัวรายงานแสดงตอนพิมพ์ */
.print-head, .print-only { display: none; }
@media print { .print-head, .print-only { display: block; } }

/* รายงานผลกิจกรรม (แบบฟอร์ม PDCA): หน้ากรอก + บันทึกข้อความ + เล่มรายงาน */
label.inline { display: flex; gap: 8px; align-items: center; color: var(--fg); }
label.inline input { width: auto; }
.self-eval td:not(:first-child), .self-eval th:not(:first-child) { text-align: center; width: 44px; }
.thumbs figure input { width: 100%; margin-top: 4px; font-size: .85rem; }
.thumbs figcaption, .book-photos figcaption { font-size: .85rem; text-align: center; }
.book-photos figure { margin: 0; }
.rpt .center { text-align: center; }
.rpt h2.rpt-part { background: #a6a6a6; color: #fff; text-align: center; padding: 6px; font-size: 1.05em; margin: 10px 0; }
.rpt .rm-dots { border-bottom: 1px dotted #000; min-height: 1.4em; margin: 2px 0; }
.rpt .rm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm 10mm; margin-top: 6mm; }
.rpt .rm-op { break-inside: avoid; }
.rpt .rm-op.wide { border-top: 1px solid #000; margin-top: 4mm; padding-top: 2mm; }
.rpt .rm-sig { text-align: center; margin: 2px 0; }
.rpt .rpt-cover { text-align: center; margin-top: 20mm; }
.rpt .rpt-cover .doc-logo { position: static; display: block; margin: 0 auto 6mm; }
.rpt .rpt-by { margin: 20mm 0; font-weight: 700; }
.rpt .rpt-sign { text-align: right; margin: 10mm 0; }
.rpt .p01-top { display: grid; grid-template-columns: 30mm 1fr 30mm; align-items: center; }
/* นำเข้าระหว่างปี: ตารางยืนยันพอดีจอ ไม่ต้องเลื่อนด้านข้าง */
.co-table { width: 100%; table-layout: auto; }
.co-table td { vertical-align: top; }
.co-table td:first-child, .co-table th:first-child { width: 48px; min-width: 0; text-align: center; }
.co-table td:nth-child(2) { min-width: 180px; }
.co-table td.num { white-space: nowrap; }
.co-table textarea { min-width: 140px; }
.co-table select { max-width: 100%; }
@media (max-width: 700px) {
  .co-table thead { display: none; }
  .co-table, .co-table tbody, .co-table tr, .co-table td { display: block; width: auto !important; min-width: 0 !important; }
  .co-table tr[data-act] { position: relative; padding: 8px 0 8px 40px; border-bottom: 1px solid var(--line); }
  .co-table tr[data-act] td { border: 0; padding: 2px 0; text-align: left; }
  .co-table tr[data-act] td:first-child { position: absolute; left: 0; top: 10px; width: 36px !important; }
  .co-table td.num { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; white-space: normal; }
  .co-table td.num::before { content: attr(data-label); color: var(--muted); }
  .co-table textarea { min-width: 0; width: 100%; }
}
.co-table [hidden] { display: none !important; }

/* ===== แบรนด์ T³ Tiny Teacher Tools (เครื่องหมายเดียวกับเว็บหลัก tinyteachertools.app) ===== */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; color: var(--fg); flex: none; }
.brand-mark.sm { width: 18px; height: 18px; }
.brand-name { font-weight: 600; letter-spacing: -.01em; }
.side .brand { display: flex; }
.t3-by { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px 2px; font-size: .75rem; color: var(--muted); text-decoration: none; }
.t3-by:hover { color: var(--fg); }
.login-brand { margin: 24px 0 8px; font-size: 1.05rem; }

/* ===== หน้าแรก (ยังไม่ล็อกอิน): แนะนำผลิตภัณฑ์ ===== */
body.landing-page main { max-width: 1040px; padding-top: 0; }
body.landing-page .top { display: none; }
.landing { padding-bottom: 24px; }
.ld-nav { display: flex; align-items: center; gap: 12px; padding: 18px 0; }
.ld-nav .brand { font-size: 1.05rem; }
.ld-nav .ld-by { color: var(--muted); font-size: .82rem; text-decoration: none; margin-right: auto; }
.ld-nav .ld-by:hover { color: var(--fg); }
.ld-hero { padding: 36px 0 12px; }
.ld-kicker { color: var(--accent-ink); font-size: .85rem; font-weight: 500; margin: 0 0 10px; }
.ld-hero h1 { font-size: clamp(1.7rem, 4.2vw, 2.6rem); line-height: 1.25; margin: 0 0 14px; letter-spacing: -.02em; }
.ld-accent { color: #E76F51; }
.ld-lead { font-size: 1.08rem; color: var(--muted); max-width: 680px; margin: 0 0 22px; }
.ld-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; scroll-margin-top: 16px; }
.ld-cta .card { margin: 0; padding: 18px 20px; }
.ld-cta .card p { margin: 0 0 8px; }
.ld-section { margin-top: 44px; }
.ld-section h2 { font-size: 1.3rem; margin: 0 0 14px; }
.ld-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; counter-reset: s; }
.ld-steps li { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.ld-steps p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.ld-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.ld-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ld-grid.four { grid-template-columns: repeat(4, 1fr); }
.ld-grid.two { grid-template-columns: repeat(2, 1fr); }
.ld-module .ld-mod-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ld-module ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: .92rem; }
.ld-module li { margin: 3px 0; }
.ld-grid .card { margin: 0; }
.ld-grid .card p { margin: 6px 0 0; font-size: .92rem; }
.ld-final { text-align: center; padding: 26px 20px; }
.ld-final h2 { margin-top: 0; }
.ld-foot { margin-top: 40px; padding: 18px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted); font-size: .85rem; }
.ld-foot .t3-by { padding: 0; font-size: .9rem; color: var(--fg); font-weight: 600; }
.ld-foot .ld-links { margin-left: auto; }
.ld-foot a { color: inherit; }
@media (max-width: 820px) {
  .ld-cta, .ld-steps, .ld-grid, .ld-grid.four, .ld-grid.two { grid-template-columns: 1fr; }
  .ld-hero { padding-top: 16px; }
  .ld-foot .ld-links { margin-left: 0; }
  .ld-nav .ld-by { display: none; }
  .ld-nav .brand { margin-right: auto; }
}
.ld-nav .button, .brand-name { white-space: nowrap; }
.brand-icon { width: 26px; height: 26px; border-radius: 6px; flex: none; }
