:root {
  --primary: #3b6ef5;
  --primary-dark: #2a55d4;
  --primary-soft: rgba(59, 110, 245, 0.1);
  --accent: #ea580c;
  --accent-dark: #c2410c;
  --accent-soft: rgba(234, 88, 12, 0.2);
  --accent-wash: #fff7ed;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --sidebar-w: 260px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 56px;
  height: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.brand small {
  color: var(--text-muted);
  font-size: 12px;
}

.side-nav {
  padding: 16px 12px;
  overflow: auto;
}

.side-nav .nav-label {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 8px 12px;
  margin-top: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.side-nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.side-nav a.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(59, 110, 245, .28);
}

.nav-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 4px;
}

.nav-group-btn span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-group-btn:hover,
.nav-group-btn.open {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(59, 110, 245, .28);
}

.nav-group-btn .nav-caret {
  transition: transform .2s ease;
  font-size: 12px;
}

.nav-group-btn.open .nav-caret {
  transform: rotate(180deg);
}

.nav-sub {
  display: none;
  padding: 4px 0 8px 12px;
}

.nav-sub.open {
  display: block;
}

.nav-sub a {
  padding: 9px 14px;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.nav-sub a.active {
  background: #dbeafe;
  color: var(--primary-dark);
  box-shadow: none;
  font-weight: 700;
}

.nav-soon {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.nav-sub a.active .nav-soon {
  background: #fff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.coming-soon-panel {
  min-height: 360px;
  display: grid;
  place-items: center;
}

.coming-soon {
  text-align: center;
  max-width: 420px;
  padding: 24px;
}

.coming-soon i {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 14px;
}

.coming-soon h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.coming-soon p {
  margin: 0 0 20px;
  color: var(--text-muted);
  line-height: 1.6;
}

.onet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.onet-tabs a {
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
}

.onet-tabs a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.onet-tabs a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.onet-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.onet-class-switch {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.onet-class-switch a {
  padding: 9px 16px;
  font-weight: 700;
  color: var(--text-muted);
}

.onet-class-switch a.active {
  background: var(--primary);
  color: #fff;
}

.onet-table td,
.onet-table th {
  text-align: center;
}

.onet-table .col-name {
  text-align: left !important;
}

.delta-up {
  display: inline-block;
  margin-left: 4px;
  color: #16a34a;
  font-size: 12px;
  font-weight: 700;
}

.delta-down {
  display: inline-block;
  margin-left: 4px;
  color: #e11d48;
  font-size: 12px;
  font-weight: 700;
}

.delta-flat {
  display: inline-block;
  margin-left: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.onet-note {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.onet-report-banner {
  background: linear-gradient(180deg, #fff9e6 0%, #fff3cc 100%);
  border: 1px solid #f0d78c;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.65;
  color: #5c4a1f;
}

.onet-report-panel {
  padding: 0 !important;
  overflow: hidden;
  margin-bottom: 20px;
}

.onet-stat-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.onet-stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}

.onet-stat-table caption {
  caption-side: top;
  text-align: left;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
}

.onet-stat-table th,
.onet-stat-table td {
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
}

.onet-stat-table .onet-stat-subject {
  text-align: left;
  min-width: 150px;
  font-weight: 700;
}

.onet-stat-obec .onet-stat-head-main th {
  background: #c45c26;
  color: #fff;
  font-weight: 700;
}

.onet-stat-obec .onet-stat-head-sub th {
  background: #d97706;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.onet-stat-obec tbody th.onet-stat-subject {
  background: #f4a460;
  color: #fff;
}

.onet-stat-obec tbody td {
  background: #fff7ed;
  color: #1e293b;
}

.onet-stat-obec tbody tr:nth-child(even) td {
  background: #ffedd5;
}

.onet-stat-obec tbody tr.onet-stat-avg-row td,
.onet-stat-obec tbody tr.onet-stat-avg-row th.onet-stat-subject {
  background: #fdba74;
  font-weight: 700;
}

.onet-stat-nation .onet-stat-head-main th {
  background: #166534;
  color: #fff;
  font-weight: 700;
}

.onet-stat-nation .onet-stat-head-sub th {
  background: #15803d;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.onet-stat-nation tbody th.onet-stat-subject {
  background: #4ade80;
  color: #14532d;
}

.onet-stat-nation tbody td {
  background: #f0fdf4;
  color: #1e293b;
}

.onet-stat-nation tbody tr:nth-child(even) td {
  background: #dcfce7;
}

.onet-stat-nation tbody tr.onet-stat-avg-row td,
.onet-stat-nation tbody tr.onet-stat-avg-row th.onet-stat-subject {
  background: #86efac;
  font-weight: 700;
}

.address-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 72vh;
}

table.address-table {
  min-width: 1400px;
  font-size: 12.5px;
}

table.address-table th,
table.address-table td {
  white-space: nowrap;
  padding: 8px 10px;
  vertical-align: middle;
}

table.address-table .col-name {
  white-space: normal;
  min-width: 160px;
  max-width: 220px;
}

table.address-table a {
  color: var(--primary);
  word-break: break-all;
}

table.address-table a:hover {
  text-decoration: underline;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.legend-item i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.legend-item.dist-10 i { background: #22c55e; }
.legend-item.dist-30 i { background: #3b82f6; }
.legend-item.dist-50 i { background: #f59e0b; }
.legend-item.dist-50p i { background: #ef4444; }

.map-filter-panel { margin-bottom: 16px; }

.map-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.map-filter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.map-filter-row label,
.map-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.map-filter-row select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  min-width: 220px;
}

.school-map {
  height: 420px;
  width: 100%;
  background: #e2e8f0;
}

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

.dist-badge.dist-10 { background: #dcfce7; color: #166534; }
.dist-badge.dist-30 { background: #dbeafe; color: #1d4ed8; }
.dist-badge.dist-50 { background: #fef3c7; color: #b45309; }
.dist-badge.dist-50p { background: #fee2e2; color: #b91c1c; }
.dist-badge.dist-na { background: #f1f5f9; color: #64748b; }

table.network-table a {
  color: var(--primary);
  word-break: break-all;
}

table.network-table a:hover {
  text-decoration: underline;
}

table.network-table .col-web,
table.network-table .col-email {
  max-width: 220px;
}

.grade-summary-table tr.subtotal td {
  background: #f8fafc;
  font-weight: 700;
}

.grade-summary-table tr.grandtotal td {
  background: #eff6ff;
  font-weight: 800;
}

.context-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.context-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.context-tabs a.active,
.context-tabs a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.registry-table-wrap {
  overflow-x: auto;
}

table.registry-table {
  min-width: 1800px;
  font-size: 12px;
}

table.registry-table th,
table.registry-table td {
  white-space: nowrap;
}

table.registry-table .col-name {
  white-space: normal;
  min-width: 160px;
}

.level-table-wrap {
  overflow-x: auto;
}

table.level-table {
  min-width: 2600px;
  font-size: 12px;
}

table.level-table th,
table.level-table td {
  white-space: nowrap;
  text-align: center;
}

table.level-table .col-name {
  text-align: left;
  white-space: normal;
  min-width: 160px;
}

table.level-table thead tr:first-child th {
  vertical-align: middle;
  background: #f8fafc;
}

table.level-table thead tr:nth-child(2) th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.stats-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.text-danger { color: #e11d48; font-weight: 700; }
.text-success { color: #16a34a; font-weight: 700; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
}

.btn-login {
  background: var(--primary);
  color: #fff !important;
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 40px;
  height: auto;
  display: block;
  object-fit: contain;
}

.visitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.visitor-badge i {
  color: var(--primary);
}

.visitor-badge strong {
  color: var(--primary-dark);
  font-size: 15px;
}

.content {
  padding: 24px;
}

.bread-card,
.panel,
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.bread-card {
  padding: 18px 22px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.bread-card h2 {
  margin: 0;
  color: var(--primary);
  font-size: 22px;
  font-weight: 800;
}

.bread-card p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.year-select {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-select select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: inherit;
  min-width: 140px;
  background: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, .1);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  opacity: .12;
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-card .hint {
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.stat-card.total .value { color: var(--cyan); }
.stat-card.total::after { background: var(--cyan); }
.stat-card.small .value { color: var(--success); }
.stat-card.small::after { background: var(--success); }
.stat-card.medium .value { color: var(--warning); }
.stat-card.medium::after { background: var(--warning); }
.stat-card.large .value { color: var(--danger); }
.stat-card.large::after { background: var(--danger); }
.stat-card.xlarge .value { color: var(--purple); }
.stat-card.xlarge::after { background: var(--purple); }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.panel {
  padding: 20px;
}

.panel h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
}

/* หน้าแสดงข้อมูล 3 ฟีเจอร์ใหม่ — เน้นโทนส้ม 20% */
.page-accent-orange .bread-card {
  background: linear-gradient(135deg, var(--accent-soft) 0%, #fff 62%);
  border-left: 4px solid var(--accent);
}

.page-accent-orange .bread-card h2 {
  color: var(--accent-dark);
}

.page-accent-orange .panel {
  border-top: 3px solid rgba(234, 88, 12, 0.45);
}

.page-accent-orange .quality-title {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
}

.page-accent-orange .quality-subtitle {
  margin: -4px 0 14px;
  color: #9a3412;
  font-size: 14px;
}

.page-accent-orange table.data-table thead th {
  background: var(--accent-soft) !important;
  color: #9a3412 !important;
  border-color: rgba(234, 88, 12, 0.35) !important;
  text-align: center;
  font-weight: 700;
  line-height: 1.25;
}

.page-accent-orange table.data-table tbody tr:nth-child(even) {
  background: rgba(234, 88, 12, 0.06);
}

.page-accent-orange table.data-table tbody tr:hover td {
  background: rgba(234, 88, 12, 0.1);
}

.chart-wrap {
  position: relative;
  height: 320px;
  min-height: 280px;
  width: 100%;
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-wrap.tall {
  height: 380px;
  min-height: 320px;
}

.chart-wrap-md {
  height: 260px;
  min-height: 220px;
}

/* ── Home dashboard ── */
.home-dash .home-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #fff 55%, #f8fafc 100%);
}

.stats-grid-kpi {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card.kpi-rooms .value { color: var(--warning); }
.stat-card.kpi-rooms::after { background: var(--warning); }
.stat-card.kpi-students .value { color: var(--primary); }
.stat-card.kpi-students::after { background: var(--primary); }
.stat-card.kpi-lower .value { color: var(--purple); }
.stat-card.kpi-lower::after { background: var(--purple); }

.pct-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.panel-sub {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.home-charts-top .size-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.size-split {
  display: grid;
  grid-template-columns: minmax(148px, 188px) minmax(0, 1fr);
  gap: 20px 24px;
  align-items: center;
  flex: 1;
}

.size-donut-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

.size-donut {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}

.size-donut-hole {
  position: absolute;
  inset: 26%;
  background: #fff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.size-donut-hole strong {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.size-donut-hole span {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}

.size-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.size-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.size-list-item:hover {
  background: #fff;
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.size-list-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.size-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 5px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.size-list-head strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.size-list-head span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.size-bar-track {
  height: 5px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.size-bar-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 3px;
}

.size-list-nums {
  text-align: right;
  white-space: nowrap;
  min-width: 52px;
}

.size-list-nums b {
  display: block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}

.size-list-nums em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 600;
}

.size-list-item.small .size-list-nums b { color: #16a34a; }
.size-list-item.medium .size-list-nums b { color: #d97706; }
.size-list-item.large .size-list-nums b { color: #e11d48; }
.size-list-item.xlarge .size-list-nums b { color: #7c3aed; }

.gender-summary {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.gender-summary .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.gender-summary .dot.male { background: #3b82f6; }
.gender-summary .dot.female { background: #ec4899; }

.gender-summary strong {
  font-weight: 800;
  margin: 0 4px;
}

.gender-summary em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 13px;
}

.staff-ratio-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.staff-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 1px solid var(--border);
}

.staff-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(59, 110, 245, 0.28);
}

.staff-hero-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.staff-hero-value {
  display: block;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary-dark);
  margin: 4px 0;
}

.staff-hero-hint {
  display: block;
  font-size: 12px;
  color: #94a3b8;
}

.ratio-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.ratio-tile {
  padding: 14px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-top: 3px solid var(--tile, var(--primary));
  text-align: center;
  transition: transform .15s ease, box-shadow .15s ease;
}

.ratio-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.ratio-tile-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ratio-tile-value {
  display: block;
  font-size: 24px;
  font-weight: 800;
  color: var(--tile, var(--primary));
  line-height: 1.1;
}

.ratio-tile-hint {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
  line-height: 1.35;
}

.home-school-table-wrap {
  max-height: 70vh;
}

/* ── อาคารและสิ่งปลูกสร้าง (iframe OBEC Asset) ── */
.content.buildings-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100dvh - var(--header-h));
  padding-bottom: 12px;
}

.buildings-note-panel {
  padding: 12px 18px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.buildings-note-panel .budget-note {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.buildings-note-panel a {
  color: var(--primary);
  font-weight: 600;
}

.buildings-embed-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.buildings-frame-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 420px;
  height: calc(100dvh - var(--header-h) - 210px);
}

.buildings-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  border: 0;
  background: #fff;
}

.buildings-page .footer {
  flex-shrink: 0;
  margin: 0;
  padding: 4px 0 8px;
}

.table-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-success { background: #16a34a; color: #fff; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-light {
  background: #f8fafc;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.table-wrap {
  overflow: auto;
  max-height: 70vh;
}

.table-wrap-fit {
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table.table-fit {
  table-layout: fixed;
  width: 100%;
}

table.data-table th,
table.data-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}

table.data-table.table-fit th,
table.data-table.table-fit td {
  white-space: normal;
  word-break: break-word;
  vertical-align: middle;
  padding: 8px 6px;
  font-size: 13px;
}

table.data-table.table-fit thead th {
  line-height: 1.25;
  text-align: center;
}

table.data-table.table-fit thead th small {
  display: block;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

table.data-table.table-fit .col-code {
  width: 10%;
  text-align: center;
  white-space: nowrap;
}

table.data-table.table-fit .col-name {
  width: 28%;
  text-align: left;
}

table.data-table.table-fit .col-num {
  width: 11%;
  text-align: center;
  white-space: nowrap;
}

table.data-table.table-fit .col-action {
  width: 12%;
  text-align: center;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

table.data-table thead th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
}

table.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

table.data-table tbody tr:hover {
  background: #eff6ff;
}

.search-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  min-width: 220px;
  font-family: inherit;
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0 24px;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 35;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal-card {
  width: min(820px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  overflow: hidden;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #eff6ff, #fff);
}

.modal-head h4 {
  margin: 0;
  font-size: 18px;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.modal-body { padding: 18px 20px 22px; }

.modal-close {
  border: 0;
  background: #f1f5f9;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
}

.age-summary-panel {
  margin-bottom: 20px;
}

.age-summary-table {
  max-width: 760px;
}

.age-summary-table tr.grandtotal td {
  background: #eff6ff;
  font-weight: 800;
}

.age-detail-wrap {
  max-height: 72vh;
}

table.age-detail-table {
  min-width: 980px;
  font-size: 13px;
}

table.age-detail-table .col-name {
  min-width: 190px;
  white-space: normal;
}

table.age-detail-table tr.school-total td {
  background: #f8fafc;
  font-weight: 700;
}

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratio-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .staff-ratio-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .overlay.show { display: block; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .size-split {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .size-list { width: 100%; }
  .size-list-item { text-align: left; }
  .ratio-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visitor-badge { padding: 6px 10px; font-size: 12px; }
  .topbar-title { display: none; }
  .buildings-frame-wrap {
    height: calc(100dvh - var(--header-h) - 250px);
    min-height: 360px;
  }
}

@media (max-width: 576px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .search-box { width: 100%; margin-left: 0; }
  .search-box input { width: 100%; min-width: 0; }
  .content.buildings-page {
    padding: 12px;
    gap: 10px;
  }
  .buildings-note-panel {
    padding: 10px 12px;
  }
  .buildings-note-panel .budget-note {
    font-size: 13px;
  }
  .buildings-frame-wrap {
    height: calc(100dvh - var(--header-h) - 270px);
    min-height: 300px;
  }
}
