/* =====================================================================
   BorderPermit · ລະບົບຂໍອະນຸຍາດລົດ
   ແນວຄິດ: ເອກະສານລາຊະການ (ສີກົມທ່າ) + ປ້າຍທະບຽນລົດທຸລະກິດ (ສີເຫຼືອງ)
   ອອກແບບໃຫ້ມືຖືກ່ອນ ແລ້ວຂະຫຍາຍເປັນຄອມ (≥ 960px)
   ===================================================================== */

:root {
    --ink: #16325C;          /* ສີຫຼັກ: ກົມທ່າເອກະສານລາຊະການ */
    --ink-deep: #0E2342;     /* ແຖບຂ້າງ */
    --ink-soft: #E7EDF6;
    --paper: #F2F4F1;        /* ພື້ນຫຼັງ */
    --surface: #FFFFFF;
    --line: #D9DFE5;
    --line-strong: #B9C3CE;
    --text: #1C2733;
    --muted: #5B6573;
    --plate: #F6C400;        /* ປ້າຍທະບຽນລົດທຸລະກິດ */
    --plate-edge: #000000;
    --go: #1E7D4F;
    --go-soft: #E3F2EA;
    --stop: #C23B2E;
    --stop-soft: #FBE9E6;
    --wait: #8A5300;
    --wait-soft: #FFF3D1;
    --check: #2F5FA8;
    --check-soft: #E4ECF8;

    --font: "Noto Sans Lao", "Phetsarath OT", "Saysettha OT", system-ui, sans-serif;
    --font-head: "Noto Sans Lao Looped", "Noto Sans Lao", "Phetsarath OT", sans-serif;

    --r-panel: 14px;
    --r-ctrl: 10px;
    --r-plate: 6px;
    --tap: 48px;             /* ຂະໜາດແຕະຂັ້ນຕ່ຳໃນມືຖື */
    --bb-h: 64px;            /* ແຖບເມນູລຸ່ມ */
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;            /* 16px ກັນ iOS zoom ຕອນແຕະ input */
    line-height: 1.65;          /* ພາສາລາວມີສະຫຼະເທິງ-ລຸ່ມ ຕ້ອງການບ່ອນຫວ່າງ */
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.4; margin: 0; color: var(--ink); }
h1 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); font-weight: 700; }
h2 { font-size: 1.08rem; font-weight: 700; }
h3 { font-size: 1rem; }
p { margin: 0 0 .5rem; }
a { color: var(--check); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
code { font-size: .9em; background: var(--ink-soft); padding: .1em .4em; border-radius: 4px; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

:focus-visible { outline: 3px solid var(--plate); outline-offset: 2px; border-radius: 4px; }

.icon { flex: none; display: inline-block; vertical-align: middle; }
.flip { transform: rotate(180deg); }
.rot-up { transform: rotate(-90deg); }
.rot-down { transform: rotate(90deg); }
.hint { color: var(--muted); font-size: .85rem; }
.muted { opacity: .55; }

/* ---------------------------------------------------------------------
   ໂຄງໜ້າ: ມືຖື = topbar + ເມນູລຸ່ມ, ຄອມ = ແຖບຂ້າງ
   --------------------------------------------------------------------- */
.shell { min-height: 100dvh; }

.side { display: none; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(.55rem + var(--safe-t)) 1rem .55rem;
    background: var(--ink); color: #fff;
}

.main {
    padding: 1.1rem 1rem calc(var(--bb-h) + var(--safe-b) + 1.5rem);
    max-width: 1180px;
    margin: 0 auto;
}
.main-plain { padding: 0; max-width: none; }

.bottombar {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    display: flex;
    height: calc(var(--bb-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.bb-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font: inherit; font-size: .74rem; line-height: 1.3; color: var(--muted); text-decoration: none;
    background: none; border: 0; cursor: pointer; position: relative;
}
.bb-link.active { color: var(--ink); font-weight: 600; }
.bb-link.active::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    background: var(--plate); border-radius: 0 0 3px 3px;
}

@media (min-width: 960px) {
    .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
    .topbar, .bottombar { display: none; }
    .side {
        display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100dvh;
        background: var(--ink-deep); color: #C9D4E3;
        padding: 1.25rem .85rem 1rem;
    }
    .main { padding: 2rem 2.25rem 3rem; width: 100%; }
}

/* ---------- ໂລໂກ້ ---------- */
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark {
    display: grid; place-items: center; width: 40px; height: 40px; flex: none;
    background: var(--plate); color: #000; border-radius: var(--r-plate);
    box-shadow: inset 0 0 0 2px #000;
}
.brand-compact .brand-mark { width: 34px; height: 34px; }
.brand-name { display: block; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.brand-sub { display: block; font-size: .78rem; opacity: .7; line-height: 1.3; }

/* ---------- ແຖບຂ້າງ (ຄອມ) ---------- */
.side .brand { padding: 0 .5rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: .75rem; }
.side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side-group { font-size: .78rem; color: #8B9AB0; padding: 1rem .75rem .35rem; }
.side-link {
    display: flex; align-items: center; gap: .7rem;
    min-height: 44px; padding: .45rem .75rem;
    color: inherit; text-decoration: none; border-radius: var(--r-ctrl);
    font: inherit; background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
.side .side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side .side-link.active { background: rgba(246,196,0,.14); color: #fff; box-shadow: inset 3px 0 0 var(--plate); }
.side-user {
    display: flex; align-items: center; gap: .6rem;
    padding: .9rem .5rem 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: .75rem;
}
.side-user form { margin-left: auto; }
.side .icon-btn { color: #C9D4E3; }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.side-user-text strong { color: inherit; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .side-user-text strong { color: #fff; }
.side-user-text span { font-size: .8rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
    display: grid; place-items: center; width: 38px; height: 38px; flex: none;
    border-radius: 50%; background: var(--ink-soft); color: var(--ink); font-weight: 700;
}
.avatar-btn { border: 2px solid rgba(255,255,255,.35); cursor: pointer; font: inherit; font-weight: 700; }

/* ---------------------------------------------------------------------
   ອົງປະກອບພື້ນຖານ
   --------------------------------------------------------------------- */
.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem;
    margin-bottom: 1.1rem;
}
.lead { color: var(--muted); margin: .15rem 0 0; }
.back-link {
    display: inline-flex; align-items: center; gap: .25rem;
    color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: .35rem;
}
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.narrow { max-width: 640px; margin-inline: auto; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    padding: 1rem;
    margin-bottom: 1rem;
}
@media (min-width: 720px) { .panel { padding: 1.25rem 1.4rem; } }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-bottom: .9rem;
}
.panel-head h2 { display: flex; align-items: center; gap: .55rem; }
.link { font-size: .9rem; text-decoration: none; font-weight: 600; }
.sub { margin: 1rem 0 .4rem; font-size: .95rem; }

.step {
    display: inline-grid; place-items: center; width: 26px; height: 26px;
    border-radius: 50%; background: var(--ink); color: #fff;
    font-family: var(--font); font-size: .82rem; font-weight: 700;
}

/* ---------- ປຸ່ມ ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: var(--tap); padding: .5rem 1.1rem;
    font: inherit; font-weight: 600; line-height: 1.3;
    border-radius: var(--r-ctrl); border: 1px solid transparent;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ink-deep); color: #fff; }
.btn-approve { background: var(--go); color: #fff; }
.btn-approve:hover:not(:disabled) { background: #176240; color: #fff; }
.btn-danger { background: var(--stop); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.btn-ghost.danger { color: var(--stop); }
.btn-ghost.danger:hover:not(:disabled) { border-color: var(--stop); color: var(--stop); }
.btn-dashed {
    background: transparent; border: 1.5px dashed var(--line-strong); color: var(--ink);
    flex-wrap: wrap; white-space: normal; text-align: center;
}
.btn-dashed:hover { border-color: var(--ink); background: var(--ink-soft); }
.btn-sm { min-height: 38px; padding: .3rem .8rem; font-size: .9rem; }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-grow { flex: 1; }

.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
    border: 0; border-radius: var(--r-ctrl); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--ink-soft); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger:hover { background: var(--stop-soft); color: var(--stop); }

/* ---------- ຊ່ອງປ້ອນຂໍ້ມູນ ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; margin: 0; border: 0; padding: 0; }
.field > span:first-child, .field > legend { font-size: .9rem; font-weight: 600; color: var(--text); padding: 0; }
.input {
    width: 100%; min-height: var(--tap);
    padding: .55rem .8rem;
    font: inherit; color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-ctrl);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22,50,92,.15); }
.input::placeholder { color: #9AA4AF; }
textarea.input { min-height: 96px; resize: vertical; }
select.input {
    appearance: none; padding-right: 2.2rem; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235B6573' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .6rem center;
}
.input.bad, .input.invalid { border-color: var(--stop); background: #FFFBFA; }
.input.num { font-variant-numeric: tabular-nums; }

/* ຊ່ອງວັນທີ/ເວລາ: iOS Safari ໃຫ້ຄວາມກວ້າງຂັ້ນຕ່ຳຂອງມັນເອງ (ລົ້ນຂອບຂວາ) ແລະ ຈັດກາງ → ບັງຄັບໃຫ້ພໍດີຊ່ອງ ແລະ ຊິດຊ້າຍ */
input.input[type="date"], input.input[type="time"], input.input[type="datetime-local"], input.input[type="month"] {
    -webkit-appearance: none; appearance: none;
    max-width: 100%; min-width: 0; text-align: left; line-height: 1.5;
}
input.input[type="date"]:not(.input-auto):not(.input-date),
input.input[type="time"]:not(.input-auto),
input.input[type="datetime-local"]:not(.input-auto) { display: block; width: 100%; }
input.input[type="date"]::-webkit-date-and-time-value,
input.input[type="time"]::-webkit-date-and-time-value,
input.input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.input-plate { font-weight: 700; letter-spacing: .03em; }
.input-auto { width: auto; max-width: 100%; text-overflow: ellipsis; }
.input-date { min-height: 40px; padding: .3rem .6rem; }
.field-error, .validation-message { color: var(--stop); font-size: .85rem; margin: 0; }

.grid-2, .grid-3, .grid-form { display: grid; gap: .9rem 1rem; }
/* grid ທີ່ບໍ່ໄດ້ກຳນົດຖັນ (ມືຖື) → 1 ຖັນທີ່ຫົດໄດ້ ບໍ່ໃຫ້ເນື້ອຫາຍາວດັນໃຫ້ກວ້າງເກີນຈໍ.
   ຕັ້ງໄວ້ກ່ອນ @media ຂອງແຕ່ລະອັນ ເພື່ອໃຫ້ກົດຂອງຈໍໃຫຍ່ທັບໄດ້ */
.grid-2, .grid-3, .grid-form, .cards, .actions-hero, .grid-dash, .detail-grid, .checkgrid, .perm-layout,
.vreg-grid, .vrd-wrap, .dept-list, .queues, .choice-row { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
    .grid-2, .grid-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid-3 { margin: .9rem 0; }

.row-tight { display: flex; gap: .5rem; }
.row-tight select { flex: 1; min-width: 0; }

.stepper {
    display: inline-flex; align-items: center; flex: none;
    border: 1.5px solid var(--line-strong); border-radius: var(--r-ctrl); overflow: hidden;
}
.stepper button {
    width: 40px; height: calc(var(--tap) - 3px); border: 0; background: var(--paper);
    font-size: 1.25rem; color: var(--ink); cursor: pointer;
}
.stepper button:active { background: var(--ink-soft); }
.stepper span { min-width: 4.2em; text-align: center; font-weight: 600; font-size: .9rem; }

.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
    min-height: 40px; padding: .35rem .9rem;
    font: inherit; font-size: .9rem; color: var(--text);
    border: 1.5px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-static {
    display: inline-block; min-height: 0; padding: .05rem .6rem; margin-left: .4rem;
    font-size: .78rem; border-color: var(--line); background: var(--ink-soft); color: var(--ink); cursor: default;
}

/* ---------- ປ້າຍທະບຽນ: ຈຸດເດັ່ນຂອງທັງລະບົບ ---------- */
.plate {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 6.5em; padding: .12em .65em;
    font-family: var(--font); font-weight: 700; font-size: 1rem; line-height: 1.5;
    letter-spacing: .04em; white-space: nowrap; font-variant-numeric: tabular-nums;
    color: #000; background: var(--plate);
    border-radius: var(--r-plate);
    box-shadow: inset 0 0 0 2px var(--plate-edge), inset 0 0 0 4px var(--plate);
}
.plate-sm { min-width: 5.6em; font-size: .86rem; padding: .05em .5em; box-shadow: inset 0 0 0 1.5px #000; }
.plate-xl { font-size: clamp(2rem, 6vw, 3.4rem); padding: .1em .55em; box-shadow: inset 0 0 0 4px #000, inset 0 0 0 8px var(--plate); }
.more { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---------- ສະຖານະ ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .1rem .65rem; border-radius: 999px;
    font-size: .8rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-draft     { background: #ECEEF1; color: #4E5865; }
.badge-pending   { background: var(--wait-soft); color: var(--wait); }
.badge-checking  { background: var(--check-soft); color: var(--check); }
.badge-approved  { background: var(--go-soft); color: var(--go); }
.badge-rejected  { background: var(--stop-soft); color: var(--stop); }
.badge-cancelled { background: #ECEEF1; color: #7A838E; text-decoration: line-through; }
.badge-signing   { background: #EFE7FB; color: #6A3FB0; }
.badge-ready     { background: #DFF3F4; color: #136A72; }

/* ---------- ແຖບກອງ ---------- */
.tabs {
    display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none;
    margin: 0 -1rem .8rem; padding: 0 1rem .2rem;
    -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 960px) { .tabs { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; } }
.tab {
    flex: none; display: inline-flex; align-items: center; gap: .45rem;
    min-height: 42px; padding: .3rem .95rem;
    font: inherit; font-size: .92rem; color: var(--muted);
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.tab-n {
    min-width: 1.6em; padding: 0 .4em; border-radius: 999px;
    background: var(--paper); color: var(--text); font-size: .78rem; text-align: center; font-weight: 600;
}
.tab.on .tab-n { background: var(--plate); color: #000; }

.searchbar { position: relative; margin-bottom: 1rem; }
.searchbar .icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbar .input { padding-left: 2.6rem; }
.searchbar-inline { flex: 1; min-width: 220px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }

/* ---------- ລາຍການຄຳຂໍ ---------- */
.plist { display: flex; flex-direction: column; gap: .55rem; }
.prow {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .9rem;
    width: 100%; padding: .85rem 1rem;
    font: inherit; text-align: left; color: inherit; text-decoration: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); cursor: pointer;
    transition: border-color .15s;
}
.prow:hover { border-color: var(--line-strong); color: inherit; }
.prow:active { background: #FAFBFC; }
.prow-plates { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.prow-main { min-width: 0; display: flex; flex-direction: column; }
.prow-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow-meta { display: flex; flex-wrap: wrap; gap: .1rem .9rem; color: var(--muted); font-size: .84rem; }
.prow-meta span { display: inline-flex; align-items: center; gap: .2rem; }
.prow-reason { color: var(--stop); font-size: .84rem; }
.prow-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: .2rem; }
.prow-side time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.plist { container-type: inline-size; }
@container (min-width: 640px) {
    .prow { grid-template-columns: minmax(170px, 230px) minmax(0, 1fr) auto; align-items: center; }
    .prow-plates { grid-column: auto; }
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.pager-info { color: var(--muted); font-size: .88rem; text-align: center; }

/* ---------- ໜ້າຫຼັກ: ບໍລິສັດ ---------- */
.actions-hero { display: grid; gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .actions-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.hero-btn {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.2rem; min-height: 84px;
    background: var(--surface); color: var(--ink); text-decoration: none;
    border: 1px solid var(--line); border-radius: var(--r-panel);
}
.hero-btn span { flex: 1; display: flex; flex-direction: column; line-height: 1.4; }
.hero-btn strong { font-family: var(--font-head); font-size: 1.12rem; }
.hero-btn small { color: var(--muted); font-size: .85rem; }
.hero-btn:hover { border-color: var(--ink); color: var(--ink); }
.hero-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.hero-primary small { color: #C9D4E3; }
.hero-primary .icon:first-child { color: var(--plate); }
.hero-primary:hover { background: var(--ink-deep); color: #fff; }

/* ---------- ໜ້າຫຼັກ: ເຈົ້າໜ້າທີ່ ---------- */
.queues {
    display: grid; margin-bottom: 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden;
}
@media (min-width: 720px) { .queues { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); } }
.queue {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .9rem;
    padding: .9rem 1.1rem; background: var(--surface); color: var(--text); text-decoration: none;
    outline: 1px solid var(--line); outline-offset: -.5px;
}
.queue:hover { background: #FAFBFC; color: var(--text); }
.queue .icon { color: var(--line-strong); }
.queue-n {
    font-size: 1.7rem; font-weight: 700; line-height: 1.2; color: var(--ink);
    min-width: 2ch; font-variant-numeric: tabular-nums;
}
.queue-label { font-size: .9rem; color: var(--muted); line-height: 1.4; }
.queue.hot { box-shadow: inset 4px 0 0 var(--plate); }
.queue.hot .queue-label { color: var(--text); font-weight: 600; }

.grid-dash { display: grid; gap: 0 1rem; }
@media (min-width: 1040px) { .grid-dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: start; } }

.bars { display: flex; align-items: flex-end; gap: .5rem; height: 170px; padding-top: .5rem; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .25rem; }
.bar { width: 100%; max-width: 38px; background: var(--ink); border-radius: 6px 6px 2px 2px; }
.bar-col:last-child .bar { background: var(--plate); box-shadow: inset 0 0 0 1.5px #000; }
.bar-n { font-size: .8rem; font-weight: 600; color: var(--text); }
.bar-d { font-size: .74rem; color: var(--muted); }

/* ---------- ແບບຟອມຂໍອະນຸຍາດ ---------- */
.form-page { max-width: 860px; }
.vlist { display: flex; flex-direction: column; gap: .8rem; margin-bottom: .9rem; }
.vcard {
    border: 1px solid var(--line); border-radius: var(--r-ctrl);
    background: #FBFCFB; padding: .9rem;
}
.vcard-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; min-height: 40px; }
.vcard-head .icon-btn { margin-left: auto; }
.vcard-no { font-weight: 700; color: var(--ink); }

.filepick-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
    min-height: 120px; padding: 1rem; text-align: center;
    border: 1.5px dashed var(--line-strong); border-radius: var(--r-ctrl);
    background: #FBFCFB; color: var(--ink); cursor: pointer;
}
.filepick-drop:hover { border-color: var(--ink); background: var(--ink-soft); }
.filepick-drop.busy { opacity: .6; pointer-events: none; }
.filepick-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filepick-title { font-weight: 600; }
.filelist { list-style: none; margin: .7rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.filelist li {
    display: flex; align-items: center; gap: .55rem;
    padding: .3rem .3rem .3rem .75rem; border: 1px solid var(--line); border-radius: var(--r-ctrl); background: var(--surface);
}
.filelist-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ແຖບປຸ່ມ: ມືຖືຕິດຢູ່ລຸ່ມຈໍ ເໜືອເມນູ */
.actionbar {
    position: sticky; bottom: calc(var(--bb-h) + var(--safe-b)); z-index: 20;
    display: flex; flex-wrap: wrap; gap: .5rem;
    margin: 1rem -1rem 0; padding: .75rem 1rem;
    /* ສີທຶບ ບໍ່ໃຊ້ backdrop-filter: iOS (Safari / Messenger) ແຕ້ມເງົາຂອງແຖບນີ້ຜິດບ່ອນຕອນເລື່ອນ */
    background: #F2F4F1;
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(14,35,66,.06);
    transform: translateZ(0); -webkit-transform: translateZ(0);
}
@media (min-width: 960px) {
    .actionbar {
        bottom: 0; margin: 1rem 0 0; padding: .9rem 0;
        justify-content: flex-end; background: #F2F4F1; box-shadow: none;
    }
    .actionbar .btn-grow { flex: 0 0 auto; min-width: 200px; }
}

/* ---------- ລາຍລະອຽດ ---------- */
.detail-grid { display: grid; gap: 0 1rem; }
@media (min-width: 1040px) { .detail-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.detail-grid .stack { gap: 0; }

.kv { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .4rem; display: flex; flex-direction: column; line-height: 1.45; }
.timeline li::before {
    content: ""; position: absolute; left: calc(-1.1rem - 7px); top: .35em;
    width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--line-strong);
}
.timeline p { margin: .25rem 0 0; font-size: .9rem; background: var(--paper); padding: .35rem .6rem; border-radius: 8px; }
.timeline .tl-pending::before  { border-color: #D39B00; }
.timeline .tl-checking::before { border-color: var(--check); }
.timeline .tl-approved::before { border-color: var(--go); background: var(--go); }
.timeline .tl-rejected::before, .timeline .tl-cancelled::before { border-color: var(--stop); }

/* ---------- ຕາຕະລາງ: ຄອມ = ຕາຕະລາງ, ມືຖື = ບັດ ---------- */
.rtable { width: 100%; border-collapse: collapse; font-size: .95rem; }
.rtable th {
    text-align: left; font-weight: 600; font-size: .84rem; color: var(--muted);
    padding: .55rem .7rem; border-bottom: 1.5px solid var(--line-strong); white-space: nowrap;
}
.rtable td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rtable .num { text-align: right; font-variant-numeric: tabular-nums; }
.rtable tr.sel td { background: #FFFBEA; }
.td-action { text-align: right; white-space: nowrap; }

@media (max-width: 759px) {
    .rtable thead { display: none; }
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable tr {
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
        padding: .55rem .9rem; margin-bottom: .55rem;
    }
    .rtable td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        padding: .3rem 0; border: 0; text-align: right;
    }
    .rtable td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex: none; }
    .rtable .num { text-align: right; }
    .rtable .td-action { justify-content: flex-end; padding-top: .5rem; }
    .rtable .td-check { justify-content: flex-start; }
    .panel > .rtable tr { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .6rem 0; margin: 0; }
    .panel > .rtable tr:last-child { border-bottom: 0; }
}
@media (min-width: 760px) {
    .rtable { background: var(--surface); }
    :not(.panel) > .rtable { border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; border-collapse: separate; border-spacing: 0; }
    .rtable tbody tr:hover td { background: #FAFBFC; }
    .rtable tbody tr:last-child td { border-bottom: 0; }
}

.bulkbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .55rem .9rem; margin-bottom: .6rem;
    background: var(--ink-soft); border-radius: var(--r-ctrl);
    position: sticky; top: 64px; z-index: 10;
}
@media (min-width: 960px) { .bulkbar { top: 0; } }

.expiry { font-weight: 600; font-variant-numeric: tabular-nums; }
.expiry.expired { color: var(--stop); }
.expiry.soon { color: var(--wait); }

.quota { display: inline-flex; align-items: center; gap: .5rem; font-variant-numeric: tabular-nums; }
.quota-bar { width: 64px; height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--ink); }

/* ---------- ບັດຄຳຂໍໃຊ້ລະບົບ ---------- */
.cards { display: grid; gap: .7rem; }
@media (min-width: 900px) { .cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.rcard {
    display: flex; flex-direction: column; gap: .45rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 1rem;
}
.rcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.rcard-contact { margin: 0; }
.rcard-note { margin: 0; font-size: .9rem; color: var(--muted); }
.rcard-foot { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: auto; padding-top: .4rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.checklist li { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.checklist .check span { font-size: .82rem; color: var(--muted); min-width: 5.5em; }

/* ---------- ຕັ້ງຄ່າ ---------- */
.narrow-panel { max-width: 760px; }
.md-add { display: flex; gap: .5rem; margin: .5rem 0 .75rem; }
.md-msg { margin: 0 0 .5rem; }
.md-list { list-style: none; margin: 0; padding: 0; }
.md-list li {
    display: flex; align-items: center; gap: .6rem;
    min-height: 52px; padding: .2rem 0; border-bottom: 1px solid var(--line);
}
.md-list li:last-child { border-bottom: 0; }
.md-no { width: 2em; text-align: right; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; flex: none; }
.md-name { flex: 1; min-width: 0; }
.md-edit { flex: 1; }
.md-actions { display: flex; flex: none; }
@media (max-width: 520px) { .md-actions .icon-btn { width: 36px; } }

/* ---------- ແຈ້ງເຕືອນ ---------- */
.alert {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .75rem .95rem; margin-bottom: 1rem;
    border-radius: var(--r-ctrl); border: 1px solid; font-size: .95rem;
}
.alert .icon { margin-top: .2em; }
.alert-err  { background: var(--stop-soft); border-color: #F0C4BE; color: #8E2A20; }
.alert-warn { background: var(--wait-soft); border-color: #F0D78A; color: #6B4100; }
.alert-info { background: var(--check-soft); border-color: #C5D5EE; color: #22477E; }
.alert-ok   { background: var(--go-soft); border-color: #BCDFCB; color: #165E3B; }
.alert-link { text-decoration: none; }
.alert-link:hover { filter: brightness(.98); }

.toast {
    position: fixed; z-index: 60; left: 50%; top: calc(.75rem + var(--safe-t));
    display: flex; align-items: center; gap: .5rem;
    max-width: calc(100vw - 2rem); padding: .65rem 1.1rem;
    background: var(--ink-deep); color: #fff; border-radius: 999px;
    box-shadow: 0 8px 24px rgba(14,35,66,.25);
    animation: toast 4.5s ease forwards;
}
.toast .icon { color: var(--plate); }
.toast-err { background: var(--stop); }
.toast-err .icon { color: #fff; }
@keyframes toast {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    6%, 85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -12px); visibility: hidden; }
}

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h1, .empty h2 { margin-bottom: .5rem; }
.empty .btn { margin-top: .75rem; }
.empty-sm { padding: 1.5rem .5rem; }
.loading { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Sheet / Dialog ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(14,35,66,.45); animation: fade .2s ease; }
.sheet {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column;
    max-height: 90dvh; padding-bottom: var(--safe-b);
    background: var(--surface); border-radius: 18px 18px 0 0;
    animation: sheet-up .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-head {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .9rem 1rem .6rem 1.1rem; border-bottom: 1px solid var(--line);
}
.sheet-head::before {
    content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong);
}
.sheet-body { padding: 1rem 1.1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; }
.sheet-foot { display: flex; gap: .5rem; padding: .75rem 1.1rem 1rem; border-top: 1px solid var(--line); }
.sheet-plate { display: flex; align-items: center; gap: .75rem; }
.drawer-links { gap: 2px; }
.drawer-links .side-link { color: var(--text); }
.drawer-links .side-link.active { background: var(--ink-soft); color: var(--ink); font-weight: 600; }
.drawer-links .side-link.danger { color: var(--stop); margin-top: .5rem; }
.drawer .side-user-text strong { color: var(--ink); }

@media (min-width: 720px) {
    .sheet {
        left: 50%; right: auto; bottom: auto; top: 50%;
        width: min(580px, calc(100vw - 2rem)); max-height: 85dvh;
        transform: translate(-50%, -50%);
        border-radius: var(--r-panel);
        animation: pop .18s ease;
    }
    .sheet-head::before { display: none; }
    .drawer { left: auto; right: 0; top: 0; bottom: 0; width: 320px; max-height: none; transform: none; border-radius: 0; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%); } }

/* ---------- ໜ້າເຂົ້າສູ່ລະບົບ ---------- */
.auth { min-height: 100dvh; display: grid; }
.auth-art {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
    padding: calc(2.2rem + var(--safe-t)) 1.5rem 2.2rem;
    background: var(--ink-deep); color: #C9D4E3; text-align: center;
}
.auth-road {
    position: absolute; inset: 0; opacity: .5; pointer-events: none;
    background:
        linear-gradient(90deg, transparent calc(50% - 2px), rgba(246,196,0,.55) calc(50% - 2px), rgba(246,196,0,.55) calc(50% + 2px), transparent calc(50% + 2px)) 0 0 / 100% 48px,
        linear-gradient(90deg, transparent 18%, rgba(255,255,255,.12) 18%, rgba(255,255,255,.12) calc(18% + 2px), transparent calc(18% + 2px), transparent calc(82% - 2px), rgba(255,255,255,.12) calc(82% - 2px), rgba(255,255,255,.12) 82%, transparent 82%);
    -webkit-mask: linear-gradient(transparent, #000 30%, #000 70%, transparent);
            mask: linear-gradient(transparent, #000 30%, #000 70%, transparent);
}
.auth-road { background-repeat: repeat-y, no-repeat; }
.auth-art .plate { position: relative; transform: rotate(-3deg); }
.auth-tag { position: relative; margin: 0; font-size: 1rem; line-height: 1.7; }
.auth-card { padding: 2rem 1.25rem 3rem; width: 100%; max-width: 440px; margin: 0 auto; }
.auth-card .brand { color: var(--ink); margin-bottom: 1.5rem; }
.auth-card h1 { margin-bottom: 1.1rem; }
.auth-foot { margin-top: 1.5rem; text-align: center; color: var(--muted); font-size: .92rem; }
@media (max-width: 959px) {
    .auth-art .plate-xl { font-size: 2.1rem; }
    .auth-card .brand { display: none; }
}
@media (min-width: 960px) {
    .auth { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
    .auth-art { padding: 3rem; }
    .auth-card { align-self: center; padding: 3rem 2rem; }
}

.done { text-align: center; padding: 2.5rem 1.25rem; }
.done-mark {
    display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 1rem;
    border-radius: 50%; background: var(--go-soft); color: var(--go);
}
.done p { color: var(--muted); margin-bottom: 1.25rem; }

/* ---------- ຂໍ້ຜິດພາດ Blazor ---------- */
#blazor-error-ui {
    display: none; position: fixed; z-index: 70; left: 0; right: 0; bottom: 0;
    padding: .8rem 1rem calc(.8rem + var(--safe-b));
    background: var(--stop); color: #fff;
}
#blazor-error-ui a { color: #fff; font-weight: 700; margin-left: .5rem; }

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

/* ໜ້າທີ່ບໍ່ຕ້ອງເຂົ້າລະບົບ (ຍື່ນຂໍນຳໃຊ້) */
.main-plain > .narrow, .main-plain > .empty { padding: calc(1.25rem + var(--safe-t)) 1rem 3rem; }

/* =====================================================================
   ຮອບ 2: ຂັ້ນຕອນ 4 ຂັ້ນ · ສິດ · ໂລໂກ້ · ລາຍເຊັນ · ເອກະສານພິມ
   ===================================================================== */

/* ຕົວເລກງານລໍຖ້າໃນເມນູ */
.nav-badge {
    margin-left: auto; min-width: 22px; padding: 0 .4rem; border-radius: 999px;
    background: var(--plate); color: #000; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.6;
}
.bb-badge {
    position: absolute; top: 6px; left: calc(50% + 6px);
    min-width: 18px; padding: 0 .3rem; border-radius: 999px;
    background: var(--stop); color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.5; text-align: center;
}
.tab-hot:not(.on) { border-color: var(--plate); }
.tab-hot:not(.on) .tab-n { background: var(--plate); color: #000; }

/* ໂລໂກ້ */
.brand-mark-img { background: #fff; box-shadow: none; overflow: hidden; padding: 3px; }
.brand-mark-img img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo { position: relative; max-width: 120px; max-height: 120px; object-fit: contain; background: #fff; border-radius: 16px; padding: 8px; }
.logo-editor { display: flex; flex-direction: column; gap: .9rem; align-items: flex-start; }
.logo-preview { display: flex; flex-wrap: wrap; gap: .75rem; }
.logo-sample { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: var(--r-ctrl); color: var(--ink); }
.logo-sample-dark { background: var(--ink-deep); color: #fff; border-color: var(--ink-deep); }
.filepick-sm { min-height: 92px; width: 100%; }

/* ແຖບຂັ້ນຕອນ */
.wsteps {
    list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 1rem; padding: .85rem .5rem .7rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.wstep { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; }
.wstep:not(:last-child)::after {
    content: ""; position: absolute; top: 14px; left: calc(50% + 18px); right: calc(-50% + 18px);
    height: 2px; background: var(--line);
}
.wstep-done:not(:last-child)::after { background: var(--go); }
.wstep-dot {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    font-size: .82rem; font-weight: 700; background: var(--paper); color: var(--muted); border: 2px solid var(--line);
}
.wstep-done .wstep-dot { background: var(--go); border-color: var(--go); color: #fff; }
.wstep-now .wstep-dot { background: var(--plate); border-color: #000; color: #000; }
.wstep-label { font-size: .8rem; line-height: 1.35; color: var(--muted); }
.wstep-now .wstep-label { color: var(--ink); font-weight: 700; }
.wsteps-returned { opacity: .55; }

/* ຕິກເລືອກແບບບັດ (ສາຍທາງ, ໝາຍເຫດ, ກຸ່ມສິດ) */
.checkgrid { display: grid; gap: .45rem; }
@media (min-width: 640px) { .checkgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.check-card {
    align-items: flex-start; padding: .6rem .75rem; min-height: 48px;
    border: 1.5px solid var(--line); border-radius: var(--r-ctrl); background: var(--surface); line-height: 1.5;
}
.check-card input { margin-top: .2em; }
.check-card.on { border-color: var(--ink); background: var(--ink-soft); }
.chip-route { cursor: default; display: inline-flex; align-items: center; gap: .3rem; background: var(--ink-soft); border-color: transparent; color: var(--ink); }
.notes { margin: .75rem 0 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .25rem; }

/* ລາຍເຊັນ */
.sig-preview {
    display: grid; place-items: center; padding: 1rem; min-height: 120px;
    background: repeating-linear-gradient(0deg, #fff, #fff 27px, #EEF1F4 28px);
    border: 1px dashed var(--line-strong); border-radius: var(--r-ctrl);
}
.sig-preview img { max-height: 110px; max-width: 100%; object-fit: contain; }

/* ໜ້າສິດການນຳໃຊ້ */
.perm-layout { display: grid; gap: 1rem; }
@media (min-width: 900px) { .perm-layout { grid-template-columns: 260px minmax(0, 1fr); align-items: start; } }
.perm-groups { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .2rem; }
@media (min-width: 900px) { .perm-groups { flex-direction: column; overflow: visible; position: sticky; top: 1rem; } }
.perm-group {
    flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
    min-width: 170px; padding: .7rem .9rem; text-align: left; font: inherit; color: var(--text);
    background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-ctrl); cursor: pointer;
}
.perm-group.on { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--plate); }
.perm-editor { display: flex; flex-direction: column; gap: 1rem; margin: 0; }
.perm-cat { border: 0; margin: 0; padding: 0; }
.perm-cat legend { font-family: var(--font-head); font-weight: 700; color: var(--ink); margin-bottom: .45rem; padding: 0; }
.perm-item {
    display: flex; align-items: flex-start; gap: .7rem; padding: .6rem .7rem; margin-bottom: .35rem;
    border: 1.5px solid var(--line); border-radius: var(--r-ctrl); cursor: pointer;
}
.perm-item.on { border-color: var(--go); background: var(--go-soft); }
.perm-item input { width: 20px; height: 20px; margin-top: .2em; accent-color: var(--go); flex: none; }
.perm-item span { display: flex; flex-direction: column; line-height: 1.45; }
.perm-item small { color: var(--muted); font-size: .84rem; }
.perm-foot { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- ເອກະສານສຳລັບພິມ ---------- */
.print-doc { display: none; }

@media print {
    @page { size: A4; margin: 14mm 14mm 16mm; }
    .side, .topbar, .bottombar, .actionbar, .no-print, .toast, .sheet, .sheet-backdrop, #blazor-error-ui { display: none !important; }
    body { background: #fff; font-size: 11.5pt; line-height: 1.55; color: #000; }
    .shell { display: block; }
    .main { padding: 0; max-width: none; }
    .print-doc { display: block; }
    .plate { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================================
   ແຊັດ (ອອກແບບໃໝ່): ຂໍ້ຄວາມທີ່ອ້າງອີງຄຳຂໍ = "ໃບຄຳຂໍ" ນ້ອຍ, ເຫດການ = ໃບແຈ້ງມີຕາປະທັບ
   ===================================================================== */
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ໜ້າແຊັດເຕັມຈໍ: ຕັດ padding / ຄວາມກວ້າງສູງສຸດຂອງ .main ອອກ */
.main:has(> .chat-page) { max-width: none; padding: 0; }
.chat-page {
    display: flex; width: 100%; min-height: 360px;
    height: calc(100dvh - 56px - var(--safe-t) - var(--bb-h) - var(--safe-b));
}
@media (min-width: 960px) { .chat-page { height: 100dvh; } }
.chat-page > .chat { flex: 1; }

.chat-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; width: 100%; }
.chat-split.show-thread .chat-list, .chat-split.show-list .chat-main { display: none; }
@media (min-width: 960px) {
    .chat-split { grid-template-columns: 340px minmax(0, 1fr); gap: 0; overflow: hidden; background: var(--surface); }
    .chat-split .chat-list, .chat-split .chat-main { display: flex !important; }
    .chat-split .chat-list { border: 0; border-right: 1px solid var(--line); border-radius: 0; }
    .chat-split .chat { border: 0; border-radius: 0; }
    .chat-back { display: none; }
}

/* ---------- ລາຍການຫ້ອງ ---------- */
.chat-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
@media (max-width: 959px) { .chat-list { border: 0; } }
.chat-list-head { padding: 1rem 1rem .5rem; }
.chat-list-head h1 { font-size: 1.2rem; margin-bottom: .7rem; }
.chat-list-head .searchbar { margin-bottom: .6rem; }
.chat-filter { display: flex; gap: .35rem; }
.chat-filter button {
    font: inherit; font-size: .85rem; padding: .2rem .8rem; min-height: 34px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
}
.chat-filter button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chat-items { flex: 1; overflow-y: auto; padding: .25rem .5rem .75rem; }
.chat-items-empty { padding: 1rem; }
.chat-item {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 0 .7rem; align-items: center;
    padding: .6rem .6rem; border-radius: 12px; color: var(--text); text-decoration: none;
}
.chat-item + .chat-item { margin-top: 2px; }
.chat-item:hover { background: #F5F7F9; color: var(--text); }
.chat-item.on { background: var(--ink-soft); }
.chat-item .avatar { grid-row: 1 / 3; width: 44px; height: 44px; }
.chat-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45; }
.chat-item time { font-size: .76rem; color: var(--muted); }
.chat-item-preview { font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45; }
.chat-item .nav-badge { margin: 0; justify-self: end; }
.chat-item.unread .chat-item-name { color: var(--ink); }
.chat-item.unread .chat-item-preview { color: var(--text); font-weight: 600; }
.chat-item.unread time { color: var(--ink); font-weight: 700; }

/* ສີອະວາຕາຕາມຊື່ (6 ສີ ສະບາຍຕາ) */
.av-0 { background: #E4ECF8; color: #22477E; }
.av-1 { background: #E3F2EA; color: #165E3B; }
.av-2 { background: #FFF3D1; color: #6B4100; }
.av-3 { background: #EFE7FB; color: #5B3699; }
.av-4 { background: #DFF3F4; color: #136A72; }
.av-5 { background: #FBE9E6; color: #8E2A20; }
.avatar-staff { background: var(--plate); color: #000; box-shadow: inset 0 0 0 2px #000; border-radius: 10px; }

.chat-main { display: flex; min-height: 0; min-width: 0; }
.chat-main > .chat { flex: 1; }
.chat-placeholder { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 2rem; }
.chat-placeholder .plate { margin-bottom: .9rem; }

/* ---------- ຫ້ອງແຊັດ ---------- */
.chat {
    display: flex; flex-direction: column; min-height: 0; min-width: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden;
}
.chat-page > .chat, .chat-split .chat { border: 0; border-radius: 0; }
.chat-head {
    display: flex; align-items: center; gap: .65rem; padding: .6rem .9rem;
    border-bottom: 1px solid var(--line); background: var(--surface);
}
.chat-head .avatar { width: 40px; height: 40px; }
.chat-title { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.chat-title strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .hint { display: flex; align-items: center; gap: .35rem; }
.dot-hours { width: 8px; height: 8px; border-radius: 50%; background: var(--go); flex: none; }

.chat-body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    padding: 1rem clamp(.75rem, 3vw, 1.75rem) 1.25rem;
    display: flex; flex-direction: column; gap: .2rem;
    background-color: #EEF1EC;
    background-image: radial-gradient(rgba(22,50,92,.06) 1px, transparent 1px);
    background-size: 18px 18px;
}
.chat-more { align-self: center; margin-bottom: .5rem; }
.chat-day {
    align-self: center; margin: .9rem 0 .5rem; padding: .1rem .8rem;
    font-size: .78rem; color: var(--muted); background: var(--surface); border-radius: 999px; border: 1px solid var(--line);
}
.chat-empty { margin: auto; max-width: 340px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .6rem; }

/* ກຸ່ມຂໍ້ຄວາມ: ຄົນດຽວກັນສົ່ງຕິດກັນ ສະແດງຊື່ ແລະ ອະວາຕາຄັ້ງດຽວ */
.mgroup { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0 .5rem; margin-top: .55rem; max-width: min(86%, 560px); }
.mgroup-me { align-self: flex-end; grid-template-columns: minmax(0, 1fr); justify-items: end; }
.mgroup .avatar { width: 32px; height: 32px; font-size: .85rem; align-self: end; grid-row: 1 / span 20; }
.mgroup-name { font-size: .78rem; color: var(--muted); margin: 0 0 .2rem .35rem; }
.mgroup-me .mgroup-name { display: none; }
.mgroup > .msg { grid-column: 2; }
.mgroup-me > .msg { grid-column: 1; }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 3px; min-width: 0; max-width: 100%; }
.mgroup-me .msg { align-items: flex-end; }
.msg-bubble {
    position: relative; display: flex; flex-direction: column; gap: .45rem;
    padding: .5rem .8rem .35rem; border-radius: 18px; max-width: 100%;
    background: var(--surface); color: var(--text);
    box-shadow: 0 1px 1.5px rgba(14,35,66,.12);
    overflow-wrap: anywhere;
}
.mgroup-them .msg:last-child .msg-bubble { border-bottom-left-radius: 6px; }
.mgroup-me .msg-bubble { background: var(--ink); color: #fff; box-shadow: none; }
.mgroup-me .msg:last-child .msg-bubble { border-bottom-right-radius: 6px; }
.msg-text { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.msg-time { align-self: flex-end; font-size: .7rem; line-height: 1.2; color: var(--muted); display: inline-flex; align-items: center; gap: .2rem; margin-top: -.15rem; }
.mgroup-me .msg-time { color: #AFC0D6; }
.msg-time .icon { color: var(--plate); }

/* ຮູບ: ໃຫຍ່ ເຕັມຟອງ */
.msg-bubble.has-media { padding: 4px; }
.msg-bubble.has-media .msg-text { padding: .3rem .55rem 0; }
.msg-bubble.has-media .msg-time { padding: 0 .5rem .3rem; }
.msg-imgs { display: grid; gap: 3px; grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 15px; overflow: hidden; }
.msg-imgs.one { grid-template-columns: minmax(0, 1fr); }
.msg-imgs img { display: block; width: 100%; height: 100%; max-height: 260px; min-height: 120px; object-fit: cover; background: #DDE3EA; }
.msg-imgs.one img { width: min(280px, 64vw); }

/* ໄຟລ໌ PDF: ບັດມີປ້າຍປະເພດໄຟລ໌ */
.msg-file {
    display: flex; align-items: center; gap: .65rem; min-width: min(240px, 60vw);
    padding: .45rem .55rem; border-radius: 12px; text-decoration: none; color: inherit;
    background: var(--paper); border: 1px solid var(--line);
}
.mgroup-me .msg-file { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: #fff; }
.msg-file-ext {
    display: grid; place-items: center; width: 38px; height: 44px; flex: none; border-radius: 6px;
    background: #C23B2E; color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .02em;
    clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%);
}
.msg-file-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.msg-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.msg-file-size { font-size: .76rem; opacity: .7; }

/* ---------- ຈຸດເດັ່ນ: ໃບຄຳຂໍ ທີ່ແນບໃນຂໍ້ຄວາມ ---------- */
.slip {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .75rem; align-items: center;
    padding: .55rem .7rem; min-width: min(250px, 62vw); text-decoration: none; color: var(--text);
    background: #FFFDF4; border: 1px solid #E8D9A6; border-radius: 10px;
    border-left: 5px solid var(--plate);
}
.slip:hover { color: var(--text); border-color: #D9C27A; }
.slip-no { font-weight: 700; color: var(--ink); font-size: .92rem; }
.slip .badge { font-size: .72rem; }
.slip-plates { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .25rem; }
.slip-plates .plate-sm { font-size: .74rem; min-width: 0; }

/* ---------- ເຫດການ: ສົ່ງກັບແກ້ໄຂ / ອະນຸມັດ / ຍົກເລີກ ---------- */
.event {
    align-self: center; width: min(440px, 100%); margin: .9rem 0 .4rem;
    background: var(--surface); border-radius: 14px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(14,35,66,.12); border: 1px solid var(--line);
}
.event-head { display: flex; align-items: center; gap: .55rem; padding: .55rem .85rem; font-weight: 700; }
.event-returned .event-head { background: var(--wait-soft); color: #6B4100; }
.event-approved .event-head { background: var(--go-soft); color: #165E3B; }
.event-cancelled .event-head { background: var(--stop-soft); color: #8E2A20; }
.event-head time { margin-left: auto; font-weight: 400; font-size: .75rem; opacity: .8; }
.event-body { padding: .65rem .85rem .75rem; display: flex; flex-direction: column; gap: .55rem; }
.event-body p { margin: 0; }
.event-who { font-size: .8rem; color: var(--muted); }
.event .slip { min-width: 0; }
.event-actions { display: flex; gap: .4rem; }
.event-stamp {
    margin-left: .6rem; transform: rotate(-6deg);
    font-size: .72rem; font-weight: 700; padding: 0 .45rem; border: 2px solid currentColor; border-radius: 4px; line-height: 1.6;
}

/* ---------- ຊ່ອງພິມ ---------- */
.chat-compose { padding: .5rem .75rem calc(.6rem + 0px); border-top: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: .45rem; }
.quick { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button {
    flex: none; font: inherit; font-size: .84rem; padding: .2rem .75rem; min-height: 34px;
    border-radius: 999px; border: 1px dashed var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.quick button:hover { border-style: solid; background: var(--ink-soft); }
.compose-row {
    display: flex; align-items: flex-end; gap: .25rem;
    padding: .25rem .25rem .25rem .3rem; border: 1.5px solid var(--line-strong); border-radius: 24px; background: var(--surface);
}
.compose-row:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22,50,92,.12); }
.compose-input {
    flex: 1; min-height: 40px; max-height: 140px; resize: none; field-sizing: content;
    border: 0; box-shadow: none !important; padding: .5rem .3rem; background: transparent;
}
.compose-input:focus { box-shadow: none; }
.compose-btn {
    position: relative; overflow: hidden; display: grid; place-items: center; flex: none;
    width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.compose-btn:hover { background: var(--ink-soft); color: var(--ink); }
.compose-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compose-send { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; background: var(--plate); color: #000; cursor: pointer; box-shadow: inset 0 0 0 1.5px #000; }
.compose-send:disabled { background: var(--paper); color: var(--line-strong); box-shadow: none; cursor: default; }
.compose-ref, .compose-files li {
    display: inline-flex; align-items: center; gap: .35rem; width: fit-content; max-width: 100%;
    padding: .1rem .15rem .1rem .6rem; border-radius: 999px; font-size: .84rem;
}
.compose-ref { background: #FFFDF4; border: 1px solid #E8D9A6; border-left: 4px solid var(--plate); color: var(--ink); font-weight: 600; }
.compose-attachments { display: flex; flex-wrap: wrap; gap: .35rem; }
.compose-files { list-style: none; margin: 0; padding: 0; display: contents; }
.compose-files li { border: 1px solid var(--line); background: var(--paper); }
.compose-files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.compose-ref .icon-btn, .compose-files .icon-btn { width: 26px; height: 26px; }
.chat-body > * { flex-shrink: 0; }
.compose-row textarea.compose-input { min-height: 40px; height: auto; resize: none; }
@supports not (field-sizing: content) { .compose-row textarea.compose-input { height: 40px; } }
.mgroup-them .msg-time .icon { display: none; }

.msg-file-ext.ext-png, .msg-file-ext.ext-jpg, .msg-file-ext.ext-jpeg { background: #2F5FA8; }

/* ---------- ເລືອກວິທີສົ່ງເອກະສານ (ຂັ້ນສຸດທ້າຍ) ---------- */
.choice-list { display: flex; flex-direction: column; gap: .45rem; }
.choice {
    display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; cursor: pointer;
    border: 1.5px solid var(--line); border-radius: var(--r-ctrl); background: var(--surface);
}
.choice input { width: 18px; height: 18px; accent-color: var(--ink); flex: none; margin: 0; }
.choice .icon { color: var(--muted); }
.choice span { display: flex; flex-direction: column; line-height: 1.4; }
.choice small { color: var(--muted); font-size: .84rem; }
.choice.on { border-color: var(--ink); background: var(--ink-soft); }
.choice.on .icon { color: var(--ink); }

/* ---------- ສ້າງ PDF / ຮູບ ຈາກເອກະສານ (ນອກຈໍ) ---------- */
.print-doc.exporting {
    display: block; position: fixed; left: -10000px; top: 0; width: 794px; min-height: 1123px;
    padding: 40px 48px; background: #fff; color: #000;
}

/* ຈໍກວ້າງ: ເນື້ອຫາແຊັດບໍ່ຍືດເກີນໄປ */
@media (min-width: 1400px) {
    .chat-body { padding-inline: max(1.75rem, calc((100% - 900px) / 2)); }
    .chat-compose { padding-inline: max(.75rem, calc((100% - 900px) / 2)); }
}

/* =====================================================================
   ເອກະສານທາງການ (ອ້າງອີງ) ຂອງບໍລິສັດ
   ===================================================================== */
.refdocs-sum { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.refdocs-sum .ok { color: var(--go); font-weight: 600; }
.refdocs-sum .bad { color: var(--stop); font-weight: 600; }
.refdocs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.refdoc {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem; align-items: center;
    padding: .6rem .75rem; border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
    border-radius: var(--r-ctrl); background: var(--surface);
}
.refdoc.verified { border-left-color: var(--go); }
.refdoc.expired { border-left-color: var(--stop); background: #FFFBFA; }
.refdoc-main { display: flex; flex-direction: column; min-width: 0; gap: .15rem; }
.refdoc-title { color: var(--ink); line-height: 1.45; }
.refdoc-meta { display: flex; flex-wrap: wrap; gap: .1rem .8rem; font-size: .82rem; color: var(--muted); }
.refdoc-meta .warn, .doccard-exp.warn { color: var(--wait); font-weight: 600; }
.refdoc-meta .bad, .doccard-exp.bad { color: var(--stop); font-weight: 600; }
.refdoc-files { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.refdoc-file {
    display: inline-flex; align-items: center; gap: .25rem; max-width: 100%;
    padding: .1rem .55rem; border-radius: 999px; font-size: .82rem; text-decoration: none;
    background: var(--ink-soft); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.refdoc-file:hover { background: #D6E1F1; color: var(--ink); }
.refdoc-check {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; padding: .3rem .65rem; min-height: 38px;
    border: 1.5px solid var(--line-strong); border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--muted);
}
.refdoc-check input { width: 18px; height: 18px; accent-color: var(--go); margin: 0; }
.refdoc.verified .refdoc-check { border-color: var(--go); background: var(--go-soft); color: var(--go); }
.refdoc-by { grid-column: 1 / -1; font-size: .76rem; color: var(--muted); }
.refdocs-empty {
    display: flex; align-items: center; gap: .6rem; padding: .8rem .9rem;
    border: 1.5px dashed var(--line-strong); border-radius: var(--r-ctrl); color: var(--muted); font-size: .9rem;
}

/* minmax(0,1fr): ບໍ່ໃຫ້ຊື່ໄຟລ໌ຍາວດັນບັດໃຫ້ກວ້າງເກີນຈໍ (ມືຖື) */
.docgrid { display: grid; gap: .8rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .docgrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); } }
.doccard {
    display: flex; flex-direction: column; gap: .6rem; padding: 1rem; min-width: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.doccard.expired { border-color: #F0C4BE; }
.doccard-head { display: flex; align-items: flex-start; gap: .7rem; }
.doccard-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 10px; background: #FFF3D1; color: #8A5300; }
.doccard-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.doccard-title strong { color: var(--ink); }
.doccard-exp { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0; font-size: .88rem; color: var(--muted); }
.doccard .filelist { margin: 0; }
.doccard-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; margin-top: auto; }
.doccard .filelist li { min-width: 0; }

/* =====================================================================
   ປະກາດ
   ===================================================================== */
.ann-list { display: flex; flex-direction: column; gap: .8rem; max-width: 820px; }
.ann {
    position: relative; padding: 1rem 1.15rem 1rem 1.3rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.ann::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ink); }
.ann-company::before { background: #2F5FA8; }
.ann-staff::before { background: #6A3FB0; }
.ann.pinned { border-color: #E8D9A6; background: #FFFDF4; }
.ann.pinned::before { background: var(--plate); }
.ann.inactive { opacity: .6; }
.ann-head { display: flex; align-items: flex-start; gap: .5rem; }
.ann-title { flex: 1; font-size: 1.12rem; line-height: 1.45; }
.ann-pin { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--plate); color: #000; box-shadow: inset 0 0 0 1.5px #000; }
.ann-new {
    flex: none; padding: 0 .55rem; border-radius: 999px; line-height: 1.7;
    background: var(--stop); color: #fff; font-size: .74rem; font-weight: 700;
}
.ann-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .9rem; margin: .3rem 0 .1rem; font-size: .82rem; color: var(--muted); }
.ann-aud { font-weight: 600; color: var(--ink); }
.ann-staff .ann-aud { color: #6A3FB0; }
.ann-company .ann-aud { color: #2F5FA8; }
.ann-body { margin: .6rem 0 0; white-space: pre-wrap; line-height: 1.75; }
.ann-files { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; align-items: flex-start; }
.ann-img img { display: block; max-width: min(320px, 100%); max-height: 240px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; }
.ann-foot { display: flex; justify-content: flex-end; gap: .4rem; margin-top: .75rem; }
.choice-row { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .choice-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } .choice-row .choice { flex-direction: column; align-items: flex-start; } }

/* ແຖບປະກາດໃນໜ້າຫຼັກ */
.ann-banner { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.ann-strip {
    display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
    color: var(--text); text-decoration: none;
}
.ann-strip:hover { border-color: var(--line-strong); color: var(--text); }
.ann-strip.pinned { background: #FFFDF4; border-color: #E8D9A6; }
.ann-strip-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--ink-soft); color: var(--ink); }
.ann-strip.pinned .ann-strip-icon { background: var(--plate); color: #000; box-shadow: inset 0 0 0 1.5px #000; }
.ann-strip-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.ann-strip-text strong { color: var(--ink); }
.ann-strip-text span { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ann-strip > .icon:last-child { color: var(--line-strong); }
.choice-row .choice { position: relative; }
.choice-row .choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-row .choice:has(input:focus-visible) { outline: 3px solid var(--plate); outline-offset: 2px; }

/* =====================================================================
   ໃບອະນຸຍາດ (ແບບທາງການ A4)
   ===================================================================== */
.pdoc { position: relative; font-family: var(--font); font-size: 13px; line-height: 1.5; color: #000; background: #fff; overflow: hidden; }
@media print {
    @page { size: A4; margin: 10mm 12mm 10mm; }
    .pdoc { font-size: 10.5pt; }
}
.pdoc .red { color: #D0021B; }
.pdoc-wm {
    position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
    width: 62%; opacity: .06; pointer-events: none; z-index: 0;
}
.pdoc > :not(.pdoc-wm):not(.pdoc-qr) { position: relative; z-index: 1; }
.pdoc-qr { position: absolute !important; top: 0; right: 0; width: 92px; height: 92px; image-rendering: pixelated; }
.pdoc-top { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.55; }
.pdoc-emblem { width: 76px; height: 76px; object-fit: contain; margin-bottom: 4px; }
.pdoc-top strong { font-weight: 700; font-size: 1.04em; }
.pdoc-meta { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 1rem; margin-top: 2px; }
.pdoc-org { line-height: 1.6; }
.pdoc-no { line-height: 1.7; min-width: 250px; }
.pdoc-fill { display: inline-block; min-width: 92px; text-align: right; padding-right: 2px; }
.pdoc-title { text-align: center; margin: 14px 0 12px; font-family: var(--font); font-size: 1.15em; font-weight: 700; color: #000; }
.pdoc-title span { display: inline-block; padding: 4px 18px; border: 1.5px solid #000; border-radius: 9px; }
.pdoc-draft { text-align: center; margin: -4px 0 8px; color: #D0021B; font-weight: 700; font-size: .9em; }
.pdoc-basis { list-style: none; margin: 0 0 6px; padding: 0 0 0 9%; }
.pdoc-basis li { position: relative; padding-left: 14px; }
.pdoc-basis li::before { content: "-"; position: absolute; left: 0; }
.pdoc-intro { margin: 8px 0 2px; text-indent: 8%; }
.pdoc-sec { margin: 2px 0 4px; padding-left: 3%; }
.pdoc-table { width: 100%; border-collapse: collapse; font-size: .93em; }
.pdoc-table th, .pdoc-table td { border: 1px solid #000; padding: 4px 7px; text-align: left; vertical-align: top; }
.pdoc-table th { font-weight: 600; text-align: center; vertical-align: middle; line-height: 1.4; }
.pdoc-table .c-no { width: 44px; text-align: center; }
.pdoc-table .empty-row td { height: 30px; }
.pdoc-table th:nth-child(2), .pdoc-table td:nth-child(2) { width: 15%; }
.pdoc-table th:nth-child(3), .pdoc-table td:nth-child(3) { width: 15%; }
.pdoc-table th:nth-child(4), .pdoc-table td:nth-child(4) { width: 12%; }
.pdoc-table th:nth-child(5), .pdoc-table td:nth-child(5) { width: 15%; }
.pdoc-table th:nth-child(7), .pdoc-table td:nth-child(7) { width: 15%; }
.pdoc-table .note-row td { padding: 8px 8px 12px; }
.pdoc-list { margin: 10px 0 2px; padding-left: 7%; }
.pdoc-list li { padding-left: 2px; }
.pdoc-closing { margin: 2px 0 0; text-indent: 16%; }
.pdoc-sign { display: flex; flex-direction: column; align-items: center; width: 46%; margin: 4px 0 0 auto; break-inside: avoid; }
.pdoc-sign-title { font-weight: 700; }
.pdoc-sign-img { display: block; width: 170px; max-height: 170px; object-fit: contain; margin-top: 4px; }
.pdoc-sign-empty { height: 150px; display: grid; place-items: center; color: #999; font-size: .9em; }
.pdoc-rules { margin-top: 14px; font-size: .74em; line-height: 1.5; padding-left: 2%; }
.pdoc-rules strong { display: block; margin-bottom: 2px; }
.pdoc-rules div { padding-left: 2%; }

/* ຕັ້ງຄ່າແບບເອກະສານ / ໜ້າກວດສອບ QR */
.doclogo-row { display: flex; gap: 1rem; align-items: flex-start; }
.doclogo-preview { width: 84px; height: 84px; object-fit: contain; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-ctrl); background: #fff; }
.verify { max-width: 520px; margin: 0 auto; padding: calc(1.5rem + var(--safe-t)) 1rem 3rem; }
.verify-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 1.5rem 1.25rem; text-align: center; border-top: 6px solid var(--go); }
.verify-card.bad { border-top-color: var(--stop); }
.verify-card .kv { text-align: left; margin-top: 1rem; }
.verify-mark { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--go-soft); color: var(--go); margin-bottom: .6rem; }
.verify-card.bad .verify-mark { background: var(--stop-soft); color: var(--stop); }
.verify-plates { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: 1rem; }
.print-doc.exporting .pdoc-qr { top: 36px; right: 44px; }

/* =====================================================================
   ເນັດຫຼຸດ / ເຊື່ອມຕໍ່ໃໝ່
   ===================================================================== */
#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: block; }

/* ກຳລັງເຊື່ອມຕໍ່: ແຖບນ້ອຍດ້ານເທິງ ບໍ່ບັງໜ້າຈໍ */
#components-reconnect-modal .rc-bar {
    position: fixed; z-index: 90; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%);
    display: flex; align-items: center; gap: .55rem; padding: .45rem 1rem;
    background: var(--ink-deep); color: #fff; border-radius: 999px; font-size: .9rem;
    box-shadow: 0 6px 20px rgba(14,35,66,.3);
    animation: rc-in .25s ease;
}
.rc-spin {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,.3); border-top-color: var(--plate);
    animation: rc-rot .8s linear infinite;
}
@keyframes rc-rot { to { transform: rotate(360deg); } }
@keyframes rc-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.components-reconnect-show::after {
    content: ""; position: fixed; inset: 0; z-index: 85; background: rgba(242,244,241,.35); cursor: progress;
}

/* ເຊື່ອມຕໍ່ບໍ່ໄດ້ (ຫຼັງລອງ ~10 ນາທີ) */
#components-reconnect-modal .rc-card { display: none; }
#components-reconnect-modal.components-reconnect-failed .rc-bar { display: none; }
#components-reconnect-modal.components-reconnect-failed .rc-card {
    display: flex; flex-direction: column; gap: .5rem; align-items: flex-start;
    position: fixed; z-index: 90; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(380px, calc(100vw - 2rem)); padding: 1.25rem;
    background: var(--surface); border-radius: var(--r-panel); border-top: 5px solid var(--stop);
    box-shadow: 0 16px 48px rgba(14,35,66,.3);
}
#components-reconnect-modal.components-reconnect-failed::after {
    content: ""; position: fixed; inset: 0; z-index: 85; background: rgba(14,35,66,.45);
}
.rc-card strong { color: var(--ink); font-size: 1.05rem; }
.rc-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.rc-offline { color: var(--stop) !important; font-weight: 600; }

/* ---------- ໜ້າເຂົ້າສູ່ລະບົບ (ແບບແບ່ງ 2 ຝັ່ງ) ---------- */
.login { min-height: 100dvh; display: grid; background: #F3F6FA; }
.login-hero {
    position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
    padding: calc(2.2rem + var(--safe-t)) 1.25rem 2.4rem; color: #fff; text-align: center;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.10), transparent 60%),
        linear-gradient(160deg, #1F3B66 0%, #16325C 45%, #0E2342 100%);
}
.login-hero::after {
    content: ""; position: absolute; inset: auto -20% -40% -20%; height: 60%;
    background: radial-gradient(closest-side, rgba(255,255,255,.06), transparent); pointer-events: none;
}
.login-hero-in { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; max-width: 520px; }
.login-logo {
    display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%;
    background: #fff; color: var(--ink); box-shadow: 0 10px 30px rgba(14,35,66,.18); overflow: hidden; flex-shrink: 0;
}
.login-logo img { width: 88%; height: 88%; object-fit: contain; }
.login-logo-lg { width: 120px; height: 120px; margin-bottom: 1.2rem; box-shadow: 0 0 0 6px rgba(255,255,255,.12), 0 18px 40px rgba(0,0,0,.25); }
.login-title { color: #fff; font-size: 1.6rem; font-weight: 800; margin: 0 0 .35rem; letter-spacing: .01em; }
.login-sub { margin: 0 0 .5rem; font-size: 1.02rem; color: #DCE5F2; }
.login-en { margin: 0 0 1.1rem; font-size: .98rem; color: #C9D4E3; }
.login-pill {
    display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.15rem; border-radius: 999px;
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.22); font-weight: 600; font-size: .92rem;
}
.login-feats { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; width: 100%; }
.login-feats li {
    display: flex; flex-direction: column; align-items: center; gap: .55rem; padding: .9rem .3rem;
    border-radius: 14px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
    font-size: .9rem; font-weight: 600; color: #E9EEF6;
}
.login-feats li > span {
    display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.55);
}
.login-side { display: flex; align-items: flex-start; justify-content: center; padding: 0 1rem 2.5rem; }
.login-card {
    position: relative; width: 100%; max-width: 460px; margin-top: -1.4rem; padding: 1.6rem 1.25rem 1.5rem;
    background: #fff; border-radius: 22px; box-shadow: 0 20px 50px rgba(14,35,66,.12), 0 2px 6px rgba(14,35,66,.05);
    display: flex; flex-direction: column;
}
.login-card > .login-logo { align-self: center; width: 76px; height: 76px; margin-bottom: .8rem; }
.login-h { text-align: center; font-size: 1.55rem; font-weight: 800; margin: 0; }
.login-hint { text-align: center; color: var(--muted); margin: .2rem 0 1.3rem; }
.login-card .field > span:first-child { font-weight: 700; color: var(--ink); }
.login-btn { margin-top: .4rem; border-radius: 14px; }
.login-card .input { border-radius: 14px; }

/* ຊ່ອງປ້ອນມີໄອຄອນດ້ານໜ້າ (ໃຊ້ໄດ້ທຸກຟອມ) */
.input-icon { position: relative; display: block; }
.input-icon > .icon:first-child { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: #8A96A6; pointer-events: none; }
.input-icon > .input { padding-left: 2.75rem; }
.input-icon:focus-within > .icon:first-child { color: var(--ink); }
.input-eye {
    position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px;
    background: transparent; color: #8A96A6; cursor: pointer;
}
.input-eye:hover { background: var(--ink-soft); color: var(--ink); }
.input-icon:has(.input-eye) > .input { padding-right: 3rem; }

@media (max-width: 520px) {
    .login-title { font-size: 1.35rem; }
    .login-logo-lg { width: 96px; height: 96px; }
    .login-feats { gap: .4rem; }
    .login-feats li { font-size: .8rem; padding: .7rem .2rem; }
    .login-feats li > span { width: 36px; height: 36px; }
}
@media (min-width: 960px) {
    .login { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
    .login-hero { padding: 3rem; }
    .login-title { font-size: 2.2rem; }
    .login-side { align-items: center; padding: 2rem; }
    .login-card { margin-top: 0; padding: 2.2rem 2.4rem 2rem; }
}

/* ຫົວຂໍ້ພາກໃນຟອມ (ແທນວົງເລກ) */
.sec-ico {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
    background: var(--ink-soft); color: var(--ink);
}
.form-page .field > span:first-child { font-weight: 700; }
@media (max-width: 959px) { .login-card > .login-logo { display: none; } .login-pill { font-size: .85rem; } }

/* ໜ້າ Login / Register ເຕັມຈໍ: ຕັດ padding ຂອງ .main (ກົດ desktop ທັບ .main-plain) */
.main.main-plain { padding: 0; max-width: none; width: 100%; }
.main-plain:has(> .login) { padding: 0; }
.login-card-wide { max-width: 560px; }
.login-card .back-link { align-self: flex-start; margin-bottom: .6rem; }
.login-card .done { text-align: center; padding: 1.5rem .5rem; }
@media (min-width: 960px) {
    /* ດ້ານຊ້າຍຢູ່ກັບທີ່ ເມື່ອຟອມດ້ານຂວາຍາວ */
    .login-hero { position: sticky; top: 0; height: 100dvh; align-self: start; }
    .login-side { min-height: 100dvh; padding: 2.5rem 2rem; }
}

/* ---------- ຈັດການເອກະສານ: ຕາຕະລາງແບບລະບົບເກົ່າ + ປຸ່ມໄປຂັ້ນຕໍ່ໄປ ---------- */
.main:has(> .plist-staff) { max-width: 1600px; }
.ptable-wrap { display: none; }
.pcard { display: flex; flex-direction: column; gap: 0; }
.pcard .prow { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.pcard-act {
    display: flex; justify-content: flex-end; gap: .5rem; padding: .5rem .75rem;
    background: #FAFBFC; border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 var(--r-panel) var(--r-panel);
}
.pcard-act .btn { flex: 1; }
.pcard:not(:has(.pcard-act)) .prow { border-radius: var(--r-panel); }
.is-busy { opacity: .55; pointer-events: none; }

@media (min-width: 960px) {
    .plist-mobile { display: none; }
    .ptable-wrap {
        display: block; overflow-x: auto; background: #fff;
        border: 1px solid var(--line); border-radius: 14px;
    }
    .ptable { width: 100%; border-collapse: collapse; font-size: .9rem; }
    .ptable th {
        position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
        padding: .7rem .75rem; background: #F4F6F9; color: var(--muted); font-weight: 600; font-size: .82rem;
        border-bottom: 1px solid var(--line);
    }
    .ptable td { padding: .55rem .75rem; vertical-align: top; border-bottom: 1px solid #EEF1F4; }
    .ptable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .ptable-req { cursor: pointer; }
    .ptable-req:hover td { background: #F7F9FC; }
    .ptable-req tr:last-child td, .ptable-req td[rowspan] { border-bottom: 2px solid var(--line); }
    .ptable .c-no { width: 2.5rem; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
    .ptable .c-who { min-width: 190px; }
    .ptable .c-who, .ptable .c-dest { display: table-cell; }
    .ptable .c-who > *, .ptable .c-dest > * { display: block; }
    .ptable .c-who strong { color: var(--ink); }
    .ptable .muted { color: var(--muted); font-size: .82rem; }
    .ptable .c-who-foot { display: flex !important; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .3rem; }
    .ptable .c-dest { min-width: 160px; max-width: 240px; }
    .ptable td { white-space: nowrap; }
    .ptable td.c-who, .ptable td.c-dest, .ptable td.c-wrap { white-space: normal; }
    .ptable td.c-wrap { min-width: 120px; }
    .ptable .c-files { display: flex !important; width: fit-content; align-items: center; gap: .2rem; margin-top: .3rem; color: var(--ink); font-size: .82rem; }
    .ptable .c-act { width: 1%; white-space: nowrap; cursor: default; }
    .ptable td.c-act { vertical-align: middle; }
    .ptable td.c-act .btn { display: flex; width: 100%; margin-bottom: .35rem; }
    .ptable td.c-act .btn:last-child { margin-bottom: 0; }
}

/* ---------- ໜ້າຫຼັກເຈົ້າໜ້າທີ່ (ແບບ B2) ---------- */
.main:has(> .dash) { max-width: 1400px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.dash-head .lead { margin: 0; }
.dash-head-act { display: flex; gap: .5rem; flex-wrap: wrap; }
.dash-search { position: relative; }
.dash-search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #8A96A6; pointer-events: none; }
.dash-search .input { padding-left: 2.2rem; min-width: 250px; background: #fff; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-bottom: .8rem; }
.kpi {
    display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; min-width: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
    color: inherit; text-decoration: none;
}
a.kpi:hover { color: inherit; border-color: var(--line-strong); }
.kpi-hl { border: 2px solid var(--plate); box-shadow: 0 0 0 4px #FFF4C2; }
.kpi-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; }
.ic-y { background: var(--plate); color: #000; box-shadow: inset 0 0 0 1.5px #000; }
.ic-b { background: #E6EEFB; color: #2D5BB8; }
.ic-g { background: var(--go-soft); color: var(--go); }
.ic-p { background: #F1E8FA; color: #7A3FB0; }
.kpi-b { display: flex; flex-direction: column; min-width: 0; }
.kpi-l { font-size: .84rem; color: var(--muted); line-height: 1.35; }
.kpi-n { font-size: 1.75rem; font-weight: 800; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-d { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.kpi-d.up { color: var(--go); }
.kpi-d.dn { color: var(--stop); }

.dchips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.4rem; }
.dchip {
    display: inline-flex; align-items: center; gap: .5rem; max-width: 100%;
    padding: .3rem .4rem .3rem .9rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line); color: var(--text);
    font-size: .84rem; text-decoration: none;
}
.dchip:hover { border-color: var(--line-strong); color: var(--text); }
.dchip .cnt {
    min-width: 26px; text-align: center; border-radius: 999px; font-weight: 700; font-size: .76rem;
    padding: .05rem .5rem; background: var(--ink-soft); color: var(--ink);
}
.dchip .cnt.hot { background: #FCE8E6; color: var(--stop); }
.dchip-ann { background: #FFFBEA; border-color: #EBD98A; padding-right: .9rem; }
.dchip-ann .dchip-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; font-weight: 600; color: var(--ink); }

.dash-h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.dash-more { display: block; text-align: center; padding: .7rem; font-size: .9rem; font-weight: 600; text-decoration: none; }

/* ຕາຕະລາງ: ມືຖື = ບັດ, ຄອມ = ຕາຕະລາງ */
.dtable-wrap { margin-top: .6rem; }
.dtable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.dtable thead { display: none; }
.dtable tbody { display: flex; flex-direction: column; gap: .55rem; }
.dtable tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem; padding: .8rem .9rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); cursor: pointer;
}
.dtable td { padding: 0; display: flex; flex-direction: column; min-width: 0; }
.dtable td[data-l="ບໍລິສັດ"] { grid-column: 1; }
.dtable td[data-l="ລໍມາ"] { grid-column: 2; grid-row: 1; text-align: right; font-size: .82rem; color: var(--muted); }
.dtable td[data-l="ທະບຽນ"], .dtable td[data-l="ສິນຄ້າ"] { grid-column: 1 / -1; }
.dtable td[data-l="ສິນຄ້າ"] { flex-direction: row; flex-wrap: wrap; gap: 0 .5rem; font-size: .85rem; }
.dtable td[data-l="ສະຖານະ"] { grid-column: 1; align-self: center; }
.dtable td.dt-act { grid-column: 2; align-self: center; }
.dtable .sm { font-size: .8rem; color: var(--muted); }
.dtable .late { color: var(--stop) !important; font-weight: 700; }
.dtable strong { color: var(--ink); }
.dplates { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }

@media (min-width: 960px) {
    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
    .kpi { padding: 1rem 1.1rem; }
    .dtable-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
    .dtable thead { display: table-header-group; }
    .dtable tbody { display: table-row-group; }
    .dtable tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: none; }
    .dtable th {
        text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted);
        padding: .7rem 1rem; background: #F4F6F9; border-bottom: 1px solid var(--line);
    }
    .dtable td { display: table-cell; padding: .75rem 1rem; vertical-align: middle; border-bottom: 1px solid #EEF1F4; }
    .dtable td > * { display: block; }
    .dtable td .dplates { display: flex; }
    .dtable td[data-l="ລໍມາ"] { text-align: left; font-size: .9rem; color: var(--text); white-space: nowrap; }
    .dtable td[data-l="ສິນຄ້າ"] { font-size: .9rem; }
    .dtable tbody tr:last-child td { border-bottom: 0; }
    .dtable tbody tr:hover td { background: #F7F9FC; }
    .dtable td.dt-act { text-align: right; width: 1%; white-space: nowrap; cursor: default; }
    .dtable td.dt-act > .btn { display: inline-flex; }
}
.dtable td > .badge, .dtable td > * > .badge { display: inline-flex !important; width: fit-content; align-self: flex-start; }
@media (max-width: 599px) {
    .kpi { padding: .75rem .8rem; gap: .6rem; }
    .kpi-ic { display: none; }
    .kpi-n { font-size: 1.45rem; }
    .dash-head-act { width: 100%; }
    .dash-search { flex: 1; }
    .dash-search .input { min-width: 0; width: 100%; }
    .dash-head-act > .btn { display: none; }   /* ມີເມນູລຸ່ມຢູ່ແລ້ວ */
}

/* ---------- ກັນໜ້າກວ້າງເກີນຈໍ (ເລື່ອນອອກຂ້າງ) ----------
   grid/flex ລູກມີ min-width:auto → ຊື່ໄຟລ໌ຍາວ ດັນໃຫ້ທັງໜ້າກວ້າງຕາມ. ບັງຄັບໃຫ້ຫົດໄດ້ */
body { overflow-x: hidden; overflow-x: clip; }
.main, .shell > *, .detail, .detail-grid > *, .stack > *, .panel { min-width: 0; }
.detail-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1040px) { .detail-grid { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (min-width: 960px) { .shell { grid-template-columns: 252px minmax(0, 1fr); } }
.filelist li { min-width: 0; }
.refdoc-file { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd a { overflow-wrap: anywhere; }

/* ---------- ລາຍການລົດໃນໜ້າລາຍລະອຽດ ---------- */
.vcards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.vc { border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; background: #FBFCFD; }
.vc-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.vc-no {
    display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
    background: var(--ink-soft); color: var(--ink); font-size: .75rem; font-weight: 700; flex: none;
}
.vc-type { font-size: .88rem; color: var(--text); font-weight: 600; }
.vc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .45rem .9rem; margin: .55rem 0 0; }
.vc-grid > div { min-width: 0; }
.vc-grid dt { font-size: .76rem; color: var(--muted); line-height: 1.3; }
.vc-grid dd { margin: 0; font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; line-height: 1.4; }
.vc-grid dd small { font-weight: 400; color: var(--muted); }
.vtable-desk { display: none; }
@media (min-width: 760px) {
    .vtable-desk { display: table; }
    .vcards { display: none; }
}
.vtable-desk .muted { color: var(--muted); }

/* ບໍ່ສະແດງກອບເຫຼືອງຮອບຫົວຂໍ້ ຕອນເປີດໜ້າ (Blazor ໂຟກັສ h1 ອັດຕະໂນມັດ) */
h1:focus, h1:focus-visible, [tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ຊື່ໜ້າຢູ່ແຖບເທິງ (ມືຖື) */
.topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar-title:empty::before { content: attr(data-brand); }
.topbar .brand-compact { min-width: 0; flex: 1; }
@media (max-width: 959px) {
    .title-dup { display: none !important; }
    .page-head:has(> div > h1.title-dup) { margin-bottom: .6rem; }
    .page-head > div:empty, .page-head > div:has(> .title-dup:only-child) { display: none; }
}

/* ---------- ປ້າຍທະບຽນຕາມປະເທດ (ສີຈາກ plate_types) ---------- */
.plate {
    gap: .35em;
    color: var(--pf, #000); background: var(--pb, var(--plate));
    box-shadow: inset 0 0 0 2px var(--pk, var(--plate-edge)), inset 0 0 0 4px var(--pb, var(--plate));
}
.plate-sm { box-shadow: inset 0 0 0 1.5px var(--pk, #000); }
.plate-cc {
    font-size: .58em; font-weight: 800; letter-spacing: .02em; line-height: 1;
    padding: .18em .3em; border-radius: 3px; opacity: .85;
    border: 1px solid currentColor;
}
.vplates { display: inline-flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.vplates-join { font-size: .8rem; font-weight: 700; color: var(--muted); }

/* ຕັ້ງຄ່າ → ປ້າຍທະບຽນ */
.pt-list { list-style: none; margin: .5rem 0 .9rem; padding: 0; display: flex; flex-direction: column; }
.pt-row { display: flex; align-items: center; gap: .9rem; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pt-row.muted { opacity: .55; }
.pt-name { flex: 1; min-width: 0; font-weight: 600; }
.pt-new { border: 1.5px dashed var(--line-strong); border-radius: var(--r-panel); padding: .9rem; margin-bottom: .5rem; }
.pt-edit { display: flex; flex-direction: column; gap: .8rem; width: 100%; }
.pt-preview { display: flex; justify-content: center; padding: 1rem; background: #EEF1F4; border-radius: 12px; }
.pt-preview .plate { font-size: 1.5rem; }
.pt-presets { display: flex; gap: .45rem; flex-wrap: wrap; }
.pt-swatch { width: 40px; height: 32px; border-radius: 7px; border: 2px solid; font-weight: 700; cursor: pointer; font-family: var(--font); }
.pt-colors { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.pt-colors label { display: inline-flex; align-items: center; gap: .4rem; }
.pt-colors input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.pt-foot { display: flex; gap: .5rem; justify-content: flex-end; }
.chip-sm { min-height: 30px; padding: .15rem .65rem; font-size: .8rem; }

/* ---------- ຟອມ: ປະເທດປ້າຍ + ທະບຽນ, ໄຟລ໌ລາຍຄັນ ---------- */
.plate-input { display: flex; gap: .4rem; min-width: 0; }
.plate-input .plate-cty { flex: 0 0 auto; width: auto; max-width: 42%; padding-right: 1.8rem; }
.plate-input .input-plate { flex: 1; min-width: 0; }
.linkbtn {
    align-self: flex-start; display: inline-flex; align-items: center; gap: .25rem;
    padding: .2rem 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }
.field-wide { grid-column: 1 / -1; }
.filepick-compact .filepick-drop { min-height: 0; flex-direction: row; flex-wrap: wrap; gap: .3rem .6rem; padding: .7rem .9rem; }
.filepick-compact .filepick-drop .hint { font-size: .78rem; }

/* ---------- ໄຟລ໌ເປັນຮູບນ້ອຍ ---------- */
.ftiles { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.ftile {
    position: relative; width: 84px; height: 84px; padding: 0; overflow: hidden; flex: none;
    border: 1.5px solid var(--line); border-radius: 10px; background: #F4F6F8; cursor: zoom-in;
    font-family: var(--font);
}
.ftile:hover { border-color: var(--ink); }
.ftile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ftile-doc { position: absolute; inset: 0 0 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); gap: .1rem; }
.ftile-doc small { font-weight: 700; font-size: .7rem; }
.ftile-name {
    position: absolute; left: 0; right: 0; bottom: 0; padding: .1rem .3rem;
    font-size: .64rem; line-height: 1.4; color: #fff; background: rgba(14,35,66,.72);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.ftile.ok { border-color: var(--go); box-shadow: 0 0 0 1px var(--go); }
.ftile-ok {
    position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center; background: var(--go); color: #fff; box-shadow: 0 0 0 2px #fff;
}
.vt-files td { padding-top: 0 !important; background: #FBFCFD; }
.vt-files-sum { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.vc-files { margin-top: .6rem; padding-top: .55rem; border-top: 1px dashed var(--line); }
.vt-group + .vt-group tr:first-child td { border-top: 2px solid var(--line); }

/* ແຖບສະຫຼຸບການກວດໄຟລ໌ (ໜ້າລາຍລະອຽດ) */
.fcheck {
    display: flex; align-items: center; gap: .8rem; margin: 0 0 1rem; padding: .7rem .9rem;
    background: #FFFBEA; border: 1px solid #EBD98A; border-radius: var(--r-panel);
}
.fcheck.all { background: var(--go-soft); border-color: #BCDFCB; }
.fcheck-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #fff; color: var(--ink); flex: none; }
.fcheck.all .fcheck-ic { color: var(--go); }
.fcheck-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.fcheck-txt strong { font-size: .92rem; color: var(--ink); }
.fcheck-bar { height: 6px; border-radius: 99px; background: rgba(14,35,66,.1); overflow: hidden; }
.fcheck-bar span { display: block; height: 100%; background: var(--go); border-radius: 99px; transition: width .3s; }

/* ---------- ເບິ່ງໄຟລ໌ເຕັມຈໍ ---------- */
.fv {
    position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column;
    background: #0B1220; color: #E8EDF4; outline: none; animation: fade .15s ease;
}
.fv-top {
    display: flex; align-items: center; gap: .75rem; padding: calc(.5rem + var(--safe-t)) .75rem .5rem 1rem;
    background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.08);
}
.fv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.fv-group { font-size: .78rem; color: var(--plate); font-weight: 600; }
.fv-name { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-count { font-size: .85rem; color: #9FB0C7; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fv-tools { display: flex; gap: .2rem; }
.fv-btn {
    width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px;
    background: transparent; color: #E8EDF4; cursor: pointer; text-decoration: none;
}
.fv-btn:hover, .fv-btn.on { background: rgba(255,255,255,.12); color: #fff; }
.fv-stage {
    position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: .5rem; touch-action: pan-y;
}
.fv-stage.zoomed { overflow: auto; align-items: flex-start; justify-content: flex-start; touch-action: auto; }
.fv-img {
    max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in;
    transition: transform .2s ease; user-select: none; -webkit-user-drag: none;
}
.fv-stage.zoomed .fv-img { max-width: none; max-height: none; width: 100%; cursor: zoom-out; transform-origin: top left; }
.fv-pdf { width: 100%; height: 100%; border: 0; border-radius: 6px; background: #fff; }
.fv-other { display: flex; flex-direction: column; align-items: center; gap: .6rem; color: #9FB0C7; }
.fv-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 48px; height: 64px; display: grid; place-items: center; border: 0; border-radius: 12px;
    background: rgba(0,0,0,.45); color: #fff; cursor: pointer;
}
.fv-nav:hover { background: rgba(0,0,0,.7); }
.fv-prev { left: .5rem; }
.fv-next { right: .5rem; }
.fv-bottom { padding: .55rem .75rem calc(.6rem + var(--safe-b)); background: rgba(255,255,255,.04); border-top: 1px solid rgba(255,255,255,.08); }
.fv-verify { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.fv-check { min-width: 200px; }
.fv-ok { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; color: #6EE7A8; }
.fv-ok small { font-weight: 400; color: #9FB0C7; }
.fv-wait { color: #9FB0C7; font-size: .9rem; }
.fv-hint { font-size: .72rem; color: #6B7A90; border: 1px solid #33415A; border-radius: 5px; padding: 0 .35rem; }
.fv-sum { margin-left: auto; font-size: .85rem; color: #9FB0C7; }
.fv-verify .btn-ghost { background: transparent; color: #E8EDF4; border-color: #33415A; }
.fv-strip { display: flex; align-items: center; gap: .4rem; overflow-x: auto; padding-bottom: .15rem; scrollbar-width: thin; }
.fv-strip-group {
    flex: none; align-self: stretch; display: flex; align-items: center;
    font-size: .72rem; font-weight: 700; color: var(--plate); white-space: nowrap;
    padding: 0 .35rem 0 .55rem; margin-left: .15rem; border-left: 1px solid #33415A;
}
.fv-strip-group:first-child { border-left: 0; margin-left: 0; padding-left: 0; }
.fv-thumb {
    position: relative; flex: none; width: 56px; height: 56px; padding: 0; overflow: hidden;
    border: 2px solid transparent; border-radius: 8px; background: #1B2638; cursor: pointer; opacity: .7;
}
.fv-thumb.on { border-color: var(--plate); opacity: 1; }
.fv-thumb:hover { opacity: 1; }
.fv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fv-thumb-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; font-size: .62rem; font-weight: 700; color: #C9D4E3; }
.fv-thumb-ok {
    position: absolute; right: 2px; bottom: 2px; width: 18px; height: 18px; border-radius: 50%;
    display: grid; place-items: center; background: var(--go); color: #fff;
}
@media (max-width: 599px) {
    .fv-tools .fv-btn[title^="ດາວໂຫຼດ"], .fv-tools a[title^="ເປີດໃນ"] { display: none; }
    .fv-nav { width: 38px; height: 52px; }
    .fv-check { flex: 1; min-width: 0; }
    .fv-hint { display: none; }
    .fv-sum { margin-left: 0; width: 100%; }
}
.ptable .c-files.all { color: var(--go); }

/* ---------- ທະບຽນລົດ / ເອກະສານລົດ ---------- */
.vd-chip {
    display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
    font-size: .76rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px;
}
.vd-chip.vd-ok { background: var(--go-soft); color: var(--go); }
.vd-chip.vd-pending { background: #E6EEFB; color: #2D5BB8; }
.vd-chip.vd-soon { background: #FFF4D6; color: #8A5A00; }
.vd-chip.vd-expired, .vd-chip.vd-missing { background: #FCE8E6; color: var(--stop); }
.vd-chip.vd-optional { background: #ECEEF1; color: #6B7480; }

.vreg-grid { display: grid; gap: .65rem; }
@media (min-width: 760px) { .vreg-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); } }
.vreg {
    display: flex; flex-direction: column; gap: .5rem; padding: .85rem 1rem; text-align: left;
    font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
    border-left: 4px solid var(--line); border-radius: var(--r-panel); cursor: pointer;
}
.vreg:hover { border-color: var(--line-strong); }
.vreg.vd-ok { border-left-color: var(--go); }
.vreg.vd-pending { border-left-color: #2D5BB8; }
.vreg.vd-soon { border-left-color: #D39B00; }
.vreg.vd-expired, .vreg.vd-missing { border-left-color: var(--stop); }
.vreg-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.vreg-top .vd-chip { margin-left: auto; }
.vreg-kind { font-size: .76rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 .4rem; }
.vreg-sub { display: flex; flex-wrap: wrap; gap: .1rem .7rem; font-size: .85rem; color: var(--muted); }
.vreg-sub strong { color: var(--ink); }
.vreg-docs { display: flex; flex-direction: column; gap: .15rem; }
.vd-line { display: flex; align-items: center; gap: .45rem; font-size: .84rem; }
.vd-line i { width: 8px; height: 8px; border-radius: 50%; background: #B9C3CE; flex: none; }
.vd-line em { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.vd-line.vd-ok i { background: var(--go); }
.vd-line.vd-pending i { background: #2D5BB8; }
.vd-line.vd-soon i { background: #D39B00; }
.vd-line.vd-soon em { color: #8A5A00; }
.vd-line.vd-expired i, .vd-line.vd-missing i { background: var(--stop); }
.vd-line.vd-expired em, .vd-line.vd-missing em { color: var(--stop); font-weight: 600; }

.ve-info { display: flex; flex-direction: column; gap: .8rem; }
.ve-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ve-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.ve-h { font-size: 1rem; margin: 1.1rem 0 .6rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; }
.ve-h .hint { font-weight: 400; font-size: .8rem; }
.ve-docs { display: flex; flex-direction: column; gap: .7rem; }
.ve-doc { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; padding: .75rem .85rem; display: flex; flex-direction: column; gap: .6rem; }
.ve-doc.vd-ok { border-left-color: var(--go); }
.ve-doc.vd-pending { border-left-color: #2D5BB8; }
.ve-doc.vd-soon { border-left-color: #D39B00; }
.ve-doc.vd-expired, .ve-doc.vd-missing { border-left-color: var(--stop); }
.ve-doc-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ve-doc-head .vd-chip { margin-left: auto; }
.ve-req { font-style: normal; font-size: .72rem; font-weight: 700; color: var(--stop); border: 1px solid currentColor; border-radius: 5px; padding: 0 .3rem; }
.ve-meta { margin: 0; display: flex; gap: .8rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.ve-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.ve-files li { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.dt-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; font-weight: 400; }
.dt-tags span { font-size: .74rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 .4rem; color: var(--muted); }
.dt-tags span.on { color: var(--stop); border-color: currentColor; }
.vrd-wrap { display: grid; gap: .6rem; margin-top: .5rem; }
@media (min-width: 1100px) { .vrd-wrap:has(> .vrd + .vrd) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.vrd { border: 1px dashed var(--line-strong); border-radius: 10px; padding: .55rem .7rem; background: #fff; min-width: 0; }
.vrd-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.vrd-title { font-size: .84rem; font-weight: 600; color: var(--ink); }
.vrd-link { margin-left: auto; font-size: .8rem; font-weight: 600; text-decoration: none; }
.vrd-docs { display: flex; flex-direction: column; gap: .4rem; }
.vrd-doc .ftiles { margin: .25rem 0 0 1rem; }
.vrd-doc .ftile { width: 64px; height: 64px; }
.reg-hint { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; font-size: .8rem; color: var(--muted); line-height: 1.45; }
.reg-hint a { font-weight: 600; text-decoration: none; }
.ve-shared { display: flex; flex-direction: column; gap: .45rem; padding: .6rem .7rem; border-radius: 10px; background: #F3F7FC; border: 1px dashed #A9BEDC; }
.ve-shared-txt { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--ink); }
.ve-sharedwith { margin: 0; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink); }
.ve-share-pick { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .55rem; border-radius: 10px; background: #F7F9FB; border: 1px solid var(--line); }
.ve-share-pick > .hint { width: 100%; }
.ve-cand {
    display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border-radius: 999px;
    border: 1.5px solid var(--line-strong); background: #fff; font: inherit; font-size: .85rem; cursor: pointer;
}
.ve-cand:hover { border-color: var(--ink); }
.ve-cand span { font-size: .75rem; color: var(--muted); }
.ve-cand em { font-style: normal; font-size: .75rem; color: var(--muted); }
.vrd-shared { font-size: .72rem; color: #2D5BB8; border: 1px solid #A9BEDC; border-radius: 6px; padding: 0 .35rem; }

/* ---------- ອະນຸມັດ ແລະ ເປີດບັນຊີ (ຂັ້ນດຽວ) ---------- */
.ap-sec { display: flex; flex-direction: column; gap: .6rem; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; }
.ap-sec > legend { padding: 0 .3rem; font-weight: 700; color: var(--ink); }
.ap-chip { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .4rem .7rem; border-radius: 10px; font-size: .88rem; }
.ap-chip.ok { background: var(--go-soft); color: var(--go); }
.ap-chip.new { background: #FFF4D6; color: #7A5200; }
.ap-users { display: flex; flex-direction: column; gap: .35rem; }
.ap-done { display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; }
.ap-creds { width: 100%; display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.ap-creds pre {
    margin: 0; padding: .8rem 1rem; text-align: left; white-space: pre-wrap; font-family: var(--font); font-size: .95rem; line-height: 1.7;
    background: #F4F6F9; border: 1px solid var(--line); border-radius: 10px; user-select: all;
}

/* ---------- ລາຍງານ ---------- */
.main:has(> .rp-table-wrap), .main:has(> .rp-filters) { max-width: 1500px; }
.rp-filters { display: flex; flex-direction: column; gap: .7rem; }
.rp-dates { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.rp-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rp-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.rp-search { margin: 0; grid-column: 1 / -1; }
@media (min-width: 1100px) { .rp-search { grid-column: span 2; } }
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin: .8rem 0; }
.rp-kpis > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; display: flex; flex-direction: column; }
.rp-kpis b { font-size: 1.4rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.rp-kpis span { font-size: .8rem; color: var(--muted); }
@media (max-width: 599px) { .rp-kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.rp-summary-ctl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: .6rem; margin: .8rem 0; }
.rp-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); margin-top: .6rem; }
.rp-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.rp-table th {
    position: sticky; top: 0; text-align: left; white-space: nowrap; padding: .6rem .7rem;
    background: #F4F6F9; color: var(--muted); font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--line);
}
.rp-table td { padding: .45rem .7rem; border-bottom: 1px solid #EEF1F4; vertical-align: middle; }
.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table .nowrap { white-space: nowrap; }
.rp-table .nowrap .plate + .plate { margin-left: .2rem; }
.rp-table tbody tr:hover td { background: #F9FAFC; }
.rp-table tfoot td { font-weight: 700; background: #F4F6F9; border-top: 2px solid var(--line); color: var(--ink); }
.rp-sum td:first-child { font-weight: 600; }
.rp-bar-h { min-width: 180px; }
.rp-bar-cell { display: flex; align-items: center; gap: .5rem; min-width: 180px; }
.rp-bar { flex: 1; height: 10px; border-radius: 99px; background: #EEF1F4; overflow: hidden; }
.rp-bar i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.rp-bar-cell small { width: 3.2em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-pivot td:first-child, .rp-pivot th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 600; }
.rp-pivot th:first-child { background: #F4F6F9; z-index: 2; }
.rp-pivot tfoot td:first-child { background: #F4F6F9; }
.rp-pivot .zero { color: #C3CAD3; }
.rp-pivot .tot { font-weight: 700; background: #FAFBFC; }
.rp-print-head { display: none; }

@media print {
    .rp-print-head { display: block; margin-bottom: 8px; }
    .rp-print-head h2 { font-size: 15pt; margin: 0; }
    .rp-print-head p { margin: 2px 0 0; font-size: 10pt; }
    .rp-table-wrap { border: 0; overflow: visible; }
    .rp-table { font-size: 8.5pt; }
    .rp-table th, .rp-table td { padding: 3px 5px; border: 1px solid #999; }
    .rp-table th { position: static; }
    .rp-kpis { display: none; }
    .rp-bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- ສິນຄ້າລາຍການຕໍ່ຄັນ (ຟອມຂໍອະນຸຍາດ) ---------- */
.glines { display: flex; flex-direction: column; gap: .5rem; }
.gline {
    display: grid; gap: .5rem .6rem; align-items: end;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, .7fr) minmax(0, 1fr) auto;
    padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
}
.glines:has(.gline:only-child) .gline { padding: 0; border: 0; background: none; }
.gl-f { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.gl-f small { font-size: .78rem; color: var(--muted); font-weight: 600; }
.gl-del { align-self: end; }
.gline:not(:has(.gl-type)) { grid-template-columns: minmax(0, 2fr) minmax(0, .8fr) minmax(0, .7fr) minmax(0, 1fr) auto; }
.gl-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 760px) {
    .gline, .gline:not(:has(.gl-type)) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .gl-type, .gl-detail, .gl-w { grid-column: 1 / -1; }
    .gline { position: relative; }
    .gl-del { position: absolute; top: .15rem; right: .25rem; width: 36px; height: 36px; }
}

/* ຕັ້ງຄ່າ → ສິນຄ້າ */
.gt-h { font-size: 1rem; margin: .4rem 0 .5rem; }
.gt-h:not(:first-child) { margin-top: 1.4rem; }
.gt-modes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.gt-mode {
    display: flex; flex-direction: column; gap: .2rem; text-align: left; padding: .8rem .9rem;
    border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font: inherit; color: inherit; cursor: pointer;
}
.gt-mode span { font-size: .82rem; color: var(--muted); }
.gt-mode.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.gt-mode.on strong::before { content: "✓ "; }
.gt-add { display: flex; gap: .5rem; margin: .5rem 0 .75rem; flex-wrap: wrap; }
.gt-add .input:first-child { flex: 2 1 180px; }
.gt-unit { flex: 1 1 110px; max-width: 160px; }
@media (max-width: 520px) { .gt-modes { grid-template-columns: minmax(0, 1fr); } .gt-unit { max-width: none; } }

/* =====================================================================
   ໜ່ວຍງານຮ່ວມກວດ (ອ.ຢ. ...)
   ===================================================================== */
.badge-dept { background: var(--ink-soft); color: var(--ink); }

/* ຄວາມຄືບໜ້າລາຍໜ່ວຍງານ */
.dprog-list { list-style: none; margin: 0 0 .4rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.dprog-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .9rem; align-items: center;
    padding: .65rem .8rem; border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}
.dprog-row.ok { border-left-color: var(--go); }
.dprog-row.wait { border-left-color: var(--plate); }
.dprog-row.bad { border-left-color: var(--stop); background: #FFFBFA; }
.dprog-row.off { opacity: .55; }
.dprog-row.mine { box-shadow: inset 0 0 0 1px var(--ink); }
.dprog-name { display: flex; flex-direction: column; min-width: 0; }
.dprog-name strong { font-size: .95rem; }
.dprog-state { font-size: .82rem; color: var(--muted); }
.dprog-row.ok .dprog-state { color: var(--go); font-weight: 600; }
.dprog-row.bad .dprog-state { color: var(--stop); font-weight: 600; }
.dprog-dots { display: inline-flex; gap: 4px; }
.dd { width: 22px; height: 7px; border-radius: 4px; background: #E3E7EC; }
.dd-done { background: var(--go); }
.dd-now { background: var(--plate); box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }
.dprog-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; font-size: .84rem; color: var(--muted); }
.dprog-meta:empty { display: none; }
.dprog-wait { color: var(--wait); font-weight: 600; }
.dprog-return {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem;
    padding: .5rem .6rem; border-radius: 8px; background: var(--stop-soft); color: #7A1E14; font-size: .88rem;
}
.dprog-return span { flex: 1 1 200px; }

/* ປ້າຍນ້ອຍລະໜ່ວຍງານ (ລາຍການ) */
.dpills { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 3px; }
.dpill { font-size: .7rem; font-weight: 700; padding: 0 .4rem; border-radius: 5px; line-height: 1.6; white-space: nowrap; }
.dpill-ok { background: var(--go-soft); color: var(--go); }
.dpill-ok::before { content: "✓ "; }
.dpill-wait { background: var(--wait-soft); color: var(--wait); }
.dpill-bad { background: var(--stop-soft); color: var(--stop); }
.dpill-bad::before { content: "! "; }
.dpill-sum { font-size: .7rem; color: var(--muted); font-weight: 600; }
.prow-main .dpills { display: flex; }

/* ຮັບເລື່ອງ: ເລືອກໜ່ວຍງານ */
.route-list { display: flex; flex-direction: column; gap: .45rem; margin-top: .4rem; }
.route-item span { display: flex; flex-direction: column; line-height: 1.4; }
.route-item small { color: var(--muted); font-size: .8rem; }
.route-item .route-why { color: var(--go); font-weight: 600; }
.route-item.locked { opacity: .75; cursor: default; }

/* ປະຫວັດ: ປ້າຍໜ່ວຍງານ */
.tl-dept { display: inline-block; margin-right: .35rem; padding: 0 .4rem; border-radius: 5px; background: var(--ink-soft); color: var(--ink); font-size: .75rem; }

/* ຕັ້ງຄ່າ → ໜ່ວຍງານ */
.dept-list { display: grid; gap: .55rem; margin-bottom: 1rem; }
@media (min-width: 900px) { .dept-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.dept-card {
    display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; text-align: left;
    border: 1.5px solid var(--line); border-radius: var(--r-panel); background: var(--surface); font: inherit; color: inherit; cursor: pointer;
}
.dept-card:hover { border-color: var(--line-strong); }
.dept-card.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.dept-card.muted { opacity: .55; }
.dept-badge {
    flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
    background: var(--ink); color: #fff; font-weight: 700; font-size: .8rem; text-align: center; line-height: 1.1; padding: 2px;
}
.dept-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.dept-goods { display: flex; flex-wrap: wrap; gap: .25rem; }
.dept-users { flex: none; display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .85rem; }
.dept-edit .tabs { margin-bottom: .8rem; }
.dept-foot { display: flex; gap: .5rem; }

/* =====================================================================
   ໂຄຕ້າ
   ===================================================================== */
.qbar { display: block; height: 8px; border-radius: 5px; background: #E6EAEE; overflow: hidden; min-width: 80px; }
.qbar > span { display: block; height: 100%; border-radius: inherit; background: var(--go); transition: width .3s; }
.qbar-sm { height: 6px; }
.near .qbar > span, .qbar.near > span { background: #E0A400; }
.full .qbar > span, .over .qbar > span, .qbar.full > span { background: var(--stop); }

/* ຜົນກວດໂຄຕ້າໃນຄຳຂໍ */
.qalert { border: 1px solid var(--line); border-radius: var(--r-panel); padding: .8rem .9rem; margin: .75rem 0; background: var(--surface); display: flex; flex-direction: column; gap: .55rem; }
.qalert.q-block { border-color: var(--stop); background: var(--stop-soft); }
.qalert.q-warn { border-color: #E0A400; background: var(--wait-soft); }
.qalert-head { display: flex; align-items: center; gap: .4rem; }
.qalert.q-block .qalert-head { color: var(--stop); }
.qalert.q-warn .qalert-head { color: var(--wait); }
.qalert > .btn { align-self: flex-start; }
.qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.qlist li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(min(100%, 80px), 1fr) auto; gap: .3rem .8rem; align-items: center; font-size: .9rem; }
.qlist li.over .q-num { color: var(--stop); font-weight: 700; }
.q-name em { font-style: normal; color: var(--muted); font-size: .8rem; margin-left: .25rem; }
.q-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-num small { display: block; color: var(--muted); font-weight: 400; font-size: .76rem; }
@media (max-width: 620px) {
    .qlist li { grid-template-columns: minmax(0, 1fr) auto; }
    .qlist li .qbar { grid-column: 1 / -1; grid-row: 2; }
}

/* ໜ້າໂຄຕ້າ (ບໍລິສັດ) */
.qcards { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); margin-bottom: 1.2rem; }
.qcard { border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.qcard.near { border-color: #E0A400; }
.qcard.full { border-color: var(--stop); }
.qcard-head { display: flex; flex-direction: column; }
.qcard-num { display: flex; align-items: baseline; gap: .35rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.qcard-num .big { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.qcard.full .qcard-num .big { color: var(--stop); }
.qcard-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .88rem; }

/* ຄຳຂໍເພີ່ມໂຄຕ້າ */
.qreq-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.qreq { display: flex; gap: .8rem; justify-content: space-between; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.qreq-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.qreq-main p { margin: .25rem 0 0; }
.qreq-review { color: var(--muted); font-size: .86rem; }
.qreq-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex: none; }
@media (max-width: 520px) { .qreq { flex-direction: column; } .qreq-side { flex-direction: row; align-items: center; } }

/* ໂຄຕ້າ (ເຈົ້າໜ້າທີ່) */
.qsetting { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.qsetting p { margin: .1rem 0 0; }
.rtable .quota { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.rtable .quota .qbar { width: 90px; }

/* ໜ້າຫຼັກບໍລິສັດ */
.qmini { display: flex; flex-direction: column; gap: .45rem; padding: .8rem .9rem; margin: .6rem 0; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); color: inherit; text-decoration: none; }
.qmini-head { display: flex; align-items: center; gap: .35rem; }
.qmini-head .hint { margin-left: auto; }
.qmini-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(min(100%, 60px), 1fr) auto; gap: .6rem; align-items: center; font-size: .88rem; }

/* =====================================================================
   ໂຄງແອັບເຕັມຈໍ: ເມນູ (ແຖບຂ້າງ / ແຖບເທິງ / ເມນູລຸ່ມ) ຕິດຢູ່ກັບທີ່,
   ເລື່ອນໄດ້ສະເພາະເນື້ອຫາ (.main-scroll). ບໍ່ມີການເລື່ອນທັງໜ້າ ແລະ ບໍ່ເລື່ອນຊ້າຍ-ຂວາ
   ===================================================================== */
html:has(.shell), html:has(.shell) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.shell {
    height: 100vh; height: 100dvh; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "main" "bottom";
}
.shell > .topbar { grid-area: top; position: relative; top: auto; }
.shell > .bottombar { grid-area: bottom; position: relative; inset: auto; }
.main-scroll {
    grid-area: main; min-height: 0; min-width: 0;
    overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    scroll-padding-top: 8rem; scroll-padding-bottom: 6rem;   /* ຊ່ອງທີ່ໂຟກັສບໍ່ຖືກແຖບຕິດບັງ */
}
.shell .main { padding-bottom: 1.5rem; overflow-wrap: anywhere; }
.main .btn, .main .badge, .main .chip, .main .tab, .main .plate, .main .num, .main input, .main select,
.main .nav-badge, .main .kpi-n, .main time { overflow-wrap: normal; }

/* ແຖບປຸ່ມລຸ່ມ: ຕິດຂອບລຸ່ມຂອງເນື້ອຫາ (ເມນູລຸ່ມຢູ່ນອກພື້ນທີ່ເລື່ອນແລ້ວ) */
.shell .actionbar { bottom: 0; }
.shell .bulkbar { top: 0; }

/* ແຊັດ: ເຕັມພື້ນທີ່ເນື້ອຫາ ເລື່ອນສະເພາະລາຍການຂໍ້ຄວາມ */
.main-scroll:has(.chat-page) { overflow: hidden; }
.shell .main:has(> .chat-page) { height: 100%; padding: 0; }
.shell .chat-page { height: 100%; min-height: 0; }

/* ແຖບຫົວໜ້າ (ຫົວຂໍ້ + ແຖບ + ຄົ້ນຫາ) ຂອງໜ້າລາຍການ: ຕິດດ້ານເທິງ ເລື່ອນແຕ່ຂໍ້ມູນ (ຕັ້ງໂດຍ page-title.js) */
.stick-chain { position: sticky; z-index: 12; background: var(--paper); }
.stick-chain.stick-last::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: var(--line); opacity: 0; transition: opacity .15s;
}
.main-scroll.scrolled .stick-chain.stick-last::after { opacity: 1; }

@media (min-width: 960px) {
    .shell {
        grid-template-columns: 252px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        grid-template-areas: "side main";
    }
    .shell > .side { grid-area: side; position: relative; top: auto; height: auto; min-height: 0; overflow-y: auto; }
    .shell .main { padding-bottom: 2rem; }
}

/* ຕາຕະລາງ: ຂໍ້ຄວາມຍາວຕັດແຖວ, ຕາຕະລາງກວ້າງເລື່ອນໃນກ່ອງຂອງມັນເອງ */
.rtable td, .rtable th { overflow-wrap: anywhere; }
@media (min-width: 960px) { .dtable-wrap { overflow-x: auto; } }

@media print {
    html:has(.shell), html:has(.shell) body { height: auto; overflow: visible; }
    .shell { display: block; height: auto; }
    .main-scroll { overflow: visible; height: auto; }
    .stick-chain { position: static; box-shadow: none !important; }
}

/* ບຣາວເຊີເກົ່າທີ່ບໍ່ຮອງຮັບ :has() → page-title.js ໃສ່ class has-shell ໃຫ້ */
html.has-shell, html.has-shell body { height: 100%; overflow: hidden; overscroll-behavior: none; }
/* ໜ້າທີ່ມີແຖບປຸ່ມລຸ່ມ: ແຖບຕິດຂອບລຸ່ມພໍດີ ບໍ່ມີຊ່ອງຫວ່າງໃຕ້ */
.shell .main:has(.actionbar) { padding-bottom: 0; }

/* ກັນລົ້ນຈໍ: ແຖວປຸ່ມ / ຫົວຂໍ້ ຂຶ້ນແຖວໃໝ່ໄດ້ */
.panel-head { flex-wrap: wrap; }
.panel-head > * { min-width: 0; }
.page-head > div { min-width: 0; }
.sheet-foot { flex-wrap: wrap; }
.vcard-head { flex-wrap: wrap; }
@media (max-width: 759px) {
    .rtable .td-action { flex-wrap: wrap; white-space: normal; gap: .35rem; }
    .rtable td > * { min-width: 0; }
    .dash-search, .dash-search .input { min-width: 0; width: 100%; }
    .dash-head-act { width: 100%; }
}


/* ---------- ກວດລົ້ນຈໍ (ຮອບ 2) ---------- */
.rcard, .rcard-head > div, .dchips > *, .ann-banner, .ann-strip { min-width: 0; }
.ann-strip-text strong { overflow-wrap: anywhere; }
.q-num { white-space: normal; }
.qlist li .q-num { text-align: right; }
.dprog-meta .btn, .qcard-foot .btn { white-space: normal; text-align: left; }
@media (max-width: 520px) {
    .md-list li { flex-wrap: wrap; }
    .md-actions { margin-left: auto; }
}
/* ຕາຕະລາງ (ຄອມ): ຖ້າຖັນຫຼາຍກວ່າພື້ນທີ່ → ເລື່ອນຊ້າຍ-ຂວາ ສະເພາະໃນຕາຕະລາງ */
.table-scroll { max-width: 100%; }
@media (min-width: 760px) {
    .table-scroll { overflow-x: auto; border-radius: var(--r-panel); }
    :not(.panel) > .table-scroll > .rtable { border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; border-collapse: separate; border-spacing: 0; }
}
@media (max-width: 759px) {
    .panel > .table-scroll > .rtable tr { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .6rem 0; margin: 0; }
    .panel > .table-scroll > .rtable tr:last-child { border-bottom: 0; }
}
@media (min-width: 760px) { .panel > .table-scroll > .rtable { border: 0; border-radius: 0; } }

.rcard-foot { flex-wrap: wrap; }

/* ---------- ຟອມຂໍອະນຸຍາດ: ເອກະສານໃຊ້ຊ້ຳ ---------- */
.reuse-list { display: flex; flex-direction: column; gap: .4rem; }
.reuse-item {
    display: flex; align-items: center; gap: .65rem; min-width: 0;
    padding: .55rem .75rem; border: 1.5px solid var(--line); border-radius: var(--r-ctrl); background: var(--surface); cursor: pointer;
}
.reuse-item.on { border-color: var(--ink); background: var(--ink-soft); }
.reuse-item.off { opacity: .55; cursor: not-allowed; }
.reuse-item input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--ink); }
.reuse-pick { display: flex; align-items: center; gap: .65rem; flex: 1; min-width: 0; cursor: pointer; }
.reuse-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.reuse-main strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reuse-main small { color: var(--muted); font-size: .8rem; }
.reuse-state { flex: none; font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; }
.reuse-state.ok { background: var(--go-soft); color: var(--go); }
.reuse-state.wait { background: var(--wait-soft); color: var(--wait); }
.reuse-state.bad { background: var(--stop-soft); color: var(--stop); }
.reuse-thumb { width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: cover; background: var(--paper); }
.reuse-thumb.doc { display: grid; place-items: center; color: var(--muted); }
.reuse-open { align-self: flex-start; max-width: 100%; white-space: normal; text-align: left; }
.reuse-note { display: flex; align-items: center; gap: .35rem; margin: .2rem 0 .6rem; }

/* ---------- ຂາຍປະກັນໄພໃນລະບົບ ---------- */
.ins-require .chips + .chips { margin-top: .6rem; }
.ins-require .hint { display: block; margin-top: .5rem; }
.ins-badge { background: #E8F0FB; color: #2D5BB8; border-color: #A9BEDC; }
.dur-list { display: flex; flex-direction: column; gap: .45rem; }
.dur-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto auto; gap: .45rem; align-items: center; }
.dur-row > * { min-width: 0; }
.price-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; max-width: 100%; }
.price-grid { width: 100%; border-collapse: collapse; font-size: .88rem; }
.price-grid th, .price-grid td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.price-grid thead th { background: var(--paper); font-weight: 600; color: var(--muted); font-size: .8rem; }
.price-grid td:first-child { font-weight: 600; }
.price-grid td .input, .price-grid td input { min-width: 96px; width: 100%; }
.price-grid tr:last-child td { border-bottom: 0; }

.buy-vehicles { max-height: 420px; overflow-y: auto; }
.buy-plate { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.buy-cover { display: block; color: var(--muted); white-space: pre-line; margin-top: .15rem; }
.buy-end { min-height: 44px; display: flex; align-items: center; padding: 0 .8rem; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--paper); font-weight: 600; }
.buy-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.buy-lines li { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.buy-lines li.bad strong { color: var(--stop); font-weight: 500; font-size: .84rem; }
.buy-line-main { flex: 1; min-width: 0; color: var(--muted); }
.buy-lines li strong { margin-left: auto; white-space: nowrap; }
.buy-total { border-bottom: 0 !important; padding-top: .7rem !important; font-size: 1.05rem; }
.buy-total .buy-line-main { color: var(--ink); font-weight: 600; }
.buy-pay { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin: .8rem 0; }
.buy-pay > * { min-width: 0; }
.buy-qr { width: 220px; max-width: 100%; aspect-ratio: 1; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: .4rem; }
.buy-bank { flex: 1 1 220px; margin: 0; white-space: pre-line; background: var(--paper); border-radius: 10px; padding: .7rem .85rem; font-weight: 500; overflow-wrap: anywhere; }

.porder .prow-title { white-space: normal; }

.pol-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pol-items li { display: flex; align-items: center; gap: .65rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pol-items li:last-child { border-bottom: 0; }
.pol-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .88rem; }
.pol-main strong { overflow-wrap: anywhere; }
.pol-price { font-weight: 600; white-space: nowrap; }

.ve-policy { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .84rem; background: #E8F0FB; color: #1F4489; border-radius: 8px; padding: .45rem .6rem; }
.ve-policy span { flex: 1; min-width: 0; }
.ve-policy a { font-weight: 600; white-space: nowrap; }
.ve-buy { align-self: flex-start; }
.vrd-policy { display: inline-flex; align-items: center; gap: .3rem; margin-left: 1rem; font-size: .8rem; font-weight: 600; text-decoration: none; color: #2D5BB8; }

/* ໃບຢັ້ງຢືນປະກັນ */
.cert-bar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cert { position: relative; max-width: 800px; margin: 0 auto 2rem; background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 2.2rem 2.4rem; font-size: .95rem; line-height: 1.6; }
.cert-qr { position: absolute; top: 1.4rem; right: 1.4rem; width: 96px; height: 96px; }
.cert-head { text-align: center; font-weight: 600; padding: 0 100px; }
.cert-title { text-align: center; font-size: 1.35rem; margin: 1.2rem 0 .3rem; }
.cert-no { text-align: center; margin: 0 0 1.2rem; }
.cert-kv { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr); gap: .45rem 1.2rem; margin: 0 0 1.2rem; }
.cert-kv dt { color: #555; }
.cert-kv dd { margin: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.cert-cover { border: 1px solid #ddd; border-radius: 6px; padding: .7rem .9rem; margin-bottom: 1rem; }
.cert-cover p { margin: .3rem 0 0; white-space: pre-line; }
.cert-terms { font-size: .85rem; color: #333; padding-left: 1.2rem; margin: 0 0 1.4rem; }
.cert-sign { margin-left: auto; width: max-content; max-width: 100%; text-align: center; }
.cert-sign-title { font-weight: 600; margin-top: .3rem; }
.cert-sign-img { display: block; max-width: 200px; max-height: 90px; margin: .4rem auto 0; object-fit: contain; }
.cert-foot { margin: 1.4rem 0 0; font-size: .75rem; color: #666; text-align: center; overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .cert { padding: 1.2rem 1rem; font-size: .88rem; }
    .cert-qr { position: static; display: block; margin: 0 auto .6rem; width: 84px; height: 84px; }
    .cert-head { padding: 0; }
    .dur-row { grid-template-columns: minmax(0, 1fr) 80px auto; }
    .dur-row .hint { display: none; }
}
@media print {
    .no-print { display: none !important; }
    .shell:has(.cert) .side, .shell:has(.cert) .topbar, .shell:has(.cert) .bottombar { display: none !important; }
    .shell:has(.cert) .main { padding: 0 !important; max-width: none; }
    .cert { border: 0; border-radius: 0; margin: 0; padding: 0; max-width: none; }
    .cert-qr { position: absolute; top: 0; right: 0; }
    .cert-head { padding: 0 110px; }
}

/* ---------- ເມນູຍ່ອຍ (ກຸ່ມພັບ/ກາງໄດ້) ---------- */
.side-group-btn {
    display: flex; align-items: center; gap: .5rem; width: 100%;
    min-height: 40px; margin-top: .5rem; padding: .35rem .75rem;
    background: none; border: 0; border-radius: var(--r-ctrl); cursor: pointer;
    font: inherit; font-size: .8rem; font-weight: 600; letter-spacing: .01em; text-align: left;
    color: #8B9AB0;
}
.side-group-btn > span:first-child { flex: 1; min-width: 0; }
.side-group-btn .nav-badge { margin-left: 0; }
.side-group-chev { flex: none; transition: transform .18s ease; }
.side-group-btn.open .side-group-chev { transform: rotate(90deg); }
.side .side-group-btn:hover { color: #fff; background: rgba(255,255,255,.04); }
.side .side-group-btn.has-active:not(.open) { color: #fff; }
.side-sub { display: flex; flex-direction: column; gap: 2px; }
.side-sub .side-link { padding-left: 1.1rem; }
.drawer-links .side-group-btn { color: var(--muted); }
.drawer-links .side-group-btn:hover, .drawer-links .side-group-btn.has-active:not(.open) { color: var(--ink); background: var(--paper); }

/* ແຖບເລື່ອນຂອງເມນູຂ້າງ: ບາງ ແລະ ກືນກັບພື້ນເຂັ້ມ */
.side-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; padding-right: 2px; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 6px; }
.side-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.ins-ready { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; margin-top: .2rem; }
.ins-ready.ok { color: var(--go); }
.ins-ready.bad { color: #A15C00; }
p.ins-ready { margin: 0; font-weight: 500; flex-wrap: wrap; }
.md-name .ins-ready { display: flex; }

/* ---------- ຕິດຕັ້ງເປັນແອັບ (PWA) ---------- */
.pwa-install { display: none !important; }
html.pwa-can-install .pwa-install, html.pwa-ios .pwa-install { display: flex !important; }
.side .pwa-install { color: var(--plate); margin-top: .5rem; border: 1px dashed rgba(246,196,0,.4); }
.side .pwa-install:hover { background: rgba(246,196,0,.08); color: var(--plate); }
.login-install { margin-top: .9rem; justify-content: center; }

.pwa-banner {
    position: fixed; z-index: 70; left: .75rem; right: .75rem;
    bottom: calc(.75rem + var(--safe-b));
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem .6rem .6rem .7rem; border-radius: 14px;
    background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25);
    animation: pwa-up .25s ease-out;
}
html:has(.shell) .pwa-banner { bottom: calc(var(--bb-h) + var(--safe-b) + .6rem); }
@media (min-width: 900px) { .pwa-banner { display: none; } }
.pwa-banner img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.pwa-banner > span { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pwa-banner small { color: #C9D4E3; font-size: .78rem; }
.pwa-banner-go { font: inherit; font-weight: 700; min-height: 40px; padding: 0 1rem; border: 0; border-radius: 10px; background: var(--plate); color: #000; cursor: pointer; }
.pwa-banner-x { font: inherit; width: 36px; height: 36px; border: 0; background: none; color: #C9D4E3; cursor: pointer; flex: none; }
@keyframes pwa-up { from { transform: translateY(20px); opacity: 0; } }

.pwa-ios-sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.pwa-ios-backdrop { position: absolute; inset: 0; background: rgba(10,20,40,.5); }
.pwa-ios-card {
    position: relative; width: 100%; max-width: 440px; margin: 0 .75rem calc(.75rem + var(--safe-b));
    background: #fff; color: var(--text); border-radius: 18px; padding: 1.3rem 1.2rem 1.1rem;
    display: flex; flex-direction: column; align-items: center; text-align: center; animation: pwa-up .25s ease-out;
}
.pwa-ios-card img { width: 64px; height: 64px; border-radius: 14px; }
.pwa-ios-card strong { font-size: 1.05rem; margin: .7rem 0 .4rem; }
.pwa-ios-card ol { text-align: left; margin: 0 0 1rem; padding-left: 1.3rem; line-height: 1.7; font-size: .92rem; }
.pwa-ios-card ol svg { vertical-align: -3px; color: #0A84FF; }
.pwa-ios-card button { font: inherit; font-weight: 700; width: 100%; min-height: 46px; border: 0; border-radius: 12px; background: var(--ink); color: #fff; cursor: pointer; }

/* ເປີດເປັນແອັບ (standalone): ບໍ່ໃຫ້ກົດຄ້າງເລືອກຂໍ້ຄວາມເມນູ / ບໍ່ດຶງໜ້າຈໍ */
html.pwa-standalone .side, html.pwa-standalone .bottombar, html.pwa-standalone .topbar { -webkit-user-select: none; user-select: none; }
html.pwa-standalone body { overscroll-behavior-y: none; }

/* ---------- ແຈ້ງເຕືອນ (popup ມຸມຈໍ) ---------- */
.ntf-stack {
    position: fixed; z-index: 85; top: calc(.75rem + var(--safe-t)); right: .75rem;
    width: min(380px, calc(100vw - 1.5rem)); display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
@media (max-width: 899px) { .ntf-stack { top: calc(3.9rem + var(--safe-t)); left: .75rem; right: .75rem; width: auto; } }
.ntf {
    pointer-events: auto; display: flex; align-items: flex-start; gap: .65rem;
    padding: .7rem .5rem .7rem .75rem; border-radius: 14px; text-decoration: none; color: var(--text);
    background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ink);
    box-shadow: 0 12px 32px rgba(15,30,60,.18); animation: ntf-in .28s cubic-bezier(.2,.9,.3,1.2);
}
.ntf:hover { color: var(--text); border-color: var(--line-strong); }
.ntf.out { opacity: 0; transform: translateX(16px); transition: .22s ease; }
.ntf-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ink-soft); color: var(--ink); }
.ntf-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.ntf-text strong { font-size: .92rem; }
.ntf-text small { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ntf-x { flex: none; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; font: inherit; }
.ntf-x:hover { background: var(--paper); }
.ntf-work { border-left-color: #2D5BB8; } .ntf-work .ntf-ico { background: #E8F0FB; color: #2D5BB8; }
.ntf-chat { border-left-color: var(--ink); }
.ntf-ok   { border-left-color: var(--go); }   .ntf-ok .ntf-ico { background: var(--go-soft, #E3F4EA); color: var(--go); }
.ntf-warn { border-left-color: var(--stop); } .ntf-warn .ntf-ico { background: var(--stop-soft); color: var(--stop); }
.ntf-info { border-left-color: var(--plate); } .ntf-info .ntf-ico { background: #FFF6D6; color: #8A6A00; }
@keyframes ntf-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@media print { .ntf-stack { display: none !important; } }

.ntf-vol { display: flex; align-items: center; gap: .6rem; padding-left: 1.9rem; color: var(--muted); }
.ntf-vol input[type=range] { flex: 1; max-width: 260px; accent-color: var(--ink); }
.ntf-perm { padding-left: 1.9rem; }
.ntf-kinds { list-style: none; margin: .2rem 0 0; padding: 0; display: flex; flex-direction: column; }
.ntf-kinds li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.ntf-kinds li:last-child { border-bottom: 0; }
.ntf-push { border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; display: flex; flex-direction: column; gap: .6rem; background: var(--paper); }
.ntf-push-head { display: flex; gap: .6rem; align-items: flex-start; color: var(--ink); }
.ntf-push-head > div { display: flex; flex-direction: column; min-width: 0; }
.ntf-push-head strong { color: var(--text); }
.ntf-push-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ntf-push-row .ins-ready { margin-right: auto; }
