:root {
  /* ---- Design Tokens: Modern SaaS & Enterprise UI (โทนฟ้าสุขุม, หลัก 60-30-10) ---- */
  --bg: #F4F6F9;              /* MaterialPro-like app canvas */
  --surface-solid: #FFFFFF;   /* การ์ด/โมดัล/คอนเทนเนอร์ */
  --surface: #FFFFFF;
  --border-soft: #E2E8F0;     /* Slate-200 */

  --text: #0F172A;            /* Slate-900 — หัวข้อ/ชื่อเรื่อง */
  --text-body: #334155;       /* Slate-700 — เนื้อหาทั่วไป */
  --text-muted: #64748B;      /* Slate-500 — ข้อความรอง/คำอธิบาย */

  --primary: #1e88e5;
  --primary-hover: #1a97f5;
  --primary-active: #1565c0;
  --primary-disabled-bg: #CBD5E1;   /* Slate-300 */
  --primary-disabled-text: #94A3B8; /* Slate-400 */

  --secondary-bg: #E6F4FF;
  --secondary-border: #BFE8FF;
  --secondary-text: #1e88e5;
  --secondary-bg-hover: #DDF8FB;
  --secondary-text-hover: #03aebc;

  --link: #1D4ED8;            /* Blue-700 */
  --link-hover: #1E40AF;      /* Blue-800 */
  --link-visited: #4338CA;    /* Indigo-700 */

  --accent: #03c9d7;
  --success: #2cd07e;
  --danger: #fc4b6c;
  --warning: #fec90f;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 16px 36px 0 rgba(34, 48, 74, 0.14);
  --gradient: linear-gradient(135deg, #03c9d7 0%, #1e88e5 100%);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Prompt', 'Sarabun', 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top right, rgba(3, 201, 215, 0.10), transparent 28rem),
    var(--bg);
  color: var(--text-body);
}
h1, h2, h3, h4, h5, h6 { color: var(--text); }

/* ---- ลิงก์ทั่วไป ---- */
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
a:visited { color: var(--link-visited); }

/* ---- Surface การ์ด/โมดัล — ขาวล้วน ขอบนุ่มนวล เงาบาง (ไม่ใช้ blur/โปร่งแสงแบบเดิม) ---- */
.glass {
  background: var(--surface-solid);
  border: 1px solid rgba(112,129,149,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---- ปุ่ม ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); padding: 11px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.97); }

/* Primary */
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-primary:disabled, .btn-primary[disabled] {
  background: var(--primary-disabled-bg); color: var(--primary-disabled-text); cursor: not-allowed;
}

/* Secondary / Ghost */
.btn-outline { background: var(--secondary-bg); border: 1.5px solid var(--secondary-border); color: var(--secondary-text); }
.btn-outline:hover { background: var(--secondary-bg-hover); color: var(--secondary-text-hover); border-color: var(--secondary-border); }
.btn-outline:disabled, .btn-outline[disabled] {
  background: var(--primary-disabled-bg); border-color: var(--primary-disabled-bg); color: var(--primary-disabled-text); cursor: not-allowed;
}
.btn-block { width: 100%; }

