/* ═══════════════════════════════════════════════════════════════
 *  SCS · ระบบดูแลช่วยเหลือนักเรียน — สไตล์หลัก (5-Star Premium Pro)
 *  Version: 1.0.0 · ครูวิรัตน์ หาดคำ · www.kruwirat.com
 * ═══════════════════════════════════════════════════════════════ */

:root {
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #a855f7;
  --brand-soft: #eef2ff;
  --brand-deep: #4338ca;
  --brand-grad: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);

  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --bg: #f6f7fb;
  --card: #ffffff;

  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --sky: #0ea5e9;
  --violet: #8b5cf6;
  --slate: #64748b;

  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 6px 18px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 272px;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; }

body {
  margin: 0;
  font-family: 'Sarabun', 'Kanit', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.font-display, .btn, .badge, .kpi-value, .hero-title, .stat-value, .sb-clock-time {
  font-family: 'Kanit', 'Sarabun', system-ui, sans-serif;
}

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

img { max-width: 100%; height: auto; }

/* ═══ โครงหน้าจอ ═══ */
.shell { display: flex; align-items: stretch; min-height: 100vh; width: 100%; }

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1e1b4b, #312e81 55%, #1e1b4b);
  color: #e0e7ff;
  padding: 18px 14px 24px;
  z-index: 60;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 4px; }

.main-area { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.page-wrap { flex: 1 1 auto; padding: 20px 24px 40px; max-width: 1440px; width: 100%; }

/* ═══ Sidebar ═══ */
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 14px; }
.sb-logo {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 15px; background: var(--brand-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; overflow: hidden;
  box-shadow: 0 8px 22px rgba(99, 102, 241, .45);
}
.sb-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-brand-name { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 15px; color: #fff; line-height: 1.25; }
.sb-brand-org { font-size: 11.5px; color: rgba(224, 231, 255, .72); }

.sb-clock {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; text-align: center;
}
.sb-clock-time {
  font-size: 21px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
  text-shadow: 0 0 18px rgba(165, 180, 252, .5);
}
.sb-clock-date { font-size: 11.5px; color: rgba(224, 231, 255, .78); }

.sb-user {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px; padding: 10px; margin-bottom: 14px;
}
.sb-user-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; overflow: hidden;
}
.sb-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #fff; }

.sb-cat {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(199, 210, 254, .65);
  padding: 14px 12px 6px; display: flex; align-items: center; gap: 7px;
}
.sb-cat::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #a5b4fc; box-shadow: 0 0 8px #a5b4fc; }

.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 11px;
  color: rgba(224, 231, 255, .88); font-size: 13.5px;
  position: relative; transition: all .18s var(--ease);
  white-space: nowrap;
}
.sb-link i { font-size: 16px; width: 19px; text-align: center; flex: 0 0 19px; }
.sb-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sb-link.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; }
.sb-link.active::before {
  content: ''; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--brand-grad);
  box-shadow: 0 0 12px rgba(139, 92, 246, .8);
}
/* จำนวนข้อมูลท้ายเมนู
   ★ badge คือ "ข้อมูลประกอบ" ไม่ใช่ "คำเตือน" — ต้องอ่านออกแต่ไม่แย่งสายตาจากชื่อเมนู
     ห้ามใช้สีแดงจัดเป็นค่าเริ่มต้น: ถ้าทุกเมนูแดงหมด สายตาจะล้าและเลิกสนใจสีแดงทั้งระบบ
     (ที่ถูกคือสีแดงต้องหมายถึง "ต้องรีบทำ" เท่านั้น)
   ใช้โทนเดียวกับพื้น sidebar (คราม-ม่วง) แบบโปร่ง — กลืนไปกับธีม สบายตาเมื่อมองนาน ๆ */
