/* =============================================================================
   rc58 — NebrixAI UI kit (ชั้น 1 ของ UX polish)
   ใช้ token จาก app.css เท่านั้น — หน้าใหม่/หน้าที่ปรับแล้วห้ามใส่สี hex เอง (มี test ตรวจ)
   ชื่อ class ขึ้นต้น nx- ทั้งหมด · โครงสร้าง: ปุ่ม · การ์ด · ฟอร์ม · ตาราง · ป้าย · แจ้งเตือน · สถานะว่าง/โหลด · dialog/drawer
   ============================================================================= */

/* ---------- layout helpers ---------- */
.nx-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.nx-stack--sm { gap: var(--sp-2); }
.nx-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.nx-row--end { justify-content: flex-end; }
.nx-row--between { justify-content: space-between; }
.nx-grow { flex: 1 1 auto; min-width: 0; }
.nx-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.nx-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); }
.nx-span-all { grid-column: 1 / -1; }
.nx-muted { color: var(--muted); }
.nx-small { font-size: var(--fs-sm); }
.nx-xs { font-size: var(--fs-xs); }
.nx-mono { font-family: var(--font-mono); }
.nx-num { font-variant-numeric: tabular-nums; }
.nx-nowrap { white-space: nowrap; }
.nx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-text-success { color: var(--success); }
.nx-text-danger { color: var(--danger-ink); }
.nx-text-warn { color: var(--warn); }
.nx-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- page header ---------- */
.nx-page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.nx-page-head__text { min-width: 0; flex: 1 1 420px; }
.nx-page-head h1 { font-size: var(--fs-h1); font-weight: 600; margin: 0; letter-spacing: -0.01em; line-height: 1.4; }
.nx-page-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-md); max-width: 820px; }
.nx-page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.nx-crumbs { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 4px; }
.nx-crumbs a { color: var(--indigo); text-decoration: none; }
.nx-crumbs a:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.nx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 34px; padding: 6px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card); color: var(--ink);
    font-family: inherit; font-size: var(--fs-md); font-weight: 500; line-height: 1.3;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.nx-btn:hover { border-color: var(--line-strong); background: var(--hover); }
.nx-btn:disabled, .nx-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.nx-btn--primary { background: var(--indigo); border-color: var(--indigo); color: var(--on-accent); }
.nx-btn--primary:hover { background: var(--indigo-strong); border-color: var(--indigo-strong); }
.nx-btn--danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.nx-btn--danger:hover { background: var(--danger-strong); border-color: var(--danger-strong); }
.nx-btn--danger-ghost { color: var(--danger-ink); }
.nx-btn--danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger-line); }
.nx-btn--ghost { border-color: transparent; background: transparent; }
.nx-btn--ghost:hover { background: var(--paper); border-color: transparent; }
.nx-btn--sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); }
.nx-btn--icon { min-width: 34px; padding: 6px; }
.nx-btn[aria-busy="true"]::before {
    content: ""; width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: nx-spin .7s linear infinite;
}
.nx-link { background: none; border: none; padding: 0; color: var(--indigo); font-family: inherit; font-size: inherit; cursor: pointer; text-decoration: none; text-align: left; }
.nx-link:hover { text-decoration: underline; }
@keyframes nx-spin { to { transform: rotate(360deg); } }