/* ---- ฟอร์ม ---- */
.field { margin-bottom: 16px; text-align: left; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border-soft); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text-body);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* ---- Selection controls (Radio/Checkbox) — เล็กลงเหลือ ~2/3 ของขนาด browser default ดูเป็นมืออาชีพขึ้น ---- */
input[type="radio"], input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; flex-shrink: 0; accent-color: var(--primary); cursor: pointer;
}
label:has(> input[type="radio"]), label:has(> input[type="checkbox"]) { gap: 6px !important; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; text-align: left; }
.alert-error { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: var(--accent); border: 1px solid #BBF7D0; }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }

/* ---- Login page (คงโทนฟ้าเข้มไว้เฉพาะพื้นหลังตกแต่ง ไม่ใช่พื้นผิว UI หลัก) ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 50%, #3B82F6 100%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-bg-shapes { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.login-shape { position: absolute; background: #fff; opacity: .12; }
.shape-circle { border-radius: 50%; }
.shape-hexagon { clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 380px; padding: 40px 32px; text-align: center; }
.login-logo {
  width: 72px; height: 72px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
  color: #fff; font-size: 30px; font-weight: 700;
}
.login-title { font-size: 19px; font-weight: 700; margin: 0 0 2px; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 26px; }
.login-footer { font-size: 12px; color: var(--text-muted); margin-top: 22px; }

/* ---- App shell / MaterialPro sidebar ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 292px;
  background: #fff;
  color: var(--text);
  flex-shrink: 0;
  padding: 22px 18px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1000;
  border-right: 0;
  box-shadow: 12px 0 34px rgba(34,48,74,.08);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 18px;
  margin-bottom: 4px;
  padding: 0 0 16px;
  border-radius: var(--radius);
  background: #fff;
  border: 0;
}
.sidebar-profile-cover {
  position: relative;
  min-height: 148px;
  margin: -22px -18px 18px;
  padding: 18px 14px 12px;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(180deg, rgba(30,136,229,.20) 0%, rgba(3,201,215,.15) 42%, rgba(34,48,74,.55) 100%),
    var(--sidebar-cover-image, linear-gradient(135deg, #bfe8ff 0%, #d8f8df 42%, #1e88e5 100%));
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  overflow: hidden;
}
.sidebar-profile-cover:before,
.sidebar-profile-cover:after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.sidebar-profile-cover:before {
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,255,255,.72) 0 16px, transparent 17px),
    linear-gradient(140deg, transparent 0 38%, rgba(21,101,192,.55) 39% 48%, transparent 49%),
    linear-gradient(35deg, transparent 0 55%, rgba(255,255,255,.25) 56% 59%, transparent 60%);
  opacity: .75;
}
.sidebar-profile-cover:after {
  left: -18px;
  right: -18px;
  bottom: 0;
  height: 54px;
  background:
    linear-gradient(145deg, transparent 0 15%, rgba(22,101,52,.70) 16% 39%, transparent 40%),
    linear-gradient(35deg, transparent 0 38%, rgba(20,83,45,.80) 39% 64%, transparent 65%),
    linear-gradient(0deg, rgba(20,83,45,.88), rgba(20,83,45,.88));
}
.sidebar-profile-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none !important;
}
.sidebar-profile-inner:hover {
  color: #fff;
  text-decoration: none !important;
}
.sidebar-profile-avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  border: 4px solid rgba(255,255,255,.86);
  box-shadow: 0 10px 24px rgba(15,23,42,.22);
  color: var(--primary);
  flex: 0 0 auto;
}
.sidebar-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-profile-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.42);
}
.sidebar-profile-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255,255,255,.94);
  text-shadow: 0 2px 8px rgba(0,0,0,.34);
}
.sidebar-brand .logo-circle {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--primary);
  box-shadow: 0 10px 26px rgba(10,66,120,.12);
  border: 1px solid rgba(226,232,240,.8);
}
.sidebar-cat {
  font-size: 11px;
  letter-spacing: 0;
  color: #3f3f46;
  text-transform: uppercase;
  margin: 18px 8px 7px;
  font-weight: 800;
}
.sidebar-item, .sidebar-item:visited {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 999px;
  color: #3f3f46;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 5px;
  transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.sidebar-item:hover, .sidebar-item:visited:hover {
  background: #e5fbfd;
  color: #03aebc;
  text-decoration: none;
  transform: translateX(3px);
  box-shadow: 0 12px 26px rgba(9,67,120,.18);
}
.sidebar-item.active, .sidebar-item.active:visited {
  background: #45c8ce;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 14px 28px rgba(3,201,215,.24);
}
.sidebar-item.sidebar-item-emphasis,
.sidebar-item.sidebar-item-emphasis:visited {
  color: #1e88e5;
}
.sidebar-item.sidebar-item-emphasis:hover {
  background: #dff8fb;
  color: #03aebc;
}
.sidebar-item.sidebar-item-emphasis.active,
.sidebar-item.sidebar-item-emphasis.active:visited {
  background: #45c8ce;
  color: #fff;
}
.sidebar-item.sidebar-item-dashboard,
.sidebar-item.sidebar-item-dashboard:visited {
  color: #45c8ce;
}
.sidebar-item.sidebar-item-dashboard.active,
.sidebar-item.sidebar-item-dashboard.active:visited {
  background: #45c8ce;
  color: #fff;
  box-shadow: 0 14px 28px rgba(69,200,206,.26);
}
.sidebar-item.sidebar-item-dashboard.active .sidebar-item-icon {
  color: #fff;
  background: rgba(255,255,255,.20);
}
.sidebar-item.sidebar-item-dashboard.active .sidebar-item-icon .material-icons {
  color: #fff;
}
.sidebar-item-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #edf7ff;
  color: #1e88e5;
  flex: 0 0 auto;
}
.sidebar-item-icon .material-icons {
  color: inherit;
  font-size: 19px;
  line-height: 1;
}
.sidebar-item.active .sidebar-item-icon,
.sidebar-item:hover .sidebar-item-icon {
  color: #03c9d7;
  background: #fff;
}
.main-content { flex: 1; margin-left: 292px; padding: 24px 28px; background: transparent; }
.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px 18px;
  align-items: center;
  padding: 18px 22px 12px;
  margin: -24px -28px 24px;
  background: linear-gradient(90deg, #1e88e5 0%, #1a97f5 100%) !important;
  color: #fff;
  border: 0 !important;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 10px 28px rgba(30,136,229,.18);
}
.topbar h2 { color: #fff; }
.topbar-user { color: rgba(255,255,255,.82) !important; }
.topbar .btn-outline,
.topbar .btn-outline:visited {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.30);
  color: #fff;
}
.topbar .btn-outline:hover {
  background: #fff;
  border-color: #fff;
  color: var(--primary);
  text-decoration: none;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  grid-column: 1 / 3;
}
.topbar-school-logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(10,66,120,.22);
  overflow: hidden;
  flex: 0 0 auto;
}
.topbar-school-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.topbar-title {
  min-width: 0;
}
.topbar-title strong {
  display: block;
  color: #fff;
  font-size: 22px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title span {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,.82);
  font-size: 13px;
  font-weight: 500;
}
.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 3;
  justify-self: end;
}
.topbar-alert {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  color: #fff !important;
  text-decoration: none !important;
  transition: background .16s ease, transform .16s ease;
}
.topbar-alert:hover {
  background: rgba(255,255,255,.16);
  transform: translateY(-1px);
}
.topbar-alert .material-icons {
  color: #fff;
  font-size: 25px;
}
.topbar-alert-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fec90f;
  color: #17233c;
  border: 2px solid #1a97f5;
  font-size: 11px;
  font-weight: 900;
}
.notification-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 58px;
  z-index: 1300;
  display: none;
  width: 330px;
  padding: 12px;
  background: #fff;
  border: 1px solid rgba(112,129,149,.12);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(34,48,74,.20);
}
.notification-dropdown.open {
  display: block;
}
.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 12px;
}
.notification-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}
.notification-head span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}
.notification-total {
  min-width: 34px;
  height: 34px;
  display: grid !important;
  place-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #fff7db;
  color: #8a6100 !important;
  font-size: 13px !important;
  font-weight: 900;
}
.notification-item,
.notification-item:visited {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 14px;
  color: #42526a;
  text-decoration: none;
}
.notification-item:hover {
  background: #f8fafc;
  color: var(--primary);
  text-decoration: none;
}
.notification-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
}
.notification-icon .material-icons {
  font-size: 22px;
}
.notification-icon.leave {
  background: #ffedf1;
  color: #fc4b6c;
}
.notification-icon.travel {
  background: #e6f4ff;
  color: #1e88e5;
}
.notification-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.notification-item small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}
.notification-count {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #edf7ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}
.notification-empty {
  margin: 6px 4px 2px;
  padding: 14px 10px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}
.topbar-search {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 17px;
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 999px;
  background: rgba(255,255,255,.17);
  color: #fff;
}
.topbar-search .material-icons {
  color: rgba(255,255,255,.92);
}
.topbar-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 15px;
}
.topbar-search input::placeholder {
  color: rgba(255,255,255,.82);
  opacity: 1;
}
.profile-menu-wrap {
  position: relative;
}
.profile-trigger {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 3px solid rgba(255,255,255,.55);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.22);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(10,66,120,.22);
}
.profile-trigger img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.profile-trigger .material-icons {
  color: #fff;
  font-size: 28px;
}
.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1300;
  display: none;
  width: 270px;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(112,129,149,.12);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(34,48,74,.20);
}
.profile-dropdown.open {
  display: block;
}
.profile-dropdown-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 6px;
}
.profile-dropdown-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6f4ff;
  color: var(--primary);
  flex: 0 0 auto;
}
.profile-dropdown-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-dropdown-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}
.profile-dropdown-role {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}
.profile-dropdown a,
.profile-dropdown a:visited {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border-radius: 12px;
  color: #42526a;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}
.profile-dropdown a:hover {
  background: #e6f4ff;
  color: var(--primary);
  text-decoration: none;
}
.profile-dropdown a .material-icons {
  color: var(--primary);
  font-size: 20px;
}
.profile-dropdown .logout-link {
  margin-top: 6px;
  color: #fc4b6c;
}
.profile-dropdown .logout-link .material-icons {
  color: #fc4b6c;
}
.menu-toggle { display: none; background: rgba(255,255,255,.16); border: 0; border-radius: 12px; cursor: pointer; padding: 8px; color: #fff; }
.menu-toggle .material-icons { font-size: 26px; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 0 0 20px; }
  .topbar {
    margin: 0 0 20px;
    border-radius: 0 0 18px 18px;
    padding: 18px 22px 12px;
    grid-template-columns: auto minmax(0,1fr) auto;
  }
  .menu-toggle { display: inline-flex; }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 998;
  }
  .topbar-user { display: none; }
  div[style*="display:flex"] > div.glass { flex: 1 1 100% !important; min-width: 0 !important; }
  .btn { min-height: 44px; font-size: 15px !important; padding: 12px 18px !important; }
  .field input, .field select, .field textarea { min-height: 44px; font-size: 16px; }
  table thead th, table tbody td { font-size: 14px !important; padding: 10px 10px !important; }
  h3 { font-size: 17px; }
  .glass { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 760px) {
  .topbar-title strong {
    font-size: 18px;
  }
  .topbar-title span {
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: auto minmax(0,1fr) auto;
    gap: 14px 12px;
    padding: 18px 20px 12px;
  }
  .topbar-brand {
    grid-column: 1 / 3;
  }
  .topbar-actions {
    grid-column: 3;
  }
  .topbar-brand {
    gap: 10px;
  }
  .topbar-school-logo {
    width: 46px;
    height: 46px;
  }
  .topbar-title strong {
    font-size: 17px;
  }
  .topbar-title span {
    font-size: 12px;
  }
  .topbar-actions {
    gap: 8px;
  }
  .topbar-alert {
    width: 40px;
    height: 40px;
  }
  .profile-trigger {
    width: 44px;
    height: 44px;
  }
  .profile-dropdown {
    right: -2px;
    width: min(270px, calc(100vw - 28px));
  }
  .notification-dropdown {
    right: 0;
    width: min(330px, calc(100vw - 28px));
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 12px 8px;
    padding: 16px 14px 10px;
  }
  .topbar-brand {
    gap: 8px;
  }
  .topbar-title strong {
    font-size: 15px;
    max-width: calc(100vw - 178px);
  }
  .topbar-title span {
    font-size: 10.5px;
  }
  .topbar-school-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .topbar-school-logo img {
    width: 34px;
    height: 34px;
  }
  .topbar-alert {
    width: 36px;
    height: 36px;
  }
  .profile-trigger {
    width: 40px;
    height: 40px;
  }
  .topbar-search {
    min-height: 44px;
    padding: 0 14px;
  }
}

/* ---- Data tables ---- */
table { border-collapse: collapse; width: 100%; }
table thead tr { background: #F4F8FB; }
table thead th { color: var(--text); text-align: left; padding: 12px 14px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
table tbody td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border-soft); color: var(--text-body); vertical-align: middle; }
table tbody tr:nth-child(even) { background: #FAFBFC; }
table tbody tr:hover { background: var(--secondary-bg); }
.main-content > .glass,
.main-content section.glass,
.main-content div.glass {
  max-width: 100%;
}
.main-content .glass:has(table),
.main-content div[style*="overflow-x:auto"],
.main-content div[style*="overflow-x: auto"] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.main-content .glass table {
  min-width: 720px;
}
.main-content form.glass {
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* ---- Bottom icon nav (มือถือ) — MaterialPro theme: white surface + cyan active pill ---- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    gap: 6px;
    background: rgba(255,255,255,.96);
    border: 0;
    border-top: 1px solid rgba(226,232,240,.92);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -2px 28px rgba(15,23,42,.13);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .bottom-nav a, .bottom-nav a:visited {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 8px 4px; margin: 0; border-radius: 16px;
    text-decoration: none; color: var(--text-muted); font-size: 11px; font-weight: 700;
    min-height: 56px;
    transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
  }
  .bottom-nav a .material-icons {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #EFF6FF;
    color: #1e88e5;
    font-size: 20px;
    transition: background .16s ease, color .16s ease, transform .16s ease;
  }
  .bottom-nav a:hover {
    color: #1e88e5;
    background: #F8FAFC;
    text-decoration: none;
  }
  .bottom-nav a:active { transform: scale(.96); }
  .bottom-nav a.active {
    background: linear-gradient(135deg, #03c9d7 0%, #1e88e5 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(30,136,229,.22);
  }
  .bottom-nav a.active .material-icons {
    background: rgba(255,255,255,.22);
    color: #fff;
    transform: translateY(-2px);
  }
  .main-content { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
}

/* ---- Mobile-first responsive refinements for legacy PHP pages ---- */
@media (max-width: 768px) {
  html { scroll-padding-top: 10px; }
  body { background: #f4f6f9; }

  .main-content {
    overflow-x: hidden;
  }

  .main-content > .glass,
  .main-content section.glass,
  .main-content div.glass,
  form.glass {
    border-radius: 16px;
  }

  .main-content .glass,
  .main-content section,
  .main-content form {
    max-width: 100%;
  }

  h1 { font-size: 24px; line-height: 1.25; }
  h2 { font-size: 21px; line-height: 1.28; }
  h3 { font-size: 18px; line-height: 1.32; }

  .field {
    margin-bottom: 14px;
  }

  .field label {
    font-size: 12.5px;
    margin-bottom: 7px;
  }

  .field input,
  .field select,
  .field textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    max-width: 100%;
    min-height: 46px;
    border-radius: 12px;
    font-size: 16px;
  }

  .btn,
  button.btn,
  a.btn {
    min-height: 44px;
    border-radius: 12px;
    white-space: normal;
    line-height: 1.25;
  }

  .btn-small,
  .btn.btn-small {
    min-height: 38px;
    padding: 8px 12px !important;
    border-radius: 999px;
    font-size: 13px !important;
  }

  .main-content [style*="display:flex"],
  .main-content [style*="display: flex"] {
    min-width: 0;
  }

  .main-content [style*="display:flex"] > *,
  .main-content [style*="display: flex"] > * {
    min-width: 0;
  }

  .main-content [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .main-content table.mobile-card-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  .main-content table.mobile-card-table thead {
    display: none;
  }

  .main-content table.mobile-card-table,
  .main-content table.mobile-card-table tbody,
  .main-content table.mobile-card-table tr,
  .main-content table.mobile-card-table td {
    display: block;
    width: 100%;
  }

  .main-content table.mobile-card-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15,23,42,.06);
  }

  .main-content table.mobile-card-table tbody tr:nth-child(even),
  .main-content table.mobile-card-table tbody tr:hover {
    background: #fff;
  }

  .main-content table.mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 0 !important;
    border-bottom: 1px solid #eef2f6;
    font-size: 14px !important;
    word-break: break-word;
  }

  .main-content table.mobile-card-table td:last-child {
    border-bottom: 0;
    padding-bottom: 0 !important;
  }

  .main-content table.mobile-card-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
  }

  .main-content table.mobile-card-table td[data-label=""],
  .main-content table.mobile-card-table td:not([data-label]) {
    display: block;
  }

  .main-content table.mobile-card-table td[data-label=""]::before,
  .main-content table.mobile-card-table td:not([data-label])::before {
    display: none;
  }

  .main-content table.mobile-card-table td .btn,
  .main-content table.mobile-card-table td button,
  .main-content table.mobile-card-table td a.btn {
    width: 100%;
    margin: 3px 0;
  }

  .main-content .mobile-scroll-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-content .mobile-scroll-table table {
    min-width: 680px;
  }
}

@media (max-width: 420px) {
  .main-content table.mobile-card-table td {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .main-content table.mobile-card-table td::before {
    font-size: 11.5px;
  }
}