.sb-link .sb-badge {
  margin-left: auto; flex: 0 0 auto;
  background: rgba(255, 255, 255, .10);
  color: rgba(199, 210, 254, .92);
  font-size: 10.5px; font-weight: 600; line-height: 1.65;
  min-width: 20px; padding: 1px 7px; border-radius: 99px; text-align: center;
  font-variant-numeric: tabular-nums;
  transition: all .18s var(--ease);
}
.sb-link:hover .sb-badge  { background: rgba(255, 255, 255, .18); color: #e0e7ff; }
.sb-link.active .sb-badge { background: rgba(255, 255, 255, .24); color: #fff; }

/* งานที่ต้องลงมือทำ (นัดหมายที่ยังมาไม่ถึง) — เน้นด้วยสีอุ่นแบบนวล ไม่ใช่แดงจัด */
.sb-link .sb-badge.is-due {
  background: rgba(245, 158, 11, .20);
  color: #fcd34d;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .35);
}
.sb-link:hover .sb-badge.is-due { background: rgba(245, 158, 11, .28); }
.sb-link.is-logout { color: #fda4af; }
.sb-link.is-logout:hover { background: rgba(244, 63, 94, .16); color: #fff; }

.sb-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .1); }

/* ═══ Navbar ═══ */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-burger {
  display: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  align-items: center; justify-content: center; font-size: 19px; cursor: pointer;
}
.nav-icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}
/* ★ ทุกก้อนในแถบบนต้อง nowrap + flex-shrink:0 เสมอ
   ถ้าไม่ใส่ พอพื้นที่ตึง flex จะบีบจนข้อความตัดเป็นแนวตั้งทีละตัวอักษร (อ่านไม่ได้เลย)
   ก้อนที่ยอมให้หดได้มีแค่ "ชื่อหน้า" ซึ่งต้องตัดด้วย ellipsis ไม่ใช่ขึ้นบรรทัดใหม่ */
.nav-titles { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.nav-title {
  font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 16px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub {
  font-size: 11.5px; color: var(--ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.nav-right > * { flex: 0 0 auto; }

.nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 99px;
  background: rgba(16, 185, 129, .1); color: #047857;
  font-size: 11.5px; font-weight: 600; border: 1px solid rgba(16, 185, 129, .2);
  white-space: nowrap;
}
.nav-pill .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--emerald);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.nav-clock {
  font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nav-prof {
  display: flex; align-items: center; gap: 8px; padding: 5px 11px 5px 5px;
  border: 1px solid var(--line); border-radius: 99px; background: #fff;
  cursor: pointer; transition: all .18s var(--ease); white-space: nowrap;
}
.nav-prof:hover { box-shadow: var(--shadow-sm); border-color: var(--brand-1); }
.nav-prof-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-grad);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; overflow: hidden; flex: 0 0 30px;
}
.nav-prof-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-prof-name {
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}

.nav-prof-pop {
  display: none;
  position: absolute; right: 22px; top: 62px; z-index: 90;
  min-width: 240px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 8px;
}
.nav-prof-pop.is-open { display: block; }
.nav-prof-pop .pp-head { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.nav-prof-pop a, .nav-prof-pop button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 12px; border-radius: 10px; font-size: 13px;
  color: var(--ink-soft); border: 0; background: transparent; cursor: pointer;
  font-family: inherit; text-align: left;
}
.nav-prof-pop a:hover, .nav-prof-pop button:hover { background: var(--line-soft); }
.nav-prof-pop .is-danger { color: var(--rose); }

/* ═══ Hero ═══ */
.hero {
  position: relative; overflow: hidden;
  background: var(--brand-grad);
  border-radius: var(--radius-lg); padding: 24px 26px;
  color: #fff; margin-bottom: 18px;
  box-shadow: 0 14px 34px rgba(99, 102, 241, .28);
}
.hero::before {
  content: ''; position: absolute; top: -60%; right: -8%;
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 62%);
  pointer-events: none;
}
.hero::after {
  content: ''; position: absolute; bottom: -70%; left: 12%;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .13), transparent 65%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 99px; padding: 4px 12px; font-size: 11.5px; font-weight: 600; margin-bottom: 10px;
}
.hero-title { font-size: 23px; font-weight: 800; margin: 0 0 4px; }
.hero-sub { font-size: 13px; opacity: .9; }

