/* ===== Lee Work — design system (mobile-first) ===== */

:root {
    --w-bg: #f2f4f3;
    --w-surface: #ffffff;
    --w-border: #e2e6e4;
    --w-border-strong: #cfd6d2;
    --w-text: #171c1a;
    --w-muted: #687470;
    --w-primary: #0f6b4f;
    --w-primary-dark: #0a4f3a;
    --w-primary-soft: #e6f4ee;
    --w-primary-soft-border: #b6dfca;
    --w-primary-gradient: linear-gradient(135deg, #12805e 0%, #0a4f3a 100%);
    --w-primary-rgb: 15, 107, 79;
    --w-primary-disabled: #93c2ae;
    --w-primary-soft-active: #d5ecdf;
    --w-danger: #d92d20;
    --w-danger-soft: #fef3f2;
    --w-danger-border: #fecdca;
    --w-radius-lg: 16px;
    --w-radius: 12px;
    --w-radius-sm: 10px;
    --w-shadow: 0 1px 2px rgba(15, 23, 20, .04), 0 6px 18px rgba(15, 23, 20, .06);
    --w-shadow-up: 0 -4px 18px rgba(15, 23, 20, .08);
    --w-safe-b: env(safe-area-inset-bottom, 0px);
}

/* Product OUT pages: red/pink accent */
body.theme-out {
    --w-primary: #c2185b;
    --w-primary-dark: #8e0f42;
    --w-primary-soft: #fce8f0;
    --w-primary-soft-border: #f3b5cd;
    --w-primary-gradient: linear-gradient(135deg, #e0286f 0%, #8e0f42 100%);
    --w-primary-rgb: 194, 24, 91;
    --w-primary-disabled: #e3a3bd;
    --w-primary-soft-active: #f8d0e0;
}

/* Product IN pages: blue accent */
body.theme-in {
    --w-primary: #1d64d8;
    --w-primary-dark: #14489c;
    --w-primary-soft: #e6effc;
    --w-primary-soft-border: #b6cff5;
    --w-primary-gradient: linear-gradient(135deg, #2f7ff0 0%, #14489c 100%);
    --w-primary-rgb: 29, 100, 216;
    --w-primary-disabled: #a9c3ec;
    --w-primary-soft-active: #d2e2fa;
}
/* Theme accents also apply when set on a container (not just body) */
/* Admin pages: red accent */
.theme-admin {
    --w-primary: #d32f2f;
    --w-primary-dark: #9a1c1c;
    --w-primary-soft: #fdeaea;
    --w-primary-soft-border: #f3b8b8;
    --w-primary-gradient: linear-gradient(135deg, #e53935 0%, #9a1c1c 100%);
    --w-primary-rgb: 211, 47, 47;
    --w-primary-disabled: #eaa7a7;
    --w-primary-soft-active: #fad4d4;
}
/* Order pages: orange accent */
.theme-order {
    --w-primary: #e8710a;
    --w-primary-dark: #b4560a;
    --w-primary-soft: #fff1e3;
    --w-primary-soft-border: #f7c99a;
    --w-primary-gradient: linear-gradient(135deg, #f5891f 0%, #b4560a 100%);
    --w-primary-rgb: 232, 113, 10;
    --w-primary-disabled: #f2c39a;
    --w-primary-soft-active: #ffe0c2;
}
/* Pickup pages: purple accent */
.theme-pickup {
    --w-primary: #bf42f5;
    --w-primary-dark: #8a0ac2;
    --w-primary-soft: #f7e7fe;
    --w-primary-soft-border: #e6b6fb;
    --w-primary-gradient: linear-gradient(135deg, #c655f6 0%, #8a0ac2 100%);
    --w-primary-rgb: 191, 66, 245;
    --w-primary-disabled: #d6b3e6;
    --w-primary-soft-active: #efcffc;
}
/* Check-in pages: teal accent */
/* HR pages (เกี่ยวกับงานบุคคล — checkin/leave/withdraw/leave-type settings): shared gold accent */
.theme-hr {
    --w-primary: #ca8a04;
    --w-primary-dark: #92660a;
    --w-primary-soft: #fef7e0;
    --w-primary-soft-border: #f3d98a;
    --w-primary-gradient: linear-gradient(135deg, #eab308 0%, #92660a 100%);
    --w-primary-rgb: 202, 138, 4;
    --w-primary-disabled: #e6c877;
    --w-primary-soft-active: #f9ecc0;
}

html, body { -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }

body {
    background: var(--w-bg);
    color: var(--w-text);
    font-family: "Noto Sans Thai", "Noto Sans Myanmar", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
/* Myanmar script needs taller line boxes for stacked marks */
body.lang-my, body.lang-ksw { line-height: 1.7; }
/* Vietnamese stacks two marks on one letter — ế, ộ, ữ — and "Noto Sans Thai" carries a Latin set
   that does not always have them, so the glyph falls back and the line goes ragged. Put a face that
   covers Vietnamese in front for that language, and give the line a little more room. */
body.lang-vi {
    font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

/* ================= language switcher ================= */
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-switch a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 38px; padding: 6px 14px; border-radius: 999px;
    border: 1px solid var(--w-border-strong); background: var(--w-surface);
    color: var(--w-text); font-size: 14px; font-weight: 500; text-decoration: none;
}
.lang-switch a:hover { border-color: var(--w-primary); color: var(--w-primary-dark); text-decoration: none; }
.lang-switch a.active { background: var(--w-primary); border-color: var(--w-primary); color: #fff; }
.login-lang { display: flex; justify-content: center; margin-top: 18px; }
.nav-mobile-lang { padding: 6px 12px 12px; }
.nav-mobile-lang small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--w-muted); margin-bottom: 8px; }
.lang-menu .dropdown-menu {
    border: 1px solid var(--w-border); border-radius: var(--w-radius);
    box-shadow: var(--w-shadow); padding: 6px; min-width: 160px; margin-top: 8px;
}
.lang-menu .dropdown-item { border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.lang-menu .dropdown-item.active { background: var(--w-primary-soft); color: var(--w-primary-dark); font-weight: 600; }

a { color: var(--w-primary); }
a:hover { color: var(--w-primary-dark); }
button:focus, .btn:focus, a:focus { outline: none; box-shadow: none; }

/* ================= navbar (collapse on mobile) ================= */
.app-navbar {
    background: var(--w-surface);
    border-bottom: 1px solid var(--w-border);
    padding: 0;
}
.app-navbar-inner {
    width: 100%; max-width: 640px; margin: 0 auto;
    padding: 0 12px 0 16px;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.app-navbar .navbar-brand { padding: 0; margin: 0; }
.brand {
    display: flex; align-items: center; gap: 9px; height: 58px;
    color: var(--w-text); font-weight: 700; font-size: 16px; text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--w-text); }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--w-primary-gradient); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
    box-shadow: 0 2px 6px rgba(var(--w-primary-rgb), .35);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--w-muted); line-height: 1.6; margin-top: 1px; }

.app-navbar .navbar-toggler {
    width: 44px; height: 44px; padding: 0; border: 1px solid var(--w-border);
    border-radius: var(--w-radius-sm); color: var(--w-text); font-size: 24px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center; background: var(--w-surface);
}
.app-navbar .navbar-toggler:active { background: var(--w-bg); }
.app-navbar .navbar-toggler .icon-close { display: none; font-size: 18px; }
.app-navbar .navbar-toggler[aria-expanded="true"] .icon-open { display: none; }
.app-navbar .navbar-toggler[aria-expanded="true"] .icon-close { display: inline; }

/* the menu button sits at the right edge; when the push speaker is shown, the speaker does the pushing */
.app-navbar .navbar-toggler { margin-left: auto; }
#notifToggleWrap:not([hidden]) + .navbar-toggler { margin-left: 0; }

.app-navbar .nav-link {
    display: flex; align-items: center; gap: 12px; width: 100%;
    color: var(--w-text); font-size: 15px; font-weight: 500;
    background: none; border: none; text-align: left; cursor: pointer; font-family: inherit;
}
.app-navbar button.nav-link.active { color: var(--w-primary-dark); }
.app-navbar button.nav-link.active i:first-child { color: var(--w-primary); }
.app-navbar .nav-link i:first-child { font-size: 19px; color: var(--w-muted); }
.app-navbar .nav-link.active { color: var(--w-primary-dark); }
.app-navbar .nav-link.active i:first-child { color: var(--w-primary); }
.app-navbar .nav-chev { margin-left: auto; font-size: 13px; color: var(--w-border-strong); }

.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    border: 1px solid var(--w-primary-soft-border);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}

/* -- mobile (collapsed panel) -- */
@media (max-width: 767.98px) {
    .app-navbar-scroll { width: 100%; flex-basis: 100%; }
    .app-navbar .navbar-collapse {
        width: 100%; flex-basis: 100%;
        border-top: 1px solid var(--w-border);
        margin: 0 -12px 0 -16px; padding: 8px 12px 14px 12px; width: calc(100% + 28px);
        background: var(--w-surface);
        max-height: calc(100dvh - 64px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .app-navbar .nav-item + .nav-item { margin-top: 4px; }
    .app-navbar .nav-link {
        min-height: 50px; padding: 8px 12px !important;
        border-radius: var(--w-radius-sm);
    }
    .app-navbar .nav-link:active { background: var(--w-bg); }
    .app-navbar .nav-link.active { background: var(--w-primary-soft); }
    .nav-mobile-user {
        margin-top: 10px; padding-top: 10px; padding-bottom: 200px; border-top: 1px solid var(--w-border);
    }
    .nav-mobile-user-row { display: flex; align-items: center; gap: 12px; padding: 6px 12px 10px; }
    .nav-mobile-user-row small { display: block; font-size: 11.5px; color: var(--w-muted); line-height: 1.2; }
    .nav-mobile-user-row b { font-size: 15px; font-weight: 600; }
    .nav-logout {
        display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px;
        border-radius: var(--w-radius-sm); color: var(--w-danger); font-size: 15px; font-weight: 500;
        text-decoration: none;
    }
    .nav-logout i { font-size: 19px; }
    .nav-logout:active, .nav-logout:hover { background: var(--w-danger-soft); color: var(--w-danger); text-decoration: none; }
}

/* -- desktop: left sidebar navigation -- */
@media (min-width: 768px) {
    :root { --sb-w: 240px; }
    body { padding-left: var(--sb-w); }
    body.login-body { padding-left: 0; }

    .app-navbar, .app-navbar.sticky-top {
        position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-w); z-index: 1030;
        border-bottom: 0; border-right: 1px solid var(--w-border); overflow: hidden;
    }
    body.chat-body .app-navbar { position: fixed; }
    .app-navbar-inner {
        max-width: none; height: 100%;
        flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start;
        padding: 0 12px 14px;
    }
    .app-navbar .navbar-toggler { display: none; }
    .app-navbar .brand { flex: none; height: auto; padding: 14px 8px 16px; border-bottom: 1px solid var(--w-border); margin-bottom: 10px; }
    /* only this part scrolls — the logo above stays locked in place no matter what's toggled below */
    .app-navbar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
    #notifToggleWrap { display: block; }
    .nav-sound {
        width: 100%; height: 42px; margin: 0 0 8px; justify-content: flex-start; gap: 11px; padding: 0 12px;
        border: none; font-size: 18px; border-radius: var(--w-radius-sm);
    }
    .nav-sound:hover { background: var(--w-bg); }
    .nav-sound-label { display: inline !important; font-size: 15px; font-weight: 500; }

    .app-navbar .navbar-collapse { display: flex !important; flex-direction: column; flex: 1 0 auto; flex-basis: auto; padding: 0; margin: 0; }
    .app-navbar .navbar-nav { flex-direction: column; align-items: stretch; gap: 2px; width: 100%; }
    .app-navbar .nav-main { margin: 0; }
    .app-navbar .nav-item { width: 100%; }
    .app-navbar .nav-link {
        height: 44px; padding: 0 12px !important; border-radius: var(--w-radius-sm); gap: 11px;
        width: 100%; justify-content: flex-start; white-space: nowrap;
    }
    .app-navbar .nav-link i:first-child { font-size: 18px; width: 22px; text-align: center; }
    .app-navbar .nav-link:hover { background: var(--w-bg); }
    .app-navbar .nav-link.active { background: var(--w-primary-soft); }
    .app-navbar .nav-link .nav-badge { margin-left: auto; }
    .app-navbar .nav-chev { display: none; }

    /* language + user pinned to the bottom of the sidebar */
    .app-navbar .nav-side { order: 10; margin: auto 0 0; padding: 10px 0 200px; border-top: 1px solid var(--w-border); flex: none; }
    .app-navbar .navbar-collapse { order: 5; }
    .app-navbar .nav-side .nav-link { height: 42px; }
    .user-menu { margin-left: 0; }
    .user-menu .user-toggle { padding: 0 8px !important; gap: 10px; }
    .user-menu .user-toggle::after { color: var(--w-muted); margin-left: auto; }
    .lang-menu .nav-link::after { margin-left: auto; }
    .app-navbar .dropdown-menu {
        border: 1px solid var(--w-border); border-radius: var(--w-radius);
        box-shadow: var(--w-shadow); padding: 6px; min-width: 200px;
    }
    .app-navbar .dropdown-item {
        border-radius: 8px; padding: 9px 10px; font-size: 14px;
        display: flex; align-items: center; gap: 9px;
    }
    .app-navbar .dropdown-item.active { background: var(--w-primary-soft); color: var(--w-primary-dark); }
    .user-menu .dropdown-item.text-danger:hover { background: var(--w-danger-soft); }

    /* fixed bottom elements must not slide under the sidebar */
    .action-bar { left: var(--sb-w); }
    .modal.sheet .modal-dialog { left: var(--sb-w); }
    .img-lightbox { left: 0; }
    .wrap { max-width: 760px; }
}

/* ================= layout ================= */
.wrap {
    max-width: 640px; margin: 0 auto;
    padding: 18px 16px calc(120px + var(--w-safe-b));
}
.page-head { margin-bottom: 16px; }
/* a page reached from one particular place, and that carries the way back to it */
.page-head.has-back { display: flex; align-items: center; gap: 10px; }
.page-head.has-back .chat-back { flex: none; }
.page-head-text { min-width: 0; }
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; font-size: 13px; color: var(--w-muted); }
.page-title { font-size: 19px; font-weight: 700; margin: 0 0 16px; }
.admin-quicklinks { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.admin-quicklinks a {
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
    padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
    background: var(--w-bg); border: 1px solid var(--w-border-strong); color: var(--w-text);
}
.admin-quicklinks a:hover { border-color: var(--w-primary); color: var(--w-primary-dark); text-decoration: none; }
.admin-quicklinks a i { font-size: 14px; }
.admin-quicklinks a.active { background: var(--w-primary); border-color: var(--w-primary); color: #fff; }
.table-scroll { overflow-x: auto; }
.feature-group-title { font-size: 14px; font-weight: 700; color: var(--w-muted); margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--w-border); }
.feature-group-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.feature-group-title-hr { color: var(--w-primary); }
.sa-preview-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.sa-preview-table th, .sa-preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--w-border); text-align: left; }
.sa-preview-table th { color: var(--w-muted); font-weight: 600; font-size: 12px; }
.sa-cell { text-align: center; }
.sa-check { color: #15803d; font-weight: 700; }
.sa-x { color: var(--w-danger); font-weight: 700; }

/* ================= section cards ================= */
.sec, .card-section {
    background: var(--w-surface);
    border: 1px solid var(--w-border);
    border-radius: var(--w-radius-lg);
    box-shadow: var(--w-shadow);
    margin-bottom: 14px;
    overflow: hidden;
}
.card-section { padding: 16px; }
.card-section h6 {
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--w-muted); margin-bottom: 12px;
}
.sec-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px 0;
}
.sec-step {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    background: var(--w-primary); color: #fff;
    font-size: 13px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.sec-title { font-size: 15px; font-weight: 600; margin: 0; }
.sec-title small { display: block; font-size: 12px; font-weight: 400; color: var(--w-muted); }
.sec-badge {
    margin-left: auto; background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.sec-badge.is-empty { background: var(--w-bg); color: var(--w-muted); }
.sec-body { padding: 14px 16px 16px; }

/* ================= form controls ================= */
.form-control {
    display: block; width: 100%; box-sizing: border-box;
    font-family: inherit; font-size: 16px; color: var(--w-text);
    border: 1px solid var(--w-border-strong);
    border-radius: var(--w-radius-sm);
    padding: 11px 13px; min-height: 48px;
    background: var(--w-surface);
}
.form-control::placeholder { color: #9aa6a1; }
.form-control:focus {
    border-color: var(--w-primary); color: var(--w-text);
    box-shadow: 0 0 0 4px rgba(var(--w-primary-rgb), .14);
}
textarea.form-control { resize: vertical; line-height: 1.5; }
/* select ต้องกำหนดหน้าตาเองทั้งหมด — ปล่อยให้เบราว์เซอร์วาดเองจะไม่เหมือนกันในแต่ละมือถือ (บางรุ่นลูกศรหาย/ล้นขอบ) */
select.form-control {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    line-height: 1.6; padding-top: 13px; padding-bottom: 13px; min-height: 52px; padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23687470' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 16px 16px;
}
select.form-control::-ms-expand { display: none; }
select.form-control:disabled { background-color: var(--w-bg); color: var(--w-muted); opacity: .8; }
.input-icon select.form-control { padding-right: 40px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--w-muted); display: block; margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--w-muted); margin-top: 8px; }

.input-icon { position: relative; }
.input-icon > i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--w-muted); font-size: 17px; pointer-events: none;
}
.input-icon .form-control { padding-left: 42px; }
.input-icon .form-control:focus + i, .input-icon .form-control:focus ~ i { color: var(--w-primary); }
.input-icon .toggle-pw {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border: none; background: none;
    color: var(--w-muted); font-size: 18px; border-radius: 8px;
}
.input-icon .toggle-pw:active { background: var(--w-bg); }
.input-icon.has-toggle .form-control { padding-right: 46px; }

/* ================= pickers (photo / video) ================= */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 84px; padding: 12px 8px; margin: 0;
    border: 1.5px dashed var(--w-border-strong);
    border-radius: var(--w-radius);
    background: #fafbfa; color: var(--w-muted);
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.pick-tile i { font-size: 24px; color: var(--w-primary); }
.pick-tile:active, .pick-tile:hover { border-color: var(--w-primary); background: var(--w-primary-soft); color: var(--w-primary-dark); }
.pick-tile.pick-wide { flex-direction: row; gap: 10px; min-height: 64px; }
.pick-tile.pick-wide i { font-size: 22px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-grid:empty { display: none; }
.photo-cell { position: relative; aspect-ratio: 1 / 1; border-radius: var(--w-radius-sm); overflow: hidden; background: var(--w-bg); border: 1px solid var(--w-border); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px; border-radius: 50%; border: none; padding: 0;
    background: rgba(23, 28, 26, .72); color: #fff; font-size: 15px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.photo-del:active { background: var(--w-danger); }
@media (min-width: 480px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }

.video-preview { display: none; margin-top: 12px; }
.video-preview.show { display: block; }
.video-preview video { width: 100%; max-height: 260px; background: #000; border-radius: var(--w-radius-sm); display: block; }
.video-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--w-muted); }
.video-meta span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost {
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-text);
    border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 500; line-height: 1.3;
}
.btn-ghost.danger { color: var(--w-danger); }
.btn-ghost:active { background: var(--w-bg); }

/* ================= item rows ================= */
.item-card {
    display: flex; gap: 12px; align-items: stretch;
    border: 1px solid var(--w-border); border-radius: var(--w-radius);
    padding: 12px; margin-bottom: 10px; background: var(--w-surface);
}
.item-photo {
    position: relative; flex: none; width: 104px; height: 104px; margin: 0; cursor: pointer;
    border: 1.5px dashed var(--w-border-strong); border-radius: var(--w-radius-sm);
    background: #fafbfa; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--w-muted); font-size: 11.5px; font-weight: 500; text-align: center;
    transition: border-color .15s, background .15s;
}
.item-photo i { font-size: 26px; color: var(--w-primary); }
.item-photo-text { padding: 0 6px; line-height: 1.25; overflow-wrap: anywhere; }
.item-photo:active { border-color: var(--w-primary); background: var(--w-primary-soft); }
.item-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.item-photo .item-photo-change {
    position: absolute; left: 0; right: 0; bottom: 0; display: none;
    background: rgba(23, 28, 26, .7); color: #fff; font-size: 11px; padding: 3px 0;
}
.item-photo.has-file { border-style: solid; border-color: var(--w-primary); }
.item-photo.has-file img, .item-photo.has-file .item-photo-change { display: block; }
.item-photo.has-file i, .item-photo.has-file .item-photo-text { display: none; }

.multi-photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.multi-photo-grid .item-photo.photo-add-tile { width: 80px; height: 80px; }
.multi-photo-grid .pending-image { width: 80px; height: 80px; border-radius: var(--w-radius-sm); }

.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.item-title { font-weight: 600; font-size: 14.5px; }
.item-status { font-size: 12px; color: var(--w-muted); }
.item-status.ok { color: var(--w-primary); }
.item-remove {
    width: 34px; height: 34px; border: none; background: none; border-radius: 8px;
    color: var(--w-muted); font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
    margin-right: -6px;
}
.item-remove:active { background: var(--w-danger-soft); color: var(--w-danger); }
.item-qty-label { font-size: 12px; color: var(--w-muted); margin-top: auto; margin-bottom: 4px; }

.qty-stepper { display: flex; align-items: stretch; height: 44px; }
.qty-stepper button {
    width: 44px; flex: none; font-size: 20px; font-weight: 600; padding: 0;
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-primary-dark);
}
.qty-stepper button:active { background: var(--w-primary-soft); }
.qty-stepper button:first-child { border-radius: var(--w-radius-sm) 0 0 var(--w-radius-sm); }
.qty-stepper button:last-child { border-radius: 0 var(--w-radius-sm) var(--w-radius-sm) 0; }
.qty-stepper input {
    flex: 1; min-width: 0; width: 60px; text-align: center; font-size: 17px; font-weight: 700;
    border: 1px solid var(--w-border-strong); border-left: none; border-right: none;
    border-radius: 0; padding: 0; min-height: 0; -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { box-shadow: none; border-color: var(--w-primary); }

/* ================= check-in: type toggle + location status ================= */
.type-toggle { display: flex; gap: 10px; }
.type-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.type-toggle-btn {
    flex: 1; text-align: center; padding: 14px 8px; border-radius: var(--w-radius-sm);
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-muted);
    font-size: 16px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
#typeIn:checked + .type-toggle-in { background: var(--w-primary-soft); border-color: var(--w-primary); color: var(--w-primary-dark); }
#typeOut:checked + .type-toggle-out { background: var(--w-danger-soft); border-color: var(--w-danger); color: var(--w-danger); }
input[name="wage_type"]:checked + .type-toggle-in { background: var(--w-primary-soft); border-color: var(--w-primary); color: var(--w-primary-dark); }
input[name="wage_type"]:checked + .type-toggle-out { background: var(--w-danger-soft); border-color: var(--w-danger); color: var(--w-danger); }
.type-toggle-btn.is-locked { background: var(--w-danger-soft); border-color: var(--w-danger); color: var(--w-danger); cursor: default; }

/* ================= admin/users.php: weekly day-off picker ================= */
.weekday-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-pick { position: relative; margin: 0; }
.weekday-pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.weekday-pick span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 42px; padding: 8px 10px; border-radius: 999px;
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-muted);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.weekday-pick input:checked + span { background: var(--w-primary-soft); border-color: var(--w-primary); color: var(--w-primary-dark); }
.location-status {
    display: flex; align-items: center; gap: 10px; border-radius: var(--w-radius-sm);
    padding: 12px; font-size: 13px; border: 1px solid var(--w-border); background: var(--w-bg); color: var(--w-muted);
}
.location-status .icon { font-size: 20px; flex: none; }
.location-status.ok { border-color: rgba(22, 163, 74, .35); background: rgba(22, 163, 74, .08); color: var(--w-text); }
.location-status.blocked { border-color: rgba(217, 45, 32, .4); background: var(--w-danger-soft); color: var(--w-danger); }