/* ---------- card ---------- */
.nx-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.nx-card--pad { padding: var(--sp-4) var(--sp-5); }
.nx-card--accent { border-color: var(--indigo-line); }
.nx-card--dashed { border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.nx-card__head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.nx-card__title { font-size: var(--fs-lg); font-weight: 600; margin: 0; display: flex; align-items: center; gap: var(--sp-2); }
.nx-card__title .nx-muted { font-weight: 400; font-size: var(--fs-sm); }
.nx-section-title { font-size: var(--fs-md); font-weight: 600; margin: var(--sp-4) 0 var(--sp-2); }

/* ---------- form ---------- */
.nx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nx-field > label, .nx-label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.nx-req { color: var(--danger-ink); margin-left: 2px; }
.nx-input {
    width: 100%; min-height: 36px; padding: 7px 10px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card); color: var(--ink);
    font-family: inherit; font-size: var(--fs-md);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.nx-input:hover { border-color: var(--line-strong); }
.nx-input:focus { outline: none; border-color: var(--indigo); box-shadow: var(--focus-ring); }
.nx-input:disabled { background: var(--paper); color: var(--muted); cursor: not-allowed; }
.nx-input[aria-invalid="true"] { border-color: var(--danger); }
.nx-input--mono { font-family: var(--font-mono); }
.nx-input--search { min-width: 240px; padding-left: 32px; background-image: var(--icon-search); background-repeat: no-repeat; background-position: 10px center; background-size: 14px; }
.nx-hint { font-size: var(--fs-xs); color: var(--muted); }
.nx-hint--error { color: var(--danger-ink); }
fieldset.nx-fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.nx-fieldset:disabled { opacity: .6; }

/* switch */
.nx-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
.nx-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nx-switch__track { width: 38px; height: 22px; background: var(--line-strong); border-radius: 22px; position: relative; transition: background var(--t-fast); flex-shrink: 0; }
.nx-switch__track::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--card); border-radius: 50%; transition: transform var(--t-fast); box-shadow: var(--shadow-1); }
.nx-switch input:checked + .nx-switch__track { background: var(--success); }
.nx-switch input:checked + .nx-switch__track::after { transform: translateX(16px); }
.nx-switch input:focus-visible + .nx-switch__track { box-shadow: var(--focus-ring); }
.nx-switch input:disabled + .nx-switch__track { opacity: .5; }
.nx-switch input:disabled ~ * { cursor: not-allowed; }

/* option card (เลือกหนึ่งอย่าง เช่น บทบาท · โหมดทดสอบ) */
.nx-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-2); }
.nx-option {
    display: flex; gap: 10px; align-items: flex-start; text-align: left;
    border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius);
    padding: 10px 12px; font-family: inherit; color: var(--ink); cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.nx-option:hover { border-color: var(--line-strong); }
.nx-option b { display: block; font-size: var(--fs-md); }
.nx-option small { display: block; font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
.nx-option .ic { font-size: 20px; line-height: 1.2; }
.nx-option.on, .nx-option[aria-pressed="true"], .nx-option[aria-checked="true"] { border-color: var(--indigo); background: var(--indigo-bg); }
.nx-option:disabled { opacity: .6; cursor: not-allowed; }

/* chip ที่เลือกได้ (checkbox) */
.nx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nx-chip {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--card);
    padding: 4px 11px; font-size: var(--fs-sm); color: var(--ink); cursor: pointer; font-family: inherit;
}
.nx-chip:hover { border-color: var(--line-strong); }
.nx-chip input { margin: 0; accent-color: var(--indigo); }
.nx-chip.on { border-color: var(--indigo); background: var(--indigo-bg); color: var(--indigo); }

/* ตัวกรองแบบปุ่มนับ (ทั้งหมด · Admin · …) */
.nx-filters { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.nx-filter {
    border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-pill);
    padding: 4px 14px; font-family: inherit; font-size: var(--fs-md); color: var(--muted); cursor: pointer;
}
.nx-filter b { color: var(--ink); margin-right: 3px; font-variant-numeric: tabular-nums; }
.nx-filter:hover { border-color: var(--line-strong); }
.nx-filter.on, .nx-filter[aria-pressed="true"] { border-color: var(--indigo); background: var(--indigo-bg); color: var(--indigo); }
.nx-filter.on b, .nx-filter[aria-pressed="true"] b { color: var(--indigo); }

/* ---------- table ---------- */
.nx-table-wrap { overflow-x: auto; position: relative; } /* rc63 — relative: ข้อความ nx-sr-only ในตารางไม่ดันหน้ากว้างเกินจอ (มือถือ) */
.nx-card > .nx-table-wrap:first-child .nx-table th { border-top: none; }
.nx-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.nx-table th {
    text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
    padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card);
}
.nx-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.nx-table tbody tr:last-child td { border-bottom: none; }
.nx-table--top td { vertical-align: top; }
.nx-table th.num, .nx-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.nx-table td.nowrap { white-space: nowrap; }
.nx-table td.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-table td.actions { text-align: right; white-space: nowrap; }
.nx-table tr.is-clickable { cursor: pointer; }
.nx-table tr.is-clickable:hover td { background: var(--hover); }
.nx-table tr.is-clickable:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }
.nx-table tr.is-muted td { opacity: .6; }
.nx-table tr.is-selected td { background: var(--indigo-bg); }
.nx-table tr.is-bad td { background: var(--danger-tint); }
.nx-table td.empty { text-align: center; padding: var(--sp-5); color: var(--muted); }
.nx-table-foot { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-2) 0 0; font-size: var(--fs-sm); color: var(--muted); }