.hero-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin-top: 18px;
}
.hero-kpi {
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px; padding: 11px 13px; backdrop-filter: blur(8px);
}
.hero-kpi-label { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.hero-kpi-value { font-family: 'Kanit', sans-serif; font-size: 22px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hero-kpi-sub { font-size: 10.5px; opacity: .78; }

/* ═══ การ์ด / แผง ═══ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 16px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-icon {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  background: var(--brand-soft); color: var(--brand-1);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.panel-title { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 15px; }
.panel-sub { font-size: 11.5px; color: var(--ink-muted); }
.panel-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

/* ═══ Stat cards ═══ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  width: 42px; height: 42px; border-radius: 13px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; margin-bottom: 9px;
}
.stat-label { font-size: 12px; color: var(--ink-muted); }
.stat-value { font-size: 25px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }

.g-indigo  { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.g-emerald { background: linear-gradient(135deg, #10b981, #059669); }
.g-amber   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.g-rose    { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.g-sky     { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.g-violet  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.g-pink    { background: linear-gradient(135deg, #ec4899, #db2777); }
.g-slate   { background: linear-gradient(135deg, #64748b, #334155); }
.g-teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.g-lime    { background: linear-gradient(135deg, #84cc16, #65a30d); }

/* ═══ ปุ่ม ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: 'Kanit', sans-serif; transition: all .18s var(--ease);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--ink); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand-grad); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}
.btn-primary:hover { color: #fff; box-shadow: 0 9px 22px rgba(99, 102, 241, .4); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; border-color: transparent; }
.btn-success:hover { color: #fff; }
.btn-danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; border-color: transparent; }
.btn-danger:hover { color: #fff; }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; border-color: transparent; }
.btn-warning:hover { color: #fff; }
.btn-ghost { background: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[data-state] { pointer-events: none; opacity: 1; }
.btn[data-state="loading"] { background: linear-gradient(135deg, #475569, #334155); color: #fff; border-color: transparent; }
.btn[data-state="success"] { background: linear-gradient(135deg, #10b981, #059669); color: #fff; border-color: transparent; }
.btn[data-state="error"] { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; border-color: transparent; }

.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }

/* ═══ ฟอร์ม ═══ */
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 5px;
}
.field .req { color: var(--rose); }
.field-hint { font-size: 11px; color: var(--ink-muted); margin-top: 4px; }
.field-error {
  margin-top: 5px; font-size: 12px; color: #dc2626; font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}
.field.has-error .input, .field.has-error .select, .field.has-error .textarea {
  border-color: var(--rose); background: #fef2f2;
}

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 11px; font-size: 13.5px; font-family: inherit;
  background: #fff; color: var(--ink); transition: all .16s var(--ease);
  min-width: 0;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .13);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L2 4h8z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-1); width: 16px; height: 16px; }

.fg-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.fg-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.fg-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }

