/* Same look as the PFS Dashboard (PFS-Dashboard-Demo): purple clay sidebar, glass cards, IBM Plex Sans Thai. */
:root {
    --bg-1: #ebe7fb;
    --bg-2: #f7f2fb;
    --ink: #2b2550;
    --ink-2: #5d5786;
    --ink-3: #8d88ad;
    --brand: #6c5ce7;
    --brand-2: #8f7ff2;
    --brand-deep: #5143c9;
    --brand-soft: #efecfd;
    --glass: rgba(255, 255, 255, .72);
    --glass-line: rgba(255, 255, 255, .85);
    --line: #e6e2f5;
    --good: #15803d;
    --good-soft: #e7f6ec;
    --danger: #be123c;
    --danger-soft: #fff0f3;
    --warn: #b45309;
    --clay: 0 18px 36px -16px rgba(91, 72, 200, .35), 0 2px 6px -2px rgba(91, 72, 200, .12), inset 0 1px 0 #fff, inset 0 -5px 12px rgba(120, 100, 220, .08);
    --radius: 24px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans Thai", "Sukhumvit Set", "Leelawadee UI", system-ui, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--bg-2);
}
/* Fixed background layer, as on the dashboard, so scrolling doesn't repaint the whole page. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(1200px 600px at 85% -10%, #fbe3f1 0%, transparent 60%),
                radial-gradient(900px 500px at 0% 100%, #dfe6ff 0%, transparent 60%),
                linear-gradient(160deg, var(--bg-1), var(--bg-2));
}
[hidden] { display: none !important; }
a { color: var(--brand-deep); }
code { font-size: .9em; background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- buttons & fields ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid var(--glass-line);
    background: rgba(255, 255, 255, .85);
    box-shadow: 0 6px 14px -8px rgba(91, 72, 200, .35), inset 0 1px 0 #fff;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { background: #fff; box-shadow: 0 10px 18px -10px rgba(91, 72, 200, .5), inset 0 1px 0 #fff; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .nav a:focus-visible, .dock a:focus-visible, .dock button:focus-visible { outline: 3px solid rgba(108, 92, 231, .35); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
    border: 0;
    color: #fff;
    background: linear-gradient(150deg, var(--brand-2), var(--brand-deep));
    box-shadow: 0 12px 22px -10px rgba(81, 67, 201, .8), inset 0 2px 0 rgba(255, 255, 255, .35), inset 0 -4px 8px rgba(40, 25, 140, .3);
}
.btn-primary:hover { background: linear-gradient(150deg, var(--brand), var(--brand-deep)); }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: #f8cdd7; }
.btn-danger:hover { background: #ffe4ea; }
.btn-sm { min-height: 34px; padding: 0 13px; font-size: 13.5px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .input {
    height: 44px;
    padding: 0 14px;
    border: 1px solid #ddd8f3;
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    font-size: 15px;
    font-weight: 400;
    color: var(--ink);
}
.field textarea { height: auto; padding: 10px 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, .2);
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- auth ---------- */
.auth {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 16px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px 26px;
    border-radius: 30px;
    background: var(--glass);
    border: 1px solid var(--glass-line);
    box-shadow: var(--clay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-logo {
    width: 60px;
    height: 60px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(108, 92, 231, .14), 0 10px 20px -8px rgba(81, 67, 201, .5);
}
.auth-logo img { width: 40px; height: auto; }
.auth-brand h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.eyebrow { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--brand); }
.auth-lead { margin: 0 0 4px; color: var(--ink-2); }
.auth-note { margin: 2px 0 0; text-align: center; font-size: 13px; color: var(--ink-3); }
.auth-note.left { text-align: left; }
.auth-back { font-size: 14px; font-weight: 600; text-decoration: none; }

/* ---------- shell (sidebar like the dashboard) ---------- */
.app {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    gap: 24px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px;
}
.sidebar {
    position: sticky;
    top: 24px;
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 22px 16px;
    border-radius: 30px;
    color: #fff;
    background: linear-gradient(165deg, var(--brand-2) 0%, var(--brand) 55%, var(--brand-deep) 100%);
    box-shadow: 0 26px 50px -20px rgba(81, 67, 201, .65), inset 0 2px 0 rgba(255, 255, 255, .35), inset 0 -10px 20px rgba(40, 25, 140, .25);
}
.profile { text-align: center; padding: 6px 0 16px; }
.avatar {
    width: 84px;
    height: 84px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, .28), 0 12px 24px -8px rgba(30, 20, 110, .5), inset 0 -4px 8px rgba(108, 92, 231, .2);
}
.avatar img { width: 60px; height: auto; }
.profile b { display: block; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile span { display: block; margin-top: 2px; font-size: 13px; opacity: .85; }

.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-label { margin: 14px 12px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 16px;
    color: rgba(255, 255, 255, .92);
    font-size: 14.5px;
    text-decoration: none;
    transition: background .2s, color .2s;
}
.nav a i { width: 20px; text-align: center; font-size: 16px; }
.nav a:hover { background: rgba(255, 255, 255, .14); }
.nav a[aria-current="page"], .nav a[aria-current="page"]:hover {
    background: #fff;
    color: var(--brand-deep);
    font-weight: 600;
    box-shadow: 0 10px 20px -10px rgba(30, 20, 110, .6), inset 0 -3px 6px rgba(108, 92, 231, .15);
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .2); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: rgba(255, 255, 255, .88);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.sidebar-foot button:hover { background: rgba(255, 255, 255, .14); }
.sidebar-foot button i { width: 20px; text-align: center; }

main { min-width: 0; padding-bottom: 24px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { margin: 0 0 6px; font-size: 14px; }
.crumb a { text-decoration: none; font-weight: 600; }

.card {
    background: var(--glass);
    border: 1px solid var(--glass-line);
    border-radius: var(--radius);
    box-shadow: var(--clay);
}
/* The paper form stays on a white sheet so it reads like the printed PR. */
.paper-card { overflow-x: auto; padding: 10px; }
.paper-card .pr-form { min-width: 900px; border-radius: 16px; box-shadow: 0 1px 0 rgba(43, 37, 80, .06); }

.action-bar {
    position: sticky;
    bottom: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 12px 14px 12px 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .86);
    border: 1px solid var(--glass-line);
    box-shadow: var(--clay);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.action-bar .spacer { flex: 1; }
.action-status { font-size: 14px; color: var(--ink-3); }
.action-status.is-warn { color: var(--warn); font-weight: 600; }

.notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 11px 16px;
    border-radius: 16px;
    font-size: 14px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--glass-line);
}
.notice i { margin-top: 3px; }
.notice.is-info { background: rgba(239, 236, 253, .85); border-color: #ddd6fb; color: var(--brand-deep); }
.notice.is-danger { background: rgba(255, 240, 243, .9); border-color: #f8cdd7; color: var(--danger); }

.meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); }
.meta-row strong { color: var(--ink); font-weight: 600; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.cancel { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #f0eef8; color: var(--ink-3); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }

/* ---------- list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.filters .search { position: relative; flex: 1 1 260px; }
.filters .search i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.filters .search .input { width: 100%; padding-left: 42px; border-radius: 999px; }
.filters select.input { flex: 0 1 220px; border-radius: 999px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    padding: 11px 16px;
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-3);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.is-link { cursor: pointer; transition: background .15s; }
table.data tbody tr.is-link:hover { background: rgba(108, 92, 231, .06); }
table.data .num { text-align: right; }
.cell-sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-3); }
.empty i { display: block; margin-bottom: 8px; font-size: 28px; color: #c4bdea; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }

/* ---------- admin ---------- */
.subtabs { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; background: rgba(255, 255, 255, .6); border: 1px solid var(--glass-line); }
.subtabs button { padding: 7px 18px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.subtabs button.is-active { background: linear-gradient(150deg, var(--brand-2), var(--brand-deep)); color: #fff; box-shadow: 0 8px 16px -8px rgba(81, 67, 201, .8); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.section-head p { margin: 0; font-size: 14px; color: var(--ink-2); }

/* ---------- dialog ---------- */
dialog {
    width: min(480px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--glass-line);
    border-radius: 26px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 30px 60px -12px rgba(43, 37, 80, .35);
    color: var(--ink);
}
dialog::backdrop { background: rgba(43, 37, 80, .35); backdrop-filter: blur(4px); }
dialog form, .account-panel { display: flex; flex-direction: column; gap: 14px; padding: 24px 24px 20px; }
dialog h2 { margin: 0; font-size: 19px; }
dialog .hint { margin: -6px 0 0; font-size: 14px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

#toast {
    position: fixed;
    left: 50%;
    top: 24px;
    z-index: 100;
    max-width: calc(100vw - 32px);
    padding: 12px 20px;
    border-radius: 999px;
    background: linear-gradient(150deg, var(--brand), var(--brand-deep));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 16px 30px -10px rgba(81, 67, 201, .7);
    opacity: 0;
    transform: translate(-50%, -12px);
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
#toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
#toast.is-error { background: var(--danger); box-shadow: 0 16px 30px -10px rgba(190, 18, 60, .6); }

.loading { padding: 48px; text-align: center; color: var(--ink-3); }
.dock { display: none; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; padding: 16px 16px 110px; }
    .sidebar { display: none; }
    .page-head h1 { font-size: 22px; }
    .grid-2 { grid-template-columns: 1fr; }
    .action-bar { border-radius: 22px; bottom: 96px; padding: 10px 12px; }
    .action-bar .action-status { flex-basis: 100%; }
    .dock {
        position: fixed;
        left: 50%;
        bottom: 16px;
        z-index: 20;
        display: flex;
        gap: 2px;
        width: max-content;
        max-width: calc(100% - 24px);
        padding: 6px;
        border-radius: 999px;
        transform: translateX(-50%);
        background: rgba(108, 92, 231, .9);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        box-shadow: 0 18px 36px -12px rgba(81, 67, 201, .7), inset 0 2px 0 rgba(255, 255, 255, .3);
    }
    .dock[hidden] { display: none !important; }
    .dock a, .dock button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 7px 13px;
        border: 0;
        border-radius: 999px;
        background: none;
        color: rgba(255, 255, 255, .88);
        font-size: 11.5px;
        text-decoration: none;
        cursor: pointer;
    }
    .dock i { font-size: 17px; }
    .dock a[aria-current="page"] { background: #fff; color: var(--brand-deep); font-weight: 600; }
}
@media (max-width: 400px) {
    .dock a, .dock button { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- sign-up and approvals ---------- */
.link-btn {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.link-btn:hover { color: var(--brand-deep); }
#signup-done { display: grid; gap: 14px; }
#signup-done[hidden] { display: none; }
.badge.warn { background: #fff4e0; color: var(--warn); }
tr.is-pending td { background: rgba(255, 244, 224, .45); }
.dialog-actions .btn-danger { margin-right: auto; color: var(--danger); }