/* pager */
.nx-pager { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; margin-left: auto; }
.nx-pager span { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- badge · tag ---------- */
.nx-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: var(--fs-xs); font-weight: 600; line-height: 1.6;
    padding: 0 9px; border-radius: var(--radius-pill); white-space: nowrap;
    background: var(--neutral-bg); color: var(--neutral-ink);
}
.nx-badge--info { background: var(--indigo-bg); color: var(--indigo); }
.nx-badge--success { background: var(--success-bg); color: var(--success); }
.nx-badge--warn { background: var(--warn-bg); color: var(--warn); }
.nx-badge--danger { background: var(--danger-bg); color: var(--danger-ink); }
.nx-badge--sky { background: var(--sky-bg); color: var(--sky); }
.nx-badge--square { border-radius: 5px; }

/* ---------- avatar ---------- */
.nx-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; background: var(--indigo-bg); color: var(--indigo);
}
.nx-avatar--sm { width: 28px; height: 28px; font-size: 12px; }
.nx-avatar--lg { width: 44px; height: 44px; font-size: 17px; }
.nx-avatar--square { border-radius: var(--radius-sm); }
.nx-avatar.t1 { background: var(--success-bg); color: var(--success); }
.nx-avatar.t2 { background: var(--warn-bg); color: var(--warn); }
.nx-avatar.t3 { background: var(--rose-bg); color: var(--rose); }
.nx-avatar.t4 { background: var(--sky-bg); color: var(--sky); }
.nx-avatar.t5 { background: var(--violet-bg); color: var(--violet); }
.nx-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nx-person__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.nx-person__text b { font-weight: 600; }
.nx-person__text span { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- alert ---------- */
.nx-alert {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--indigo-line); background: var(--indigo-bg); color: var(--ink);
    border-radius: var(--radius-sm); padding: 10px 14px; font-size: var(--fs-md); line-height: 1.6;
}
.nx-alert__icon { flex-shrink: 0; }
.nx-alert--success { border-color: var(--success-line); background: var(--success-bg); }
.nx-alert--warn { border-color: var(--warn-line); background: var(--warn-bg); }
.nx-alert--danger { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-ink); }

/* ---------- code / secret ---------- */
.nx-code { font-family: var(--font-mono); font-size: 12px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 5px; padding: 0 5px; word-break: break-all; }
.nx-secret { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; background: var(--paper); border-radius: var(--radius-sm); padding: 10px 12px; font-size: var(--fs-md); }
.nx-secret code { font-family: var(--font-mono); font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; word-break: break-all; }

