:root {
  color-scheme: light;
  font-family: Inter, "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif;
  color: #162c43;
  background: #eef3f8;
  line-height: 1.58;
  font-size: 15px;
  --ink: #162c43;
  --muted: #526780;
  --line: #dce6ef;
  --surface: #fff;
  --soft: #f5f8fc;
  --blue: #145d9a;
  --blue-deep: #104d81;
  --blue-soft: #e9f3fc;
  --shadow: 0 4px 14px #193b6210;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--blue-deep); text-underline-offset: .2em; }
a:hover { color: #0b3860; }
h1, h2, h3, p { margin: 0 0 .65rem; }
h1 { font-size: clamp(1.85rem, 3.6vw, 2.65rem); line-height: 1.2; }
h2 { font-size: 1.2rem; line-height: 1.35; }
h3 { font-size: 1.05rem; }
.help, .muted { color: var(--muted); font-size: .92rem; }
label { display: block; font-weight: 650; }
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"], [type="hidden"]), select, textarea {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-width: 0;
  min-height: 2.6rem;
  margin: .3rem 0 .55rem;
  padding: .46rem .65rem;
  border: 1px solid #b2c4d5;
  border-radius: .5rem;
  color: var(--ink);
  background: #fff;
}
input[type="checkbox"] { accent-color: var(--blue); }
input[type="file"] { max-width: 100%; font-size: .92rem; }
input[type="file"]::file-selector-button {
  margin-inline-end: .65rem;
  padding: .24rem .55rem;
  border: 0;
  border-radius: .3rem;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font: inherit;
  cursor: pointer;
}
button {
  min-height: 2.55rem;
  padding: .48rem .86rem;
  border: 1px solid var(--blue);
  border-radius: .5rem;
  background: var(--blue);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--blue-deep); }
button:disabled { opacity: .58; cursor: default; }
:focus-visible { outline: 3px solid #4188c2; outline-offset: 3px; }
.secondary, .sec, #chg, .search-option {
  color: var(--blue-deep);
  background: #fff;
  border-color: #b2cde4;
}
.secondary:hover:not(:disabled), .sec:hover:not(:disabled),
#chg:hover:not(:disabled), .search-option:hover:not(:disabled) { background: var(--blue-soft); }
.c {
  min-width: 0;
  margin: 0;
  padding: clamp(1rem, 2.2vw, 1.45rem);
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.form-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .9rem; }
.e {
  padding: .75rem 1rem;
  border: 1px solid #f0c7c6;
  border-radius: .6rem;
  color: #872733;
  background: #fff3f3;
}