/* กล่องตัวเลือกแบบการ์ด */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.check-card {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; font-size: 13px;
  transition: all .16s var(--ease); line-height: 1.45;
}
.check-card:hover { border-color: var(--brand-1); background: var(--brand-soft); }
.check-card input { margin-top: 3px; flex: 0 0 16px; }
.check-card.is-on { border-color: var(--brand-1); background: var(--brand-soft); font-weight: 500; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row .check-card { flex: 0 1 auto; }

/* ═══ ตาราง ═══ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.data-table thead th {
  background: var(--line-soft); color: var(--ink-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--brand-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { white-space: nowrap; text-align: right; }

/* ═══ Badge / Chip ═══ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.b-emerald { background: #d1fae5; color: #065f46; }
.b-amber   { background: #fef3c7; color: #92400e; }
.b-rose    { background: #ffe4e6; color: #9f1239; }
.b-sky     { background: #e0f2fe; color: #075985; }
.b-violet  { background: #ede9fe; color: #5b21b6; }
.b-slate   { background: #e2e8f0; color: #334155; }
.b-indigo  { background: #e0e7ff; color: #3730a3; }
.b-pink    { background: #fce7f3; color: #9d174d; }

.role-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700;
}
.role-admin    { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #78350f; }
.role-director { background: linear-gradient(135deg, #ddd6fe, #a78bfa); color: #4c1d95; }
.role-academic { background: linear-gradient(135deg, #bfdbfe, #60a5fa); color: #1e3a8a; }
.role-teacher  { background: linear-gradient(135deg, #a7f3d0, #34d399); color: #065f46; }
.role-parent   { background: linear-gradient(135deg, #fbcfe8, #f472b6); color: #831843; }

/* ═══ Toolbar ═══ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center;
  margin-bottom: 14px; padding: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.toolbar .search { flex: 1 1 220px; min-width: 180px; position: relative; }
.toolbar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); font-size: 14px; }
.toolbar .search .input { padding-left: 34px; }
.toolbar .select { width: auto; min-width: 130px; flex: 0 1 auto; }
.toolbar-spacer { margin-left: auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: #fff; font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
  cursor: pointer; transition: all .16s var(--ease);
}
.chip:hover { border-color: var(--brand-1); color: var(--brand-1); }
.chip.is-on { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(99, 102, 241, .28); }

/* ═══ การ์ดรายการ (มือถือ) ═══ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.rec-card {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand-1);
  border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm);
  transition: all .2s var(--ease); display: block; color: inherit;
}
.rec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.rec-card.tone-emerald { border-left-color: var(--emerald); }
.rec-card.tone-amber { border-left-color: var(--amber); }
.rec-card.tone-rose { border-left-color: var(--rose); }
.rec-card.tone-slate { border-left-color: var(--slate); }
.rec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.rec-avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px;
  background: var(--brand-soft); color: var(--brand-1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; overflow: hidden;
}
.rec-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rec-name { font-weight: 700; font-size: 14px; font-family: 'Kanit', sans-serif; }
.rec-meta { font-size: 11.5px; color: var(--ink-muted); }
.rec-body { font-size: 12.5px; color: var(--ink-soft); }
.rec-foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line); flex-wrap: wrap; }

/* ═══ สถานะว่าง / โหลด ═══ */
.empty-state { text-align: center; padding: 46px 20px; color: var(--ink-muted); }
.empty-state i { font-size: 44px; opacity: .35; display: block; margin-bottom: 12px; }
.empty-state p { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.empty-state small { font-size: 12.5px; }
.empty-state .btn { margin-top: 14px; }

.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 0%, #f8fafc 50%, var(--line-soft) 100%);
  background-size: 200% 100%; animation: shimmer 1.6s ease-in-out infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ═══ Pagination ═══ */
.pagination { display: flex; gap: 5px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; color: var(--ink-soft); background: #fff;
}
.pagination a:hover { border-color: var(--brand-1); color: var(--brand-1); }
.pagination .is-current { background: var(--brand-grad); color: #fff; border-color: transparent; font-weight: 700; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

/* ═══ Alert / Flash ═══ */
.flash-host { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand-1);
  border-radius: 13px; padding: 12px 14px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: slideIn .3s var(--ease);
}
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.flash i { font-size: 17px; flex: 0 0 auto; margin-top: 1px; }
.flash.is-success { border-left-color: var(--emerald); } .flash.is-success i { color: var(--emerald); }
.flash.is-error   { border-left-color: var(--rose); }    .flash.is-error i { color: var(--rose); }
.flash.is-warning { border-left-color: var(--amber); }   .flash.is-warning i { color: var(--amber); }
.flash.is-info    { border-left-color: var(--sky); }     .flash.is-info i { color: var(--sky); }
.flash-close { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: var(--ink-muted); font-size: 15px; padding: 0; }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 13px; font-size: 13px; margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--line-soft);
}
.alert i { font-size: 17px; margin-top: 1px; }
.alert-info { background: #e0f2fe; border-color: #bae6fd; color: #075985; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-danger { background: #ffe4e6; border-color: #fecdd3; color: #9f1239; }
.alert-success { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }

/* ═══ Modal ═══ */
#modal-host {
  display: none; position: fixed; inset: 0; z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px);
}
#modal-host.is-open { display: flex; }
.modal-card {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modalIn .25s var(--ease);
}
.modal-card.is-lg { max-width: 860px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head {
  position: relative; overflow: hidden;
  background: var(--brand-grad); color: #fff; padding: 18px 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; gap: 11px;
}
.modal-head::before {
  content: ''; position: absolute; top: -60%; right: -6%; width: 200px; height: 200px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .2), transparent 62%);
  pointer-events: none;
}
.modal-head > * { position: relative; z-index: 1; }
.modal-title { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 16px; }
.modal-close {
  margin-left: auto; width: 32px; height: 32px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .15);
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ═══ Spinner overlay ═══ */
#spin-host {
  display: none; position: fixed; inset: 0; z-index: 400;
  align-items: center; justify-content: center; flex-direction: column; gap: 16px;
  background: rgba(15, 23, 42, .62); backdrop-filter: blur(5px);
}
#spin-host.is-open { display: flex; }
.spin-ring {
  position: relative; width: 74px; height: 74px;
  display: flex; align-items: center; justify-content: center;
}
.spin-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid rgba(165, 180, 252, .2); border-top-color: #a5b4fc;
  animation: spin 1s linear infinite;
}
.spin-ring i { color: #a5b4fc; font-size: 27px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin-text { color: #e0e7ff; font-family: 'Kanit', sans-serif; font-size: 14px; }

/* ═══ Progress ═══ */
.progress { height: 9px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand-grad); border-radius: 99px; transition: width 1s var(--ease); }