/* ---------- tabs · menu · code block (rc58 รอบ 2) ---------- */
.nx-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.nx-tab {
    border: none; background: none; padding: 7px 12px; margin-bottom: -1px;
    font-family: inherit; font-size: var(--fs-md); color: var(--muted); cursor: pointer;
    border-bottom: 2px solid transparent;
}
.nx-tab:hover { color: var(--ink); }
.nx-tab[aria-selected="true"], .nx-tab.on { color: var(--indigo); border-bottom-color: var(--indigo); font-weight: 600; }
.nx-menu-wrap { position: relative; display: inline-block; }
.nx-menu {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 220px;
    display: flex; flex-direction: column; padding: 5px; text-align: left;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.nx-menu button, .nx-menu a {
    border: none; background: none; text-align: left; padding: 8px 10px; border-radius: 7px;
    font-family: inherit; font-size: var(--fs-md); color: var(--ink); cursor: pointer; text-decoration: none;
    display: flex; flex-direction: column; gap: 1px;
}
.nx-menu button small { color: var(--muted); font-size: var(--fs-xs); }
.nx-menu button:hover, .nx-menu a:hover, .nx-menu button:focus-visible { background: var(--paper); }
.nx-menu .is-danger { color: var(--danger-ink); }
.nx-menu hr { border: none; border-top: 1px solid var(--line-soft); margin: 4px 0; }
.nx-pre {
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
    background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius-sm);
    padding: 12px 14px; margin: 0; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
label.nx-option { cursor: pointer; }
label.nx-option input { margin-top: 3px; accent-color: var(--indigo); flex-shrink: 0; }
.nx-option.is-danger.on { border-color: var(--danger-line); background: var(--danger-bg); }
.nx-option.is-danger input { accent-color: var(--danger); }
.nx-options--stack { grid-template-columns: 1fr; }

/* ---------- empty · loading ---------- */
.nx-empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--ink); }
.nx-empty__icon { font-size: 34px; line-height: 1; margin-bottom: var(--sp-2); }
.nx-empty__title { font-size: var(--fs-lg); font-weight: 600; margin: 0 0 4px; }
.nx-empty__text { color: var(--muted); font-size: var(--fs-md); margin: 0 auto; max-width: 560px; line-height: 1.7; }
.nx-empty__actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }
.nx-skeleton { display: flex; flex-direction: column; gap: 10px; padding: var(--sp-2) 0; }
.nx-skeleton__row { display: flex; gap: var(--sp-3); }
.nx-skeleton__bar {
    height: 14px; border-radius: 6px; flex: 1;
    background: linear-gradient(90deg, var(--line-soft) 0%, var(--paper) 50%, var(--line-soft) 100%);
    background-size: 200% 100%; animation: nx-shimmer 1.2s ease-in-out infinite;
}
.nx-skeleton__bar.w1 { flex: .4; } .nx-skeleton__bar.w2 { flex: .7; } .nx-skeleton__bar.w3 { flex: 1.3; }
@keyframes nx-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* progress */
.nx-progress { height: 8px; background: var(--line-soft); border-radius: var(--radius-pill); overflow: hidden; }
.nx-progress > div { height: 100%; background: var(--indigo); border-radius: var(--radius-pill); transition: width .3s ease; }
.nx-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--indigo); display: inline-block; animation: nx-pulse 1.2s infinite; }
@keyframes nx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- dialog · drawer ---------- */
.nx-backdrop {
    position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(2px);
    z-index: var(--z-dialog); display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
    animation: nx-fade .15s ease;
}
.nx-dialog {
    background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
    width: 520px; max-width: 100%; max-height: calc(100vh - 40px);
    display: flex; flex-direction: column; outline: none;
    animation: nx-pop .18s cubic-bezier(.2, .8, .3, 1.1);
}
.nx-dialog--sm { width: 420px; }
.nx-dialog--lg { width: 720px; }
.nx-dialog__head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-2); }
.nx-dialog__head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 600; flex: 1; line-height: 1.4; }
.nx-dialog__head p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-md); }
.nx-dialog__body { padding: var(--sp-2) var(--sp-5) var(--sp-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-3); }
.nx-dialog__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) var(--sp-5); flex-wrap: wrap; }
.nx-close {
    border: none; background: none; color: var(--muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 16px; flex-shrink: 0;
}
.nx-close:hover { background: var(--paper); color: var(--ink); }
.nx-drawer-backdrop { position: fixed; inset: 0; background: var(--overlay-soft); z-index: var(--z-drawer); animation: nx-fade .15s ease; }
.nx-drawer {
    position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(480px, calc(100vw - 24px));
    background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
    z-index: calc(var(--z-drawer) + 1); display: flex; flex-direction: column; outline: none;
    animation: nx-slide .18s ease;
}
.nx-drawer__head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line-soft); }
.nx-drawer__title { font-size: var(--fs-lg); font-weight: 600; margin: 0; line-height: 1.4; }
.nx-drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-1) var(--sp-5) var(--sp-5); }
.nx-drawer__section { padding: var(--sp-4) 0; border-bottom: 1px solid var(--line-soft); }
.nx-drawer__section:last-child { border-bottom: none; }
.nx-drawer__section h3 { margin: 0 0 10px; font-size: var(--fs-md); font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.nx-drawer__section h3 a { font-weight: 400; font-size: var(--fs-sm); color: var(--indigo); text-decoration: none; }
@keyframes nx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nx-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes nx-slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- rc61: เนื้อหา markdown จาก AI (แชท · คำตอบคลังความรู้ · บทสรุปเอกสาร) ---------- */
.nx-md { white-space: normal; line-height: 1.7; overflow-wrap: anywhere; }
.nx-md p { margin: 0 0 var(--sp-2); }
.nx-md > :last-child { margin-bottom: 0; }
.nx-md ul, .nx-md ol { margin: var(--sp-1) 0 var(--sp-2); padding-left: 22px; }
.nx-md li + li { margin-top: 2px; }
.nx-md h1, .nx-md h2, .nx-md h3, .nx-md h4 { font-size: var(--fs-lg); font-weight: 600; margin: var(--sp-3) 0 6px; }
.nx-md > h1:first-child, .nx-md > h2:first-child, .nx-md > h3:first-child { margin-top: 0; }
.nx-md hr { border: none; border-top: 1px solid var(--line-soft); margin: 10px 0; }
.nx-md table { border-collapse: collapse; margin: 6px 0; font-size: 13px; display: block; max-width: 100%; overflow-x: auto; }
.nx-md th, .nx-md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.nx-md th { background: var(--paper); font-weight: 600; }
.nx-md code { background: var(--neutral-bg); border-radius: 4px; padding: 1px 4px; font-family: var(--font-mono); font-size: .92em; }
.nx-md pre { background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; }
.nx-md pre code { background: none; padding: 0; color: inherit; }
.nx-md blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--indigo-line); color: var(--muted); }
.nx-md a { color: var(--indigo); }