/* Public registration */
.portal-header { background: #fff; border-bottom: 1px solid var(--line); }
.portal-header-inner, .portal-main { width: min(calc(100% - 3rem), 77rem); margin-inline: auto; }
.portal-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  min-height: 4.2rem;
  padding-block: .65rem;
}
.portal-brand { display: inline-flex; align-items: center; gap: .55rem; font-size: 1.12rem; font-weight: 750; text-decoration: none; }
.brand-mark { display: block; width: .7rem; height: .7rem; flex: 0 0 .7rem; border-radius: .22rem; background: #39a2df; }
.portal-header nav { display: flex; flex-wrap: wrap; gap: .3rem; }
.portal-header nav a { padding: .5rem .75rem; border-radius: .45rem; font-weight: 620; text-decoration: none; }
.portal-header nav a:hover, .portal-header nav a[aria-current] { background: var(--blue-soft); }
.portal-main { padding: 2rem 0 3rem; }
.portal-intro { padding: 1.65rem clamp(1.1rem, 3vw, 2rem); margin-bottom: 1.25rem; border-radius: .9rem; background: linear-gradient(112deg, #163b61, #18699b); color: #fff; }
.portal-intro p { margin-bottom: 0; color: #e0effd; }
.registration-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.registration-form > section h2 { margin-bottom: .75rem; }
@media (min-width: 980px) {
  .registration-form { grid-template-columns: minmax(0, 1.85fr) minmax(18rem, 1fr); grid-template-rows: auto auto 1fr; }
  .registration-wide:first-of-type { grid-area: 1 / 1; }
  .registration-wide:nth-of-type(2) { grid-area: 2 / 1 / 4 / 2; }
  .registration-attachment { grid-area: 1 / 2; }
  .registration-submit { grid-area: 2 / 2; }
}
#q { max-width: 100%; }
#lst:not(:empty) { display: grid; gap: .4rem; margin-top: .65rem; }
#lst p { margin: 0; }
.search-option { text-align: left; }
#selbox { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; }
#sel { overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; }
.section-heading .help { margin-bottom: 0; }
#rows:not(:empty) { display: grid; gap: .8rem; margin-top: .7rem; }
.person-row { min-inline-size: 0; margin: 0; padding: .7rem .9rem .9rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--soft); }
.person-row legend { padding-inline: .35rem; font-weight: 700; color: var(--blue-deep); }
.person-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .15rem .8rem; margin-bottom: .45rem; }
.person-grid label { min-width: 0; }
.consent { display: flex; gap: .55rem; align-items: start; margin-bottom: .85rem; }
.consent input { flex: 0 0 auto; margin-top: .35rem; }
.verification-field { margin-block: .65rem; }
.verification-field input:not([type="hidden"]) { max-width: 10rem; }
.registration-submit .form-actions button { width: 100%; }
.portal-steps, .kv { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; }

/* Admin login and workspace */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: radial-gradient(ellipse at 15% 15%, #d8ebfa 0, transparent 55%), #eef3f8;
}
.login-content { width: min(100%, 29rem); }
.login-content > .portal-brand { margin-bottom: 1rem; }
.login-content h1 { margin-bottom: 1rem; }
.login-content .c { padding: 1.65rem; }
.login-content .admin-message { margin-bottom: .85rem; }
.login-content button { width: 100%; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 16rem minmax(0, 1fr); }
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding: 1.55rem 1rem 1rem;
  color: #e9f2fc;
  background: #122e49;
}
.admin-sidebar .portal-brand { padding: .35rem .55rem; color: #fff; }
.admin-sidebar nav { display: grid; gap: 1rem; }
.nav-group { display: grid; gap: .23rem; }
.nav-group > p { margin: 0 0 .18rem; padding-inline: .6rem; color: #b4cde4; font-size: .82rem; font-weight: 700; }
.nav-group a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .1rem .45rem;
  padding: .58rem .65rem;
  border-radius: .45rem;
  color: #e9f2fc;
  text-decoration: none;
}
.nav-group a:hover, .nav-group a[aria-current="page"] { background: #254965; color: #fff; }
.nav-group a[aria-current="page"] { box-shadow: inset 3px 0 #68b9f0; font-weight: 720; }
.admin-pending { color: #d4e9fb; font-size: .78rem; white-space: nowrap; }
.admin-sidebar > form { margin-top: auto; }
.admin-sidebar > form button { width: 100%; border-color: #5f7f9b; background: transparent; }
.admin-sidebar > form button:hover { background: #254965; }
.admin-content { min-width: 0; width: 100%; max-width: 108rem; margin-inline: auto; padding: clamp(1rem, 3vw, 2.4rem); }
.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.admin-heading h1 { margin: 0; }
.quiet-link, .report-exports a, .org-row-actions > a {
  display: inline-block;
  padding: .45rem .65rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: #fff;
  font-weight: 650;
  text-decoration: none;
}
.quiet-link:hover, .report-exports a:hover, .org-row-actions > a:hover { background: var(--blue-soft); }
.admin-body, .org-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.admin-message { margin-bottom: 1rem; color: #134769; background: var(--blue-soft); }
.field-grid, .org-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .25rem .8rem; }
.field, .org-field { min-width: 0; }
.org-field-name { grid-column: 1 / -1; }
.org-field-name input { max-width: 54rem; }
.org-form-actions, .org-list-heading, .request-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1rem; }
.org-form-actions { margin-top: .6rem; }
.org-list-heading h2, .request-heading h2, .request-heading p { margin-bottom: .15rem; }
.org-list-heading h2 span { padding-inline: .3rem; font-size: .85rem; color: var(--muted); font-weight: 550; }
.org-list .org-table { margin-top: .9rem; padding: 0; border-radius: .6rem; box-shadow: none; }
.org-code { font-family: ui-monospace, monospace; color: var(--blue-deep); }
.org-empty { margin-top: .8rem; color: var(--muted); }
.org-row-actions, .org-row-actions form { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.org-row-actions button, .admin-body td button, .org-row-actions > a { min-height: 2.05rem; padding: .27rem .5rem; font-size: .88rem; }
.org-status, .status-chip { display: inline-block; padding: .15rem .5rem; border-radius: 1rem; background: #eaf0f5; color: #405973; font-weight: 650; font-size: .88rem; white-space: nowrap; }
.org-status-active, .status-chip-active { background: #e2f5ed; color: #195d48; }
.filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem .7rem; }
.filter-form > .field-grid { flex: 1 1 22rem; }
.filter-form input, .filter-form select { margin-bottom: 0; }
.filter-form > input:not([type="hidden"]), .filter-form > select { width: auto; min-width: min(100%, 12rem); }
.s { overflow-x: auto; }
.s table { width: 100%; border-collapse: collapse; text-align: left; }
.s th, .s td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.s th { color: #284964; background: #edf4fb; font-size: .9rem; }
.s tr:last-child td { border-bottom: 0; }
.s tbody tr:nth-child(even) { background: #f8fbfe; }
.s tbody tr:hover { background: #edf5fd; }
.s td { overflow-wrap: anywhere; }
.org-table table { min-width: 44rem; }
.request-heading time { color: var(--muted); font-variant-numeric: tabular-nums; }
.request-letter { margin: .8rem 0; }
.request-people { margin: 0 0 1rem; padding: 0; list-style: none; display: grid; gap: .45rem; }
.request-people li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .65rem; padding: .55rem .7rem; border-radius: .45rem; background: var(--soft); overflow-wrap: anywhere; }
.request-people span { color: var(--muted); }
.admin-request input[name="reason"] { max-width: 42rem; }
.admin-request button[value="reject"], .admin-body button[value="delete"] { border-color: #e5b1b3; background: #fff3f3; color: #8b2935; }
.admin-request button[value="reject"]:hover, .admin-body button[value="delete"]:hover { background: #fbdedf; }
.form-disclosure summary { font-weight: 680; cursor: pointer; }
.form-disclosure[open] summary { margin-bottom: .8rem; }
.report-exports { display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0; }
.report-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .75rem; }
.report-metrics strong { display: block; margin-top: .35rem; font-size: 1.6rem; color: var(--blue-deep); font-variant-numeric: tabular-nums; }
.admin-chart { display: flex; align-items: end; height: 9rem; gap: .2rem; padding-top: .45rem; border-bottom: 1px solid var(--line); }
.admin-chart > div { display: flex; flex: 1; height: 100%; flex-direction: column-reverse; justify-content: start; }
.admin-chart i, .admin-chart b { display: block; background: #c46470; }
.admin-chart b { background: #269c88; }
@media (max-width: 760px) {
  .portal-header-inner, .portal-main { width: calc(100% - 1.5rem); }
  .portal-main { padding-top: 1rem; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .admin-sidebar { position: static; height: auto; padding: .8rem .75rem; gap: .65rem; }
  .admin-sidebar nav { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .65rem; }
  .admin-sidebar > form button { width: auto; }
}
@media print {
  :root { background: #fff; }
  .shell { display: block; }
  .admin-sidebar, .quiet-link, .report-exports, .filter-form, button { display: none !important; }
  .admin-content { padding: 0; }
  .c { box-shadow: none; }
  .s { overflow: visible; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
