* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  background: #f4f5f7;
  color: #1f2937;
  overflow-x: auto; /* จอเล็กจะเลื่อน/ซูมดูเหมือนเปิดเว็บบนคอมพิวเตอร์ แทนที่จะบีบ layout ใหม่ */
}
a { color: inherit; }

/* ---------- Layout: sidebar ซ้าย + เนื้อหาขวา (บังคับเหมือนกันทุกขนาดจอ) ---------- */
.app-shell { display: flex; align-items: flex-start; min-width: 1100px; min-height: 100vh; }

#sidebar {
  flex: 0 0 230px;
  width: 230px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  background: #0f4c5c;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
#sidebar:empty { display: none; }

.sidebar-brand { font-weight: 700; font-size: 18px; line-height: 1.3; margin-bottom: 18px; }
.sidebar-userbox { font-size: 13px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.2); border-bottom: 1px solid rgba(255,255,255,0.2); margin-bottom: 14px; }
.sidebar-userbox .name { display: block; margin-bottom: 8px; }
#sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#sidebar nav a {
  color: #e5f1f3;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
}
#sidebar nav a.active, #sidebar nav a:hover { background: rgba(255,255,255,0.15); }
#sidebar button.logout {
  background: transparent; border: 1px solid rgba(255,255,255,0.5); color: #fff;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; width: 100%; margin-top: 14px;
}

#app { flex: 1; min-width: 0; }

.container { flex: 1; max-width: 1100px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 18px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; color: #0f4c5c; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #e5e7eb; }
th { color: #6b7280; font-weight: 600; font-size: 13px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f9fafb; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.s1 { background: #dbeafe; color: #1e40af; }
.badge.s2 { background: #d1fae5; color: #065f46; }
.badge.s3 { background: #fef3c7; color: #92400e; }
.badge.s4 { background: #e5e7eb; color: #374151; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: #374151; }
input[type=text], input[type=password], input[type=date], input[type=time], textarea, select {
  width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
  font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; font-weight: 400; }
.checkbox-row input { width: auto; }

.btn {
  display: inline-block; padding: 9px 18px; border-radius: 6px; border: none;
  background: #0f4c5c; color: #fff; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn.secondary { background: #e5e7eb; color: #1f2937; }
.btn.danger { background: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }

.error-msg { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.hint { font-size: 12px; color: #6b7280; margin-top: 4px; }

.staff-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.autocomplete { position: relative; }
.staff-row .autocomplete { flex: 1; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff;
  border: 1px solid #d1d5db; border-radius: 6px; max-height: 180px; overflow-y: auto;
  z-index: 20; box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.autocomplete-list div { padding: 8px 10px; cursor: pointer; font-size: 14px; }
.autocomplete-list div:hover { background: #f3f4f6; }

.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { width: 340px; }

.section-box { border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; margin-top: 10px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; font-size: 14px; }
.detail-grid .k { color: #6b7280; }
.tag-list span { display: inline-block; background: #f3f4f6; padding: 3px 10px; border-radius: 999px; font-size: 12px; margin: 2px 4px 2px 0; }
