/* ระบบฐานข้อมูลกลาง อุตสาหกรรมไหมเชิงสร้างสรรค์
   สีครามและสีครั่งอ้างอิงสีย้อมไหมธรรมชาติ  ฟอนต์ Sarabun เป็นคู่ดิจิทัลของ TH Sarabun */

:root {
  --ground: #F6F4EE;
  --surface: #FFFFFF;
  --ink: #1B1A16;
  --muted: #555045;
  --faint: #787265;
  --line: #DBD6CA;
  --line-soft: #ECE8DD;
  --indigo: #1F3864;
  --indigo-deep: #152747;
  --indigo-tint: #E8EEF8;
  --ochre: #8F5A12;
  --ochre-fill: #B4761A;
  --ochre-tint: #F7EEDC;
  --teal: #0F6E56;
  --teal-tint: #E3F2EC;
  --red: #A32D2D;
  --red-tint: #FAEAEA;
  --radius: 10px;
  --card-shadow: 0 4px 18px -2px rgba(31, 56, 100, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Sarabun", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Anuphan", "Sarabun", sans-serif; font-weight: 600; margin: 0; }
h1 { font-size: 25px; line-height: 1.35; color: var(--indigo-deep); }
h2 { font-size: 18.5px; color: var(--indigo); }
h3 { font-size: 16px; }

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

.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1320px; }

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.88em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }

/* ---------------------------------------------------------- ส่วนหัว */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.admin-head { background: var(--indigo-deep); border-bottom: none; }
.head-row {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.head-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.head-title { font-family: "Anuphan", sans-serif; font-weight: 700; font-size: 16.5px; color: var(--indigo-deep); }
.head-sub { font-size: 12.5px; color: var(--muted); }
.admin-head .head-title { color: #FFFFFF; }
.admin-head .head-sub { color: #9FB0CD; }
.head-nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.navlink {
  color: #D7DEEC; text-decoration: none; font-size: 14px;
  padding: 9px 13px; border-radius: 6px; transition: background 0.15s ease;
}
.navlink:hover { background: #27406E; color: #FFFFFF; }
.navlink.is-active { background: #27406E; color: #FFFFFF; font-weight: 500; }
.who { color: #9FB0CD; font-size: 13px; padding-left: 6px; }
.admin-head .btn-ghost { background: transparent; color: #D7DEEC; border-color: #3A5486; }
.admin-head .btn-ghost:hover { background: #27406E; color: #FFFFFF; }

/* Shared navigation: real interactive menu bar with clear brand identity and button states. */
.ui-icon { flex-shrink:0;vertical-align:middle; }
.wrap.wrap-nav { max-width: 1200px; }
.public-head {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  border-top: 3px solid var(--indigo);
  border-bottom: 1px solid #D5CFC2;
  box-shadow: 0 4px 16px -4px rgba(21, 39, 71, 0.08);
}
.public-head .head-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex: 1 1 auto;
}
.public-brand:hover .head-title {
  color: var(--indigo);
}
.public-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo-deep) 0%, var(--indigo) 100%);
  color: #F5D996;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(21, 39, 71, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.public-head .head-id {
  margin-bottom: 0;
  gap: 2px;
  min-width: 0;
}
.public-head .head-title {
  font-size: 15.5px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.public-head .head-sub {
  font-size: 12.5px;
  color: #64748B;
}
.public-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
  gap: 4px;
  background: #F8F7F3;
  border: 1px solid #E2DDD2;
  padding: 5px;
  border-radius: 12px;
}
.public-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #334155;
  font-family: "Anuphan", "Sarabun", sans-serif;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.16s ease;
}
.public-nav-link .ui-icon {
  color: #64748B;
  transition: color 0.16s ease;
}
.public-nav-link:hover {
  background: #FFFFFF;
  color: var(--indigo-deep);
  border-color: #DCD6C8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.public-nav-link:hover .ui-icon {
  color: var(--indigo);
}
.public-nav-link.is-active {
  background: #FFFFFF;
  color: var(--indigo-deep);
  border-color: #C3D2EC;
  box-shadow: 0 2px 6px rgba(31, 56, 100, 0.1), inset 0 -2px 0 var(--indigo);
  font-weight: 700;
}
.public-nav-link.is-active .ui-icon {
  color: var(--indigo);
}
.public-nav-divider {
  width: 1px;
  height: 22px;
  background: #D8D2C5;
  margin: 0 4px;
  flex-shrink: 0;
}
.public-nav .header-login {
  margin-left: 0;
  background: #EEF2F9;
  color: var(--indigo-deep);
  border: 1px solid #C5D3EB;
}
.public-nav .header-login .ui-icon {
  color: var(--indigo);
}
.public-nav .header-login:hover {
  background: var(--indigo);
  color: #FFFFFF;
  border-color: var(--indigo);
}
.public-nav .header-login:hover .ui-icon {
  color: #FFFFFF;
}
.public-nav .header-login.is-active {
  background: var(--indigo);
  color: #FFFFFF;
  border-color: var(--indigo-deep);
  box-shadow: 0 2px 8px rgba(31, 56, 100, 0.25);
}
.public-nav .header-login.is-active .ui-icon {
  color: #FFFFFF;
}
.public-nav-link:focus-visible { outline:2px solid var(--indigo);outline-offset:2px; }
@media (max-width: 960px) {
  .public-head .head-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }
  .public-brand {
    justify-content: center;
    text-align: left;
  }
  .public-nav {
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: center;
  }
}
.admin-head .navlink { display:inline-flex;align-items:center;gap:8px;border-radius:4px; }
.admin-head .navlink.is-active { background:rgba(255,255,255,.09);box-shadow:inset 0 -2px 0 #b9cce9; }
.admin-head .who { display:inline-flex;align-items:center;gap:6px;color:#b8c7df; }
.admin-head .head-sub { font-size:13px;line-height:1.5;color:#b8c7df; }
.admin-head .admin-badge { background:transparent;border:1px solid #50627e;border-radius:3px; }
.admin-head .btn-ghost { border-color:#50627e;box-shadow:none; }

main { padding: 26px 0 60px; }

/* ----------------------------------------------------------- ปุ่ม */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 11px 22px;
  border-radius: 8px; border: 1.5px solid transparent;
  font-family: "Anuphan", "Sarabun", sans-serif; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: all 0.18s ease;
}
.btn-primary {
  background: var(--indigo);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(31, 56, 100, 0.2);
}
.btn-primary:hover {
  background: var(--indigo-deep);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(31, 56, 100, 0.3);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--surface);
  color: var(--indigo);
  border-color: #C2CBDC;
  font-weight: 500;
}
.btn-ghost:hover {
  background: #F4F7FC;
  border-color: var(--indigo);
}
.btn-soft { background: var(--indigo-tint); color: var(--indigo); font-weight: 500; }
.btn-soft:hover { background: #D9E4F5; }
.btn-danger { background: var(--surface); color: var(--red); border-color: #E0B6B6; }
.btn-danger:hover { background: var(--red-tint); }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 13.5px; border-radius: 6px; }
@media (pointer: coarse) { .btn-sm { min-height: 44px; } }
.btn:disabled, .btn[aria-disabled="true"] {
  background: #F0EDE6; color: #8A857B; border-color: var(--line); cursor: not-allowed;
  transform: none; box-shadow: none;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.form-nav-row {
  margin-top: 10px;
  padding-top: 16px;
}

/* ----------------------------------------------------------- กล่องการ์ด */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: var(--card-shadow);
}
.card-tight { padding: 0; overflow: hidden; }
.card-head { padding: 17px 20px 15px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin-bottom: 4px; }

/* หัวข้อส่วนต่างๆ ของการ์ด */
.card-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1.5px solid var(--line-soft);
}
.sec-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Anuphan", sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--indigo-tint);
  color: var(--indigo);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.card-section-head h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--indigo-deep);
  line-height: 1.4;
}

/* Hero Banner */
.hero {
  background: linear-gradient(135deg, #152442 0%, #1F3864 100%);
  color: #FFFFFF;
  border-radius: 12px;
  padding: 28px 30px;
  margin-bottom: 22px;
  box-shadow: 0 6px 20px -4px rgba(22, 40, 74, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.hero h1 {
  color: #FFFFFF;
  margin-bottom: 10px;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.hero p {
  margin: 0;
  color: #D2DDF0;
  font-size: 15px;
  line-height: 1.6;
}
.hero-notice {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(229, 170, 80, 0.5);
  border-radius: 6px;
  font-size: 13.5px;
  color: #E2EAF8;
  line-height: 1.65;
}
.hero-facts { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 18px; }
.hero-facts div { display: flex; flex-direction: column; gap: 2px; }
.hero-facts dt { font-size: 12.5px; color: #9FB0CD; }
.hero-facts dd { margin: 0; font-family: "Anuphan", sans-serif; font-weight: 600; font-size: 18px; }

/* --------------------------------------------------------- แจ้งเตือน */
.note {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14.5px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  line-height: 1.65;
}
.note-ok { background: var(--teal-tint); border-color: #B2DDCB; color: #094F3D; }
.note-warn { background: var(--ochre-tint); border-color: #E6D2A4; color: #663E0B; }
.note-error { background: var(--red-tint); border-color: #EAC5C5; color: #832020; }
.note-consent {
  background: #FAF8F4;
  border-color: #E5E0D5;
  color: #4A463C;
  line-height: 1.7;
}

/* --------------------------------------------------------- แถบขั้นตอน */
.steps {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.steps li {
  flex: 1 1 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: 9px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  transition: all 0.2s ease;
}
.step-no {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Anuphan", sans-serif;
  font-size: 13px;
  font-weight: 700;
  background: #ECE9DF;
  color: var(--faint);
  transition: all 0.2s ease;
}
.step-label {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.4;
}
.steps li.is-now {
  border-color: var(--indigo);
  background: #FAFBFD;
  box-shadow: 0 2px 8px rgba(31, 56, 100, 0.08);
}
.steps li.is-now .step-no {
  background: var(--indigo);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(31, 56, 100, 0.25);
}
.steps li.is-now .step-label {
  color: var(--indigo-deep);
  font-weight: 600;
}
.steps li.is-done {
  border-color: #BCE0D0;
  background: #F8FBF9;
}
.steps li.is-done .step-no {
  background: var(--teal-tint);
  color: #0A5340;
}
.steps li.is-done .step-label {
  color: #2F594A;
}

/* --------------------------------------------------------- ฟอร์ม */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}
.field > label {
  font-family: "Anuphan", "Sarabun", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #2D2A24;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field .hint {
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.5;
}
.label-unit, .label-hint {
  font-size: 13px;
  font-weight: 400;
  color: var(--faint);
}
.req {
  color: #dc2626;
  font-weight: 700;
  font-size: 1.15em;
  line-height: 1;
  margin-left: 3px;
  vertical-align: baseline;
}

.password-input-wrap { position: relative; }
.password-input-wrap > input[type] { padding-right: 56px; }
.password-visibility-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted, #475569);
  cursor: pointer;
}
.password-visibility-toggle:hover { background: #f1f5f9; color: var(--ink, #16284a); }
.password-visibility-toggle:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.password-visibility-toggle .password-eye-slash { display: none; }
.password-visibility-toggle[aria-pressed="true"] .password-eye-slash { display: block; }

input[type="text"], input[type="tel"], input[type="email"],
input[type="number"], input[type="password"], select, textarea {
  min-height: 46px;
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 14px;
  border: 1.5px solid #D6D1C7;
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input::placeholder, textarea::placeholder {
  color: var(--faint);
}
input:hover, select:hover, textarea:hover {
  border-color: #B5AEA0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--indigo);
  outline-offset: 1px;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3.5px rgba(31, 56, 100, 0.12);
  background: #FFFFFF;
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--red);
  background: #FFFBFB;
}
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3.5px rgba(163, 45, 45, 0.12);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E5A50' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}
.err { font-size: 12.5px; color: var(--red); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 0 16px; }

/* ----------------------------- ส่วนพิเศษ: อายุ และ เพศ */
.grid-age-gender {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 640px) {
  .grid-age-gender {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

.input-unit-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-unit-wrap input {
  padding-right: 48px;
}
.input-unit-wrap input[type="number"]::-webkit-inner-spin-button,
.input-unit-wrap input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-unit-wrap input[type="number"] {
  -moz-appearance: textfield;
}
.unit-tag {
  position: absolute;
  right: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  background: #F0EDE5;
  padding: 3px 8px;
  border-radius: 5px;
  pointer-events: none;
}

/* Gender Pills */
.gender-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  align-items: center;
}
.gender-pill {
  position: relative;
  cursor: pointer;
  user-select: none;
}
.gender-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.gender-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 9px 16px;
  border-radius: 8px;
  background: #FAF9F6;
  border: 1.5px solid #D6D1C7;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.gender-pill:hover span {
  border-color: #B0A99A;
  background: #F3F1EC;
}
.gender-pill input:checked + span {
  background: var(--indigo);
  color: #FFFFFF;
  border-color: var(--indigo);
  box-shadow: 0 2px 6px rgba(31, 56, 100, 0.22);
  font-weight: 600;
}
.gender-pill input:focus-visible + span {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

/* ---------------------------------------------------- Fieldsets */
.form-fieldset {
  border: 1.5px solid #E5E1D7;
  border-radius: 10px;
  background: #FCFBF9;
  padding: 16px 18px 18px;
  margin: 0 0 20px;
  transition: border-color 0.2s ease;
}
.form-fieldset:hover {
  border-color: #D3CDC1;
}
.fieldset-legend {
  font-family: "Anuphan", sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--indigo-deep);
  padding: 0 8px;
}
.sub-hint {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--faint);
  margin-left: 4px;
}

/* ---------------------------------------------------- Choice Cards */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.choice-item {
  border: 1.5px solid #E2DED5;
  border-radius: 9px;
  background: var(--surface);
  transition: all 0.18s ease;
  overflow: hidden;
}
.choice-item:hover {
  border-color: #B5BFD0;
  background: #FAF9F6;
}
.choice-item:has(input:checked),
.choice-item.is-selected {
  border-color: var(--indigo);
  background: #F3F6FA;
  box-shadow: 0 2px 8px rgba(31, 56, 100, 0.08);
}
.choice-item .choice {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  background: transparent;
  box-shadow: none;
}

.choice {
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  min-height: 52px;
  border: 1.5px solid #E2DED5;
  border-radius: 9px;
  padding: 13px 16px;
  margin-bottom: 10px;
  background: var(--surface);
  transition: all 0.18s ease;
}
.choice:hover {
  border-color: #B5BFD0;
  background: #FAF9F6;
}
.choice:has(input:checked) {
  border-color: var(--indigo);
  background: #F3F6FA;
  box-shadow: 0 2px 8px rgba(31, 56, 100, 0.08);
}
.choice > input[type="radio"],
.choice > input[type="checkbox"] {
  width: 19px;
  height: 19px;
  accent-color: var(--indigo);
  flex: 0 0 auto;
  cursor: pointer;
}
.choice-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.choice-label {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
}
.choice-hint { font-size: 12.5px; color: var(--faint); line-height: 1.55; }
.choice-sub-box {
  padding: 0 16px 14px 49px;
  animation: fadeIn 0.2s ease;
}
.choice-sub-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--faint);
  margin-bottom: 6px;
}
.choice-sub-box input[type="text"] {
  width: 100%;
  min-height: 44px;
  font-size: 14.5px;
  border-radius: 8px;
  background: #FFFFFF;
}
@media (max-width: 640px) {
  .choice-sub-box {
    padding: 0 14px 12px 14px;
  }
}

/* ----------------------------------------------------------- Chips */
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background: #FFFFFF;
  color: #3C382F;
  border: 1.5px solid #D6D1C7;
  transition: all 0.15s ease;
  user-select: none;
}
.chip:hover span {
  border-color: #B5AEA1;
  background: #F7F5EE;
}
.chip input:checked + span {
  background: var(--indigo);
  color: #FFFFFF;
  border-color: var(--indigo);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(31, 56, 100, 0.22);
}
.chip input:focus-visible + span { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* --------------------------------------------------- สรุปข้อมูล (Step 3) */
.summary-card {
  background: #FAF8F4;
  border-color: #E6E1D5;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  font-size: 14.5px;
}
.summary-item {
  background: #FFFFFF;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #ECE7DD;
}
.summary-full {
  grid-column: 1 / -1;
}
.summary-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.summary-val {
  color: var(--ink);
}
.summary-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* --------------------------------------------------- การ์ดเลือกรุ่น */
.session-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 13px; }
.session { position: relative; }
.session input { position: absolute; opacity: 0; width: 0; height: 0; }
.session-box {
  display: flex; flex-direction: column; gap: 9px;
  padding: 16px 17px; border-radius: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); height: 100%;
}
.session input:checked + .session-box { border: 2px solid var(--indigo); background: #F2F5FB; padding: 15px 16px; }
.session input:focus-visible + .session-box { outline: 2px solid var(--indigo); outline-offset: 2px; }
.session-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.session-title { font-size: 14.5px; font-weight: 500; line-height: 1.45; }
.session-meta { font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ---------------------------------------------------------- ป้าย */
.badge {
  display: inline-block; font-size: 12px; padding: 3px 9px;
  border-radius: 4px; white-space: nowrap; font-weight: 500;
}
.badge-ok { background: var(--teal-tint); color: #0B5542; }
.badge-warn { background: var(--ochre-tint); color: #6E440D; }
.badge-bad { background: var(--red-tint); color: var(--red); }
.badge-info { background: var(--indigo-tint); color: var(--indigo); }
.badge-idle { background: #EFEDE6; color: var(--muted); }

/* -------------------------------------------------------- ตัวเลข */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 13px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; }
.stat-value { font-family: "Anuphan", sans-serif; font-weight: 700; font-size: 27px; line-height: 1.1; display: block; }
.stat-note { font-size: 12px; color: var(--faint); display: block; margin-top: 5px; }
.bar { height: 6px; background: #ECE8DF; border-radius: 3px; overflow: hidden; margin-top: 9px; }
.bar > i { display: block; height: 100%; background: var(--indigo); border-radius: 3px; }

/* ------------------------------------------------------- ตาราง */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data thead tr { background: #F7F5F0; }
table.data th {
  text-align: left; padding: 10px 14px; font-weight: 600;
  color: var(--muted); font-size: 12.5px; white-space: nowrap;
}
table.data td { padding: 12px 14px; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.data tr.is-flagged { background: #FDF7F7; }
.table-foot {
  padding: 13px 20px; background: #F7F5F0; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--muted);
}

/* -------------------------------------------------------- เส้นเวลา */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 13px; padding-bottom: 16px; }
.tl-rail { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--teal); flex: 0 0 auto; }
.timeline li.is-next .tl-dot { background: var(--surface); border: 2px solid var(--indigo); }
.tl-line { width: 2px; flex: 1 1 auto; min-height: 20px; background: #B6DCCB; }
.timeline li.is-next .tl-line { background: var(--line); }
.timeline li:last-child .tl-line { display: none; }
.tl-title { font-size: 14.5px; }
.timeline li.is-next .tl-title { font-weight: 600; color: var(--indigo); }
.tl-detail { font-size: 12.5px; color: var(--faint); }

/* --------------------------------------------------------- ส่วนท้าย */
.site-foot {
  border-top: 1px solid var(--line); padding: 22px 0 32px;
  font-size: 13px; color: var(--faint); text-align: center;
}

.login-box { max-width: 420px; margin: 50px auto; }

@media (max-width: 640px) {
  h1 { font-size: 21px; }
  .card { padding: 20px 16px; }
  .hero { padding: 22px 18px; }
  .wrap { padding: 0 16px; }
  .steps li { flex: 1 1 100%; }
}

/* --------------------------------------------------- แดชบอร์ด & หลังบ้าน */
.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #DDE7F6;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.nav-badge {
  background: #E5A33D;
  color: #1A1A1A;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  display: inline-block;
  line-height: 1.4;
}

.admin-header-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1.5px solid var(--line);
}
.admin-header-bar h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--indigo-deep);
  margin-bottom: 4px;
}
.admin-header-bar p {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
}

/* Quick Stat Cards for Registrations */
.quick-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.quick-stat-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all 0.15s ease;
}
.quick-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(31, 56, 100, 0.06);
}
.quick-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: 0 0 auto;
}
.quick-stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.quick-stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.quick-stat-val {
  font-family: "Anuphan", sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--indigo-deep);
  line-height: 1.2;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(31, 56, 100, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
}
.kpi-card:hover {
  border-color: #B9C6DC;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(31, 56, 100, 0.08);
}
.kpi-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--indigo-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: 0 0 auto;
}
.kpi-name {
  font-family: "Anuphan", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--indigo-deep);
  line-height: 1.35;
}
.kpi-numbers {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.kpi-current {
  font-family: "Anuphan", sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--indigo);
  line-height: 1;
}
.kpi-target {
  font-size: 13.5px;
  color: var(--muted);
}
.kpi-progress {
  height: 7px;
  background: #EBE7DC;
  border-radius: 4px;
  overflow: hidden;
}
.kpi-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1F3864 0%, #2A4E8B 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.kpi-note {
  font-size: 12px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
}

/* Project overview: grouped totals and restrained progress panels. */
.admin-workspace { background:#f5f5f2; }
.admin-workspace .admin-header-bar { align-items:flex-start; }
.admin-workspace .admin-header-bar h1 { font-size:26px; }
.admin-workspace .admin-header-bar p { font-size:15px;line-height:1.6; }
.admin-workspace .admin-header-bar .dashboard-updated { margin-top:4px;font-size:13px;color:var(--faint); }
.admin-workspace .admin-header-bar .btn { gap:12px;border-radius:5px;box-shadow:none;transform:none; }
.dashboard-action-count { padding-left:12px;border-left:1px solid #7486a2;font-weight:400;font-size:13px; }
.admin-workspace .quick-stat-grid { grid-template-columns:repeat(4,minmax(0,1fr));gap:0;border:1px solid var(--line);border-radius:6px;background:#fff;margin-bottom:30px; }
.admin-workspace .quick-stat-card { border:0;border-right:1px solid var(--line-soft);border-radius:0;background:transparent;box-shadow:none;padding:20px 22px;gap:12px;align-items:flex-start; }
.admin-workspace .quick-stat-card:last-child { border-right:0; }
.admin-workspace .quick-stat-card:hover { transform:none;box-shadow:none; }
.admin-workspace .quick-stat-icon { width:22px;height:22px;margin-top:2px;background:transparent;border-radius:0;color:var(--muted); }
.admin-workspace .quick-stat-label { font-size:14px;font-weight:500;line-height:1.5; }
.admin-workspace .quick-stat-val { margin-top:7px;font-size:30px;font-variant-numeric:tabular-nums; }
.quick-stat-unit { font-size:14px;font-weight:400;color:var(--muted); }
.admin-workspace .is-pending .quick-stat-val { color:var(--ochre); }
.admin-workspace .is-approved .quick-stat-val { color:var(--teal); }
.admin-workspace .kpi-grid { grid-template-columns:repeat(5,minmax(0,1fr));gap:12px; }
.admin-workspace .kpi-card { border:1px solid var(--line);border-radius:6px;box-shadow:none;padding:20px 18px;gap:16px; }
.admin-workspace .kpi-card:hover { transform:none;box-shadow:none;border-color:var(--line); }
.admin-workspace .kpi-top { min-height:46px;align-items:flex-start; }
.admin-workspace .kpi-name { font-size:15px;line-height:1.5;font-weight:600;color:var(--ink); }
.admin-workspace .kpi-current { font-size:32px;font-variant-numeric:tabular-nums; }
.admin-workspace .kpi-target { font-size:14px; }
.admin-workspace .kpi-progress { height:5px;border-radius:2px;background:#e9e9e2; }
.admin-workspace .kpi-progress-fill { background:var(--indigo);border-radius:2px; }
.admin-workspace .kpi-note { flex-direction:column;gap:4px;font-size:13px;line-height:1.5; }
.kpi-state { color:var(--muted); }
.kpi-state.is-complete { color:var(--teal);font-weight:600; }
.admin-workspace .card { border-radius:6px;box-shadow:none; }
@media(max-width:1100px) {
  .admin-workspace .kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media(max-width:720px) {
  .admin-workspace .quick-stat-grid,.admin-workspace .kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-workspace .quick-stat-card { padding:16px;border-bottom:1px solid var(--line-soft); }
  .admin-workspace .quick-stat-card:nth-child(2n) { border-right:0; }
  .admin-workspace .quick-stat-card:nth-last-child(-n+2) { border-bottom:0; }
}
@media(max-width:440px) {
  .admin-workspace .kpi-grid { grid-template-columns:minmax(0,1fr); }
  .admin-workspace .admin-header-bar h1 { font-size:23px; }
  .dashboard-action-count { border:0;padding-left:0; }
}

/* Province Cards */
.prov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.prov-card {
  border: 1.5px solid #E4E0D5;
  border-radius: 9px;
  padding: 13px 15px;
  background: #FFFFFF;
  transition: all 0.15s ease;
}
.prov-card:hover {
  border-color: var(--indigo);
  background: #FAFBFD;
}
.prov-title {
  font-size: 14px;
  font-weight: 600;
  color: #2D2A24;
}
.prov-val {
  font-family: "Anuphan", sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--indigo);
}

/* Inspection Drawer for Registrations */
.details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--indigo);
  cursor: pointer;
  padding: 5px 11px;
  border-radius: 6px;
  background: var(--indigo-tint);
  border: 1px solid #D2DFEE;
  margin-top: 8px;
  user-select: none;
  transition: all 0.15s ease;
}
.details-toggle:hover {
  background: #D8E4F4;
  border-color: var(--indigo);
}
.app-detail-card {
  background: #FAF8F4;
  border: 1.5px solid #E6E1D5;
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.app-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.app-sub-box {
  background: #FFFFFF;
  border: 1px solid #ECE7DD;
  border-radius: 8px;
  padding: 12px 15px;
}
.app-sub-title {
  font-family: "Anuphan", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid #F4F1E8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-info-row {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 4px;
  color: #2E2B25;
}
.app-info-row .lbl {
  color: var(--muted);
  font-weight: 600;
}

/* Address Form 4-column responsive grid */
.grid-address {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* Course selection list */
.course-group {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  background: #FFFFFF;
}
.course-group-head {
  background: #F3F1EA;
  padding: 10px 16px;
  font-family: "Anuphan", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--indigo);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.course-group-head .module-badge {
  background: var(--indigo);
  color: #FFFFFF;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: inherit;
}
.course-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #F0ECE2;
  cursor: pointer;
  transition: background 0.12s ease;
  gap: 14px;
}
.course-row:last-child {
  border-bottom: none;
}
.course-row:hover {
  background: #F8F7F2;
}
.course-row.is-checked {
  background: #F0F5FA;
}
.course-check-wrap {
  flex: 0 0 auto;
}
.course-check-wrap input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--indigo);
}
.course-info {
  flex: 1 1 auto;
  min-width: 0;
}
.course-code-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  font-size: 12.5px;
}
.course-meta .meta-item {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.course-meta .meta-date {
  color: var(--indigo);
  font-weight: 600;
  background: var(--indigo-tint);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Priority Card Grid */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.priority-item {
  background: #FAF8F4;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.priority-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.priority-label .pri-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--indigo);
  color: #FFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* Limit counter badge */
.limit-badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #E8EEF8;
  color: var(--indigo);
  font-weight: 600;
  margin-left: 8px;
}
.limit-badge.limit-reached {
  background: #FDF3DE;
  color: #965E0C;
}


.registration-interview-status { display:flex; flex-wrap:wrap; align-items:flex-start; gap:6px; }
.registration-interview-status > .cell-sub { flex-basis:100%; }
.registration-interview-status > p { flex-basis:100%; margin:4px 0 8px; color:var(--muted); font-size:14px; line-height:1.6; }

/* Skip link: visible only on keyboard focus */
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 1000;
  padding: 10px 16px; background: var(--indigo); color: #fff;
  border-radius: 6px; font-weight: 600; text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; outline: 2px solid #fff; outline-offset: 2px; }
#main-content:focus { outline: none; }

/* Fallback focus ring for links and buttons that define none */
a:focus-visible, button:focus-visible, summary:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--indigo); outline-offset: 2px;
}