/* ---------- rc61: หน้าเข้าสู่ระบบ/สมัคร (AuthCard) ---------- */
.nx-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-6) var(--sp-4); background: linear-gradient(160deg, var(--paper) 0%, var(--indigo-bg) 100%); }
.nx-auth__card { position: relative; width: 420px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 34px 40px 30px; }
.nx-auth__card--wide { width: 540px; }
.nx-auth__back { position: absolute; top: var(--sp-4); right: 20px; font-size: var(--fs-sm); color: var(--muted); text-decoration: none; }
.nx-auth__back:hover { color: var(--indigo); }
.nx-auth__brand { font-weight: 600; letter-spacing: .12em; font-size: var(--fs-xl); margin-bottom: 10px; }
.nx-auth__brand em { font-style: normal; color: var(--indigo); }
.nx-auth__card h1 { font-size: 21px; font-weight: 600; margin: 0 0 4px; }
.nx-auth__sub { color: var(--muted); font-size: 13px; margin: 0 0 var(--sp-4); line-height: 1.7; }
.nx-auth__body { display: flex; flex-direction: column; gap: var(--sp-3); }
.nx-auth__body form { display: flex; flex-direction: column; gap: var(--sp-3); }
.nx-auth__submit { width: 100%; min-height: 42px; font-size: var(--fs-lg); font-weight: 600; margin-top: var(--sp-1); }
.nx-auth__foot { font-size: 13px; color: var(--muted); margin-top: var(--sp-4); text-align: center; display: flex; flex-direction: column; gap: 6px; }
.nx-auth__foot a { color: var(--indigo); font-weight: 500; text-decoration: none; }
.nx-auth__foot a:hover { text-decoration: underline; }
.nx-auth__divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.nx-auth__divider::before, .nx-auth__divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.nx-auth__group { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .12em; color: var(--muted); margin-top: var(--sp-2); }
.nx-auth__check { display: flex; gap: 9px; align-items: flex-start; font-size: var(--fs-sm); color: var(--muted); line-height: 1.7; cursor: pointer; }
.nx-auth__check input { margin-top: 4px; accent-color: var(--indigo); }
@media (max-width: 560px) { .nx-auth__card { padding: 26px 22px; } }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .nx-grid-2 { grid-template-columns: 1fr; }
    /* rc63 — ตารางบนมือถือไม่บีบคอลัมน์จนชื่อขาดเป็นคำ ๆ: กว้างขั้นต่ำแล้วเลื่อนแนวนอน (โฟกัสด้วยคีย์บอร์ดได้ — js/nx-ui.js) */
    .nx-table { min-width: 600px; }
    .nx-table .nx-person__text b { white-space: nowrap; }
    .nx-input--search { min-width: 0; width: 100%; }
    .nx-page-head__actions { width: 100%; }
    .nx-dialog__foot .nx-btn { flex: 1 1 auto; }
}

/* ---------- rc73 — แถบความคืบหน้าเมื่อเปลี่ยนหน้า/ส่งฟอร์ม (js/nx-ui.js) ---------- */
.nx-navprog { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity .15s; overflow: visible; }
.nx-navprog.is-on { opacity: 1; }
.nx-navprog__bar { position: absolute; inset: 0; overflow: hidden; background: var(--indigo-line); }
.nx-navprog__bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--indigo); animation: nx-navprog 1.1s ease-in-out infinite; }
.nx-navprog__msg { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: none; padding: 4px 12px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-1); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.nx-navprog.is-slow .nx-navprog__msg:not(:empty) { display: block; }
@keyframes nx-navprog { 0% { left: -40%; } 100% { left: 100%; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
