:root {
    --font-sans: "Prompt", "Noto Sans Thai", Tahoma, Arial, sans-serif;
    --bs-font-sans-serif: var(--font-sans);
    --bs-body-font-family: var(--font-sans);
    --ink: #16324f;
    --muted: #64748b;
    --line: #d9e6eb;
    --surface: #ffffff;
    --canvas: #f4fbfc;
    --teal: #0f8f83;
    --teal-deep: #08766f;
    --blue: #1e70c9;
    --blue-deep: #1559a6;
    --mint: #e9f8f5;
    --sky: #edf6ff;
    --danger: #b42318;
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100dvh;
    color: var(--ink);
    background: var(--canvas);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
}

a { color: var(--teal-deep); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(30, 112, 201, .35);
    outline-offset: 2px;
}

.site-header {
    border-top: 4px solid var(--teal);
    background: var(--surface);
    border-bottom: 1px solid #e3eef1;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 76px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--teal-deep);
    background: var(--mint);
    border: 1px solid #b6e4da;
    border-radius: 50%;
}

.brand__mark svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand__name, .brand__sub { display: block; line-height: 1.25; }
.brand__name { color: var(--teal-deep); font-size: 1rem; font-weight: 800; letter-spacing: .06em; }
.brand__sub { color: var(--muted); font-size: .7rem; }

.line-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    color: #126f63;
    background: var(--mint);
    border: 1px solid #ccebe4;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.line-chip__dot { width: 7px; height: 7px; background: #16a88f; border-radius: 50%; }
.page-shell { padding: 22px 0 48px; }
.register-container { max-width: 820px; }
.narrow-container { max-width: 720px; }

.dev-banner, .connection-state {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: .875rem;
}