/* ═══ Footer ═══ */
.app-footer {
  align-self: stretch; margin: 16px 24px 20px; padding: 14px 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; font-size: 12px; color: var(--ink-muted); flex-wrap: wrap;
}
.app-footer::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-grad); }
.af-ver {
  background: var(--brand-grad); color: #fff; padding: 2px 9px;
  border-radius: 99px; font-weight: 700; font-size: 10.5px; margin-left: 6px;
}
.af-dev { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.af-dev:hover { color: var(--brand-1); }
.af-dev-logo {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, .28);
}
.af-dev-label { font-size: 10.5px; color: var(--ink-muted); }
.af-dev-name { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

/* ═══ ตัวช่วย ═══ */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 8px; } .mb-1 { margin-bottom: 8px; }
.mt-2 { margin-top: 16px; } .mb-2 { margin-bottom: 16px; }
.mt-3 { margin-top: 24px; } .mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; } .text-right { text-align: right; }
.text-muted { color: var(--ink-muted); }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.5px; }
.fw-700 { font-weight: 700; } .fw-600 { font-weight: 600; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-muted); font-size: 12.5px; }
.kv dd { margin: 0; color: var(--ink); }

.avatar-lg {
  width: 84px; height: 84px; border-radius: 22px; overflow: hidden;
  background: var(--brand-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; flex: 0 0 84px;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.section-title {
  font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 14.5px;
  padding-left: 11px; border-left: 4px solid var(--brand-1);
  margin: 20px 0 12px;
}

/* ═══ Bottom nav (มือถือ) ═══ */
.bottom-nav { display: none; }
.sb-backdrop { display: none; }


/* ═══ Hero variants ═══ */
.hero-violet { background: linear-gradient(135deg, #8b5cf6, #7c3aed, #a855f7); box-shadow: 0 14px 34px rgba(139, 92, 246, .28); }
.hero-sky    { background: linear-gradient(135deg, #0ea5e9, #0284c7, #38bdf8); box-shadow: 0 14px 34px rgba(14, 165, 233, .28); }
.hero-emerald{ background: linear-gradient(135deg, #10b981, #059669, #34d399); box-shadow: 0 14px 34px rgba(16, 185, 129, .28); }
.hero-amber  { background: linear-gradient(135deg, #f59e0b, #d97706, #fbbf24); box-shadow: 0 14px 34px rgba(245, 158, 11, .28); }
.hero-rose   { background: linear-gradient(135deg, #f43f5e, #e11d48, #fb7185); box-shadow: 0 14px 34px rgba(244, 63, 94, .28); }

/* ═══ Key-value list ═══ */
dl.kv { margin: 0; display: grid; grid-template-columns: 170px 1fr; gap: 0; }
dl.kv dt {
  font-size: 12px; color: var(--ink-muted); font-weight: 600;
  padding: 8px 10px 8px 0; border-bottom: 1px dashed var(--line-soft);
}
dl.kv dd {
  margin: 0; font-size: 13px; padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft); word-break: break-word; overflow-wrap: anywhere;
}
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }

/* ═══ Plain list ═══ */
.list-plain { display: flex; flex-direction: column; }
.lp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px dashed var(--line-soft);
  color: inherit; text-decoration: none; transition: background .18s;
}
.lp-item:last-child { border-bottom: 0; }
.lp-item:hover { background: var(--line-soft); }
.lp-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.lp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lp-main strong { font-size: 13px; font-weight: 600; }

/* ═══ Calendar ═══ */
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.cal-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-muted); }
.cal-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-wd {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink-muted); text-transform: uppercase; padding-bottom: 4px;
}
.cal-cell {
  min-height: 96px; border: 1px solid var(--line); border-radius: 12px;
  padding: 5px 6px; background: #fff; display: flex; flex-direction: column; gap: 3px;
  transition: border-color .18s, box-shadow .18s;
}
.cal-cell:hover { border-color: var(--brand-1); }
.cal-cell.is-empty { background: var(--line-soft); border-style: dashed; min-height: 60px; }
.cal-cell.is-today { border-color: var(--brand-1); box-shadow: 0 0 0 2px rgba(99, 102, 241, .16); }
.cal-day { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; }
.cal-cell.is-today .cal-day span { color: var(--brand-1); }
.cal-add {
  width: 20px; height: 20px; border-radius: 6px; display: none;
  align-items: center; justify-content: center; color: var(--brand-1);
  background: var(--line-soft); font-size: 12px; text-decoration: none;
}
.cal-cell:hover .cal-add { display: inline-flex; }
.cal-ev {
  display: block; font-size: 11px; line-height: 1.35; padding: 3px 6px;
  background: var(--line-soft); border-left: 3px solid var(--brand-1);
  border-radius: 5px; color: var(--ink); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev:hover { background: #eef2ff; }
.cal-ev-time { font-weight: 700; margin-right: 3px; font-variant-numeric: tabular-nums; }


/* ═══ Avatar เล็ก + ปุ่มจิ๋ว ═══ */
.avatar-sm {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover;
  flex: 0 0 34px; border: 1px solid var(--line); background: var(--line-soft);
}
.btn-xs {
  padding: 4px 8px; font-size: 11.5px; border-radius: 8px; line-height: 1.2;
}


/* ═══ Stepper ═══ */
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.step {
  flex: 1; min-width: 160px; display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; font-size: 13px; color: var(--ink-muted); font-weight: 500;
}
.step-n {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--line-soft); color: var(--ink-muted); font-weight: 700; font-size: 12.5px;
}
.step.is-current { border-color: var(--brand-1); color: var(--ink); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.step.is-current .step-n { background: var(--brand-grad); color: #fff; }
.step.is-done { border-color: var(--emerald); color: var(--ink); }
.step.is-done .step-n { background: var(--emerald); color: #fff; }


/* ═══ คู่มือการใช้งาน ═══ */
.guide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.guide-list li { display: flex; gap: 12px; align-items: flex-start; }
.guide-n {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 13px;
}
.guide-t { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.guide-d { font-size: 13px; color: var(--ink-muted); line-height: 1.7; }
.guide-tip {
  margin-top: 6px; font-size: 12px; color: #92400e;
  background: #fffbeb; border-left: 3px solid #f59e0b; border-radius: 0 8px 8px 0; padding: 6px 10px;
}
.faq { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.faq summary {
  cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 13.5px;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '\002B'; font-size: 17px; color: var(--ink-muted); flex: 0 0 auto; }
.faq[open] summary::after { content: '\2212'; }
.faq[open] { border-color: var(--brand-1); }
.faq[open] summary { background: var(--line-soft); }
.faq-body { padding: 10px 14px 14px; font-size: 13px; color: var(--ink-muted); line-height: 1.75; }

/* ═══ Flow diagram ═══ */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow i { color: var(--ink-muted); }
.flow-step {
  background: var(--line-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 13px; font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.4;
}
.flow-step small { font-weight: 400; color: var(--ink-muted); font-size: 10.5px; }
.flow-step.is-start { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.flow-step.is-warn  { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.flow-step.is-end   { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed; left: -300px; top: 0; bottom: 0; width: 280px; flex: none;
    transition: left .26s var(--ease); box-shadow: 0 0 40px rgba(0, 0, 0, .4);
  }
  .sidebar.is-open { left: 0; }
  .sb-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 55; }
  .sb-backdrop.is-open { display: block; }
  .nav-burger { display: flex; }
  .page-wrap { padding: 16px 14px 30px; }
  .app-footer { margin: 12px 14px 90px; flex-direction: column-reverse; text-align: center; }
}

/* ═══ แถบบน — ยุบทีละระดับตามความกว้าง ═══
   ★ ห้ามยุบทีเดียวตอนถึงจอมือถือ ต้องไล่ตัดของที่ "จำเป็นน้อยสุด" ออกก่อน
     ลำดับความสำคัญ: ปุ่มเมนู > ชื่อหน้า > รูปโปรไฟล์ > ชื่อผู้ใช้ > ป้ายออนไลน์ > นาฬิกา
     สิ่งที่ซ่อนไปไม่ได้หายจากระบบ — ชื่อผู้ใช้ยังอยู่ในเมนูโปรไฟล์ · วันเวลาอยู่ในเมนูข้าง */

/* ระดับ 1 (≤980px) — ตัดนาฬิกา (ยาวสุดและมีซ้ำในเมนูข้างอยู่แล้ว) */
@media (max-width: 980px) {
  .nav-clock { display: none; }
}

/* ระดับ 2 (≤820px) — ตัดชื่อผู้ใช้ เหลือรูปโปรไฟล์กลม ๆ กดเปิดเมนูได้เหมือนเดิม */
@media (max-width: 820px) {
  .navbar { padding: 10px 16px; gap: 10px; }
  .nav-prof-name { display: none; }
  .nav-prof { padding: 5px; gap: 5px; }
}

/* ระดับ 3 (≤620px) — ตัดป้ายออนไลน์ + คำโปรยใต้ชื่อหน้า เหลือเฉพาะที่จำเป็น */
@media (max-width: 620px) {
  .navbar { padding: 9px 13px; gap: 9px; }
  .nav-pill { display: none; }
  .nav-sub { display: none; }
  .nav-icon { width: 36px; height: 36px; flex: 0 0 36px; font-size: 16px; border-radius: 11px; }
  .nav-burger { width: 36px; height: 36px; font-size: 17px; }
  .nav-title { font-size: 15px; }
  /* เมนูโปรไฟล์กางเต็มความกว้างจอ ไม่ล้นขอบ */
  .nav-prof-pop { right: 10px; left: 10px; top: 56px; min-width: 0; }
}

/* ระดับ 4 (≤380px) — จอเล็กมาก ย่อชื่อหน้าลงอีกขั้น (ยังอ่านออก ไม่ตัดบรรทัด) */
@media (max-width: 380px) {
  .navbar { padding: 8px 11px; gap: 8px; }
  .nav-title { font-size: 14px; }
  .nav-icon { width: 32px; height: 32px; flex: 0 0 32px; font-size: 15px; }
}

@media (max-width: 768px) {
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dt { padding-bottom: 0; border-bottom: 0; }
  dl.kv dd { padding-top: 2px; }
  .cal-cell { min-height: 62px; padding: 3px; border-radius: 8px; }
  .cal-ev { font-size: 9.5px; padding: 2px 3px; }
  .cal-ev-time { display: none; }
  .cal-grid { gap: 3px; }
  .cal-add { display: none !important; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--ink-muted); font-size: 10px; border: 0; background: transparent;
    padding: 5px 2px; position: relative; text-decoration: none; font-family: inherit; cursor: pointer;
    min-height: 46px; justify-content: center;
  }
  .bn-item i { font-size: 19px; }
  .bn-item.active { color: var(--brand-1); }
  .bn-item.active::before {
    content: ''; position: absolute; top: -6px; width: 28px; height: 3px;
    border-radius: 0 0 4px 4px; background: var(--brand-grad);
  }
  .page-wrap { padding-bottom: 86px; }
  .hero { padding: 18px; border-radius: 18px; }
  .hero-title { font-size: 19px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { padding: 10px; }
  .toolbar .select { flex: 1 1 130px; }
  .modal-card { max-width: 100%; border-radius: 20px 20px 0 0; margin-top: auto; max-height: 92vh; }
  #modal-host { align-items: flex-end; padding: 0; }
  .table-wrap { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .mobile-cards { display: none; }
}

/* ═══ พิมพ์ ═══ */
@media print {
  @page { size: A4 portrait; margin: 12mm 10mm 14mm; }
  .sidebar, .navbar, .app-footer, .bottom-nav, .toolbar, .pagination,
  .no-print, .flash-host, #modal-host, #spin-host, .sb-backdrop { display: none !important; }
  body { background: #fff !important; }
  .shell { display: block !important; }
  .page-wrap { padding: 0 !important; max-width: 100% !important; }
  .panel, .card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  .hero { background: var(--brand-1) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { display: block !important; overflow: visible !important; }
  .mobile-cards { display: none !important; }
  .data-table { min-width: 0 !important; font-size: 11px; }
  .data-table thead { display: table-header-group; }
  .data-table tr { break-inside: avoid; }
  a[href]::after { content: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