/* in-page camera capture (check-in selfie): full-screen live feed, no OS file picker involved */
.camera-modal {
    position: fixed; inset: 0; z-index: 2700; background: #000;
    display: flex; align-items: center; justify-content: center;
}
.camera-modal[hidden] { display: none; }
.camera-modal video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-modal-actions {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 24px calc(28px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; justify-content: center;
}
.camera-modal-shutter {
    width: 72px; height: 72px; border-radius: 50%; background: #fff; border: 4px solid rgba(255,255,255,.4);
    box-shadow: 0 0 0 2px rgba(0,0,0,.3);
}
.camera-modal-shutter:active { background: #ddd; }
.camera-modal-close {
    position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; left: auto; bottom: auto;
    width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.5); border: none; color: #fff; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
}

.btn-add-row {
    width: 100%; min-height: 48px; font-size: 15px; font-weight: 600;
    border: 1.5px dashed var(--w-primary-soft-border);
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: var(--w-radius-sm);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-add-row:active { background: var(--w-primary-soft-active); }

/* ================= action bar ================= */
.action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1010;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--w-border); box-shadow: var(--w-shadow-up);
    padding: 10px 16px calc(10px + var(--w-safe-b));
}
.action-bar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.action-summary { flex: 1; min-width: 0; line-height: 1.25; }
.action-summary small { display: block; font-size: 11.5px; color: var(--w-muted); }
.action-summary b { font-size: 15px; font-weight: 700; }
.action-bar .btn-save { flex: none; width: auto; min-width: 150px; padding: 0 22px; }