.dev-banner { margin-bottom: 12px; color: #174b80; background: var(--sky); border: 1px solid #c5dcf8; }
.dev-banner__icon { font-size: 1.05rem; line-height: 1.5; }
.connection-state { margin-bottom: 20px; color: #436274; background: #edf8f8; border: 1px solid #d5ebea; }
.connection-state--ready { color: #126f63; background: var(--mint); border-color: #bfe8dc; }
.connection-state--error { color: var(--danger); background: #fff3f2; border-color: #f4c7c3; }
.connection-state .spinner-border { margin-top: 4px; }

.page-intro {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding: 4px 4px 0;
}

.page-intro__visual {
    display: grid;
    flex: 0 0 74px;
    place-items: center;
    width: 74px;
    height: 74px;
    color: var(--teal-deep);
    background: #e6f6f6;
    border: 1px solid #c5e8e4;
    border-radius: 22px;
}

.page-intro__visual svg { width: 54px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.page-intro h1 { margin: 0; color: #124b83; font-size: clamp(1.8rem, 6vw, 2.65rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.page-intro p { margin: 5px 0 0; color: var(--teal-deep); font-size: 1.05rem; font-weight: 700; }

.registration-card, .content-card, .success-card {
    background: var(--surface);
    border: 1px solid #dce8ed;
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(20, 63, 80, .07);
}

.registration-card { padding: clamp(20px, 5vw, 38px); }
.section-heading { display: flex; align-items: flex-start; gap: 11px; padding-bottom: 16px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-heading__icon { display: grid; place-items: center; width: 32px; height: 32px; color: #fff; background: var(--teal); border-radius: 50%; font-size: 1.4rem; line-height: 1; transform: rotate(-20deg); }
.section-heading h2 { margin: 0; color: #194f83; font-size: 1.25rem; font-weight: 800; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.field-block { margin-top: 22px; }
.form-label { margin-bottom: 7px; color: #183d62; font-size: .95rem; font-weight: 700; }
.form-label--small { margin-bottom: 4px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.required-mark { color: #d92d20; }
.form-control, .form-select { min-height: 48px; border-color: #cfdde4; border-radius: 10px; color: var(--ink); }
.form-control::placeholder { color: #98a8b4; }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 .2rem rgba(30, 112, 201, .13); }
.gender-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice-tile { display: flex; align-items: center; gap: 8px; min-height: 47px; padding: 9px 11px; color: #31536b; background: #fbfdfe; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice-tile:has(input:checked) { color: #0a6c63; background: var(--mint); border-color: #71cbbb; }
.choice-tile input { accent-color: var(--teal); width: 17px; height: 17px; }
.birth-row .form-select { padding-right: 22px; font-size: .9rem; }
.form-hint { margin-top: 8px; color: var(--muted); font-size: .8rem; }
.invalid-feedback { min-height: 0; font-size: .82rem; }
.invalid-feedback:empty { display: none !important; }
.birth-select.is-invalid { border-color: var(--danger); }
.consent-box { margin-top: 26px; padding: 15px; background: #f2fbf9; border: 1px solid #83d6c4; border-radius: 13px; }
.consent-box .form-check { display: flex; align-items: flex-start; gap: 10px; }
.consent-box .form-check-input { flex: 0 0 auto; width: 22px; height: 22px; margin: 2px 0 0; border-color: #4fbfae; }
.consent-box .form-check-input:checked { background-color: var(--teal); border-color: var(--teal); }
.consent-box .form-check-label { color: #25455c; font-size: .9rem; font-weight: 700; }
.consent-box__detail { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.consent-box a { display: inline-block; margin-top: 5px; font-weight: 700; }
.medical-note { margin-top: 18px; padding: 12px 14px; color: #5b6d78; background: #f7fafb; border-left: 3px solid #6bbbc0; border-radius: 8px; font-size: .82rem; }
.btn-submit { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; margin-top: 22px; background: var(--blue); border: 0; border-radius: 11px; font-size: 1rem; font-weight: 800; box-shadow: 0 7px 16px rgba(30, 112, 201, .2); }
.btn-submit:hover, .btn-submit:focus { background: var(--blue-deep); }
.btn-submit:disabled { color: #fff; background: #9cb5c4; box-shadow: none; opacity: 1; }
.btn-submit__icon { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid currentColor; border-radius: 6px; font-size: .8rem; line-height: 1; }
.submit-hint { margin: 9px 0 0; color: var(--muted); text-align: center; font-size: .75rem; }
.site-footer { padding: 20px 0 28px; color: #75909c; font-size: .75rem; }
.site-footer a { color: #377b85; }

.success-card { padding: clamp(28px, 8vw, 54px); }
.success-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 18px; color: #fff; background: var(--teal); border-radius: 50%; font-size: 2.3rem; font-weight: 700; line-height: 1; }
.success-kicker, .content-kicker { margin: 0 0 5px; color: var(--teal-deep); font-size: .85rem; font-weight: 800; }
.success-card h1, .content-card h1 { margin: 0; color: #124b83; font-size: clamp(1.65rem, 5vw, 2.3rem); font-weight: 800; }
.success-copy { margin: 10px auto 0; max-width: 460px; color: var(--muted); }
.secondary-link { display: block; margin-top: 16px; font-size: .9rem; font-weight: 700; }
.admin-shell { padding-top: 20px; }
.admin-card { max-width: 620px; margin: 0 auto; padding: clamp(22px, 6vw, 42px); background: var(--surface); border: 1px solid #dce8ed; border-radius: var(--radius); box-shadow: 0 12px 30px rgba(20, 63, 80, .07); }
.admin-card--wide { max-width: 1100px; }
.admin-dashboard--overview { max-width: 1320px; }
.admin-dashboard--overview .admin-card { max-width: none; padding: clamp(24px, 3.2vw, 44px); }
.admin-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.admin-heading__icon { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--teal); border-radius: 13px; font-size: 1.3rem; }
.admin-heading h1, .admin-toolbar h1 { margin: 0; color: #124b83; font-size: clamp(1.45rem, 5vw, 2rem); font-weight: 800; }
.admin-note, .admin-subtitle { margin: 16px 0 0; color: var(--muted); font-size: .82rem; }
.admin-logout-form { margin-top: 12px; text-align: center; }
.admin-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.admin-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.admin-actions .btn { white-space: nowrap; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.admin-stat-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 20px; }
.admin-stat { padding: 16px; background: #f4fbfb; border: 1px solid #d6eceb; border-radius: 12px; }
.admin-stat span, .admin-stat strong { display: block; }
.admin-stat span { color: var(--muted); font-size: .78rem; }
.admin-stat strong { margin-top: 4px; color: var(--teal-deep); font-size: 1.7rem; line-height: 1.2; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 6px; padding: 12px; background: #f6fafb; border: 1px solid #dcebed; border-radius: 12px; }
.admin-nav a { padding: 7px 10px; color: #1c6481; background: #fff; border: 1px solid #cfe3e9; border-radius: 8px; font-size: .82rem; font-weight: 700; text-decoration: none; }
.admin-nav a:hover { background: #e9f8f5; }
.admin-user-create { padding: 16px; background: #f6fafb; border: 1px solid #dcebed; border-radius: 12px; }
.admin-inline-form { display: flex; align-items: center; justify-content: flex-end; gap: 7px; min-width: 420px; }
.admin-inline-form .form-select { width: 135px; }
.admin-table { margin-top: 10px; color: var(--ink); }
.admin-table th { color: #526875; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.admin-table td { font-size: .88rem; }
.admin-table code { color: #176f77; }
.admin-inline-actions { display: inline-flex; gap: 6px; }
.status-badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.status-badge--active { color: #126f63; background: #e5f7f1; }
.status-badge--inactive { color: #697984; background: #eef2f4; }
.report-filter { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px; background: #f6fafb; border: 1px solid #dcebed; border-radius: 12px; }
.report-filter > div { min-width: 180px; flex: 1 1 180px; }
.report-filter .form-label { display: block; margin-bottom: 4px; font-size: .8rem; }
.report-filter .btn { min-height: 39px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 24px; margin-top: 28px; }
.admin-section-title { margin: 22px 0 8px; color: #194f83; font-size: 1.05rem; font-weight: 800; }
.report-grid .admin-section-title { margin-top: 0; }
.audit-metadata { display: inline-block; max-width: 260px; overflow: hidden; color: #5d7780; font-size: .72rem; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.content-card { padding: clamp(22px, 6vw, 44px); }
.back-link { display: inline-block; margin-bottom: 22px; font-size: .88rem; font-weight: 700; text-decoration: none; }
.content-card .lead { margin: 8px 0 20px; color: var(--teal-deep); font-weight: 700; }
.policy-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 25px; padding: 11px 13px; color: var(--muted); background: #f6fafb; border-radius: 9px; font-size: .8rem; }
.content-card h2 { margin: 25px 0 5px; color: #194f83; font-size: 1.05rem; font-weight: 800; }
.content-card p { margin: 0; color: #526875; font-size: .92rem; }

@media (max-width: 767.98px) {
    .admin-dashboard--overview .admin-card { padding: 24px clamp(18px, 5vw, 30px); }
    .admin-dashboard--overview .admin-toolbar { flex-direction: column; }
    .admin-dashboard--overview .admin-actions { justify-content: flex-start; }
    .admin-dashboard--overview .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-dashboard--overview .admin-nav a { flex: 1 1 calc(50% - 5px); text-align: center; }
}

@media (max-width: 420px) {
    .site-header__inner { min-height: 68px; }
    .brand__sub { max-width: 168px; font-size: .62rem; }
    .line-chip { padding: 6px 8px; font-size: .67rem; }
    .page-shell { padding-top: 16px; }
    .page-intro { gap: 11px; }
    .page-intro__visual { flex-basis: 62px; width: 62px; height: 62px; border-radius: 18px; }
    .page-intro__visual svg { width: 45px; }
    .page-intro h1 { font-size: 1.75rem; }
    .page-intro p { font-size: .92rem; }
    .registration-card { padding: 18px 15px; }
    .section-heading p { font-size: .78rem; }
    .admin-toolbar { display: block; }
    .admin-actions { justify-content: flex-start; margin-top: 16px; }
    .admin-stat-grid { grid-template-columns: 1fr; }
    .admin-stat-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-dashboard--overview .admin-card { padding: 20px 16px; }
    .admin-dashboard--overview .admin-nav a { flex-basis: 100%; text-align: left; }
    .report-grid { grid-template-columns: 1fr; gap: 8px; }
    .admin-inline-form { min-width: 360px; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
