:root {
    --primary: #1f9d57;
    --primary-dark: #157a43;
    --primary-soft: #e6f6ec;
    --teal: #2a8f7f;
    --teal-dark: #1d6f62;
    --bg: #eef5f3;
    --card: #ffffff;
    --text: #1d2b29;
    --muted: #6a7c78;
    --border: #dce8e4;
    --row: #f6faf9;
    --blue: #2563eb;
    --amber: #d97706;
    --rose: #e11d48;
    --info: #0284c7;
    --radius: 16px;
    --shadow: 0 6px 24px rgba(30, 80, 70, .08);
    --sidebar-w: 270px;
    --topbar-h: 84px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Kanit', system-ui, sans-serif;
    font-weight: 300;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}
h1, h2, h3 { font-weight: 500; margin: 0; line-height: 1.3; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin: 10px 0 6px; display: flex; align-items: center; gap: 6px; }
strong, b { font-weight: 500; }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: #f1f5f4; padding: 1px 6px; border-radius: 6px; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.wrap { word-break: break-all; }
.grow { flex: 1; }
.spacer { flex: 1; }
.inline { display: inline; }
.w-80 { width: 80px; }
.w-num { width: 70px; text-align: center; }
.text-danger { color: var(--rose); }
.ok { color: var(--primary); }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 24px;
    padding: 0 24px;
    background: linear-gradient(100deg, #ffffff 0%, #ffffff 22%, #e9f7f1 45%, #d5efe7 100%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(30, 80, 70, .06);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 240px; }
.brand:hover { text-decoration: none; }
.brand-text strong { display: block; font-size: 1.3rem; font-weight: 600; color: #134e44; }
.brand-text small { color: var(--muted); }
.logo { width: 56px; height: 56px; border-radius: 50%; object-fit: contain; }
.logo-fallback {
    display: inline-flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 30% 30%, #2fb36e, #157a43); color: #fff;
    border: 3px solid #cdeedd;
}
.logo-fallback .icon { width: 28px; height: 28px; }
.system-title {
    flex: 1; display: flex; align-items: center; gap: 12px;
    font-size: 1.15rem; font-weight: 500; color: #134e44; line-height: 1.35;
}
.system-icon {
    display: inline-flex; width: 52px; height: 52px; border-radius: 14px;
    align-items: center; justify-content: center; color: var(--primary);
    background: #fff; box-shadow: var(--shadow);
}
.system-icon .icon { width: 30px; height: 30px; }
.topbar .menu-toggle { display: none; }

.user-menu { position: relative; }
.user-menu summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, .85); padding: 8px 14px; border-radius: 14px;
    box-shadow: var(--shadow);
}
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3cc58a, var(--teal)); color: #fff;
}
.user-meta strong { display: block; font-size: .95rem; }
.user-meta small { color: var(--muted); }
.dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
    background: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    padding: 6px; border: 1px solid var(--border);
}
.dropdown a, .dropdown button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border-radius: 8px; color: var(--text);
    background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--primary-soft); text-decoration: none; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    width: var(--sidebar-w); flex: none;
    background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
    padding: 20px 14px; color: #fff;
    position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
    display: flex; flex-direction: column; overflow-y: auto;
}
.nav-link {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; border-radius: 12px; margin-bottom: 4px;
    color: #eafaf5; font-weight: 400;
}
.nav-link .icon { width: 22px; height: 22px; }
.nav-link:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.nav-link.active { background: #c9f0dc; color: #0f5040; font-weight: 500; box-shadow: 0 4px 12px rgba(0, 0, 0, .1); }
.nav-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin: 16px 16px 6px; }
.sidebar-foot {
    margin-top: auto; display: flex; gap: 10px; align-items: flex-start;
    font-size: .75rem; opacity: .8; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .2);
}
.sidebar-backdrop { display: none; }
.content { flex: 1; min-width: 0; padding: 18px 28px 28px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 24px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.breadcrumb span { color: var(--text); font-weight: 400; }
.breadcrumb .sep { width: 14px; height: 14px; }

/* ---------- Card ---------- */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px; border: 1px solid #e6efec; overflow: hidden;
}
.card.narrow { max-width: 760px; }
.card-head {
    display: flex; align-items: center; gap: 16px; padding: 16px 22px;
    background: linear-gradient(90deg, #f4fbf8, #ffffff);
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head p { margin: 2px 0 0; }
.head-icon {
    width: 56px; height: 56px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #34c27a, var(--primary-dark)); color: #fff;
    box-shadow: 0 6px 14px rgba(31, 157, 87, .3);
}
.head-icon .icon { width: 28px; height: 28px; }
.head-icon.small { width: 40px; height: 40px; background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.head-icon.small .icon { width: 22px; height: 22px; }
.head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 18px 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 .card { margin-bottom: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 14px; background: var(--row); border: 1px solid var(--border); }
.stat small { color: var(--muted); display: block; }
.stat strong { font-size: 1.6rem; font-weight: 600; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.tone-green { color: var(--primary); } .stat-icon.tone-green { background: #dcf5e6; }
.tone-blue { color: var(--blue); } .stat-icon.tone-blue { background: #e0e9ff; }
.tone-amber { color: var(--amber); } .stat-icon.tone-amber { background: #fff1d6; }
.tone-teal { color: var(--teal); } .stat-icon.tone-teal { background: #d9f2ee; }
.tone-rose { color: var(--rose); } .stat-icon.tone-rose { background: #ffe1e8; }

/* ---------- Forms ---------- */
input, select, textarea, button { font-family: inherit; font-size: inherit; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=month], input[type=number],
input[type=search], input[type=file], input:not([type]), select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #cfdcd8; border-radius: 10px;
    background: #fff; color: var(--text); font-weight: 300;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 157, 87, .15); }
input[readonly] { background: #f3f6f5; }
select[multiple] { padding: 6px; }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .75; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child { font-weight: 400; font-size: .92rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 40px; }
.input-icon.sm > .icon { width: 16px; height: 16px; }
.input-icon.sm input { padding: 6px 10px 6px 34px; font-size: .9rem; }
.check-row { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 16px;
    max-height: 320px; overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--row);
}
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters > * { width: auto; flex: 0 1 220px; }
.filters .input-icon { flex: 1 1 260px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.date-nav { display: flex; gap: 6px; align-items: center; }
.date-label { font-weight: 500; color: var(--teal-dark); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 18px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 400; cursor: pointer; white-space: nowrap; line-height: 1.3;
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #24ad61, var(--primary-dark)); color: #fff; box-shadow: 0 4px 12px rgba(31, 157, 87, .3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--text); border-color: #d4e0dc; }
.btn-light:hover { background: #f3f8f6; }
.btn-outline { background: #fff; color: var(--primary-dark); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfe7cf; }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; padding: 12px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
    background: #eef4f2; vertical-align: middle;
}
.icon-btn:hover { filter: brightness(.95); text-decoration: none; }
.icon-btn.tone-blue { background: #e3ebff; }
.icon-btn.tone-teal { background: #dcf2ee; }
.icon-btn.tone-green { background: #dcf5e6; }
.icon-btn.tone-amber { background: #fff0d4; }
.icon-btn.tone-rose { background: #ffe4ea; }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; background: #f1f6f4; padding: 4px; border-radius: 12px; gap: 4px; flex-wrap: wrap; }
.seg-item { padding: 7px 16px; border-radius: 9px; color: var(--text); }
.seg-item:hover { text-decoration: none; background: #fff; }
.seg-item.active { background: var(--primary); color: #fff; font-weight: 400; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: #eaf6f1; font-weight: 500; text-align: left; padding: 11px 12px;
    border-bottom: 1px solid var(--border); white-space: nowrap; color: #1e3d38;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #edf3f1; vertical-align: middle; }
.table tbody tr:hover { background: var(--row); }
.table tfoot td { background: #f5faf8; font-weight: 400; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table.compact input, .table.compact select { padding: 6px 8px; }
.table tr.inactive td { color: #9aa9a6; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }

/* ---------- Badge ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px;
    border-radius: 999px; font-size: .82rem; font-weight: 400; white-space: nowrap;
}
.badge-success { background: #dcf5e6; color: #127040; }
.badge-warning { background: #fff1d6; color: #9a5b00; }
.badge-info { background: #dff1fb; color: #075985; }
.badge-danger { background: #ffe1e8; color: #9f1239; }
.badge-muted { background: #eef2f1; color: #64748b; }
.chip-type { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: #eef4f2; }
.chip-type.type-ward { background: #e5f0ff; color: #1e40af; }
.chip-type.type-service { background: #fdf0de; color: #92400e; }
.type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--teal); }
.type-dot.type-service { background: var(--amber); }

/* ---------- Alerts ---------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px;
    margin-bottom: 14px; border: 1px solid transparent;
}
.alert > span { flex: 1; }
.alert-success { background: #e8f8ee; border-color: #bfe7cf; color: #11532f; }
.alert-error { background: #fff0f3; border-color: #ffc9d5; color: #8a1030; }
.alert-warning { background: #fff7e6; border-color: #fde2a7; color: #7a4a00; }
.alert-info { background: #ebf6fd; border-color: #bfe3f7; color: #0c4a6e; }
.alert-close { background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.temp-pass .secret { font-size: 1.05rem; }

/* ---------- Progress ---------- */
.progress-line { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.bar { flex: 1; min-width: 160px; height: 10px; border-radius: 99px; background: #e4eeeb; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #34c27a, var(--teal)); border-radius: 99px; transition: width .4s; }

/* ---------- Roster editor ---------- */
.picker { padding: 12px 16px; border-bottom: 1px dashed var(--border); }
.picker:last-child { border-bottom: 0; }
.roster-picker { border: 1px solid var(--border); border-radius: 14px; background: #fbfdfc; padding: 16px; margin-bottom: 16px; }
.shift-pickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 16px; }
.shift-pickers .roster-picker { margin-bottom: 0; border-top-width: 4px; }
.shift-morning { border-top-color: #f2b705; }
.shift-afternoon { border-top-color: #e8590c; }
.shift-night { border-top-color: #3b5bdb; }
.group-row th { background: var(--row); text-align: left; font-weight: 600; border-left: 4px solid var(--border); }
.shift-row-morning th { border-left-color: #f2b705; }
.shift-row-afternoon th { border-left-color: #e8590c; }
.shift-row-night th { border-left-color: #3b5bdb; }
.picker-label { font-weight: 400; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.count { background: var(--primary); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 9px; min-width: 24px; text-align: center; }
.count.zero { background: #cbd5d2; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; margin-bottom: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
    border-radius: 999px; background: #fff; border: 1px solid #bfe2d1; font-size: .9rem;
}
.chip small { color: var(--muted); margin-left: 6px; font-size: .75rem; }
.chip b { font-weight: 400; }
.chip-x { border: 0; background: #eef4f2; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); padding: 0; }
.chip-x:hover { background: #ffe1e8; color: var(--rose); }
.chip-x .icon { width: 14px; height: 14px; }
.chip.flash { animation: flash 1s; }
@keyframes flash { from { background: #c9f0dc; } to { background: #fff; } }
.picker-open .icon { width: 16px; height: 16px; }

/* ---------- Modal (ป๊อปอัปเลือกบุคลากร) ---------- */
.modal {
    width: min(560px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 48px));
    padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 24px 64px rgba(0, 0, 0, .2);
    color: var(--text); flex-direction: column; overflow: hidden;
}
.modal[open] { display: flex; }
.modal::backdrop { background: rgba(20, 50, 45, .45); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: linear-gradient(90deg, #e2f5ec, #f3faf7); border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; color: #134e44; }
.modal-search { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.modal-list { flex: 1; overflow-y: auto; padding: 6px 10px 10px; min-height: 160px; }
.modal-group { font-size: .8rem; color: var(--muted); padding: 10px 8px 4px; position: sticky; top: -6px; background: #fff; }
.modal-empty { text-align: center; color: var(--muted); padding: 32px 0; }
.modal-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-list .check { padding: 6px 8px; border-radius: 8px; }
.check-list .check:hover { background: var(--row); }
.check-list .check[hidden] { display: none; }
.modal-head .d-block { display: block; font-weight: 400; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--row); flex-wrap: wrap; }
.person {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer;
}
.person:hover, .person:focus-visible { background: var(--primary-soft); outline: none; }
.person-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.person-info b { font-weight: 400; }
.person-info small { color: var(--muted); font-size: .8rem; }
.person-tag { font-size: .8rem; color: var(--primary-dark); background: var(--primary-soft); padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.person:hover .person-tag { background: var(--primary); color: #fff; }
.person.added { cursor: default; opacity: .6; }
.person.added:hover { background: none; }
.person.added .person-tag { background: #eef2f1; color: var(--muted); }

/* ---------- Files ---------- */
.file-list { list-style: none; margin: 0 0 12px; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #edf3f1; flex-wrap: wrap; }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.upload-row input[type=file] { flex: 1; min-width: 220px; }
.p4p-search { margin-bottom: 20px; }
.p4p-results { margin-top: 10px; }
.p4p-status:empty { display: none; }
.p4p-status { padding: 6px 2px; font-size: .9rem; }
.p4p-list { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; border-radius: 12px; }
.p4p-list:has(.p4p-item) { border: 1px solid var(--border); }
.p4p-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid #edf3f1; background: #fff; font: inherit; color: inherit; cursor: pointer; }
.p4p-item:last-child { border-bottom: 0; }
.p4p-item:hover:not(:disabled), .p4p-item:focus-visible { background: var(--row); outline: none; }
.p4p-item:disabled { cursor: default; opacity: .65; }
.p4p-item .p4p-info { min-width: 0; }
.p4p-action { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: .88rem; font-weight: 600; color: var(--primary, #0f766e); }
.p4p-action .icon { width: 16px; height: 16px; }
.p4p-item:disabled .p4p-action { color: var(--muted); font-weight: 400; }
.error-list { max-height: 240px; overflow: auto; color: #8a1030; font-size: .9rem; }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.pager-info { margin-right: auto; color: var(--muted); font-size: .88rem; margin-top: 10px; }
.pg { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--border); color: var(--text); background: #fff; }
.pg:hover { text-decoration: none; background: var(--row); }
.pg.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg.disabled { opacity: .4; pointer-events: none; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.steps { padding-left: 20px; margin: 8px 0 16px; }
.steps li { margin-bottom: 6px; }
.secret-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--row); border: 1px dashed #b7d8cc; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.secret-box small { width: 100%; color: var(--muted); }
.secret { font-size: 1.1rem; letter-spacing: .08em; background: #fff; padding: 4px 10px; }

/* ---------- Auth ---------- */
.auth-body { background: linear-gradient(135deg, #dff3ea 0%, #f4fbf8 45%, #e2f1fb 100%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
    background: linear-gradient(160deg, var(--teal) 0%, var(--teal-dark) 70%); color: #fff;
    padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 20px;
}
.auth-brand { display: flex; gap: 14px; align-items: center; }
.auth-brand strong { display: block; font-size: 1.4rem; font-weight: 600; }
.auth-brand small { opacity: .8; }
.auth-hero h1 { font-size: 2.1rem; font-weight: 600; }
.auth-hero p { opacity: .9; max-width: 520px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, .1); padding: 10px 14px; border-radius: 12px; max-width: 460px; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 20px; }
.auth-panel > .alert { width: 100%; max-width: 440px; }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 20px; box-shadow: 0 16px 48px rgba(20, 70, 60, .14); padding: 32px; }
.auth-card h2 { font-size: 1.4rem; display: flex; gap: 8px; align-items: center; }
.auth-card .muted { margin: 4px 0 20px; }
.hint { font-size: .82rem; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 16px; }
.otp-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; }
.error-card { text-align: center; }
.error-code { font-size: 4rem; font-weight: 600; color: var(--primary); }
.debug { text-align: left; font-size: .75rem; background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 320px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .system-title { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    :root { --topbar-h: 68px; }
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar .menu-toggle { display: inline-flex; }
    .brand { min-width: 0; }
    .brand-text small, .user-meta, .user-menu .chev { display: none; }
    .logo { width: 42px; height: 42px; }
    .brand-text strong { font-size: 1.05rem; }
    .user-menu { margin-left: auto; }
    .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .3); z-index: 35; }
    .content { padding: 14px 16px; }
    .card-head, .card-body { padding: 14px 16px; }
    .head-actions { margin-left: 0; width: 100%; }
    .form-grid, .form-grid.cols-4 { grid-template-columns: 1fr; }
    .span-2, .span-4 { grid-column: auto; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { padding: 28px 20px; }
    .auth-hero h1 { font-size: 1.5rem; }
    .auth-points { display: none; }
    .kv { grid-template-columns: 1fr; }
    .filters > * { flex: 1 1 100%; }
}

/* ---------- เพิ่มผู้ใช้จาก P4P ---------- */
.p4p-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf3f1; flex-wrap: wrap; }
.p4p-info { flex: 1; min-width: 240px; display: flex; flex-direction: column; }
.p4p-add { flex-basis: 100%; }
.p4p-add > summary { list-style: none; display: inline-flex; }
.p4p-add > summary::-webkit-details-marker { display: none; }
.p4p-add[open] > summary { margin-bottom: 10px; }
.p4p-add form { background: var(--row); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.badge-source { background: #efe9ff; color: #5b21b6; }