/* ================= buttons ================= */
.btn-save {
    width: 100%; min-height: 50px; font-size: 16px; font-weight: 600;
    border: none; border-radius: var(--w-radius);
    background: var(--w-primary); color: #fff;
    box-shadow: 0 4px 14px rgba(var(--w-primary-rgb), .28);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .15s, transform .05s;
}
.btn-save:active { background: var(--w-primary-dark); transform: translateY(1px); }
.btn-save:disabled { background: var(--w-primary-disabled); box-shadow: none; }
.btn-save .spinner-border { width: 18px; height: 18px; border-width: 2px; }

/* ================= bottom-sheet modal ================= */
.modal.sheet .modal-dialog {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; width: 100%;
    transform: translateY(100%); transition: transform .25s ease-out;
}
.modal.sheet.show .modal-dialog { transform: translateY(0); }
.modal.sheet .modal-content {
    border: none; border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + var(--w-safe-b));
    max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal.sheet .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--w-border-strong); margin: 4px auto 16px; }
.modal.sheet h5 { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.modal.sheet p { color: var(--w-muted); font-size: 14px; margin: 0 0 16px; }
.sheet-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.sheet-stat { background: var(--w-bg); border-radius: var(--w-radius-sm); padding: 10px 8px; text-align: center; }
.sheet-stat b { display: block; font-size: 20px; font-weight: 700; color: var(--w-primary-dark); line-height: 1.1; }
.sheet-stat span { font-size: 11.5px; color: var(--w-muted); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.7fr; gap: 10px; }
.sheet-actions .btn-save { font-size: 15px; line-height: 1.25; padding: 6px 10px; }
.btn-cancel {
    min-height: 50px; border-radius: var(--w-radius); font-size: 15px; font-weight: 600;
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-text);
    /* an icon and its label are two words, not one — they need the space between them */
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
}
.btn-cancel:active { background: var(--w-bg); }
@media (min-width: 576px) {
    .modal.sheet .modal-dialog { bottom: auto; top: 50%; transform: translateY(-40%); opacity: 0; transition: opacity .2s, transform .2s; }
    .modal.sheet.show .modal-dialog { transform: translateY(-50%); opacity: 1; }
    .modal.sheet .modal-content { border-radius: 20px; padding-bottom: 20px; }
}

/* ================= nav badge ================= */
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--w-danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
    margin-left: 6px;
}
.app-navbar .nav-link .nav-badge { margin-left: 8px; }
@media (max-width: 767.98px) { .app-navbar .nav-link .nav-badge { margin-left: auto; margin-right: 8px; } }

