/* =====================================================================
   รอบ 77: หน้าแรกโรงเรียนแบบใหม่ (/school — SchoolHome.razor) prefix sh-
   ใช้ร่วมกับ .sdb-* (school-dashboard.css: การ์ด/กราฟ/รายการ) และ .sch-* (school.css: ภาคเรียน/ระดับชั้น/ลิงก์)
   สีทั้งหมดจากตัวแปรใน :root (app.css / dark.css) → สีของโรงเรียน + โหมดมืดใช้ได้เลย
   จุดเด่นจุดเดียว: ใบปฏิทินวันนี้ที่หัวหน้า (แถบสีโรงเรียน + เลขวันใหญ่) — ส่วนอื่นเรียบ
   มือถือ ≤760px: ตัวเลข 2 คอลัมน์ งานวันนี้ 2 คอลัมน์ ห้ามเลื่อนข้าง · คอม 1280: ตัวเลขแถวเดียว
   ===================================================================== */

@media screen {
  /* ---------- หัว: ใบปฏิทิน + ทักทาย ---------- */
  .sh-head { align-items: center; }
  .sh-hello { display: flex; align-items: center; gap: 16px; min-width: 0; }
  .sh-date {
    position: relative; flex: none; display: flex; flex-direction: column; align-items: stretch; width: 78px;
    border-radius: 14px; overflow: hidden; text-align: center; background: var(--surface);
    border: 1px solid var(--line); box-shadow: var(--shadow);
  }
  /* ห่วงปฏิทิน 2 วง */
  .sh-date::before, .sh-date::after {
    content: ""; position: absolute; top: 4px; width: 7px; height: 7px; border-radius: 999px;
    background: var(--surface); opacity: .85;
  }
  .sh-date::before { left: 20px; }
  .sh-date::after { right: 20px; }
  .sh-date-m {
    padding: 13px 4px 3px; background: var(--brand); color: var(--brand-ink);
    font-size: .72rem; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sh-date-d { padding-top: 4px; font-size: 2.1rem; font-weight: 800; line-height: 1.05; color: var(--ink); letter-spacing: -.02em; }
  .sh-date-w { padding: 1px 4px 7px; font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-hello-text { min-width: 0; }
  .sh-greet { margin: 0; font-size: .9rem; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
  .sh-hello-text h1 { margin: 0; font-size: 1.6rem; line-height: 1.25; overflow-wrap: anywhere; }
  .sh-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0 0; font-size: .82rem; }
  .sh-meta .sch-term { font-size: .78rem; }
  .sh-year { font-weight: 700; color: var(--ink); }
  .sh-range, .sh-kind { color: var(--muted); }
  .sh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .sh-body { gap: 16px; }

  /* ---------- 1 เริ่มต้นใช้งาน ---------- */
  .sh-start.panel {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 0; padding: 12px 14px;
    background: linear-gradient(110deg, var(--brand-soft), var(--brand-tint) 60%, var(--surface));
    border: 1px solid rgba(var(--brand-rgb), .22);
  }
  .sh-start-prog { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
  .sh-start-prog .ob-dash-ring { width: 44px; height: 44px; }
  .sh-start-title { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
  .sh-start-title strong { font-size: 1rem; }
  .sh-start-title small { color: var(--muted); font-size: .8rem; font-weight: 600; }
  .sh-start-next { display: flex; flex-direction: column; flex: 1 1 160px; min-width: 0; line-height: 1.35; padding-left: 14px; border-left: 1px solid rgba(var(--brand-rgb), .25); }
  .sh-start-next small { color: var(--muted); font-size: .76rem; font-weight: 600; }
  .sh-start-next strong { overflow-wrap: anywhere; }
  .sh-start-go, .sh-start-all { white-space: nowrap; }
  .sh-start-all { background: var(--surface); }
  .sh-start-x {
    min-height: 36px; padding: 0 8px; border: 0; border-radius: 9px; background: none; color: var(--muted);
    font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
  }
  .sh-start-x:hover:not(:disabled) { color: var(--ink); background: var(--surface); }

  /* ---------- 3 งานวันนี้ ---------- */
  .sh-todo { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; min-width: 0; }
  .sh-todo-h { flex: none; margin: 0; font-size: 1rem; font-weight: 800; }
  .sh-todo-list { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; min-width: 0; margin: 0; padding: 0; list-style: none; }
  .sh-todo-list > li { min-width: 0; }
  .sh-todo-item {
    display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 5px 14px 5px 6px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem;
  }
  .sh-todo-item:hover { border-color: rgba(var(--brand-rgb), .5); }
  .sh-todo-n {
    flex: none; display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px;
    background: var(--brand-soft); color: var(--brand-strong); font-size: 1.05rem; font-weight: 800;
  }
  .sh-todo-item.warn .sh-todo-n { background: var(--warn-soft); color: var(--warn-text, #7A5300); }
  .sh-todo-item.bad .sh-todo-n { background: var(--danger-soft); color: var(--danger); }
  .sh-todo-l { min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
  .sh-todo-none { margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: .9rem; }
  .sh-todo-wait { margin: 0; font-size: .88rem; }

  /* ---------- 4 ตัวเลขสำคัญ ---------- */
  .sh-keys { display: flex; flex-wrap: wrap; gap: 10px; }
  .sh-key {
    display: flex; flex-direction: column; gap: 1px; flex: 1 1 150px; min-width: min-content; padding: 12px 14px;
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  }
  a.sh-key:hover { border-color: rgba(var(--brand-rgb), .5); }
  /* ห้ามตัดตัวเลขเงิน: ตัวเลขไม่ตัดบรรทัด + การ์ดกว้างอย่างน้อยเท่าตัวเลข (min-content) — ไม่พอ = ขึ้นแถวใหม่ */
  .sh-key-l { font-size: .8rem; font-weight: 700; color: var(--muted); line-height: 1.35; }
  .sh-key-n { font-size: 1.35rem; font-weight: 800; line-height: 1.2; white-space: nowrap; }
  .sh-key-s, .sh-key-m { font-size: .76rem; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
  .sh-key-m { color: var(--ink); opacity: .8; }
  .sh-key.warn { background: var(--warn-soft); border-color: transparent; }
  .sh-key-money { flex: 2 1 260px; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
  a.sh-key-money:hover { border-color: var(--brand-strong); background: var(--brand-strong); }
  .sh-key-money .sh-key-l, .sh-key-money .sh-key-s, .sh-key-money .sh-key-m { color: var(--brand-ink); opacity: .85; }
  .sh-key-money .sh-key-n { font-size: 1.65rem; }
  .sh-key.sh-wait { justify-content: center; }
  .sh-key-money.sh-wait .sh-key-l, .sh-key-money.sh-wait .muted { color: var(--brand-ink); }
  .sh-key-err { flex: 2 1 260px; }
  .sh-noyear { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--brand-tint); color: var(--ink); font-size: .9rem; }

  /* ---------- 6 รายละเอียดการเงิน ---------- */
  .sh-money-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sh-money-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-content: start; }
  .sh-mini {
    display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--chip); color: var(--ink); text-decoration: none; border: 1px solid transparent;
  }
  a.sh-mini:hover { border-color: rgba(var(--brand-rgb), .45); }
  .sh-mini > span { font-size: .78rem; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-mini strong { font-size: 1.12rem; font-weight: 800; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sh-mini small { font-size: .74rem; color: var(--muted); overflow-wrap: anywhere; }
  .sh-mini.bad { background: var(--danger-soft); }
  .sh-mini.bad strong { color: var(--danger); }
  .sh-chart { margin: 0; }
  /* รอบ 98: ไม่มีเงินเข้า 14 วัน — ข้อความกลางกราฟ แท่งจาง ๆ เป็นเส้นฐาน */
  .sh-chart.is-empty { position: relative; }
  .sh-chart-empty {
    position: absolute; left: 0; right: 0; top: calc(50% - 6px); transform: translateY(-50%); z-index: 1;
    margin: 0 auto; width: fit-content; max-width: 90%; padding: 6px 14px; border-radius: 999px;
    background: var(--chip); font-size: .86rem; text-align: center;
  }
  .sh-chart.is-empty .sdb-bar-x { opacity: .55; }
  @media (min-width: 1100px) {
    .sh-money-grid { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); align-items: start; }
    .sh-money-nums { grid-template-columns: minmax(0, 1fr); }
  }

  /* ---------- 7a สอนวันนี้ ---------- */
  .sh-tt-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
  .sh-tt-list li { display: flex; align-items: baseline; gap: 12px; min-width: 0; padding: 7px 8px; border-radius: var(--radius-sm); }
  .sh-tt-list li + li { border-top: 1px solid var(--line); }
  .sh-tt-list li.now { background: var(--brand-tint); border-top-color: transparent; box-shadow: inset 3px 0 0 var(--brand); }
  .sh-tt-list li.now + li { border-top-color: transparent; }
  .sh-tt-time { flex: none; min-width: 46px; font-weight: 800; font-size: .92rem; }
  .sh-tt-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
  .sh-tt-main strong { overflow-wrap: anywhere; }
  .sh-tt-main small { font-size: .78rem; overflow-wrap: anywhere; }
}

/* ---------- มือถือ ---------- */
@media screen and (max-width: 760px) {
  .sh-hello { gap: 12px; }
  .sh-date { width: 64px; border-radius: 12px; }
  .sh-date::before { left: 15px; }
  .sh-date::after { right: 15px; }
  .sh-date-m { padding-top: 12px; font-size: .68rem; }
  .sh-date-d { font-size: 1.7rem; }
  .sh-date-w { font-size: .66rem; }
  .sh-hello-text h1 { font-size: 1.25rem; }
  .sh-greet { font-size: .84rem; }
  .sh-meta { font-size: .78rem; }
  .sh-range { flex-basis: 100%; }

  .sh-start.panel { gap: 8px 12px; }
  .sh-start-prog { flex: 1 1 auto; }
  .sh-start-all { order: 1; }
  .sh-start-next { flex-basis: 100%; order: 2; padding-left: 0; border-left: 0; }
  .sh-start-go { order: 3; flex: 1 1 auto; text-align: center; }
  .sh-start-x { order: 4; }

  .sh-todo { align-items: stretch; flex-direction: column; gap: 8px; }
  .sh-todo-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sh-todo-item { height: 100%; font-size: .84rem; padding-right: 10px; }
  .sh-todo-none { align-self: flex-start; }

  /* รอบ 98: ตัวเลขการเงิน 2 คอลัมน์ — ช่องสุดท้ายที่เหลือเดี่ยวเต็มแถว (เดิมเหลือช่องว่างขวา) */
  .sh-money-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sh-money-nums > :last-child:nth-child(odd) { grid-column: 1 / -1; }

  .sh-key { padding: 10px 12px; }
  .sh-key-n { font-size: 1.15rem; }
  .sh-key-money .sh-key-n { font-size: 1.5rem; }
}