/* ================= chat: list ================= */
.chat-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-page-head h1 { margin: 0; }
.btn-new-chat {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    min-height: 38px; padding: 0 14px; border-radius: 999px;
    background: var(--w-primary); color: #fff; font-size: 13.5px; font-weight: 600; text-decoration: none;
    box-shadow: 0 3px 10px rgba(var(--w-primary-rgb), .3);
}
.btn-new-chat:hover, .btn-new-chat:active { color: #fff; text-decoration: none; background: var(--w-primary-dark); }

.chat-avatar {
    width: 48px; height: 48px; border-radius: 50%; flex: none;
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}
.chat-avatar.is-group { background: #eef1ff; color: #4c5fd5; font-size: 20px; }

.chat-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--w-surface); border: 1px solid var(--w-border); border-radius: var(--w-radius);
    padding: 12px; margin-bottom: 10px; text-decoration: none; color: var(--w-text);
    box-shadow: var(--w-shadow);
}
.chat-row:hover { border-color: var(--w-primary); text-decoration: none; color: var(--w-text); }
.chat-row-body { flex: 1; min-width: 0; }
.chat-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-row-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-time { font-size: 11.5px; color: var(--w-muted); flex: none; }
.chat-row-preview { display: block; font-size: 13px; color: var(--w-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat-unread-badge {
    flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
    background: var(--w-danger); color: #fff; font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ================= chat: conversation page ================= */
/* หน้าแชท: บีบทั้ง body ให้พอดีจอ ไม่ต้อง hardcode ความสูง navbar — flexbox คำนวณให้เอง */
body.chat-body {
    height: 100dvh; margin: 0; overflow: hidden;
    display: flex; flex-direction: column;
}
body.chat-body .app-navbar { flex: none; }
.chat-page {
    display: flex; flex-direction: column;
    flex: 1; min-height: 0; /* สำคัญ: ให้ลูก flex ยอมหดและ scroll ข้างในแทนการดันความสูง body */
}
.chat-header {
    display: flex; align-items: center; gap: 12px; flex: none;
    padding: 10px 16px; border-bottom: 1px solid var(--w-border); background: var(--w-surface);
}
.chat-back { color: var(--w-text); font-size: 20px; flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; }
.chat-back:hover { color: var(--w-primary); text-decoration: none; }
.chat-header-text { min-width: 0; }
.chat-header-title { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-sub { font-size: 12px; color: var(--w-muted); }

.chat-messages {
    flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 16px; display: flex; flex-direction: column; gap: 10px;
    max-width: 720px; width: 100%; margin: 0 auto; box-sizing: border-box;
}
.chat-messages .empty-state { margin: auto; }
.chat-day-divider { display: flex; align-items: center; justify-content: center; margin: 6px 0; }
.chat-day-divider span {
    background: var(--w-bg); color: var(--w-muted); font-size: 11.5px; font-weight: 600;
    padding: 4px 12px; border-radius: 999px; border: 1px solid var(--w-border);
}
.chat-load-older { display: flex; align-items: center; justify-content: center; padding: 10px 0; }
.chat-load-older .spinner-border { width: 20px; height: 20px; border-width: 2px; color: var(--w-primary); }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 82%; }
.msg-row.other { align-self: flex-start; }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none;
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg-row.me .msg-col { align-items: flex-end; }
.msg-sender { font-size: 11.5px; color: var(--w-muted); margin: 0 2px 3px; }
.msg-bubble {
    background: var(--w-surface); border: 1px solid var(--w-border); border-radius: 16px 16px 16px 4px;
    padding: 9px 13px; box-shadow: var(--w-shadow); max-width: 100%;
}
.msg-row.me .msg-bubble { background: var(--w-primary); border-color: var(--w-primary); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-text { font-size: 14.5px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.msg-text .mention { font-weight: 700; color: var(--w-primary-dark); }
.msg-row.me .msg-text .mention { color: #eafff5; text-decoration: underline; }
.msg-time-row { display: flex; align-items: center; }
.msg-time { font-size: 10.5px; color: var(--w-muted); margin: 3px 4px 0; }
.msg-receipts { margin: 1px 4px 0; }
.receipt-line { font-size: 10px; color: var(--w-primary-dark); line-height: 1.4; }

.msg-image { display: block; margin-top: 6px; border-radius: 10px; overflow: hidden; max-width: 220px; }
.msg-bubble > .msg-image:first-child { margin-top: 0; }
.msg-image img { width: 100%; display: block; max-height: 260px; object-fit: cover; }
.msg-file {
    display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 10px;
    background: rgba(0, 0, 0, .04); border-radius: 10px; text-decoration: none; color: inherit; max-width: 220px;
}
.msg-row.me .msg-file { background: rgba(255, 255, 255, .16); }
.msg-bubble > .msg-file:first-child { margin-top: 0; }
.msg-file i { font-size: 20px; flex: none; }
.msg-file-name { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.msg-file-size { font-size: 11px; opacity: .75; flex: none; }

.msg-voice { display: flex; align-items: center; gap: 8px; margin-top: 6px; max-width: 240px; }
.msg-bubble > .msg-voice:first-child { margin-top: 0; }
.msg-voice i { font-size: 16px; flex: none; }
.msg-voice audio { height: 34px; flex: 1; min-width: 0; }
.msg-voice-dur { font-size: 11px; opacity: .8; flex: none; }

.msg-video { display: block; margin-top: 6px; border-radius: 10px; max-width: 240px; max-height: 260px; background: #000; }
.msg-bubble > .msg-video:first-child { margin-top: 0; }

.unsent-bubble { background: transparent !important; border: 1px dashed var(--w-border-strong) !important; color: var(--w-muted) !important; font-size: 13px; padding: 8px 13px; }
.msg-resend-btn {
    border: none; border-radius: 8px; margin: 3px 4px 0 0; padding: 1px 5px;
    background: none; color: var(--w-primary-dark); font-size: 10.5px; font-weight: 600;
}
.msg-resend-btn:active { background: var(--w-bg); }
.msg-download-btn, .msg-share-btn {
    border: none; border-radius: 8px; margin: 3px 4px 0 0; padding: 1px 5px;
    background: none; color: var(--w-muted); font-size: 10.5px; font-weight: 600;
}
.msg-download-btn:active, .msg-share-btn:active { background: var(--w-bg); color: var(--w-primary); }

/* The share sheet, in bands: the company's own rooms, then one band per page or account. Each band
   scrolls on its own and is capped, so every band stays visible at once and a page with two hundred
   customers cannot push the rest off the sheet. */
.share-conv-list { height: 150px; overflow-y: auto; padding-right: 2px; }
.share-band { margin-bottom: 10px; }
.share-band-head {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700; color: var(--w-muted);
    padding: 4px 0 6px; border-bottom: 1px solid var(--w-border); margin-bottom: 6px;
}
.share-band-head small {
    margin-left: auto; font-weight: 600; color: var(--w-muted);
    background: var(--w-bg); border-radius: 999px; padding: 1px 8px;
}
.share-band-mark { font-size: 15px; }
.share-row { margin-bottom: 6px; }
/* the name, then where the room lives — the same two lines, in the same order, as the chat list */
.share-row .check-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.share-row .check-text b { font-size: 14px; line-height: 1.25; }
.share-row .check-text small {
    font-size: 11.5px; line-height: 1.3; color: var(--w-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ================= chat: composer ================= */
.chat-composer { flex: none; border-top: 1px solid var(--w-border); background: var(--w-surface); padding: 8px 12px calc(8px + var(--w-safe-b)); position: relative; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; max-width: 720px; margin: 0 auto; }
.composer-attach {
    flex: none; width: 40px; height: 40px; border: none; background: none; border-radius: 50%;
    color: var(--w-muted); font-size: 20px; display: inline-flex; align-items: center; justify-content: center;
}
.composer-attach:active { background: var(--w-bg); color: var(--w-primary); }
.composer-text {
    flex: 1; min-width: 0; resize: none; max-height: 120px; min-height: 40px;
    border: 1px solid var(--w-border-strong); border-radius: 20px; padding: 9px 16px;
    font-size: 15px; line-height: 1.35; background: var(--w-bg);
}
.composer-text:focus { border-color: var(--w-primary); box-shadow: 0 0 0 3px rgba(var(--w-primary-rgb), .12); background: var(--w-surface); }
.composer-send {
    flex: none; width: 40px; height: 40px; border: none; border-radius: 50%;
    background: var(--w-primary); color: #fff; font-size: 16px; display: inline-flex; align-items: center; justify-content: center;
}
.composer-send:active { background: var(--w-primary-dark); }
.composer-send:disabled { background: var(--w-primary-disabled); }

.voice-record-bar { display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 auto; height: 40px; }
.voice-discard, .voice-send {
    flex: none; width: 40px; height: 40px; border: none; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.voice-discard { background: var(--w-bg); color: var(--w-muted); }
.voice-discard:active { background: var(--w-border); }
.voice-send { background: var(--w-primary); color: #fff; }
.voice-send:active { background: var(--w-primary-dark); }
.voice-record-indicator { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--w-text); }
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: #e0453a; animation: voice-pulse 1.1s ease-in-out infinite; }
@keyframes voice-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.composer-pending { display: flex; flex-wrap: wrap; gap: 8px; max-width: 720px; margin: 0 auto 8px; }
.composer-pending:empty { display: none; }
.pending-item { position: relative; }
.pending-image { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--w-border); }
.pending-image img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.pending-file {
    display: flex; align-items: center; gap: 6px; max-width: 160px;
    background: var(--w-bg); border: 1px solid var(--w-border); border-radius: 10px; padding: 6px 22px 6px 8px; font-size: 12px;
}
.pending-file i { color: var(--w-primary); }
.pending-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-del {
    position: absolute; top: -6px; right: -6px; z-index: 3; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--w-surface);
    background: var(--w-danger); color: #fff; font-size: 12px; line-height: 1; padding: 0;
}

.mention-menu {
    position: absolute; left: 12px; right: 12px; bottom: 100%; margin-bottom: 6px;
    background: var(--w-surface); border: 1px solid var(--w-border); border-radius: var(--w-radius-sm);
    box-shadow: var(--w-shadow); max-height: 220px; overflow-y: auto; z-index: 20;
}
.mention-item {
    display: block; width: 100%; text-align: left; border: none; background: none;
    padding: 10px 14px; font-size: 14px; color: var(--w-text);
}
.mention-item:hover, .mention-item:active { background: var(--w-primary-soft); color: var(--w-primary-dark); }

/* ================= admin: users ================= */
.user-card {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--w-border); border-radius: var(--w-radius);
    padding: 12px; margin-bottom: 10px; background: var(--w-surface);
}
.user-info { flex: 1; min-width: 0; }
.user-actions { display: flex; flex-direction: column; gap: 2px; margin-right: -4px; }
.user-actions .item-remove { margin: 0; }
.user-edit:active { background: var(--w-primary-soft); color: var(--w-primary-dark); }
.user-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.user-login { font-size: 13px; color: var(--w-muted); overflow: hidden; text-overflow: ellipsis; }
.user-meta { font-size: 12px; color: var(--w-muted); margin-top: 2px; }
.badge-admin, .badge-you {
    display: inline-flex; align-items: center; gap: 3px;
    border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.badge-admin { background: var(--w-primary-soft); color: var(--w-primary-dark); }
.badge-you { background: var(--w-bg); color: var(--w-muted); border: 1px solid var(--w-border); }
.sec-step i { font-size: 13px; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px 8px; }
.member-row-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }

.check-row { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; padding: 10px 12px; border: 1px solid var(--w-border-strong); border-radius: var(--w-radius-sm); }
.check-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
    width: 24px; height: 24px; flex: none; border-radius: 7px;
    border: 1.5px solid var(--w-border-strong); background: var(--w-surface); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.check-row input:checked + .check-box { background: var(--w-primary); border-color: var(--w-primary); }
.check-row input:focus-visible + .check-box { box-shadow: 0 0 0 4px rgba(var(--w-primary-rgb), .14); }
.check-row input:checked + .check-box-danger { background: var(--w-danger); border-color: var(--w-danger); }
.check-text { line-height: 1.3; }
.check-text b { display: block; font-size: 14px; font-weight: 600; }
.check-text small { font-size: 12px; color: var(--w-muted); }
.btn-danger-solid { background: var(--w-danger) !important; box-shadow: 0 4px 14px rgba(217, 45, 32, .28) !important; }

/* ================= list / view ================= */
.pi-card {
    display: block; position: relative; background: var(--w-surface);
    border: 1px solid var(--w-border); border-radius: var(--w-radius-lg);
    padding: 14px 16px; margin-bottom: 12px; color: var(--w-text); text-decoration: none;
    box-shadow: var(--w-shadow);
}
.pi-card:hover { border-color: var(--w-primary); text-decoration: none; color: var(--w-text); }
.pi-card-edit { position: absolute; top: 10px; right: 10px; margin: 0; }
.pickup-card-wrap { position: relative; }
.pickup-edit-btn {
    position: absolute; top: 14px; right: 16px; z-index: 2;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--w-surface); border: 1px solid var(--w-border-strong);
    display: flex; align-items: center; justify-content: center;
    color: var(--w-text); font-size: 14px; box-shadow: var(--w-shadow);
}
.pickup-edit-btn:hover { border-color: var(--w-primary); color: var(--w-primary-dark); text-decoration: none; }
.pi-sender { font-weight: 600; font-size: 15px; white-space: pre-line; }
.pi-meta { font-size: 12px; color: var(--w-muted); margin-top: 8px; }
.pi-badge {
    display: inline-block; background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.thumb-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb-wrap { position: relative; width: 76px; height: 76px; }
/* pickup list cards: image strip (70%, horizontal scroll) + qty box (30%) side by side */
.pickup-media-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pickup-media-row .thumb-row {
    flex: 0 0 70%; max-width: 70%; margin-top: 0;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
}
.pickup-media-row.no-images .thumb-row { display: none; }
.pickup-media-row .pickup-qty-box {
    flex: 0 0 30%; max-width: 30%; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.pickup-media-row.no-images .pickup-qty-box { flex: 1 1 auto; max-width: none; text-align: left; align-items: flex-start; }
.pickup-qty-note { font-size: 14px; font-weight: 500; color: var(--w-muted); }
.pickup-qty-num { font-size: 20px; font-weight: 700; color: var(--w-text); }

/* horizontal progress bar (pickup list cards): created -> accepted -> picked_up/rejected */
.pp { display: flex; margin-top: 12px; }
.pp-step { flex: 1; text-align: center; position: relative; min-width: 0; }
.pp-step:not(:first-child)::before {
    content: ''; position: absolute; top: 11px; left: -50%; width: 100%; height: 3px;
    background: #d1d5db; z-index: 0;
}
.pp-step.reached:not(:first-child)::before { background: #000; }
.pp-dot {
    width: 24px; height: 24px; border-radius: 50%; margin: 0 auto; position: relative; z-index: 1;
    background: var(--w-border-strong); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.pp-step.reached .pp-dot { background: var(--pp-color, var(--w-primary)); }
.pp-step .pp-dot i { display: none; }
.pp-step.reached .pp-dot i { display: block; }
.pp-step.pp-created { --pp-color: var(--w-primary-dark); }
.pp-step.pp-accepted { --pp-color: #a15c00; }
.pp-step.pp-rejected { --pp-color: var(--w-danger); }
.pp-step.pp-picked-up { --pp-color: #15803d; }
.pp-label { font-size: 11px; font-weight: 600; color: var(--w-text); margin-top: 6px; padding: 0 2px; }
.pp-step:not(.reached) .pp-label { color: var(--w-muted); font-weight: 500; }
.pp-sub { font-size: 10.5px; color: var(--w-muted); margin-top: 3px; line-height: 1.35; padding: 0 2px; overflow-wrap: anywhere; }
.pp-date { font-size: 10px; color: var(--w-muted); margin-top: 1px; padding: 0 2px; }
.pp-note { font-size: 10.5px; color: var(--w-text); margin-top: 4px; padding: 0 2px; overflow-wrap: anywhere; white-space: pre-line; }
.pickup-section-divider { border: none; border-top: 6px solid #fff; margin: 10px 0 22px; border-radius: 3px; }
.thumb-img, .thumb-wrap img {
    width: 76px; height: 76px; object-fit: cover;
    border-radius: var(--w-radius-sm); border: 1px solid var(--w-border); display: block;
}
.checkin-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.pit-row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--w-border); padding: 10px 0; }
.pit-row:last-child { border-bottom: none; }
.pit-row img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--w-radius-sm); border: 1px solid var(--w-border); }
.checkin-manual-thumb {
    width: 64px; height: 64px; border-radius: var(--w-radius-sm); border: 1px dashed var(--w-border-strong);
    display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--w-muted); flex: none;
}
/* checkin/list.php: เข้า-ออก คู่กันในแถวเดียว ซ้าย=เข้า ขวา=ออก */
.pit-row-session { align-items: flex-start; gap: 10px; }
.pit-session-side { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-start; gap: 10px; }
.pit-session-side + .pit-session-side { padding-left: 10px; border-left: 1px solid var(--w-border); }
.pit-session-side img,
.pit-session-side .checkin-manual-thumb,
.pit-session-side .checkin-missing-thumb { width: 48px; height: 48px; flex: none; }
.checkin-missing-thumb {
    border-radius: var(--w-radius-sm); border: 1px dashed var(--w-border); background: var(--w-bg);
    display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--w-border-strong);
}
@media (max-width: 420px) {
    .pit-session-side { gap: 6px; }
    .pit-session-side img,
    .pit-session-side .checkin-manual-thumb,
    .pit-session-side .checkin-missing-thumb { width: 38px; height: 38px; }
}
.pit-qty { font-size: 16px; font-weight: 700; color: var(--w-primary-dark); }
.pit-label { font-size: 13px; color: var(--w-muted); }
.empty-state { text-align: center; color: var(--w-muted); padding: 40px 10px; font-size: 14px; }
.pre-line { white-space: pre-line; }
.video-embed { width: 100%; border-radius: var(--w-radius-sm); display: block; }

/* ================= login ================= */
body.login-body { background: var(--w-bg); min-height: 100vh; min-height: 100dvh; }
.login-hero {
    background: var(--w-primary-gradient);
    padding: calc(40px + env(safe-area-inset-top, 0px)) 24px 80px;
    color: #fff; text-align: center; position: relative; overflow: hidden;
}
.login-hero::before, .login-hero::after {
    content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .06);
}
.login-hero::before { width: 280px; height: 280px; top: -120px; right: -90px; }
.login-hero::after { width: 200px; height: 200px; bottom: -110px; left: -70px; }
.login-logo {
    width: 68px; height: 68px; border-radius: 20px; margin: 0 auto 14px;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25);
    display: flex; align-items: center; justify-content: center; font-size: 32px;
    position: relative; backdrop-filter: blur(6px);
}
.login-hero h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; position: relative; }
.login-hero p { margin: 4px 0 0; font-size: 13.5px; opacity: .85; position: relative; }
.login-card-wrap { max-width: 420px; margin: -52px auto 0; padding: 0 16px 32px; position: relative; }
.login-card {
    background: var(--w-surface); border: 1px solid var(--w-border);
    border-radius: 20px; box-shadow: 0 10px 34px rgba(15, 23, 20, .12); padding: 26px 22px 22px;
}
.login-card h2 { font-size: 17px; font-weight: 700; margin: 0 0 2px; }
.login-card .sub { font-size: 13px; color: var(--w-muted); margin-bottom: 18px; }
.login-card .field-label { margin-top: 12px; }
.login-card .btn-save { margin-top: 20px; }
.login-foot { text-align: center; font-size: 12px; color: var(--w-muted); margin-top: 22px; }
@media (min-width: 768px) {
    .login-hero { padding-top: 80px; padding-bottom: 96px; }
}

/* ================= alerts ================= */
.alert {
    border-radius: var(--w-radius-sm); font-size: 14px; padding: 11px 14px;
    border: 1px solid transparent; display: flex; align-items: flex-start; gap: 9px; margin-bottom: 14px;
}
.alert i { font-size: 17px; line-height: 1.3; }
.alert-danger { background: var(--w-danger-soft); color: #b42318; border-color: var(--w-danger-border); }
.alert-success { background: var(--w-primary-soft); color: var(--w-primary-dark); border-color: var(--w-primary-soft-border); }

/* ================= สั่งของ (order) ================= */
.status-pill {
    display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
    margin-left: 6px;
}
.status-pending { background: var(--w-bg); color: var(--w-muted); border: 1px solid var(--w-border); }
.status-ordered { background: #fff4e0; color: #a15c00; }
.status-prepared { background: #e6f0ff; color: #1a56c4; }
.status-fulfilled { background: #dcfce7; color: #15803d; }
.status-rejected { background: var(--w-danger-soft); color: var(--w-danger); }

.item-photo-wide { width: 100%; height: 200px; }
.qty-stepper-standalone { max-width: 220px; }

/* ส่วนงานเดียวที่มีสิทธิ์ — แสดงเป็นข้อความนิ่งแทน dropdown ไม่ต้องให้เลือก */
.order-cat-fixed {
    display: flex; align-items: center; gap: 10px; min-height: 48px;
    padding: 11px 13px; border-radius: var(--w-radius-sm); border: 1px solid var(--w-border);
    background: var(--w-primary-soft); color: var(--w-primary-dark); font-weight: 600; font-size: 15px;
}
.order-cat-fixed i { font-size: 17px; }

/* ---- order status timeline ---- */
.order-timeline { position: relative; padding-left: 4px; }
.order-timeline-item { position: relative; display: flex; gap: 12px; padding: 0 0 18px 22px; }
.order-timeline-item:last-child { padding-bottom: 0; }
.order-timeline-item::before {
    content: ""; position: absolute; left: 5px; top: 16px; bottom: -2px; width: 2px; background: var(--w-border);
}
.order-timeline-item:last-child::before { display: none; }
.order-timeline-dot {
    position: absolute; left: 0; top: 3px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--w-border-strong); border: 2px solid var(--w-surface); box-shadow: 0 0 0 1px var(--w-border-strong);
}
.order-timeline-item.is-current .order-timeline-dot { background: var(--w-primary); box-shadow: 0 0 0 1px var(--w-primary); }
.order-timeline-body { flex: 1; min-width: 0; }
.order-timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order-timeline-head .status-pill { margin-left: 0; }
.order-timeline-time { font-size: 12px; color: var(--w-muted); }
.order-timeline-note { font-size: 13.5px; margin-top: 6px; }
.order-timeline-by { font-size: 11.5px; color: var(--w-muted); margin-top: 4px; }

/* ================= chat: image lightbox ================= */
.msg-image { cursor: zoom-in; }
.img-lightbox {
    position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, .88);
    display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out;
    -webkit-tap-highlight-color: transparent;
}
.img-lightbox[hidden] { display: none; }
.img-lightbox a { display: block; max-width: 100%; max-height: 100%; line-height: 0; cursor: pointer; }
.img-lightbox img {
    max-width: 100%; max-height: calc(100vh - 32px); width: auto; height: auto; object-fit: contain;
    border-radius: 8px; box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
}
.img-lightbox-close {
    position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .18); color: #fff; font-size: 30px; line-height: 1; cursor: pointer;
}
.img-lightbox-close:hover { background: rgba(255, 255, 255, .32); }
body.lightbox-open { overflow: hidden; }

/* ================= date filter (toggle) ================= */
.date-filter { margin: 0 0 14px; border: 1px solid rgba(0,0,0,.08); border-radius: 12px; background: #fff; overflow: hidden; }
.date-filter-toggle {
    width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: transparent;
    font-weight: 600; color: var(--w-text, #222); text-align: left; cursor: pointer;
}
.date-filter-toggle .bi-calendar-range { color: var(--w-primary, #0f6b4f); }
.date-filter-toggle span { flex: 1; }
.date-filter-chev { transition: transform .2s; }
.date-filter.is-open .date-filter-chev { transform: rotate(180deg); }
.date-filter.is-active .date-filter-toggle { color: var(--w-primary, #0f6b4f); }
.date-filter.is-active { border-color: var(--w-primary, #0f6b4f); }
.date-filter-panel { display: none; padding: 4px 14px 14px; gap: 10px; flex-wrap: wrap; align-items: flex-end; border-top: 1px solid rgba(0,0,0,.06); }
.date-filter.is-open .date-filter-panel { display: flex; }
.date-filter-panel label { flex: 1 1 140px; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.date-filter-panel label small { color: #6c757d; }
.date-filter-panel input[type=date] { min-height: 38px; }
.date-filter-actions { display: flex; gap: 6px; flex: 1 1 100%; }
@media (min-width: 576px) { .date-filter-actions { flex: 0 0 auto; } }

/* ================= check-in list: user/place/date filter ================= */
.checkin-filter-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.checkin-filter-form > .input-icon { flex: 1 1 180px; margin: 0; }
.checkin-filter-dates { display: flex; gap: 10px; flex: 1 1 260px; }
.checkin-filter-dates label { flex: 1; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.checkin-filter-dates label small { color: var(--w-muted); }
.checkin-filter-actions { display: flex; gap: 8px; flex: 1 1 100%; }
@media (min-width: 576px) { .checkin-filter-actions { flex: 0 0 auto; } }

/* ================= check-in add page: today's status tabs + map ================= */
.checkin-status-sec { margin-top: 16px; }
.tab-bar { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--w-border); overflow-x: auto; }
.tab-btn {
    appearance: none; border: none; background: transparent; color: var(--w-muted);
    font-family: inherit; font-size: 14px; font-weight: 700; padding: 8px 4px 10px; margin-bottom: -1px;
    border-bottom: 3px solid transparent; cursor: pointer; display: flex; align-items: center; gap: 8px;
    white-space: nowrap; transition: color .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--w-text); }
.tab-btn.active { color: var(--w-primary-dark); border-bottom-color: var(--w-primary); }
.tab-btn .count {
    font-size: 11px; font-weight: 600; color: var(--w-muted); background: var(--w-bg);
    border: 1px solid var(--w-border); border-radius: 999px; padding: 1px 8px;
}
.tab-btn.active .count { color: var(--w-primary-dark); background: var(--w-primary-soft); border-color: var(--w-primary-soft-border); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.map-card { background: var(--w-bg); border: 1px solid var(--w-border); border-radius: var(--w-radius); padding: 12px; margin-bottom: 14px; }
.map-header { margin-bottom: 10px; font-size: 13px; }
.map-header .map-label { color: var(--w-text); font-weight: 600; }
.map-frame { width: 100%; height: 240px; border-radius: var(--w-radius-sm); background: var(--w-surface); }
.map-placeholder {
    height: 100px; display: flex; align-items: center; justify-content: center; color: var(--w-muted);
    font-size: 13px; background: var(--w-surface); border: 1px dashed var(--w-border-strong); border-radius: var(--w-radius-sm);
}
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.map-legend .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--w-muted); }
.map-legend .legend-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--w-border-strong); flex-shrink: 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--w-surface); color: var(--w-text); }

.checked-out-note {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; padding-top: 12px;
    border-top: 1px dashed var(--w-border-strong); font-size: 12px;
}
.checked-out-note .label { color: var(--w-muted); font-weight: 600; }
.checked-out-note .chip {
    display: inline-flex; align-items: center; gap: 5px; background: var(--w-surface); border: 1px solid var(--w-border);
    border-radius: 999px; padding: 3px 10px; color: var(--w-text);
}
.checked-out-note .chip .time { color: var(--w-muted); }

.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.emp-card { background: var(--emp-color, var(--w-surface)); border: 1px solid var(--w-border); border-radius: var(--w-radius); padding: 12px; }
.emp-name { font-size: 15px; font-weight: 700; color: var(--w-text); margin-bottom: 8px; word-break: break-word; }
.checkins { display: flex; flex-direction: column; gap: 8px; }
.checkin-row { display: flex; align-items: center; gap: 10px; background: var(--w-surface); border: 1px solid var(--w-border); border-radius: var(--w-radius-sm); padding: 6px 8px; }
.emp-card .checkin-row { background: rgba(255,255,255,.55); }
.checkin-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: #000; }
.checkin-info { min-width: 0; flex: 1; }
.checkin-info .badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-bottom: 2px; }
.checkin-info .badge-in { background: var(--w-primary-soft); color: var(--w-primary-dark); }
.checkin-info .badge-out { background: var(--w-danger-soft); color: var(--w-danger); }
.checkin-time { font-size: 13px; font-weight: 600; color: var(--w-text); }
.checkin-latlong { font-size: 11px; color: var(--w-muted); display: block; margin-top: 2px; }
.checkin-latlong a { color: var(--w-muted); text-decoration: none; }
.checkin-latlong a:hover { color: var(--w-primary-dark); text-decoration: underline; }
.no-work { color: var(--w-muted); font-size: 12px; padding: 4px 0; }

/* ================= leave-document list: inline approve/reject/undo ================= */
.leave-mark-row { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.leave-mark-form { display: inline-block; }
.leave-mark-btn {
    border: none; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
}
.leave-mark-btn-review { background: var(--w-primary); color: #fff; }
.leave-mark-btn-review:active { background: var(--w-primary-dark); }
.leave-mark-btn-reject { background: var(--w-danger); color: #fff; }
.leave-mark-btn-reject:active { background: var(--w-danger); filter: brightness(.9); }
.leave-mark-btn-undo { background: var(--w-bg); color: var(--w-muted); border: 1px solid var(--w-border-strong); }

/* ================= product/car catalog reference data ================= */
.catalog-sub-details { margin: 2px 0 12px 44px; }
.catalog-sub-details summary {
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--w-primary-dark);
    padding: 6px 0; list-style: none;
}
.catalog-sub-details summary::-webkit-details-marker { display: none; }
.catalog-sub-details summary::before { content: "▸ "; }
.catalog-sub-details[open] summary::before { content: "▾ "; }
.catalog-sub-card { opacity: .92; }

/* ================= nav groups (collapsible) ================= */
.nav-group .nav-group-toggle { width: 100%; }
.nav-group-toggle .nav-badge { margin-left: auto; }
.nav-group-toggle .nav-badge + .nav-group-chev { margin-left: 8px; }
.nav-group-chev { margin-left: auto; font-size: 13px; color: var(--w-border-strong); transition: transform .2s; }
.nav-group.is-open > .nav-group-toggle .nav-group-chev { transform: rotate(180deg); }
.nav-group.is-current > .nav-group-toggle { color: var(--w-primary-dark); }
.nav-group.is-current > .nav-group-toggle i:first-child { color: var(--w-primary); }
.nav-sub { list-style: none; margin: 0; padding: 0; display: none; }
.nav-group.is-open > .nav-sub { display: block; }
.nav-sub .nav-link { padding-left: 44px !important; font-size: 14.5px; }
.nav-sub .nav-link i:first-child { font-size: 15px; }
.nav-sub .nav-sub .nav-link { padding-left: 64px !important; font-size: 14px; }
@media (max-width: 767.98px) {
    .nav-sub { margin-top: 2px; }
    .nav-sub .nav-link { min-height: 44px; }
}
@media (min-width: 768px) {
    .nav-sub { margin-top: 2px; }
    .nav-sub .nav-link { height: 38px; }
    .app-navbar .nav-group-chev { display: inline; }
}

/* ================= super admin: "view as company" bar ================= */
.sa-impersonate-bar { position: sticky; top: 0; z-index: 1031; background: var(--w-primary-dark); color: #fff; }
.sa-impersonate-bar-inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 14px; font-size: 13px; }
.sa-impersonate-label { display: inline-flex; align-items: center; gap: 6px; }
.sa-impersonate-label b { font-weight: 700; }
.sa-impersonate-form { display: inline-flex; align-items: center; margin: 0; }
.sa-impersonate-form select {
    background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
    padding: 3px 8px; font-size: 12.5px; max-width: 180px;
}
.sa-impersonate-form select option { color: #000; }
.sa-impersonate-exit {
    background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
    padding: 3px 10px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.sa-impersonate-exit:hover { background: rgba(255,255,255,.28); }

/* ================= chat: search ================= */
.chat-page-head { flex-wrap: wrap; }
.chat-page-head h1 { flex: none; }
.chat-page-head .btn-new-chat { order: 2; }
.chat-search { position: relative; flex: 1 1 200px; order: 1; min-width: 0; }
.chat-search > .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--w-muted); font-size: 15px; pointer-events: none; }
.chat-search-input {
    width: 100%; height: 40px; padding: 0 36px 0 36px; border: 1px solid var(--w-border); border-radius: 999px;
    background: var(--w-surface); font-size: 14.5px; color: var(--w-text); outline: none; -webkit-appearance: none;
}
.chat-search-input:focus { border-color: var(--w-primary); box-shadow: 0 0 0 3px var(--w-primary-soft); }
.chat-search-input::-webkit-search-cancel-button { display: none; }
.chat-search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--w-muted); font-size: 16px; padding: 4px; line-height: 1; cursor: pointer; }
.chat-search-clear:hover { color: var(--w-text); }
.chat-row[hidden] { display: none !important; }
@media (max-width: 575.98px) {
    .chat-search { flex-basis: 100%; order: 3; }
    .chat-page-head .btn-new-chat { order: 2; margin-left: auto; }
}

/* ================= profile pictures ================= */
.user-avatar.has-img, .chat-avatar.has-img, .msg-avatar.has-img { padding: 0; overflow: hidden; background: #fff; }
.user-avatar img, .chat-avatar img, .msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.user-avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.avatar-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar-pick .avatar-preview { width: 64px; height: 64px; font-size: 26px; color: var(--w-muted); }
.avatar-pick .btn-pick {
    display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 8px 14px; cursor: pointer;
    border: 1px solid var(--w-border); border-radius: 999px; background: var(--w-surface); font-size: 14px; font-weight: 500;
}
.avatar-pick .btn-pick:hover { background: var(--w-bg); }
.avatar-pick .hint { flex-basis: 100%; margin: 0; color: var(--w-muted); font-size: 12.5px; }
.avatar-pick .check-row-sm { margin: 0; }
.doc-preview {
    width: 64px; height: 64px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    background: var(--w-bg); border: 1px dashed var(--w-border); color: var(--w-muted); font-size: 22px; overflow: hidden; flex-shrink: 0;
}
.doc-preview.has-img { border-style: solid; padding: 0; background: #fff; }
.doc-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ================= voice call ================= */
.chat-call-btn {
    margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
    background: var(--w-primary-soft); color: var(--w-primary-dark); font-size: 17px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.chat-call-btn:hover { background: var(--w-primary); color: #fff; }
.chat-call-btn:disabled { opacity: .5; cursor: default; }
.call-panel { position: fixed; inset: 0; z-index: 2500; background: rgba(15, 23, 42, .72); display: flex; align-items: center; justify-content: center; padding: 20px; }
.call-panel[hidden] { display: none; }
.call-card { background: var(--w-surface); border-radius: 20px; padding: 28px 22px 22px; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.call-avatar { width: 84px; height: 84px; font-size: 32px; margin: 0 auto 12px; }
.call-name { font-size: 19px; font-weight: 700; }
.call-status { color: var(--w-muted); margin-top: 4px; min-height: 22px; }
.call-timer { font-size: 26px; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.call-btn { border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: #fff; }
.call-btn i { font-size: 18px; }
.call-accept { background: #16a34a; }
.call-decline, .call-hangup { background: #dc2626; }
.call-mute { background: #e5e7eb; color: #111; }
.call-mute.is-on { background: #f59e0b; color: #fff; }
.call-close { background: #e5e7eb; color: #111; }
.call-panel[data-mode="calling"] .call-avatar, .call-panel[data-mode="incoming"] .call-avatar { animation: callpulse 1.4s ease-in-out infinite; }
@keyframes callpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); } 50% { box-shadow: 0 0 0 16px rgba(22,163,74,0); } }
/* site-wide incoming overlay */
.call-overlay { position: fixed; inset: 0; z-index: 2600; background: rgba(15, 23, 42, .72); display: none; align-items: center; justify-content: center; padding: 20px; }
.call-overlay.show { display: flex; }
.call-overlay-card { background: var(--w-surface); border-radius: 20px; padding: 28px 22px 22px; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.call-overlay-icon { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; background: #dcfce7; color: #16a34a; font-size: 30px; display: flex; align-items: center; justify-content: center; animation: callpulse 1.4s ease-in-out infinite; }
.call-overlay-title { color: var(--w-muted); }
.call-overlay-name { font-size: 20px; font-weight: 700; margin-top: 2px; }
.call-overlay-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }

/* active group meeting alert: dismissible top banner (any page) */
.meeting-alert {
    position: fixed; left: 12px; right: 12px; top: calc(-140px - env(safe-area-inset-top, 0px)); z-index: 2550;
    max-width: 420px; margin: 0 auto;
    background: var(--w-surface); border-radius: var(--w-radius); box-shadow: 0 12px 34px rgba(0,0,0,.25);
    display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
    transition: top .25s ease-out;
}
.meeting-alert.show { top: calc(12px + env(safe-area-inset-top, 0px)); }
.meeting-alert-icon {
    width: 44px; height: 44px; border-radius: 50%; flex: none; background: #dcfce7; color: #16a34a;
    font-size: 19px; display: flex; align-items: center; justify-content: center; animation: callpulse 1.4s ease-in-out infinite;
}
.meeting-alert-body { flex: 1; min-width: 0; }
.meeting-alert-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-alert-sub { font-size: 12.5px; color: var(--w-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-alert-actions { display: flex; gap: 8px; flex: none; }
.meeting-alert-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none; flex: none;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px;
    text-decoration: none; cursor: pointer;
}
.meeting-alert-btn:hover { color: #fff; text-decoration: none; opacity: .9; }
.meeting-alert-accept { background: #16a34a; }
.meeting-alert-decline { background: #dc2626; }
@media (min-width: 768px) { .meeting-alert { left: calc(var(--sb-w, 0px) + 12px); } }

.nav-profile { color: var(--w-text) !important; }
.nav-profile:hover, .nav-profile:active { background: var(--w-bg) !important; }
@media (max-width: 767.98px) { .nav-mobile-lang { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--w-border); } }

/* video call — desktop: windowed card (toggle to full screen); mobile: always full screen (.is-fs) */
.chat-video-btn { margin-left: 8px; }
.call-panel.is-video .call-avatar { display: none; }
.call-panel.is-video .call-card { max-width: 760px; padding: 12px 12px 14px; }
.call-video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.call-video-wrap[hidden] { display: none; }
#remoteVideo { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
#localVideo {
    position: absolute; top: 12px; right: 12px; width: 24%; max-width: 170px; aspect-ratio: 4 / 3;
    object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.75); background: #222;
    box-shadow: 0 4px 16px rgba(0,0,0,.5); z-index: 2;
}
.call-panel.is-video[data-mode="calling"] .call-avatar, .call-panel.is-video[data-mode="connecting"] .call-avatar {
    display: inline-flex; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2;
}
.call-panel.is-video .call-card { position: relative; }
.call-fs-btn.is-on { background: var(--w-primary); color: #fff; }

/* full-screen mode (mobile always; desktop when toggled) */
.call-panel.is-fs { padding: 0; background: #000; }
.call-panel.is-fs .call-card {
    max-width: none; width: 100%; height: 100%; padding: 0; border-radius: 0; background: #000; box-shadow: none;
    position: relative; display: flex; flex-direction: column; justify-content: flex-end;
}
.call-panel.is-fs .call-video-wrap { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; margin: 0; }
.call-panel.is-fs #localVideo { top: calc(12px + env(safe-area-inset-top, 0px)); width: 30%; max-width: 150px; aspect-ratio: 3 / 4; }
.call-panel.is-fs .call-name, .call-panel.is-fs .call-status, .call-panel.is-fs .call-timer {
    position: relative; z-index: 2; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); margin: 0 16px;
}
.call-panel.is-fs .call-name { font-size: 17px; }
.call-panel.is-fs .call-status { color: rgba(255,255,255,.85); }
.call-panel.is-fs .call-timer { font-size: 20px; }
.call-panel.is-fs .call-actions {
    position: relative; z-index: 2; margin: 12px 0 0; padding: 12px 12px calc(18px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,0));
}
.call-panel.is-fs .call-btn span { display: none; }
.call-panel.is-fs .call-btn { width: 56px; height: 56px; justify-content: center; padding: 0; border-radius: 50%; }
.call-panel.is-fs .call-btn i { font-size: 22px; }
.call-panel.is-fs .call-mute { background: rgba(255,255,255,.22); color: #fff; }
.call-panel.is-fs .call-mute.is-on, .call-panel.is-fs .call-fs-btn.is-on { background: #f59e0b; }
.call-panel.is-fs .call-hangup { width: 64px; height: 64px; }

/* installed to Home Screen (standalone): keep the top bar below the clock / signal area */
@media (display-mode: standalone) {
    .app-navbar { padding-top: env(safe-area-inset-top, 0px); }
    .call-panel, .call-overlay, .img-lightbox { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
    .meeting-panel-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}

/* self-preview is draggable inside the video box */
#localVideo { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: left .18s ease-out, top .18s ease-out; }
#localVideo.dragging { cursor: grabbing; transition: none; opacity: .9; box-shadow: 0 8px 28px rgba(0,0,0,.6); }

/* mirror whichever frame shows your own camera */
#localVideo.mirror, #remoteVideo.mirror { transform: scaleX(-1); }

/* ================= group meetings (mesh video/voice) ================= */
.meeting-banner {
    display: flex; align-items: center; gap: 8px; background: #fee2e2; color: #991b1b;
    padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.meeting-banner i { font-size: 15px; }
.meeting-banner span:not(.meeting-banner-join) { flex: 1; }
.meeting-banner-join {
    border: none; border-radius: 999px; padding: 5px 14px; font-size: 12.5px; font-weight: 700;
    background: var(--w-primary); color: #fff;
}
.meeting-panel { position: fixed; inset: 0; z-index: 2400; background: #111827; display: flex; flex-direction: column; }
.meeting-panel[hidden] { display: none; }
.meeting-panel-head { flex: none; padding: 12px 16px; color: #fff; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.meeting-rec-indicator {
    display: inline-flex; align-items: center; gap: 4px; margin-left: auto;
    background: #dc2626; color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700;
    animation: meeting-rec-pulse 1.4s ease-in-out infinite;
}
@keyframes meeting-rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.meeting-grid {
    flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 8px; padding: 8px 16px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    align-content: start;
}
.meeting-tile { position: relative; background: #1f2937; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.meeting-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.meeting-tile-name { position: absolute; left: 8px; bottom: 6px; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.meeting-tile-avatar { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: #374151; }
.meeting-tile.cam-off video { visibility: hidden; }
.meeting-tile.cam-off .meeting-tile-avatar { display: flex; }
.meeting-tile-avatar span {
    width: 30%; min-width: 44px; max-width: 88px; aspect-ratio: 1 / 1; border-radius: 50%;
    background: var(--w-primary); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: clamp(16px, 6vw, 32px); font-weight: 700;
}
.meeting-tile-avatar.has-img img { width: 100%; height: 100%; object-fit: cover; }
.meeting-tile.is-me video { transform: scaleX(-1); }
/* คนที่กำลังแชร์จอ: ขยายให้เต็มแถว ไม่ mirror (จอที่แชร์ไม่ควรกลับด้าน) แสดงพอดีจอไม่ครอป */
.meeting-tile.is-presenting { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.meeting-tile.is-presenting video { object-fit: contain; transform: none !important; }
.meeting-controls { flex: none; display: flex; justify-content: center; gap: 14px; padding: 16px; padding-bottom: calc(16px + var(--w-safe-b)); }
.meeting-ctl {
    width: 52px; height: 52px; border: none; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff;
    font-size: 19px; display: inline-flex; align-items: center; justify-content: center;
}
.meeting-ctl.is-on { background: #f59e0b; }
.meeting-ctl:disabled { opacity: .35; }
.meeting-leave { background: var(--w-danger); }

/* ================= ปฏิทิน (calendar) ================= */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav h2 { margin: 0; font-size: 16px; font-weight: 700; }
.cal-nav-btn {
    width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--w-bg); color: var(--w-text); border: 1px solid var(--w-border-strong);
}
.cal-nav-btn:hover { border-color: var(--w-primary); color: var(--w-primary-dark); text-decoration: none; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--w-muted); margin-bottom: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--w-muted); padding: 4px 0; }
.cal-cell {
    min-height: 46px; border-radius: 8px; border: 1px solid var(--w-border); background: var(--w-surface);
    padding: 4px 3px; display: flex; flex-direction: column; align-items: flex-start; position: relative;
}
.cal-cell-empty { border-color: transparent; background: transparent; min-height: 0; }
.cal-cell.is-today { border-color: var(--w-primary); border-width: 2px; }
.cal-cell.has-data { cursor: pointer; }
.cal-cell.has-data:hover { border-color: var(--w-primary); }
.cal-day-num { font-size: 12px; font-weight: 600; }
.cal-dots { display: flex; gap: 3px; margin-top: 2px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.cal-dot-leave { background: #e8710a; }
.cal-dot-withdraw { background: #ca8a04; }
.cal-dot-checkin { background: #ca8a04; }
.cal-detail-section-checkin h6 { color: #92660a; }
.cal-legend-time {
    font-family: monospace; background: var(--w-bg); border: 1px solid var(--w-border-strong);
    border-radius: 4px; padding: 1px 6px; font-size: 11px;
}
.cal-legend-time-withdraw { color: #92660a; border-color: #ca8a04; }
.cal-checkin-lines { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; width: 100%; }
.cal-checkin-line {
    font-size: 9.5px; font-weight: 700; line-height: 1.3; max-width: 100%;
}
.cal-checkin-in { color: #15803d; }
.cal-checkin-out { color: #b91c1c; }
/* In the day detail, in is green and out is red beside their own labels. In the grid cell there are
   no labels — just "16:43-16:43" — so green-and-red there reads as a warning rather than as two
   directions. One blue instead, the same blue the caption used before it was dropped. */
.cal-checkin-line .cal-checkin-in,
.cal-checkin-line .cal-checkin-out { color: #1d64d8; }
.cal-worktime-label { color: #1d64d8; font-weight: 700; margin-right: 6px; }
.cal-withdraw-line {
    font-size: 9.5px; font-weight: 700; color: #92660a; line-height: 1.3; margin-top: 2px;
    display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 480px) {
    .cal-day-num { font-size: 10.5px; }
    .cal-cell { padding: 3px 2px; border-radius: 6px; min-height: 40px; }
    .cal-checkin-line, .cal-withdraw-line { font-size: 8.3px; }
}
@media (min-width: 768px) {
    .cal-page-wrap { max-width: 960px; }
    .cal-cell { min-height: 76px; padding: 8px 7px; border-radius: 10px; }
    .cal-day-num { font-size: 14px; }
    .cal-checkin-line, .cal-withdraw-line { font-size: 11.5px; }
    .cal-dot { width: 7px; height: 7px; }
    .cal-dow { font-size: 12.5px; padding: 6px 0; }
    .cal-nav h2 { font-size: 19px; }
}
.cal-detail-section { margin-bottom: 14px; }
.cal-detail-section:last-child { margin-bottom: 0; }
.cal-detail-section h6 { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.cal-detail-section h6 .cal-dot { width: 8px; height: 8px; }
.cal-detail-row { font-size: 13.5px; padding: 4px 0; border-bottom: 1px solid var(--w-border); }
.cal-detail-row:last-child { border-bottom: none; }
.cal-detail-row-withdraw { display: flex; align-items: center; gap: 10px; }
.cal-withdraw-thumb.thumb-wrap { width: 44px; height: 44px; flex: none; }
.cal-withdraw-thumb.thumb-wrap img { width: 44px; height: 44px; }
.cal-detail-total { font-weight: 700; border-bottom: none; }

/* ================= notification sound toggle (top bar) ================= */
/* A speaker means push notifications are on for this device; a crossed-out speaker means they are
   off. It sits in the top bar so the state is visible without opening a menu. */
.nav-sound {
    position: relative; border-radius: var(--w-radius-sm); background: var(--w-surface);
    color: var(--w-muted); padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.nav-sound:active { background: var(--w-bg); }
.nav-sound.active { color: var(--w-primary); border-color: var(--w-primary-soft-border); background: var(--w-primary-soft); }
.nav-sound.active i { color: var(--w-primary); }

/* The label belongs to the sidebar row only. Hidden by default so a 44px icon button can never be
   stretched open by a long word — the button keeps its meaning through title and aria-label. */
.nav-sound-label { display: none; }

/* On a phone it is an icon-only button in the bar, beside the menu button. */
@media (max-width: 767.98px) {
    #notifToggleWrap { flex: none; margin-left: auto; margin-right: 8px; }
    .nav-sound {
        width: 44px; height: 44px; font-size: 20px;
        border: 1px solid var(--w-border);
    }
}
