/**
 * BorThong common theme for App Center and other web-services.
 * Link from HTML: <link rel="stylesheet" href="/theme.css">
 * Do not overwrite /css/theme.css (used by PM / RE / DO / subdirectory apps).
 * After the shared shell, this file still includes App Center page styles (ME, My App, …).
 */

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

:root {
    /* BorThong brand — yellow ↔ green */
    --bt-yellow: #F5C518;
    --bt-yellow-light: #FFF8DC;
    --bt-yellow-dark: #D4A017;
    --bt-green: #2E8B57;
    --bt-green-light: #4CAF50;
    --bt-green-dark: #1B5E3B;
    --bt-gradient: linear-gradient(135deg, var(--bt-yellow) 0%, var(--bt-green-light) 55%, var(--bt-green) 100%);
    --bt-gradient-soft: linear-gradient(135deg, rgba(245, 197, 24, 0.15), rgba(46, 139, 87, 0.15));

    --bg: #F4F7F0;
    --surface: #ffffff;
    --text: #1a2e1a;
    --text-muted: #5a6b5a;
    --border: rgba(46, 139, 87, 0.12);
    --shadow: 0 2px 12px rgba(27, 94, 59, 0.08);
    --shadow-lg: 0 8px 28px rgba(27, 94, 59, 0.12);
    --radius: 14px;
    --nav-h: 64px;
    --header-h: 172px;
    --sidebar-w: 240px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --ticker-h: 0px;
}

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Sarabun', 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ── SHELL ── */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── PFTB topbar (แถบบนเขียว) ── */
.pftb {
    position: relative;
    z-index: 6000;
    height: var(--header-h);
    background: var(--bt-gradient);
    overflow: hidden;
    flex-shrink: 0;
}

.pftb::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('/images/borthong_landplot.png') center/cover no-repeat;
    opacity: 0.35;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.pftb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(27, 94, 59, 0.25), rgba(27, 94, 59, 0.55));
    pointer-events: none;
}

.pftb-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.pftb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pftb-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 8;
    pointer-events: auto;
}

.pftb-debug {
    border: 1px solid rgba(253, 224, 71, 0.7);
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    pointer-events: auto;
    position: relative;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pftb-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-top: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.pftb-refresh:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
}

.pftb-refresh:active {
    transform: scale(0.92);
}

.pftb-refresh.spinning .refresh-icon {
    animation: refreshSpin 0.65s linear;
}

.pftb-logout:hover {
    background: rgba(220, 38, 38, 0.85);
    border-color: rgba(255, 255, 255, 0.55);
}

.pftb-debug:hover { filter: brightness(1.08); }

.app-impersonate-banner {
    display: none;
    position: relative;
    z-index: 20000;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #7c2d12, #b45309);
    color: #fff8eb;
    font-size: 0.82rem;
    font-weight: 600;
    pointer-events: auto;
}
.app-impersonate-banner:not([hidden]) {
    display: flex !important;
}
.app-imp-exit {
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: #fff;
    color: #7c2d12;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 2;
    touch-action: manipulation;
}
.app-imp-exit:hover,
.app-imp-exit:focus-visible {
    filter: brightness(1.06);
    outline: none;
}
body.has-impersonate-banner { padding-top: 0 !important; }

@keyframes refreshSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pftb-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0;
    border-radius: 0;
    max-width: none;
}

.pftb-badge-short {
    display: none;
}

.pftb-badge-logo-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
    overflow: hidden;
    border-radius: 6px;
}

.me-home-brand-wrap {
    overflow: hidden;
    border-radius: 8px;
}

.pftb-badge-logo {
    display: block;
    height: 56px;
    width: auto;
    max-width: none;
    object-fit: contain;
    background: transparent;
    border-radius: 0;
    padding: 0;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.pftb-badge-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ── FLIP CLOCK ── */
.pftb-clock-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.flip-clock {
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: 'Inter', 'Sarabun', sans-serif;
    --fd-h: 40px;
    --fd-w: 30px;
}

/* ── CLOCK STYLES (non-flip) ── */
.pftb-clock {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.clock-minimal {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    letter-spacing: 0.06em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.clock-neon {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.12rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--bt-yellow);
    letter-spacing: 0.08em;
    text-shadow:
        0 0 6px rgba(245, 197, 24, 0.9),
        0 0 14px rgba(245, 197, 24, 0.45),
        0 0 22px rgba(46, 139, 87, 0.35);
    animation: neonPulse 2s ease-in-out infinite;
}

@keyframes neonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.88; }
}

.clock-segment {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 1.08rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: #7dff9a;
    letter-spacing: 0.12em;
    text-shadow: 0 0 8px rgba(125, 255, 154, 0.55);
}

.clock-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(245, 197, 24, 0.45);
    border-radius: 999px;
    padding: 3px 10px 3px 12px;
    font-family: 'Inter', system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    color: #fff;
    box-shadow: 0 0 12px rgba(245, 197, 24, 0.2);
}

.clock-badge-sec {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--bt-yellow);
}

.clock-simple.tick {
    animation: clockTick 0.35s ease;
}

@keyframes clockTick {
    0% { opacity: 0.55; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── CLOCK PICKER (Settings) ── */
.clock-picker-note {
    padding: 10px 16px 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.clock-picker {
    position: relative;
    padding: 12px 16px 14px;
}

.clock-picker-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.clock-picker-trigger:hover,
.clock-picker.open .clock-picker-trigger {
    border-color: var(--bt-green);
    box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.12);
}

.clock-picker-trigger-info {
    flex: 1;
    min-width: 0;
}

.clock-picker-trigger-info strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.clock-picker-trigger-info span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.clock-picker-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.clock-picker.open .clock-picker-arrow {
    transform: rotate(180deg);
}

.clock-picker-menu {
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
}

.clock-picker-menu[hidden] {
    display: none !important;
}

.clock-picker.open .clock-picker-menu {
    display: block;
}

.clock-picker-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s;
}

.clock-picker-option:last-child {
    border-bottom: none;
}

.clock-picker-option:hover {
    background: var(--bt-yellow-light);
}

.clock-picker-option.selected {
    background: var(--bt-gradient-soft);
}

.clock-picker-option-info strong {
    display: block;
    font-size: 0.88rem;
    color: var(--text);
}

.clock-picker-option-info span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.clock-preview-sample {
    width: 118px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #2E8B57 0%, #1B5E3B 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* mini previews */
.sample-flip {
    display: flex;
    gap: 2px;
    align-items: center;
}

.sample-flip .sd {
    width: 10px;
    height: 14px;
    background: linear-gradient(180deg, #3a5a42, #1e3a28);
    border-radius: 2px;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    font-family: Inter, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sample-flip .sc {
    color: #F5C518;
    font-size: 8px;
    font-weight: 800;
}

.sample-minimal {
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.06em;
}

.sample-neon {
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 800;
    color: #F5C518;
    text-shadow: 0 0 6px rgba(245, 197, 24, 0.8);
    letter-spacing: 0.06em;
}

.sample-segment {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #7dff9a;
    letter-spacing: 0.08em;
    text-shadow: 0 0 4px rgba(125, 255, 154, 0.5);
}

.sample-badge {
    font-family: Inter, sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(245, 197, 24, 0.5);
    border-radius: 999px;
    padding: 3px 8px;
}

.sample-badge em {
    font-style: normal;
    color: #F5C518;
    font-size: 8px;
    margin-left: 2px;
}

.clock-preview-hint {
    margin: 0 16px 12px;
    padding: 10px 12px;
    background: rgba(245, 197, 24, 0.15);
    border: 1px solid rgba(245, 197, 24, 0.35);
    border-radius: 10px;
    font-size: 0.78rem;
    color: var(--bt-green-dark);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.clock-preview-hint[hidden] {
    display: none;
}

.btn-link {
    background: none;
    border: none;
    color: var(--bt-green);
    font-weight: 700;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
    padding: 0;
}

.btn-save-clock {
    margin-bottom: 16px;
}

.flip-colon {
    color: var(--bt-yellow);
    font-size: calc(var(--fd-h) * 0.42);
    font-weight: 800;
    line-height: 1;
    padding: 0 1px;
    animation: colonPulse 1s step-end infinite;
    text-shadow: 0 0 8px rgba(245, 197, 24, 0.6);
}

@keyframes colonPulse {
    50% { opacity: 0.35; }
}

.flip-digit {
    position: relative;
    width: var(--fd-w);
    height: var(--fd-h);
    perspective: 320px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: calc(var(--fd-h) * 0.72);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.flip-digit.seconds {
    --fd-h: 44px;
    --fd-w: 34px;
    font-size: calc(var(--fd-h) * 0.72);
}

.flip-card {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.flip-card::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 5;
    pointer-events: none;
}

.flip-half {
    position: absolute;
    left: 0;
    right: 0;
    height: 50%;
    overflow: hidden;
    background: linear-gradient(180deg, #2a4a32 0%, #1e3a28 100%);
    color: #fff;
}

/* ตัวเลขเต็มหลัก: span สูงเท่าการ์ด วาง top/bottom แล้ว clip ครึ่งบน/ล่าง */
.flip-half span {
    position: absolute;
    left: 0;
    width: 100%;
    height: var(--fd-h);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: inherit;
    line-height: 1;
}

.flip-top,
.flip-top-flip {
    top: 0;
    border-radius: 6px 6px 0 0;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.2);
}

.flip-top span,
.flip-top-flip span {
    top: 0;
}

.flip-bottom,
.flip-bottom-flip {
    bottom: 0;
    border-radius: 0 0 6px 6px;
}

.flip-bottom span,
.flip-bottom-flip span {
    bottom: 0;
}

.flip-top-flip,
.flip-bottom-flip {
    position: absolute;
    left: 0;
    right: 0;
    height: 50%;
    overflow: hidden;
    background: linear-gradient(180deg, #3a5a42 0%, #254832 100%);
    color: #fff;
    backface-visibility: hidden;
    z-index: 3;
}

.flip-top-flip {
    transform-origin: bottom center;
    transform: rotateX(0deg);
}

.flip-bottom-flip {
    transform-origin: top center;
    transform: rotateX(90deg);
    z-index: 2;
}

.flip-digit.play .flip-top-flip {
    animation: flipTopDown 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.flip-digit.play .flip-bottom-flip {
    animation: flipBottomUp 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes flipTopDown {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(-90deg); }
}

@keyframes flipBottomUp {
    0% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.flip-digit.seconds .flip-card,
.flip-digit.seconds .flip-top-flip,
.flip-digit.seconds .flip-bottom-flip {
    box-shadow: 0 0 12px rgba(245, 197, 24, 0.25);
}

.flip-digit.seconds .flip-half,
.flip-digit.seconds .flip-top-flip,
.flip-digit.seconds .flip-bottom-flip {
    background: linear-gradient(180deg, #3d5c3a 0%, #2a5030 100%);
}

.pftb-date {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
}

.pftb-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.pftb-info {
    flex: 1;
    min-width: 0;
}

.pftb-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    line-height: 1.15;
    letter-spacing: 0.03em;
}

.pftb-title::after {
    content: '';
    display: block;
    width: 52px;
    height: 3px;
    margin-top: 5px;
    background: linear-gradient(90deg, var(--bt-yellow), rgba(245, 197, 24, 0.35));
    border-radius: 2px;
}

.pftb-company {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.93);
    margin-top: 6px;
    line-height: 1.45;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    padding-left: 10px;
    border-left: 3px solid var(--bt-yellow);
    max-width: 520px;
}

.pftb-info p.pftb-sub {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.pftb-tags {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.pftb-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bt-yellow);
    color: var(--bt-green-dark);
}

.pftb-tag.green {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.pftb-logo {
    width: auto;
    height: 72px;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.28));
}

/* ── MAIN BODY ── */
.body-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 16px 14px calc(var(--nav-h) + var(--safe-bottom) + 16px);
    overflow-y: auto;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--bt-green);
    margin-bottom: 12px;
}

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    padding: 11px 16px 11px 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--bt-green-light);
}

.search-bar .si {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.45;
    font-size: 16px;
}

/* ── APP GRID ── */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.service-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
    min-height: 72px;
}

button.service-card {
    width: 100%;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(46, 139, 87, 0.12);
}

.service-card:active {
    transform: scale(0.97);
}

.service-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(245, 197, 24, 0.35);
}

.service-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bt-gradient-soft);
    border: 2px solid rgba(46, 139, 87, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.service-name {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

.badge-new {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--bt-yellow);
    color: var(--bt-green-dark);
    font-size: 8px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 999px;
}

.service-card.hidden {
    display: none;
}

.room-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.room-bar[hidden] {
    display: none !important;
}

.room-back {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--bt-green-dark);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.room-bar .section-title {
    margin-bottom: 0;
}

.room-code {
    font-family: 'Share Tech Mono', ui-monospace, monospace;
    letter-spacing: 0.4px;
}

.room-meta {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

.room-card .service-name {
    white-space: normal;
}

.room-dept {
    font-family: 'Sarabun', 'Inter', sans-serif;
    font-weight: 600;
    letter-spacing: 0;
}

.room-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.room-code-line {
    font-family: 'Share Tech Mono', ui-monospace, monospace;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.room-dept-line {
    font-family: 'Sarabun', 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.25;
}

/* ไอคอนห้อง = โฟลเดอร์แก้วใส (SVG จาก roomFolderIcon() ใน index.html)
   สีเงาตั้งผ่าน --rf-shadow-rgb / --rf-halo-rgb ตามสีที่บันทึกใน a03c_ui_setting */
.room-card .service-icon {
    width: 56px;
    height: 49px;
    margin-top: 2px;
    border-radius: 0;
    border: none;
    background: none;
    box-shadow: none;
    position: relative;
    overflow: visible;
    transform: rotate(-4deg);
    filter: drop-shadow(0 5px 8px rgba(var(--rf-shadow-rgb, 167, 139, 250), 0.32)) drop-shadow(0 0 6px rgba(var(--rf-halo-rgb, 244, 114, 182), 0.3));
}

.room-card .service-icon .room-folder-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.room-card:hover .service-icon {
    filter: drop-shadow(0 7px 11px rgba(var(--rf-shadow-rgb, 167, 139, 250), 0.4)) drop-shadow(0 0 10px rgba(var(--rf-halo-rgb, 244, 114, 182), 0.45));
}

/* แถบเลือกสีโฟลเดอร์ใน My App — แสดงเฉพาะบัญชีที่ API ตอบ can_edit */
.folder-color-picker {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.folder-color-picker[hidden] {
    display: none;
}

.fcp-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin-bottom: 10px;
}

.fcp-title {
    font-weight: 700;
    color: var(--text);
}

.fcp-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.fcp-group-title {
    margin: 4px 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.fcp-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 8px;
}

.fcp-swatches + .fcp-group-title {
    margin-top: 12px;
}

.fcp-swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px 6px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.fcp-swatch:hover {
    transform: translateY(-2px);
    background: var(--bt-gradient-soft);
}

.fcp-swatch.is-picked {
    border-color: var(--bt-green);
    background: var(--bt-gradient-soft);
    box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.18);
}

.fcp-check {
    position: absolute;
    top: 4px;
    right: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: transparent;
    font-size: 11px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
}

.fcp-swatch.is-picked .fcp-check {
    background: var(--bt-green);
    border-color: var(--bt-green);
    color: #fff;
}

.fcp-icon {
    width: 44px;
    height: 39px;
    transform: rotate(-4deg);
    filter: drop-shadow(0 3px 5px rgba(var(--sw-shadow), 0.35));
}

.fcp-icon .room-folder-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.fcp-name {
    font-size: 0.74rem;
    line-height: 1.2;
    text-align: center;
}

.fcp-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.fcp-status {
    flex: 1 1 auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.fcp-btn {
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.fcp-btn.fcp-save {
    background: var(--bt-green);
    border-color: var(--bt-green);
    color: #fff;
}

.fcp-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

@media (max-width: 767px) {
    .fcp-swatches {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .fcp-swatch {
        padding: 6px 2px 4px;
    }

    .fcp-icon {
        width: 34px;
        height: 30px;
    }

    .fcp-check {
        width: 15px;
        height: 15px;
        font-size: 9px;
        line-height: 12px;
    }

    .fcp-name {
        font-size: 0.66rem;
    }
}

/* My App — mobile: capsule cards */
@media (max-width: 767px) {
.apps-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px 12px;
        padding: 2px 2px 8px;
    }

    .service-card {
        flex-direction: column;
        align-items: center;
        justify-content: center;
    text-align: center;
        gap: 10px;
        min-height: 118px;
        padding: 18px 10px 16px;
        border-radius: 999px;
        background:
            radial-gradient(90% 70% at 50% 12%, rgba(245, 197, 24, 0.18) 0%, transparent 58%),
            linear-gradient(180deg, #ffffff 0%, #eef8f1 100%);
        border: 1.5px solid rgba(46, 139, 87, 0.16);
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.95) inset,
            0 8px 18px rgba(27, 94, 59, 0.08);
    }

    button.service-card {
        text-align: center;
    }

    .service-card:hover {
        border-color: rgba(46, 139, 87, 0.32);
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 1) inset,
            0 10px 22px rgba(27, 94, 59, 0.14);
    }

    .service-card:active {
        transform: scale(0.96);
    }

    .service-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        font-size: 22px;
        background: linear-gradient(145deg, #fffdf0 0%, #dff3e6 100%);
        border: 1.5px solid rgba(46, 139, 87, 0.24);
        box-shadow: 0 3px 10px rgba(27, 94, 59, 0.12);
    }

    .service-name {
        font-size: 0.68rem;
        font-weight: 700;
        line-height: 1.25;
        letter-spacing: 0.01em;
        max-width: 92%;
        padding: 0 2px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .badge-new {
        top: 10px;
        right: 50%;
        transform: translateX(50%);
        font-size: 7px;
        padding: 2px 7px;
    }
}

/* ── ANNOUNCEMENTS ── */
.announce-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.announce-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.announce-card .date {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.announce-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bt-green-dark);
    margin-bottom: 6px;
}

.announce-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.announce-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.announce-panel-head .section-title {
    margin: 0;
}

.btn-announce-admin {
    border: 1px solid rgba(46, 139, 87, 0.35);
    background: var(--bt-gradient-soft);
    color: var(--bt-green-dark);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.announce-card-click {
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.announce-card-click:hover {
    border-color: rgba(46, 139, 87, 0.35);
    box-shadow: 0 4px 16px rgba(27, 94, 59, 0.1);
}

.announce-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.announce-clip {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--bt-green);
    text-decoration: none;
    background: var(--bt-gradient-soft);
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(46, 139, 87, 0.2);
}

.announce-clip:hover {
    text-decoration: underline;
}

.btn-announce-delete {
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(254, 226, 226, 0.9);
    color: #b91c1c;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
}

.btn-announce-delete:hover {
    background: #fecaca;
}

.announce-card-top-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.announce-delete-title {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 0 0 8px;
    line-height: 1.45;
}

/* Ticker — ME HOME มือถือเท่านั้น เหนือแท็บ ME / MyTask / My App */
.announce-ticker {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-h) + var(--safe-bottom));
    z-index: 220;
    height: 30px;
    background: #F5C518;
    color: #111;
    display: none;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.18);
    touch-action: manipulation;
}

.announce-ticker[hidden] {
    display: none !important;
}

.announce-ticker-track {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}

.announce-ticker-marquee {
    display: inline-flex;
    white-space: nowrap;
    will-change: transform;
    animation: announceTickerLoop var(--ticker-duration, 60s) linear infinite;
}

.announce-ticker-row {
    display: inline-block;
    flex-shrink: 0;
    font-size: 0.63rem;
    font-weight: 600;
    line-height: 1.2;
}

.announce-ticker-sep {
    opacity: 0.55;
    margin: 0 0.35rem;
}

.announce-ticker-new {
    display: inline-block;
    color: #1d4ed8;
    font-size: 0.54rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 4px;
    animation: announceNewBlink 1s ease-in-out infinite;
}

@keyframes announceNewBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.18; }
}

.announce-ticker-label {
    color: #111;
}

.announce-ticker-title {
    font-weight: 700;
    color: #111;
}

.announce-ticker-body {
    font-weight: 500;
    opacity: 0.95;
}

.announce-ticker-file {
    display: inline-block;
    color: #111;
    font-weight: 700;
    font-size: 0.58rem;
    font-family: inherit;
    line-height: 1.2;
    text-decoration: underline;
    margin-left: 6px;
    padding: 0 4px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.08);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.announce-ticker-file:active {
    background: rgba(0, 0, 0, 0.35);
}

@keyframes announceTickerLoop {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.announce-ticker-close {
    flex-shrink: 0;
    width: 28px;
    height: 30px;
    border: none;
    border-left: 1px solid rgba(0, 0, 0, 0.18);
    background: rgba(0, 0, 0, 0.08);
    color: #111;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
}

@media (max-width: 767px) {
    body.has-announce-ticker {
        --ticker-h: 30px;
    }

    body.has-announce-ticker .announce-ticker {
        display: flex;
        height: 30px;
        z-index: 220;
    }

    .announce-ticker-row {
        font-size: 0.63rem;
    }

    .announce-ticker-file {
        padding: 0 4px;
        margin-left: 6px;
    }

    .announce-ticker-close {
        width: 28px;
        height: 30px;
    }
}

@media (min-width: 768px) {
    .announce-ticker {
        display: none !important;
    }
}

body.has-announce-ticker .mobile-qr-fab {
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 38px);
}

body.has-announce-ticker .save-toast {
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 38px);
}

.announce-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 420;
    background: rgba(8, 18, 12, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: calc(12px + var(--safe-bottom));
}

.announce-gallery-overlay[hidden] {
    display: none !important;
}

.announce-gallery {
    width: min(560px, 100%);
    background: #0f2418;
    color: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.announce-gallery-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #14532d;
}

.announce-gallery-head h3 {
    flex: 1;
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
}

.announce-gallery-count {
    font-size: 0.78rem;
    opacity: 0.85;
}

.announce-gallery-stage {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #08140e;
}

.announce-gallery-stage img {
    max-width: 100%;
    max-height: min(62vh, 420px);
    object-fit: contain;
}

.announce-gallery-nav {
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
}

.announce-gallery-btn {
    flex: 1;
    min-height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}

.announce-gallery-btn.is-next {
    background: #F5C518;
    color: #14532d;
}

.announce-gallery-btn[hidden] {
    display: none !important;
}

/* Announce modals */
.announce-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(15, 36, 24, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(16px + var(--safe-bottom));
}

.announce-modal-overlay[hidden] {
    display: none !important;
}

.announce-modal {
    width: min(100%, 520px);
    max-height: min(90vh, 720px);
    overflow: auto;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.announce-modal.wide {
    width: min(100%, 640px);
}

.announce-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bt-gradient);
    color: #fff;
}

.announce-modal-head h3 {
    font-size: 1rem;
    font-weight: 700;
}

.announce-modal-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
}

.announce-modal-body {
    padding: 16px;
}

.announce-detail-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.announce-detail-content {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text);
    white-space: pre-wrap;
    margin-bottom: 14px;
}

.announce-detail-attach {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--bt-gradient-soft);
    border: 1px solid rgba(46, 139, 87, 0.25);
    color: var(--bt-green-dark);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.88rem;
}

.announce-form-grid {
    display: grid;
    gap: 12px;
}

.announce-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bt-green-dark);
}

.announce-form-grid input,
.announce-form-grid textarea,
.announce-form-grid select {
    font-family: inherit;
    font-size: 0.88rem;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.announce-form-grid textarea {
    min-height: 88px;
    resize: vertical;
}

.announce-form-row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.announce-admin-list {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    max-height: 180px;
    overflow: auto;
}

.announce-admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.82rem;
}

.announce-admin-row span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-announce-edit {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
}

.announce-admin-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.btn-announce-save {
    width: 100%;
    margin-top: 4px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--bt-gradient);
    color: #fff;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.announce-form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.announce-file-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.announce-file-row label {
    flex: 1 1 200px;
}

.btn-drive-folder {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bt-gradient-soft);
    border: 1px solid rgba(46, 139, 87, 0.3);
    color: var(--bt-green-dark);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    margin-bottom: 2px;
}

.btn-drive-folder:hover {
    background: rgba(245, 197, 24, 0.25);
}

.announce-link-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(46, 139, 87, 0.08);
    border: 1px dashed rgba(46, 139, 87, 0.35);
}

.announce-link-preview[hidden] {
    display: none !important;
}

.announce-link-open {
    flex: 1 1 180px;
    color: var(--bt-green-dark);
    font-size: 0.82rem;
    font-weight: 600;
    word-break: break-all;
    text-decoration: underline;
}

.btn-copy-file-link {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--bt-green-dark);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.btn-copy-file-link:hover {
    background: var(--bt-gradient-soft);
}

.announce-admin-status {
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 8px 10px;
    border-radius: 8px;
    margin-top: 4px;
}

.announce-admin-status.ok {
    background: rgba(46, 139, 87, 0.1);
    color: var(--bt-green-dark);
}

.announce-admin-status.err {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
}

.announce-auth-gate {
    display: flex;
    justify-content: center;
    padding: 32px 16px 48px;
}

.announce-auth-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 28px 24px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 8px 28px rgba(27, 94, 59, 0.08);
}

.announce-auth-card.denied {
    border-color: rgba(239, 68, 68, 0.25);
}

.announce-auth-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.announce-auth-card h3 {
    font-size: 1.15rem;
    color: var(--bt-green-dark);
    margin-bottom: 8px;
}

.announce-auth-card.denied h3 {
    color: #b91c1c;
}

.announce-auth-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 12px;
}

.announce-auth-card a {
    color: var(--bt-green);
    font-weight: 600;
}

.announce-auth-note {
    font-size: 0.78rem !important;
    margin-top: 12px !important;
    margin-bottom: 0 !important;
}

.announce-auth-hint {
    font-size: 0.78rem;
    color: #b45309;
    background: rgba(245, 158, 11, 0.1);
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 4px !important;
}

.announce-auth-hint.err {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.08);
}

.btn-announce-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-announce-google:hover {
    background: #f8faf8;
}

.btn-announce-google.secondary {
    background: var(--bt-gradient-soft);
    border-color: rgba(46, 139, 87, 0.3);
    color: var(--bt-green-dark);
}

.announce-admin-gate-err {
    font-size: 0.78rem;
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.08);
    padding: 8px 10px;
    border-radius: 8px;
    margin: 0;
}

.announce-admin-gate-err[hidden] {
    display: none !important;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px dashed rgba(46, 139, 87, 0.25);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--bt-green-dark);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── SETTINGS ── */
.settings-group {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.settings-group.settings-group-clock {
    overflow: visible;
    position: relative;
    z-index: 20;
}

.settings-group-title {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bt-green);
    background: var(--bt-gradient-soft);
    border-bottom: 1px solid var(--border);
}

.layout-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.layout-option:last-child {
    border-bottom: none;
}

.layout-option:hover {
    background: var(--bt-yellow-light);
}

.layout-option input[type="radio"] {
    accent-color: var(--bt-green);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.layout-option-info {
    flex: 1;
}

.layout-option-info strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.layout-option-info span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.layout-preview {
    width: 48px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.layout-preview .bar {
    position: absolute;
    background: var(--bt-green);
    border-radius: 1px;
}

.preview-sidebar-left .bar:nth-child(1) {
    left: 0;
    top: 0;
    width: 30%;
    height: 100%;
}

.preview-sidebar-right .bar:nth-child(1) {
    right: 0;
    top: 0;
    width: 30%;
    height: 100%;
}

.preview-top-nav .bar:nth-child(1) {
    top: 0;
    left: 0;
    width: 100%;
    height: 28%;
}

.preview-wide-grid .bar:nth-child(1) {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 22%;
}

.btn-save {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--bt-gradient);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(46, 139, 87, 0.3);
    transition: transform 0.15s, opacity 0.15s;
}

.btn-save:hover {
    opacity: 0.92;
}

.btn-save:active {
    transform: scale(0.98);
}

.save-toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bt-green-dark);
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
    white-space: nowrap;
}

.save-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.app-deny-modal[hidden] {
    display: none !important;
}

.app-deny-modal {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
}

.app-deny-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 22px 20px 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
    text-align: center;
}

.app-deny-card h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: #b45309;
}

.app-deny-card p {
    margin: 0 0 16px;
    font-size: 0.92rem;
    line-height: 1.55;
    color: #334155;
}

.app-deny-card button {
    width: 100%;
    min-height: 46px;
    border: none;
    border-radius: 12px;
    background: #0f766e;
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
}

.mobile-qr-fab[hidden] {
    display: none !important;
}

/* ── MOBILE QR SCAN ── */
.mobile-qr-fab {
    display: none;
}

.qr-scanner-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(15, 36, 24, 0.92);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(16px + var(--safe-bottom));
}

.qr-scanner-overlay[hidden] {
    display: none !important;
}

.qr-scanner-panel {
    width: min(100%, 380px);
    background: var(--surface);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.qr-scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bt-gradient);
    color: #fff;
}

.qr-scanner-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.qr-scanner-close {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}

#qrReader {
    width: 100%;
    min-height: 280px;
    background: #111;
}

#qrReader video {
    border-radius: 0 !important;
}

.qr-scanner-hint {
    padding: 12px 16px 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.45;
}

.settings-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.settings-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: border-color 0.15s;
}

button.settings-link {
    width: 100%;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.settings-link:hover {
    border-color: var(--bt-yellow);
}

.settings-link .si2 {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bt-gradient-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.desktop-only-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 8px 16px 12px;
    line-height: 1.45;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    z-index: 120;
    box-shadow: 0 -4px 20px rgba(27, 94, 59, 0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 6px 2px;
    position: relative;
    transition: color 0.15s;
}

.nav-item .nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: background 0.15s;
}

.nav-item.active {
    color: var(--bt-green);
}

.nav-item.active .nav-icon {
    background: var(--bt-gradient-soft);
    border: 1px solid rgba(46, 139, 87, 0.2);
}

a.nav-item {
    text-decoration: none;
}

.nav-item[data-tab="attendance"] {
    font-size: 0.52rem;
    line-height: 1.15;
}

.nav-item[data-tab="myapp"] {
    font-size: 0.52rem;
}

.me-panel-head {
    display: none;
}

.me-pu-sub-bar {
    position: relative;
    margin-bottom: 8px;
    flex-shrink: 0;
    padding: 6px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(27, 94, 59, 0.07) 0%, rgba(27, 94, 59, 0.03) 100%);
    box-shadow: inset 0 1px 3px rgba(27, 94, 59, 0.12);
}

.me-pu-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow: visible;
    border: none;
    background: transparent;
}

.me-pu-subtab {
    flex: 1 1 calc((100% - 12px) / 3);
    max-width: calc((100% - 12px) / 3);
    padding: 7px 4px;
    min-height: 34px !important;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #5a6b5a;
    font-family: inherit;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
    white-space: normal;
    text-align: center;
    box-shadow: none;
}

.me-pu-subtab[data-me-hub-row="2"] {
    flex: 1 1 calc((100% - 18px) / 4);
    max-width: calc((100% - 18px) / 4);
}

.me-pu-subtabs.is-row1-4 .me-pu-subtab[data-me-hub-row="1"] {
    flex: 1 1 calc((100% - 18px) / 4);
    max-width: calc((100% - 18px) / 4);
}

.me-approval-sub-bar {
    margin: 0 14px 10px 22px;
    padding: 5px;
    border-radius: 10px;
    background: linear-gradient(180deg, #eef5f8 0%, #e3eef4 100%);
    box-shadow: inset 0 1px 2px rgba(15, 76, 92, 0.12);
    border: 1px solid rgba(15, 76, 92, 0.14);
}

.me-approval-sub-bar .me-pu-subtabs {
    gap: 5px;
}

.me-approval-sub-bar .me-pu-subtab {
    flex: 1 1 calc((100% - 20px) / 5);
    max-width: calc((100% - 20px) / 5);
    border-radius: 8px;
    min-height: 30px !important;
    padding: 6px 3px;
    background: #fff;
    color: #3d5a66;
    border: 1px solid rgba(15, 76, 92, 0.16);
    font-size: 0.62rem;
    font-weight: 650;
    box-shadow: none;
}

.me-approval-sub-bar .me-pu-subtab.active {
    background: linear-gradient(180deg, #2BB3A3 0%, #17887A 55%, #0F6B61 100%);
    color: #fff;
    border-color: #0e5c54;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.28) inset,
        0 3px 8px rgba(15, 107, 97, 0.32);
}

.me-pu-subtab.active {
    background: linear-gradient(180deg, #FFE566 0%, #F5C518 55%, #D4A017 100%);
    color: #1B5E3B;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.55) inset,
        0 4px 10px rgba(180, 130, 10, 0.38);
}

@media (min-width: 1024px) {
    #mePuSubTabs.me-pu-subtabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    body.panel-me-hub-active .me-pu-sub-bar {
        margin-bottom: 0;
    }

    #mePuSubTabs .me-pu-subtab {
        flex: 0 0 auto !important;
        max-width: none !important;
        width: auto !important;
        white-space: nowrap;
        padding: 9px 14px;
        min-height: 40px !important;
        font-size: 0.95rem;
        font-weight: 800;
        color: #12351f;
    }
}

.me-home-panel {
    width: 100%;
    min-height: 0;
}

.me-home-panel[hidden],
.me-iframe[hidden],
.me-frame-slot[hidden],
.me-pu-sub-bar[hidden] {
    display: none !important;
}

.me-frame-slot:not([hidden]) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: calc(100vh - var(--header-h) - var(--nav-h) - var(--safe-bottom) - 120px);
    min-height: 420px;
    position: relative;
    overflow: hidden;
}

.me-home-panel .checkin-cta {
    margin-bottom: 0;
}

.me-checkin-wrap {
    position: relative;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.me-checkin-wrap .checkin-cta {
    padding-left: 72px;
}

.checkin-demo-btn {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    border: 1px dashed rgba(255, 255, 255, 0.55);
    background: rgba(15, 23, 42, 0.28);
    color: #fff8eb;
    font-family: inherit;
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.15;
    padding: 4px 5px;
    max-width: 62px;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.88;
    touch-action: manipulation;
    text-align: center;
}

.checkin-demo-btn:hover,
.checkin-demo-btn:focus-visible {
    opacity: 1;
    background: rgba(15, 23, 42, 0.42);
    border-color: rgba(255, 255, 255, 0.75);
}

.demo-scan-modal {
    position: fixed;
    inset: 0;
    z-index: 2147481500;
    display: flex;
    flex-direction: column;
    background: #0f172a;
}

.demo-scan-modal[hidden] {
    display: none !important;
}

body.demo-scan-open,
body.checkin-embed-open {
    overflow: hidden;
}

body.demo-scan-open #__debug-bar,
body.checkin-embed-open #__debug-bar {
    display: none !important;
}

.demo-scan-back {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 8px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.62);
    color: #fff;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 8px 14px 8px 11px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    touch-action: manipulation;
}

.demo-scan-back:hover,
.demo-scan-back:focus-visible {
    background: rgba(15, 23, 42, 0.78);
}

.demo-scan-back-icon {
    font-size: 1rem;
    line-height: 1;
}

.demo-scan-modal-frame-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #0f172a;
}

.demo-scan-modal-frame-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #f1f5f9;
}

.me-home-card {
    background: linear-gradient(145deg, var(--bt-green-dark) 0%, var(--bt-green) 55%, #3CB371 100%);
    border-radius: 16px;
    padding: 38px 12px 12px;
    color: #fff;
    text-align: center;
    box-shadow: 0 8px 28px rgba(27, 94, 59, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    position: relative;
}

.me-home-return,
.me-home-return[hidden] {
    display: none !important;
}

.me-home-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.me-home-who {
    width: 100%;
    min-width: 0;
}

.me-home-role {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.me-home-clock {
    width: 100%;
    text-align: center;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.26);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.me-home-sum {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.16);
    text-align: center;
    color: #fff;
}

.me-home-sum.is-loading {
    opacity: 0.6;
}

.me-home-sum-late {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 8px;
}

.me-home-sum-late b {
    font-size: 2.6rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: #ef4444;
    letter-spacing: 0.02em;
    padding: 0 6px;
    text-shadow:
        0 1px 0 #7f1d1d,
        0 0 10px rgba(239, 68, 68, 0.55),
        0 0 18px rgba(220, 38, 38, 0.35);
}

.me-home-sum-late.has-late b {
    color: #dc2626;
}

.me-home-sum-row {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.5;
    opacity: 0.98;
}

.me-home-sum-row + .me-home-sum-row {
    margin-top: 2px;
}

.me-home-sum-row .sep {
    opacity: 0.45;
    font-weight: 400;
    padding: 0 8px;
}

.me-home-sum-row b {
    font-weight: 900;
    color: #fef9c3;
}
.me-home-sum-tasks{
    appearance:none;
    -webkit-appearance:none;
    border:0;
    background:transparent;
    color:inherit;
    width:100%;
    font:inherit;
    cursor:pointer;
    flex-wrap:wrap;
    gap:0 2px;
}
.me-home-sum-mods{
    display:inline;
    font-size:.72em;
    font-weight:600;
    opacity:.86;
    padding-left:6px;
}
.me-home-sum-tasks.has-overdue b:last-of-type{color:#fecaca}

.me-home-avatar {
    width: 64px;
    height: 64px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.me-home-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.me-home-brand-wrap {
    display: none;
}

.me-home-brand {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

@keyframes bt-gear-glint {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }
    14% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.25);
    }
    32% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.45);
    }
}

@keyframes bt-logo-sheen {
    0% { background-position: 130% 0; }
    100% { background-position: -30% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .me-home-brand-wrap::before,
    .me-home-brand-wrap::after {
        animation: none;
        opacity: 0;
    }

    .pftb-badge-logo-wrap::before,
    .pftb-badge-logo-wrap::after {
        animation: none;
        opacity: 0;
    }
}

.me-home-name {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
}

.me-home-position {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.95;
    line-height: 1.3;
}

.me-home-position:empty {
    display: none;
}

.me-home-dept {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 0.68rem;
    font-weight: 700;
    margin: 0;
}

.me-home-date {
    font-size: 0.78rem;
    opacity: 0.92;
    margin: 2px 0 0;
    font-weight: 600;
    line-height: 1.25;
    max-width: none;
}

.me-home-time {
    font-size: 1.85rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.8px;
    line-height: 1.1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.me-home-time .me-time-colon {
    display: inline-block;
    margin: 0 1px;
    animation: meClockColonPulse 1s ease-in-out infinite;
}

.me-home-time .me-time-sec {
    display: inline-block;
    animation: meClockSecTick 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes meClockColonPulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px rgba(255, 255, 255, 0.65); }
    50% { opacity: 0.32; text-shadow: none; }
}

@keyframes meClockSecTick {
    0% { opacity: 0.65; transform: translateY(-2px); }
    100% { opacity: 1; transform: translateY(0); }
}

.me-home-punch {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: auto;
    max-width: calc(100% - 16px);
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}
.me-home-punch-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 6px;
    padding: 2px 6px;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.me-home-punch-lbl {
    font-size: 0.5rem;
    font-weight: 700;
    opacity: 0.82;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.me-home-punch-val {
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    line-height: 1.1;
}
.me-home-punch-val.is-empty {
    font-size: 0.58rem;
    font-weight: 700;
    opacity: 0.72;
    letter-spacing: 0;
}
.me-home-punch-day {
    display: none;
}

.me-home-auto-punch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(255, 255, 255, 0.58);
    background: rgba(15, 23, 42, 0.28);
    color: #fff8eb;
    border-radius: 6px;
    padding: 2px 6px;
    min-height: 20px;
    font-family: inherit;
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.15;
    cursor: pointer;
    touch-action: manipulation;
}
.me-home-auto-punch:hover,
.me-home-auto-punch:focus-visible {
    background: rgba(15, 23, 42, 0.42);
    border-color: rgba(255, 255, 255, 0.8);
}
.me-home-auto-punch[hidden] {
    display: none !important;
}

.me-home-proxy-punch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border-radius: 6px;
    padding: 2px 7px;
    min-height: 20px;
    font-family: inherit;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.15;
    cursor: pointer;
    touch-action: manipulation;
}
.me-home-proxy-punch:hover,
.me-home-proxy-punch:focus-visible {
    background: rgba(255, 255, 255, 0.36);
}

@property --me-late-border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.me-home-stat-late {
    position: relative;
    isolation: isolate;
    overflow: visible;
    border: 2px solid transparent;
    background:
        linear-gradient(rgba(255, 236, 150, 0.22), rgba(255, 236, 150, 0.22)) padding-box,
        conic-gradient(
            from var(--me-late-border-angle),
            #fde047 0deg,
            #fbbf24 90deg,
            #f59e0b 180deg,
            #fde047 270deg,
            #fde047 360deg
        ) border-box;
    animation: meLateBorderRun 2.4s linear infinite;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.25);
}

.me-home-stat-late.has-late {
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.42);
    animation-duration: 1.8s;
}

@keyframes meLateBorderRun {
    to { --me-late-border-angle: 360deg; }
}

.me-home-late-val-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 5px;
    max-width: 100%;
}

.me-home-late-point {
    display: inline-block;
    font-size: 1em;
    line-height: 1;
    margin-right: 0;
    transform: rotate(6deg);
    transform-origin: left center;
    filter: sepia(1) saturate(6) hue-rotate(320deg) brightness(1.05) drop-shadow(0 1px 2px rgba(185, 28, 28, 0.45));
    animation: meLateHandBlink 0.75s ease-in-out infinite;
}

@keyframes meLateHandBlink {
    0%, 100% {
        opacity: 1;
        transform: rotate(6deg) translateX(0);
    }
    50% {
        opacity: 0.3;
        transform: rotate(6deg) translateX(5px);
    }
}

.me-home-late-count {
    display: inline-block;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: #fef08a;
    animation: meLateCountBlink 1.35s ease-in-out infinite;
    text-shadow:
        0 0 6px rgba(253, 224, 71, 0.95),
        0 0 14px rgba(251, 191, 36, 0.65),
        0 1px 0 #ca8a04;
}

.me-home-stat-late.has-late .me-home-late-count {
    animation-duration: 1s;
}

@keyframes meLateCountBlink {
    0%, 100% {
        color: #fef9c3;
        opacity: 1;
        transform: scale(1);
        filter: brightness(1.15);
    }
    50% {
        color: #facc15;
        opacity: 0.45;
        transform: scale(1.08);
        filter: brightness(1.45);
    }
}

@media (prefers-reduced-motion: reduce) {
    .me-home-stat-late {
        animation: none;
        border-color: rgba(253, 224, 71, 0.75);
    }
    .me-home-late-point,
    .me-home-late-count {
        animation: none;
    }
}

.me-home-stats-block {
    margin-top: 8px;
    padding-top: 0;
    width: 100%;
    flex-shrink: 0;
}

.me-home-stats-title {
    margin: 0 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0.85;
    text-align: center;
    text-transform: uppercase;
}

.me-home-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

.me-home-stat {
    background: linear-gradient(145deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.08) 100%);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-bottom: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    padding: 6px 4px 5px;
    min-height: 0;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        inset 0 -1px 0 rgba(0,0,0,0.10),
        0 3px 8px rgba(0,0,0,0.18),
        0 1px 2px rgba(0,0,0,0.12);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    cursor: default;
    transition: transform .12s ease, box-shadow .12s ease;
}

.me-home-stat:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        0 1px 4px rgba(0,0,0,0.18);
}

.me-home-stat-icon {
    font-size: 0.85rem;
    line-height: 1;
    margin-bottom: 1px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

.me-home-stat-val {
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.01em;
    word-break: break-word;
    text-align: center;
}

.me-home-stat-sub {
    font-size: 0.55rem;
    font-weight: 600;
    opacity: 0.82;
    line-height: 1.2;
    text-align: center;
}

.me-home-stat-lbl {
    font-size: 0.55rem;
    font-weight: 700;
    opacity: 0.72;
    line-height: 1.2;
    text-align: center;
}

.me-home-stat.is-loading .me-home-stat-val,
.me-home-stat.is-loading .me-home-stat-sub {
    opacity: 0.55;
}

/* ME HOME v2 — สรุปมาสายเด่น + แถบ compact + ปุ่มลัด */
.me-home-stats-v2 {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.me-home-late-hero {
    border-radius: 12px;
    padding: 8px 10px 7px;
    background: rgba(255, 255, 255, 0.14);
    border: 2px solid rgba(253, 224, 71, 0.55);
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.18);
}

.me-home-late-hero.has-late {
    border-color: rgba(253, 224, 71, 0.95);
    box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
    animation: meLateBorderRun 2s linear infinite;
}

.me-home-late-hero-lbl {
    font-size: 0.68rem;
    font-weight: 800;
    opacity: 0.88;
    margin-bottom: 2px;
}

.me-home-late-hero-val {
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.02em;
}

.me-home-late-pftb-sub {
    font-size: 0.62rem;
    font-weight: 700;
    opacity: 0.88;
    margin-top: 2px;
}

.me-home-stat-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 6px;
    padding: 7px 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.me-home-stat-strip b {
    font-weight: 900;
    color: #fef9c3;
}

.me-home-stat-strip .sep {
    opacity: 0.45;
    font-weight: 400;
    padding: 0 1px;
}

.me-home-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
    margin-top: 10px;
    flex-shrink: 0;
}

.me-home-act {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.me-home-act-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
    transition: transform .12s ease;
}

.me-home-act:active .me-home-act-icon {
    transform: scale(0.94);
}

.me-home-act-lbl {
    font-size: 0.62rem;
    font-weight: 800;
    color: #334155;
    line-height: 1.2;
    text-align: center;
    max-width: 100%;
}

.me-home-embed-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(46, 139, 87, 0.18);
    box-shadow: 0 2px 10px rgba(27, 94, 59, 0.08);
    flex-shrink: 0;
}

.me-home-embed-bar[hidden] {
    display: none !important;
}

.me-home-embed-back {
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #F0FDF4 0%, #DCFCE7 100%);
    color: var(--bt-green-dark);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 7px 12px;
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
}

.me-home-embed-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

body.panel-me-embed-active .me-tab-bar,
body.panel-me-embed-active .me-checkin-wrap {
    display: none;
}

body.panel-me-embed-active .me-home-embed-bar:not([hidden]) {
    display: flex;
}

.btn-me-open {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--bt-green-dark);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bt-gradient-soft);
    border: 1px solid rgba(46, 139, 87, 0.25);
    white-space: nowrap;
}

.mytask-panel-head {
    display: none;
}

/* MyTask — แท็บย่อย App Center แบบมีมิติ (segmented pill) */
.mytask-tab-bar {
    position: sticky;
    top: 0;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 12px;
    background: linear-gradient(180deg, #F8FAF6 0%, #FFFFFF 100%);
    border-bottom: 1px solid rgba(46, 139, 87, 0.1);
    box-shadow: 0 4px 18px rgba(27, 94, 59, 0.07);
    z-index: 2;
}

.mytask-tabs {
    display: flex;
    flex: 1;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 5px;
    border-radius: 14px;
    background: rgba(46, 139, 87, 0.07);
    border: 1px solid rgba(46, 139, 87, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(27, 94, 59, 0.04);
}

.mytask-tabs::-webkit-scrollbar {
    display: none;
}

.mytask-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1 1 0;
    min-width: 72px;
    max-width: none;
    width: auto;
    min-height: 52px;
    padding: 8px 8px 7px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #64748B;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    touch-action: manipulation;
    box-sizing: border-box;
    transition: color .15s, background .15s, box-shadow .15s, transform .12s, border-color .15s;
}

.mytask-tab:hover {
    color: var(--bt-green-dark);
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(46, 139, 87, 0.12);
}

.mytask-tab-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1;
    transition: background .15s, box-shadow .15s, transform .12s;
}

.mytask-tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mytask-tab .lbl-short {
    display: none;
}

.mytask-tab.active {
    color: var(--bt-green-dark);
    background: linear-gradient(180deg, #FFFDF5 0%, #FFE9A0 100%);
    border-color: rgba(212, 160, 23, 0.45);
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(212, 160, 23, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
}

.mytask-tab.active::after {
    display: none;
}

.mytask-tab.active .mytask-tab-icon {
    background: linear-gradient(145deg, var(--bt-green) 0%, #3CB371 100%);
    box-shadow: 0 3px 10px rgba(46, 139, 87, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transform: scale(1.04);
}

.btn-mytask-open {
    display: none;
    flex-shrink: 0;
    align-self: center;
    margin: 0 12px 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--bt-green-dark);
    text-decoration: none;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--bt-gradient-soft);
    border: 1px solid rgba(46, 139, 87, 0.22);
    white-space: nowrap;
}

body.panel-mytask-active .main-content,
body.panel-announce-active .main-content {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.announce-iframe {
    display: block;
    width: 100%;
    flex: 1 1 0;
    height: auto;
    min-height: 0;
    border: none;
    background: #f8fafc;
}

#panel-announcements.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

#panel-mytask.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

/* ME — แท็บแยกชิ้น มีมิติ ไม่ใช่ตารางมีเส้น */
.me-tab-bar {
    margin-bottom: 12px;
}

.me-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 2px 1px 6px;
}

.me-tabs::-webkit-scrollbar {
    display: none;
}

.me-tab {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    width: auto;
    max-width: none;
    padding: 10px 12px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(165deg, #ffffff 0%, #eef3f0 100%);
    color: #6b7280;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.15;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    touch-action: manipulation;
    box-sizing: border-box;
    box-shadow:
        5px 5px 12px rgba(27, 94, 59, 0.16),
        -4px -4px 10px rgba(255, 255, 255, 0.95);
    transform: translateY(0) scale(1);
    transition:
        transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.26s cubic-bezier(0.22, 1, 0.36, 1),
        background 0.22s ease,
        color 0.18s ease;
}

.me-tab:hover {
    color: #374151;
    transform: translateY(-2px) scale(1.015);
    box-shadow:
        7px 7px 14px rgba(27, 94, 59, 0.2),
        -5px -5px 12px rgba(255, 255, 255, 1);
}

.me-tab:active {
    transform: translateY(1.5px) scale(0.975);
}

.me-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}

.me-tab-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.me-tab.active {
    background: linear-gradient(145deg, #0c3d22 0%, #166534 46%, #22a35a 100%);
    color: #fff;
    transform: translateY(1.5px) scale(0.985);
    box-shadow:
        inset 7px 8px 14px rgba(2, 18, 8, 0.78),
        inset -5px -5px 12px rgba(186, 255, 214, 0.32);
}

.me-tab.active:hover {
    color: #fff;
    transform: translateY(1.5px) scale(0.985);
    box-shadow:
        inset 8px 9px 16px rgba(2, 18, 8, 0.82),
        inset -4px -4px 10px rgba(186, 255, 214, 0.28);
}

@media (hover: none) {
    .me-tab:hover,
    .me-tab.active:hover {
        box-shadow:
            5px 5px 12px rgba(27, 94, 59, 0.16),
            -4px -4px 10px rgba(255, 255, 255, 0.95);
    }

    .me-tab.active:hover {
        box-shadow:
            inset 7px 8px 14px rgba(2, 18, 8, 0.78),
            inset -5px -5px 12px rgba(186, 255, 214, 0.32);
    }
}

.mytask-iframe {
    display: block;
    width: 100%;
    flex: 1 1 0;
    height: auto;
    min-height: 0;
    border: none;
    border-radius: 0;
    background: #F4F7F0;
}

.me-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #F4F7F0;
}

@media (min-width: 768px) {
    .btn-mytask-open {
        display: inline-flex;
    }

    .mytask-tab-bar {
        padding: 8px 12px;
    }

    .mytask-tabs {
        align-items: center;
        padding: 4px;
    }

    .mytask-tab {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 40px;
        min-height: 40px;
        max-height: 40px;
        padding: 0 12px;
        font-size: 0.82rem;
        min-width: 0;
    }

    .mytask-tab-icon {
        width: 22px;
        height: 22px;
        border-radius: 6px;
        font-size: 0.82rem;
        flex-shrink: 0;
    }

    .mytask-tab.active,
    .mytask-tab.active .mytask-tab-icon {
        transform: none;
    }

    .me-tab-bar {
        width: 100%;
    }

    .me-tabs {
        flex-wrap: nowrap;
        overflow-x: visible;
        width: 100%;
        gap: 10px;
    }

    .me-tab {
        flex: 1 1 0;
        flex-direction: row;
        gap: 10px;
        min-width: 0;
        min-height: 64px;
        font-size: 0.95rem;
        padding: 14px 18px;
        border-radius: 22px;
    }

    .me-tab-icon {
        width: 1.35rem;
        height: 1.35rem;
        font-size: 1.35rem;
    }

    #panel-me .me-iframe {
        border-radius: 10px;
    }

    body.panel-me-active .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    body.panel-mytask-active .main-content,
    body.panel-announce-active .main-content {
        padding: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .mytask-iframe {
        min-height: 0;
    }

    .me-frame-slot:not([hidden]) {
        height: calc(100vh - var(--header-h) - 120px);
        min-height: 520px;
    }

    .me-home-panel .checkin-cta {
        margin-bottom: 12px;
    }

    .me-home-card {
        padding: 44px 24px 28px;
        max-width: 1080px;
        margin: 0 auto;
        text-align: center;
        flex: none;
    }

    .me-home-identity {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .me-home-who {
        width: 100%;
    }

    .me-home-role {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 18px;
    }

    .me-home-clock {
        display: flex;
        flex-direction: column-reverse;
        width: auto;
        max-width: 420px;
        margin: 0 auto 4px;
        padding: 14px 28px;
    }

    .me-home-stats-block {
        flex: none;
        justify-content: flex-start;
        padding-top: 0;
    }

    .me-home-avatar {
        width: 88px;
        height: 88px;
        margin: 0 auto 14px;
        border-width: 3px;
        font-size: 1.6rem;
    }

    .me-home-name {
        margin: 0 0 6px;
        font-size: 1.45rem;
        display: block;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .me-home-position {
        margin: 0;
        font-size: 0.95rem;
    }

    .me-home-dept {
        padding: 5px 14px;
        font-size: 0.82rem;
        margin-bottom: 18px;
    }

    .me-home-date {
        font-size: 0.95rem;
        margin: 0 0 6px;
        max-width: none;
        opacity: 0.92;
    }

    .me-home-time {
        font-size: 3rem;
        letter-spacing: 1px;
    }

    .me-home-punch {
        top: 10px;
        left: 12px;
        gap: 5px 8px;
    }
    .me-home-punch-val {
        font-size: 0.78rem;
    }
    .me-home-punch-lbl {
        font-size: 0.56rem;
    }

    .me-home-stats-block {
        flex: none;
        justify-content: flex-start;
        padding-top: 0;
    }

    .me-home-stats-title {
        font-size: 0.82rem;
        margin-top: 22px;
    }

    .me-home-stats {
        gap: 10px;
    }

    .me-home-stat {
        min-height: 108px;
        padding: 14px 10px 12px;
        border-radius: 14px;
    }

    .me-home-stat-icon {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }

    .me-home-stat-val {
        font-size: 1.12rem;
    }

    .me-home-stat-sub {
        font-size: 0.72rem;
    }

    .me-home-stat-lbl {
        font-size: 0.72rem;
    }
}

@media (min-width: 1024px) {
    .me-home-card {
        max-width: none;
    }

    .me-home-stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 12px;
    }

    .me-home-stat {
        min-height: 120px;
        padding: 16px 10px 14px;
    }

    .me-home-stat-val {
        font-size: 1.2rem;
    }
}

@keyframes checkinPulse {
    0%, 100% {
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.4) inset,
            0 6px 0 #c2410c,
            0 8px 18px rgba(249, 115, 22, 0.45);
        transform: translateY(0);
    }
    50% {
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.45) inset,
            0 6px 0 #c2410c,
            0 12px 28px rgba(251, 146, 60, 0.55);
        transform: translateY(-1px);
    }
}

.checkin-cta {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 0 14px;
    padding: 16px 18px;
    border-radius: 16px;
    background: linear-gradient(180deg, #fdba74 0%, #fb923c 38%, #f97316 72%, #ea580c 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-bottom: 3px solid #c2410c;
    animation: checkinPulse 2s ease-in-out infinite;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.4) inset,
        0 6px 0 #c2410c,
        0 8px 18px rgba(249, 115, 22, 0.45);
    text-shadow: 0 1px 1px rgba(154, 52, 18, 0.35);
}

.checkin-cta::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -45%;
    width: 36%;
    height: 140%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.42) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-24deg);
    pointer-events: none;
    animation: checkinShineSweep 4.2s ease-in-out infinite;
}

@keyframes checkinShineSweep {
    0%, 58% { left: -45%; opacity: 0; }
    64% { opacity: 1; }
    88% { left: 125%; opacity: 0.9; }
    100% { left: 125%; opacity: 0; }
}

.checkin-cta:active {
    transform: translateY(4px) scale(0.985);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.25) inset,
        0 2px 0 #c2410c,
        0 3px 10px rgba(234, 88, 12, 0.35);
}

.checkin-cta-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 2px 4px rgba(154, 52, 18, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.checkin-cta-icon-wrap svg {
    width: 22px;
    height: 22px;
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
}

.nav-badge.badge-pop {
    animation: navBadgePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes navBadgePop {
    0% { transform: scale(0.5); }
    65% { transform: scale(1.28); }
    100% { transform: scale(1); }
}

/* ── PFSB sidebar (แถบเมนูเขียวซ้าย/ขวา) ── */
.pfsb {
    display: none;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #1B5E3B 0%, #0f2418 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    flex-direction: column;
    padding: 16px 0;
    overflow-y: auto;
}

.pfsb-right {
    border-right: none;
    border-left: 1px solid var(--border);
    order: 2;
}

.pfsb .nav-item {
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: calc(100% - 16px);
    height: auto;
    margin: 4px auto;
    padding: 12px 6px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.1;
    text-align: center;
    transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.pfsb .nav-item:hover {
    background: rgba(167, 243, 208, 0.18);
    color: #fff;
}

.pfsb .nav-item:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.pfsb .nav-item.active {
    background: linear-gradient(180deg, #5EBE86 0%, #1B6B40 100%);
    border: 1px solid rgba(255, 255, 255, 0.38);
    color: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        inset 0 -3px 5px rgba(0, 40, 20, 0.22),
        0 0 8px rgba(110, 231, 160, 0.32);
}

.pfsb-right .nav-item.active {
    border: 1px solid rgba(255, 255, 255, 0.38);
}

.pfsb .nav-item .nav-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 0;
    background: none;
    font-size: 19px;
    color: inherit;
}

.pfsb .nav-item .nav-icon svg {
    width: 26px;
    height: 26px;
    display: block;
}

.pfsb .nav-item .nav-text {
    font-size: 0.78rem;
    font-weight: 500;
    color: inherit;
    line-height: 1.1;
}

.pfsb .nav-item.active .nav-icon {
    background: none;
    border: none;
}

.pfsb .nav-badge {
    position: absolute;
    top: -2px;
    right: -4px;
}

.pfsb-brand {
    padding: 0 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.pfsb-brand img {
    height: 40px;
    object-fit: contain;
    filter: brightness(1.1);
}

.pfsb-brand span {
    display: block;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 4px;
}


/* ── TOP NAV (desktop) ── */
.top-nav-bar {
    display: none;
    background: linear-gradient(135deg, #1B5E3B 0%, #2E8B57 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 24px;
    gap: 4px;
    flex-shrink: 0;
}

.top-nav-bar .nav-item {
    flex: none;
    flex-direction: row;
    gap: 8px;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.78);
}

.top-nav-bar .nav-item:hover {
    color: #fff;
}

.top-nav-bar .nav-item.active {
    border-bottom: 3px solid var(--bt-yellow);
    color: #fff;
}

/* ── PANELS ── */
.panel {
    display: none;
}

.panel.active {
    display: block;
}

/* ── DESKTOP LAYOUTS ── */
@media (min-width: 768px) {
    :root {
        --header-h: 64px;
        --nav-h: 0px;
        --sidebar-w: 96px;
    }

    .pftb {
        height: var(--header-h);
    }

    .pftb-inner {
        padding: 0 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        height: 100%;
    }

    .pftb-bottom {
        display: none;
    }

    .pftb-top {
        width: 100%;
        align-items: center;
    }

    .pftb-badge {
        font-size: 0.82rem;
        padding: 0;
        background: transparent;
        border: none;
        max-width: none;
    }

    .pftb-badge-logo {
        height: 56px;
    }

    .pftb-badge-logo-wrap::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(
            105deg,
            rgba(255, 255, 255, 0) 42%,
            rgba(255, 255, 255, 0.16) 47%,
            rgba(255, 255, 255, 0.62) 50%,
            rgba(255, 255, 255, 0.16) 53%,
            rgba(255, 255, 255, 0) 58%
        );
        background-size: 240% 100%;
        background-repeat: no-repeat;
        animation: bt-logo-sheen 4s ease-in-out infinite;
        pointer-events: none;
        -webkit-mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        -webkit-mask-size: 100% 100%;
        mask-size: 100% 100%;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
    }

    .pftb-badge .pftb-badge-short {
        display: none;
    }

    .pftb-badge .pftb-badge-long::after {
        content: ' - App Center';
        font-weight: 600;
    }

    .pftb-clock-wrap {
        gap: 2px;
    }

    .pftb-date {
        font-size: 0.62rem;
    }

    .flip-clock {
        --fd-h: 30px;
        --fd-w: 22px;
    }

    .clock-segment { font-size: 0.82rem; }
    .clock-minimal { font-size: 0.88rem; }
    .clock-neon { font-size: 0.85rem; }
    .clock-badge { padding: 2px 8px 2px 10px; font-size: 0.78rem; }

    .pftb-refresh {
        width: 32px;
        height: 32px;
    }

    .pfsb-brand {
        display: none;
    }

    .pfsb {
        padding: 10px 0;
    }

    .pfsb .nav-text {
        display: block;
        max-width: 100%;
        overflow: visible;
        text-overflow: unset;
        white-space: nowrap;
        padding: 0;
        letter-spacing: 0;
    }

    .pftb-title {
        font-size: 2.1rem;
    }

    .pftb-title::after {
        width: 64px;
        height: 4px;
        margin-top: 6px;
    }

    .pftb-company {
        font-size: 0.88rem;
        margin-top: 8px;
        padding-left: 12px;
        border-left-width: 4px;
    }

    .flip-clock {
        --fd-h: 44px;
        --fd-w: 32px;
    }

    .flip-digit.seconds {
        --fd-h: 48px;
        --fd-w: 36px;
    }

    .pftb-date {
        font-size: 0.72rem;
    }

    .pftb-logo {
        width: 80px;
        height: 80px;
    }

    .main-content {
        padding: 24px 28px 28px;
    }

    /* default mobile nav hidden on desktop for sidebar/top layouts */
    body.layout-sidebar-left .bottom-nav,
    body.layout-sidebar-right .bottom-nav,
    body.layout-top-nav .bottom-nav {
    display: none;
}

    body.layout-sidebar-left .pfsb-left,
    body.layout-sidebar-right .pfsb-right {
        display: flex;
    }

    body.layout-sidebar-left .body-wrap,
    body.layout-sidebar-right .body-wrap {
        flex-direction: row;
    }

    body.layout-top-nav .top-nav-bar {
        display: flex;
    }

    body.layout-wide-grid .bottom-nav {
        position: fixed;
        max-width: 720px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 16px;
        border-radius: 20px;
        border: 1px solid var(--border);
        height: 60px;
        box-shadow: var(--shadow-lg);
    }

    body.layout-wide-grid .main-content {
        padding-bottom: 100px;
    }

    body.layout-sidebar-left .apps-grid,
    body.layout-sidebar-right .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    body.layout-top-nav .apps-grid,
    body.layout-wide-grid .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 14px;
    }

    .save-toast {
        bottom: 32px;
    }
}

@media (min-width: 1024px) {

    body.layout-sidebar-left .apps-grid,
    body.layout-sidebar-right .apps-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    body.layout-top-nav .apps-grid,
    body.layout-wide-grid .apps-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Mobile always uses bottom nav */
@media (max-width: 767px) {
    :root {
        --header-h: 0px;
        --nav-h: 78px;
        --safe-top: env(safe-area-inset-top, 0px);
    }

    .pftb {
        display: none !important;
    }

    .pfsb,
    .top-nav-bar {
        display: none !important;
    }

    .bottom-nav {
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: stretch;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
        box-shadow: 0 -6px 24px rgba(27, 94, 59, 0.12);
        z-index: 200;
    }

    .bottom-nav .nav-item {
        flex: none;
        width: auto;
        max-width: 100%;
        overflow: hidden;
        gap: 4px;
        font-size: 0.72rem;
        font-weight: 700;
        padding: 8px 1px 6px;
        min-width: 0;
        min-height: 0;
        color: #3d4f3d;
        line-height: 1.15;
    }

    .bottom-nav .nav-item .nav-icon {
        width: 40px;
        height: 40px;
        max-width: 100%;
        border-radius: 14px;
        font-size: 22px;
        line-height: 1;
        overflow: visible;
        flex-shrink: 0;
        font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    }

    .bottom-nav .nav-item .nav-text {
        display: block;
        width: 100%;
        max-width: 100%;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .bottom-nav .nav-item[data-tab="myapp"],
    .bottom-nav .nav-item[data-tab="attendance"] {
        font-size: 0.78rem;
    }

    .bottom-nav .nav-item.active {
        color: var(--bt-green-dark);
    }

    .bottom-nav .nav-item.active .nav-icon {
        transform: scale(1.06);
    }

    .bottom-nav .nav-badge {
        top: 6px;
        right: calc(50% - 28px);
        min-width: 18px;
        height: 18px;
        font-size: 10px;
    }

    .pftb-inner {
        padding: calc(6px + var(--safe-top)) 10px 8px;
        gap: 4px;
        justify-content: space-between;
    }

    .pftb-top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 8px;
    }

    .pftb-badge {
        font-size: 0.58rem;
        padding: 0;
        background: transparent;
        border: none;
        max-width: none;
        gap: 8px;
    }

    .pftb-badge-logo {
        height: 40px;
    }

    /* แสงขาวพาดผ่านโลโก้ — สไตล์เดียวกับปุ่มลงเวลาส้ม */
    .pftb-badge-logo-wrap::before {
        content: '';
        position: absolute;
        top: -22%;
        left: -48%;
        width: 40%;
        height: 145%;
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.45) 48%,
            rgba(255, 255, 255, 0) 100%
        );
        transform: skewX(-22deg);
        pointer-events: none;
        z-index: 3;
        animation: checkinShineSweep 4.2s ease-in-out infinite;
    }

    .pftb-badge-logo-wrap::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 2;
        background: linear-gradient(
            105deg,
            rgba(255, 255, 255, 0) 42%,
            rgba(255, 255, 255, 0.12) 47%,
            rgba(255, 255, 255, 0.5) 50%,
            rgba(255, 255, 255, 0.12) 53%,
            rgba(255, 255, 255, 0) 58%
        );
        background-size: 240% 100%;
        background-repeat: no-repeat;
        animation: bt-logo-sheen 4s ease-in-out infinite;
        pointer-events: none;
        -webkit-mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        -webkit-mask-size: 100% 100%;
        mask-size: 100% 100%;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
    }

    .pftb-badge-name {
        font-size: 1rem;
    }

    .pftb-badge-long {
        display: none;
    }

    .pftb-badge-short {
        display: inline;
    }

    .pftb-actions {
        gap: 6px;
    }

    .pftb-refresh {
        width: 30px;
        height: 30px;
        margin-top: 0;
    }

    .pftb-refresh .refresh-icon {
        width: 15px;
        height: 15px;
    }

    .pftb-clock-wrap {
        align-items: flex-end;
        width: auto;
        flex-shrink: 0;
        padding: 4px 7px 3px;
        background: rgba(12, 36, 22, 0.45);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
        gap: 2px;
    }

    .flip-clock {
        justify-content: flex-end;
        gap: 2px;
        width: auto;
        --fd-h: 24px;
        --fd-w: 17px;
    }

    .flip-digit.seconds {
        --fd-h: 26px;
        --fd-w: 19px;
    }

    .clock-minimal { font-size: 0.82rem; }
    .clock-neon { font-size: 0.8rem; }
    .clock-segment { font-size: 0.76rem; }
    .clock-badge { padding: 2px 8px 2px 10px; font-size: 0.78rem; }
    .clock-badge-sec { font-size: 0.62rem; }

    .flip-digit.seconds .flip-card {
        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.3),
            0 0 8px rgba(245, 197, 24, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.12);
    }

    .flip-colon {
        padding: 0 1px;
        margin-top: -1px;
    }

    .flip-card {
        border-radius: 5px;
    }

    .pftb-date {
        font-size: 0.5rem;
        text-align: right;
        width: auto;
        letter-spacing: 0;
        opacity: 0.9;
        line-height: 1.2;
    }

    .pftb-bottom {
        align-items: center;
        gap: 10px;
    }

    .pftb-info {
        flex: 1;
        min-width: 0;
    }

    .pftb-info h2,
    .pftb-title {
        font-size: 1.35rem;
    }

    .pftb-title::after {
        width: 44px;
        height: 3px;
        margin-top: 4px;
    }

    .pftb-company {
        font-size: 0.66rem;
        margin-top: 5px;
        padding-left: 8px;
        border-left-width: 2px;
        line-height: 1.35;
        max-width: none;
    }

    .pftb-info p.pftb-sub {
        display: none;
    }

    .pftb-tags {
        display: none;
    }

    .pftb-tag {
        font-size: 0.58rem;
        padding: 2px 5px;
    }

    .pftb-logo {
        width: auto;
        height: 56px;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    .main-content {
        padding: calc(8px + var(--safe-top)) 10px calc(var(--nav-h) + var(--safe-bottom) + var(--ticker-h) + 12px);
    }

    body.panel-mytask-active .main-content,
    body.panel-announce-active .main-content {
        padding: 0 0 calc(var(--nav-h) + var(--safe-bottom));
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .mytask-iframe,
    .announce-iframe {
        height: calc(100vh - var(--nav-h) - var(--safe-bottom) - 58px);
        min-height: 360px;
        border-radius: 10px;
    }

    .me-frame-slot:not([hidden]) {
        height: calc(100dvh - var(--nav-h) - var(--safe-bottom) - 118px);
        min-height: 240px;
    }

    body.panel-mytask-active .mytask-iframe,
    body.panel-announce-active .announce-iframe {
        flex: 1 1 0;
        height: 100%;
        min-height: 0;
        border-radius: 0;
    }

    body.panel-announce-active .announce-ticker {
        display: none !important;
    }

    .mytask-tab-bar {
        padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 10px;
    }

    .mytask-tab-bar::after {
        content: '';
        position: absolute;
        top: env(safe-area-inset-top, 0px);
        right: 0;
        bottom: 0;
        width: 28px;
        background: linear-gradient(to right, transparent, #F8FAF6);
        pointer-events: none;
    }

    .mytask-tabs {
        padding: 4px 18px 4px 4px;
        gap: 5px;
    }

    .mytask-tab {
        flex: 0 0 auto;
        min-width: auto;
        min-height: 50px;
        padding: 7px 12px 6px;
        overflow: visible;
        font-size: 0.68rem;
    }

    .mytask-tab-icon {
        width: 28px;
        height: 28px;
        font-size: 0.88rem;
    }

    .mytask-tab .lbl-full {
        display: none;
    }

    .mytask-tab .lbl-short {
        display: inline;
    }

    .mytask-tab-label {
        overflow: visible;
        text-overflow: unset;
    }

    .mytask-tab.active::after {
        display: none;
    }

    #panel-me.panel.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    body.panel-me-active .main-content {
        display: flex;
        flex-direction: column;
        min-height: calc(100dvh - var(--nav-h) - var(--safe-bottom) - var(--safe-top));
    }

    .me-home-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    /* display:flex ด้านบนทับ [hidden] ของเบราว์เซอร์ — ต้องบังคับซ่อน */
    .me-home-panel[hidden],
    .me-iframe[hidden],
    .me-frame-slot[hidden],
    .me-pu-sub-bar[hidden] {
        display: none !important;
    }

    #panel-me .me-frame-slot:not([hidden]) {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
        min-width: 0;
        max-width: 100%;
        position: relative;
        overflow: hidden;
    }

    #panel-me .me-frame-slot .me-iframe {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 0;
        border-radius: 10px;
    }

    body.panel-me-embed-active #panel-me .me-frame-slot:not([hidden]),
    body.panel-me-hub-active #panel-me .me-frame-slot:not([hidden]) {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
    }

    body.panel-me-embed-active #panel-me .me-iframe,
    body.panel-me-hub-active #panel-me .me-iframe {
        border: none;
        border-radius: 0;
    }

    body.panel-me-embed-active .main-content {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    body.panel-me-hub-active,
    body.panel-me-embed-active {
        overflow: hidden;
        height: 100dvh;
    }

    body.panel-me-hub-active .app-shell,
    body.panel-me-embed-active .app-shell {
        height: 100dvh;
        overflow: hidden;
    }

    body.panel-me-hub-active .body-wrap,
    body.panel-me-embed-active .body-wrap {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.panel-me-hub-active .main-content,
    body.panel-me-embed-active .main-content {
        padding: calc(6px + var(--safe-top)) 0 calc(var(--nav-h) + var(--safe-bottom));
        overflow: hidden;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0 !important;
    }

    body.panel-me-hub-active .me-tab-bar {
        margin: 0;
        padding: 6px 8px 4px;
        background: #F4F7F0;
    }

    body.panel-me-hub-active .me-tabs {
        gap: 6px;
        padding: 0 0 4px;
    }

    body.panel-me-hub-active .me-tab {
        min-height: 48px;
        padding: 8px 4px;
        font-size: 0.72rem;
    }

    body.panel-me-hub-active .me-pu-sub-bar {
        margin: 0 8px 8px;
        padding: 6px;
    }

    body.panel-me-hub-active .me-pu-subtab {
        padding: 7px 3px;
        font-size: 0.64rem;
        min-height: 34px !important;
    }

    body.panel-me-hub-active .me-approval-sub-bar {
        margin: 0 10px 8px 18px;
        padding: 4px;
        border-radius: 9px;
    }

    body.panel-me-hub-active .me-approval-sub-bar .me-pu-subtab {
        padding: 6px 2px;
        font-size: 0.58rem;
        min-height: 28px !important;
        border-radius: 7px;
    }

    .me-home-card {
        flex: 0 0 auto;
        min-height: 0;
        padding: 36px 8px 14px;
    }

    .me-home-stats-block {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 6px;
    }

    .me-home-avatar {
        width: 96px;
        height: 96px;
        margin-bottom: 6px;
        font-size: 1.7rem;
    }

    .me-home-name {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .me-home-position {
        font-size: 0.88rem;
    }

    .me-home-clock {
        padding: 12px 12px 10px;
        margin-top: 6px;
        max-width: none;
        width: 100%;
    }

    .me-home-time {
        font-size: 2.5rem;
    }

    .me-home-date {
        font-size: 0.85rem;
    }

    .me-home-stats-title {
        margin-bottom: 4px;
        font-size: 0.66rem;
    }

    .me-home-actions {
        margin-top: 8px;
        gap: 8px 6px;
    }

    .me-home-act-icon {
        width: 46px;
        height: 46px;
        font-size: 1.1rem;
    }

    .me-home-act-lbl {
        font-size: 0.58rem;
    }

    .me-home-panel {
        overflow: hidden;
    }

    .me-tab-bar {
        margin-bottom: 8px;
        flex-shrink: 0;
    }

    .checkin-cta {
        gap: 8px;
        margin-bottom: 8px;
        padding: 10px 12px;
        font-size: 0.88rem;
        border-radius: 12px;
        flex-shrink: 0;
    }

    .me-checkin-wrap .checkin-cta {
        margin-bottom: 0;
        padding-left: 68px;
    }

    .checkin-demo-btn {
        left: 4px;
        max-width: 58px;
        font-size: 0.48rem;
        padding: 3px 4px;
    }

    .checkin-cta-icon-wrap {
        width: 32px;
        height: 32px;
        border-radius: 10px;
    }

    .checkin-cta-icon-wrap svg {
        width: 18px;
        height: 18px;
    }

    .me-home-punch {
        top: 6px;
        left: 6px;
        gap: 3px 5px;
    }

    .me-home-punch-item {
        padding: 2px 5px;
        border-radius: 5px;
    }

    .me-home-punch-lbl {
        font-size: 0.48rem;
    }

    .me-home-punch-val {
        font-size: 0.68rem;
    }

    .me-home-punch-val.is-empty {
        font-size: 0.54rem;
    }

    .search-bar {
        margin-bottom: 8px;
    }

    .search-bar input {
        font-size: 16px;
        padding: 9px 14px 9px 38px;
    }

    .section-title {
        margin-bottom: 8px;
    }

    .apps-grid {
        gap: 12px 8px;
    }

    .service-card {
        min-height: 108px;
        padding: 14px 8px 12px;
        gap: 8px;
    }

    .service-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .service-name {
        font-size: 0.62rem;
    }

    .bottom-nav .nav-item {
        font-size: 0.72rem;
        min-height: 0;
        padding: 8px 1px 6px;
    }

    .bottom-nav .nav-item .nav-icon {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .layout-option {
        padding: 14px 14px;
        min-height: 56px;
    }

    .btn-save {
        min-height: 48px;
        font-size: 1rem;
    }

    .settings-link {
        min-height: 56px;
        padding: 12px 14px;
    }

    .save-toast {
        bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
        max-width: calc(100vw - 32px);
        white-space: normal;
        text-align: center;
    }

    .mobile-qr-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: fixed;
        right: 14px;
        bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
        z-index: 60;
        height: 48px;
        padding: 0 16px 0 14px;
        border: none;
        border-radius: 999px;
        background: linear-gradient(135deg, var(--bt-green) 0%, var(--bt-green-dark) 100%);
        color: #fff;
        font-family: inherit;
        font-size: 0.82rem;
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 6px 20px rgba(27, 94, 59, 0.4);
        transition: transform 0.15s;
    }

    .mobile-qr-fab:active {
        transform: scale(0.96);
    }

    .mobile-qr-fab svg {
        flex-shrink: 0;
    }

    .empty-state {
        padding: 36px 16px;
    }
}

@media (max-width: 380px) {
    :root {
        --header-h: 0px;
    }

    .pftb {
        display: none !important;
    }

    .me-tab {
        font-size: 0.72rem;
        padding: 8px 6px;
        min-height: 48px;
        min-width: 62px;
    }

    .bottom-nav .nav-item {
        font-size: 0.66rem;
    }

    .bottom-nav .nav-item .nav-icon {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .service-name {
        font-size: 0.68rem;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .flip-digit.play .flip-top-flip,
    .flip-digit.play .flip-bottom-flip {
        animation: none;
    }

    .flip-colon {
        animation: none;
        opacity: 1;
    }
}
/* HOME summary strip below clock */
#meHomeStats.me-home-sum {
    display: block;
    width: 100%;
    min-width: 0;
}
.me-home-stats-v2 {
    display: grid;
    grid-template-columns: minmax(150px, 1.15fr) minmax(0, 5fr);
    gap: 10px;
    width: 100%;
    min-width: 0;
}
.me-home-late-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(255, 235, 151, .65);
    background: linear-gradient(120deg, #216b44, #537c32);
    box-shadow: none;
    animation: none;
}
.me-home-late-hero-lbl { font-size: 12px; margin: 0; }
.me-home-late-hero-val { font-size: 22px; line-height: 1.15; white-space: nowrap; }
.me-home-late-pftb-sub { font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.me-home-late-val-wrap { gap: 6px; align-items: baseline; }
.me-home-late-count {
    font-size: 1.4em;
    color: #fff2a1;
    text-shadow: 0 0 10px rgba(253, 224, 71, .35);
    animation: none;
}
.me-home-late-hero.has-late { animation: none; box-shadow: none; }
.me-home-late-hero.has-late .me-home-late-count { animation: meHomeCountPulse 2.4s ease-in-out infinite; }
@keyframes meHomeCountPulse {
    0%, 100% { transform: scale(1); text-shadow: 0 0 8px rgba(253,224,71,.3); }
    50% { transform: scale(1.06); text-shadow: 0 0 16px rgba(253,224,71,.65); }
}
.me-home-stat-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 0;
    padding: 0;
    min-width: 0;
    background: rgba(7, 53, 33, .24);
    overflow: hidden;
}
.me-home-metric {
    min-width: 0;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    border-right: 1px solid rgba(255,255,255,.15);
}
.me-home-metric:last-child { border-right: 0; }
.me-home-metric-label { font-size: 11px; font-weight: 600; color: #e4f1e7; }
.me-home-stat-strip .me-home-metric-value {
    display: block;
    font-size: 16px;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    color: #fff;
    overflow-wrap: anywhere;
}
.me-home-stats-v2.is-loading { opacity: .65; }
.me-home-card {
    width: 100%;
    min-width: 0;
    padding: 34px 20px 16px;
    gap: 12px;
}
.me-home-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.me-home-avatar { width: 80px; height: 80px; margin: 0 0 4px; font-size: 1.6rem; }
.me-home-name { font-size: 22px; text-align: center; margin: 0 0 3px; }
.me-home-role { flex-direction: row; justify-content: center; gap: 8px; margin: 0 0 10px; }
.me-home-position { font-size: 15px; }
.me-home-dept { font-size: 13px; margin: 0; padding: 3px 10px; }
    .me-home-clock { width: 100%; max-width: none; margin: 0; padding: 10px 20px; flex-direction: column; text-align: center; }
.me-home-time { font-size: 36px; text-align: center; letter-spacing: 1px; }
.me-home-date { font-size: 13px; margin: 3px 0 0; text-align: center; }
.me-home-stats-block { flex: none; margin: 8px 0 0; padding: 0; }
.me-home-stats-title { margin: 0 0 5px; font-size: 11px; letter-spacing: 0.04em; }
.me-home-card > .me-home-actions {
    width: 100%;
    max-width: 660px;
    align-self: center;
    margin: 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(255,255,255,.2);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.me-home-act { min-width: 0; min-height: 72px; padding: 3px; gap: 5px; border-radius: 12px; }
.me-home-act:hover { background: rgba(255,255,255,.1); }
.me-home-act:focus-visible { outline: 2px solid #fff3a3; outline-offset: 2px; }
.me-home-act-icon { width: 46px; height: 46px; font-size: 22px; box-shadow: 0 3px 8px rgba(5,43,28,.2); }
.me-home-card .me-home-act-lbl { color: #fff; font-size: 12px; line-height: 1.3; }
@media (max-width: 1023px) {
    .me-home-stats-v2 { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    .me-home-late-hero {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        text-align: left;
    }
    .me-home-late-pftb-sub { margin: 0; text-align: right; }
    .me-home-stat-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .me-home-metric { grid-column: span 2; padding: 7px 6px; gap: 3px; }
    .me-home-metric:nth-child(n+4) { grid-column: span 3; border-top: 1px solid rgba(255,255,255,.15); }
    .me-home-metric:nth-child(3) { border-right: 0; }
}
@media (max-width: 767px) {
    body.panel-me-active:not(.panel-me-embed-active):not(.panel-me-hub-active) .main-content { min-height: 0; }
    #meHomePanel:not([hidden]) { flex: none; overflow: visible; }
    /* card layout */
    .me-home-card { padding: 32px 12px 12px; gap: 8px; flex: none; }
    /* identity — centered column */
    .me-home-identity { flex-direction: column; align-items: center; gap: 4px; }
    .me-home-avatar { width: 72px; height: 72px; font-size: 1.5rem; margin: 0 0 4px; }
    #meHomeName { font-size: 20px !important; font-weight: 800; line-height: 1.25; margin: 0 0 2px; text-align: center; overflow-wrap: anywhere; }
    .me-home-position { font-size: 13px; font-weight: 600; text-align: center; opacity: 0.95; }
    .me-home-role { gap: 6px; justify-content: center; margin: 0 0 4px; }
    .me-home-dept { font-size: 11px; padding: 2px 8px; }
    /* clock box — full width, prominent */
    .me-home-clock { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; max-width: none; padding: 10px 14px 8px; gap: 2px; }
    .me-home-time { font-size: 32px; letter-spacing: 1px; text-align: center; font-weight: 800; }
    .me-home-date { font-size: 12px; margin: 0; text-align: center; opacity: 0.92; }
    /* stats */
    .me-home-stats-block { margin-top: 4px; }
    .me-home-stats-title { font-size: 10px; margin: 0 0 5px; letter-spacing: 0.04em; }
    .me-home-stats { gap: 6px; }
    .me-home-stat { padding: 7px 4px 6px; border-radius: 10px; }
    .me-home-stat-val { font-size: 14px; font-weight: 900; }
    .me-home-stat-sub { font-size: 10px; }
    .me-home-stat-lbl { font-size: 10px; }
    .me-tab-bar { margin-bottom: 6px; }
}
@media (max-width: 767px) and (max-height: 680px) {
    body.panel-me-active:not(.panel-me-embed-active):not(.panel-me-hub-active) .main-content {
        padding-top: calc(4px + var(--safe-top));
        padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--ticker-h) + 8px);
    }
    .me-tab { min-height: 44px; padding: 4px 6px; }
    .me-tab-icon { font-size: 17px; }
    .me-checkin-wrap .checkin-cta { min-height: 44px; padding: 6px 8px 6px 52px; }
    .checkin-cta-icon-wrap { width: 28px; height: 28px; }
    .checkin-demo-btn { width: 34px; left: 3px; top: 0; bottom: 0; }
    .me-home-card { padding: 32px 8px 12px; gap: 8px; }
}
@media (max-width: 340px) and (max-height: 600px) {
    .me-checkin-wrap .checkin-cta { font-size: 12px; }
    .me-checkin-wrap .checkin-cta-icon-wrap { display: none; }
    .me-home-card { gap: 4px; }
    .me-home-metric { padding-top: 4px; padding-bottom: 4px; }
    .me-home-card > .me-home-actions { gap: 2px; padding-top: 4px; }
    .me-home-card .me-home-act-lbl { font-size: 10px; line-height: 1.2; }
    .me-home-act-icon { width: 34px; height: 34px; }
}
@media (max-width: 767px) {
    body.panel-me-active:not(.panel-me-embed-active):not(.panel-me-hub-active) .main-content {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding-top: calc(6px + var(--safe-top));
        padding-left: 8px;
        padding-right: 8px;
        padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--ticker-h) + 8px);
    }

    #panel-me.panel.active {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    #meHomePanel:not([hidden]) {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .me-checkin-wrap {
        flex-shrink: 0;
    }

    .me-home-card {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 8px 8px 8px;
        gap: 4px;
        border-radius: 14px;
        width: 100%;
        max-width: none;
    }

    .me-home-identity {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
    }

    .me-home-avatar {
        position: static;
        top: auto;
        right: auto;
        z-index: 2;
        width: 80px;
        height: 80px;
        margin: 0 auto 8px;
        font-size: 1.4rem;
        border-width: 2px;
    }

    .checkin-demo-btn {
        display: none !important;
    }

    .me-checkin-wrap .me-home-proxy-punch {
        position: absolute;
        left: 4px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 2;
        max-width: 58px;
        min-height: 0;
        padding: 3px 4px;
        border-radius: 8px;
        font-size: 0.48rem;
        line-height: 1.15;
        text-align: center;
    }

    .me-home-punch {
        display: grid;
        grid-template-columns: auto auto;
        justify-content: start;
        align-items: center;
        column-gap: 5px;
        row-gap: 3px;
    }

    .me-home-punch > .me-home-punch-item:nth-child(2) {
        grid-column: 1;
        grid-row: 1;
    }

    .me-home-punch > .me-home-punch-item:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    .me-home-punch > button.me-home-auto-punch {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        min-height: 20px;
        height: auto;
        padding: 2px 6px;
    }

    .me-home-brand-wrap {
        display: block;
        position: absolute;
        top: 6px;
        right: 6px;
        z-index: 6;
        width: 64px;
        height: 72px;
        pointer-events: none;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    }

    .me-home-brand-wrap::before {
        content: '';
        position: absolute;
        top: -22%;
        left: -48%;
        width: 40%;
        height: 145%;
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.48) 50%,
            rgba(255, 255, 255, 0) 100%
        );
        transform: skewX(-22deg);
        pointer-events: none;
        z-index: 3;
        animation: checkinShineSweep 4.2s ease-in-out infinite;
    }

    .me-home-brand-wrap::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 2;
        background: linear-gradient(
            105deg,
            rgba(255, 255, 255, 0) 42%,
            rgba(255, 255, 255, 0.16) 47%,
            rgba(255, 255, 255, 0.62) 50%,
            rgba(255, 255, 255, 0.16) 53%,
            rgba(255, 255, 255, 0) 58%
        );
        background-size: 240% 100%;
        background-repeat: no-repeat;
        animation: bt-logo-sheen 4s ease-in-out infinite;
        pointer-events: none;
        -webkit-mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        mask-image: url("/images/logo-borthong33-estate.png?v=20261014v");
        -webkit-mask-size: contain;
        mask-size: contain;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: top right;
        mask-position: top right;
    }

    .me-home-brand {
        display: block;
        position: static;
        width: 100%;
        height: 100%;
        object-fit: contain;
        object-position: top right;
    }

    .me-home-identity { padding-top: 0; }
    .me-home-return,
    .me-home-return:not([hidden]) {
        display: none !important;
    }
    #meHomeName { font-size: 1.6rem !important; font-weight: 800; line-height: 1.2; margin: 2px 0 4px; }
    .me-home-position { font-size: 0.95rem; font-weight: 700; }
    .me-home-dept { font-size: 0.68rem; padding: 2px 8px; }
    .me-home-role { margin: 0 0 2px; gap: 4px; }

    .me-home-clock {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        max-width: none;
        padding: 4px 4px 3px;
        flex-shrink: 0;
    }
    .me-home-time {
        width: 100%;
        font-size: clamp(2.6rem, 13.5vw, 3.9rem);
        letter-spacing: 0.08em;
        line-height: 0.95;
        font-weight: 800;
        text-align: center;
    }
    .me-home-date { font-size: 0.78rem; margin-top: 2px; }

    /* สรุปวันลา — ตัวอักษรเต็มกรอบเขียว ตัวเลขสายเด่นแดง */
    .me-home-sum,
    #meHomeStats.me-home-sum {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        margin-top: 8px;
        padding: 10px 8px;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        gap: 0;
        overflow: hidden;
        container-type: size;
    }
    .me-home-sum-late,
    .me-home-sum-row {
        flex: 1 1 0;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
    }
    .me-home-sum-late {
        font-size: clamp(1.25rem, 4.8vw, 1.7rem);
        font-size: clamp(1.25rem, 8cqh, 1.7rem);
        font-weight: 800;
        line-height: 1;
    }
    .me-home-sum-late b {
        font-size: clamp(3.6rem, 16vw, 5.8rem);
        font-size: clamp(3.6rem, 32cqh, 5.8rem);
        font-weight: 900;
        font-variant-numeric: tabular-nums;
        color: #ef4444;
        letter-spacing: 0.02em;
        padding: 0 8px;
        line-height: 0.9;
        text-shadow:
            0 1px 0 #7f1d1d,
            0 0 10px rgba(239, 68, 68, 0.55),
            0 0 18px rgba(220, 38, 38, 0.35);
    }
    .me-home-sum-late.has-late b {
        color: #dc2626;
    }
    .me-home-sum-row {
        width: 100%;
        min-width: 0;
        white-space: nowrap;
        gap: 0.2em;
        font-size: clamp(1.25rem, 4.8vw, 1.7rem);
        font-size: clamp(1.25rem, 8cqh, 1.7rem);
        line-height: 1.15;
        font-weight: 800;
    }
    .me-home-sum-row + .me-home-sum-row {
        margin-top: 0;
    }
    .me-home-sum-row b {
        font-size: 1.12em;
    }
    .me-home-sum-tasks{
        flex:0 0 auto;
        padding-top:2px;
        line-height:1.2;
    }
    .me-home-sum-mods{
        display:block;
        width:100%;
        padding:2px 4px 0;
        font-size:.68em;
        line-height:1.25;
        opacity:.88;
    }
}

@media (max-width: 767px) {
    .apps-grid > .service-card.room-card {
        background: transparent;
        border: none;
        border-radius: 14px;
        box-shadow: none;
        min-width: 0;
        min-height: 0;
        padding: 4px 2px 6px;
        gap: 6px;
    }

    .apps-grid > .service-card.room-card:hover,
    .apps-grid > .service-card.room-card:active {
        background: rgba(255, 255, 255, 0.45);
        border: none;
        box-shadow: none;
    }

    .apps-grid > .service-card.room-card .service-icon {
        width: 60px;
        height: 52px;
        margin-top: 4px;
        border-radius: 0;
        border: none;
        background: none;
        box-shadow: none;
    }

    .apps-grid > .service-card.room-card .room-label {
        align-items: center;
        width: 100%;
        min-width: 0;
        gap: 1px;
    }

    .apps-grid > .service-card.room-card .service-name {
        display: block;
        overflow: visible;
        -webkit-line-clamp: unset;
        max-width: 100%;
        font-size: 0.72rem;
        font-weight: 800;
        padding: 0;
    }

    .apps-grid > .service-card.room-card .room-dept-line {
        font-size: 0.62rem;
        max-width: 100%;
    }

    .apps-grid > .service-card.room-card .room-meta {
        font-size: 0.58rem;
        margin-top: 1px;
    }

    /* ชื่อแอปย่อยเป็นข้อความบรรทัดเดียว ถ้าปล่อยไว้จะดันความกว้างขั้นต่ำของคอลัมน์จนกริดล้นจอ */
    .apps-grid > .service-card.room-card .room-apps-preview {
        display: none;
    }

    .me-tabs {
        gap: 6px;
    }

    button.me-tab,
    body.panel-me-hub-active button.me-tab {
        flex: 1 1 auto;
        gap: 5px;
        min-height: 50px;
        padding: 8px 7px;
        font-size: 1.15rem;
        font-weight: 800;
    }

    .me-tab-icon,
    body.panel-me-hub-active .me-tab-icon {
        width: 1.15rem;
        height: 1.15rem;
        font-size: 1.15rem;
    }
}

/* My App — เอาเมาส์ชี้การ์ดห้อง = แถบเหลืองอ่อน + การ์ดลอย 3D + โฟลเดอร์แง้มกระดาษขยับ */
.room-folder-svg .rf-papers,
.room-folder-svg .rf-paper-1,
.room-folder-svg .rf-paper-2,
.room-folder-svg .rf-front {
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-box: fill-box;
    transform-origin: center bottom;
}

.room-apps-preview {
    font-size: 0.64rem;
    color: #92400e;
    font-weight: 600;
    line-height: 1.25;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0;
    max-height: 0;
    transition: opacity 0.2s ease, max-height 0.2s ease;
}

@media (hover: hover) {
    .apps-grid > .service-card.room-card {
        transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.22s ease;
    }
    .apps-grid > .service-card.room-card:hover {
        background: #fef9c3;
        border-color: #fde68a;
        box-shadow: 0 8px 20px rgba(202, 138, 4, 0.18);
        transform: translateY(-3px);
    }
    .apps-grid > .service-card.room-card:hover .room-folder-svg .rf-papers {
        transform: translateY(-3.5px) scale(1.03);
    }
    .apps-grid > .service-card.room-card:hover .room-folder-svg .rf-front {
        transform: translateY(1px) scaleY(0.94) skewX(-2deg);
    }
    .apps-grid > .service-card.room-card:hover .service-icon {
        animation: rf-wiggle 0.55s ease-in-out;
    }
    /* จองความสูงบรรทัดชื่อแอปไว้ตลอด — ถ้าความสูงเปลี่ยนตอนชี้ การ์ดทั้งแถวของกริดจะยืดตามและขยับไปด้วย */
    .apps-grid > .service-card.room-card .room-apps-preview {
        max-height: 22px;
    }
    .apps-grid > .service-card.room-card:hover .room-apps-preview {
        opacity: 1;
    }
}

@keyframes rf-wiggle {
    0%, 100% { transform: rotate(-4deg); }
    20% { transform: rotate(-9deg); }
    40% { transform: rotate(1deg); }
    60% { transform: rotate(-7deg); }
    80% { transform: rotate(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
    .apps-grid > .service-card.room-card:hover .service-icon {
        animation: none;
    }
}

/* My App — แถบรายการโปรด & ใช้ล่าสุด + ดาวปักหมุด + ไฮไลต์คำค้นหา + การ์ดเรียงปรากฏ */
.myapp-quick-shelf {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, #fffef7 0%, #fefce8 100%);
    border: 1px solid #fde68a;
    box-shadow: 0 2px 8px rgba(202, 138, 4, 0.08);
}
.myapp-quick-shelf[hidden] {
    display: none !important;
}
.quick-shelf-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
}
.quick-shelf-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #92400e;
    letter-spacing: 0.01em;
}
.quick-shelf-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.quick-app-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    border: 1px solid rgba(46, 139, 87, 0.22);
    background: #ffffff;
    color: #1e293b;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.quick-app-chip.is-fav {
    border-color: #f59e0b;
    background: #fffbeb;
}
.quick-app-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.1);
    background: #fef9c3;
}
.quick-app-chip .q-star {
    color: #f59e0b;
    font-size: 0.82rem;
    line-height: 1;
}
.quick-app-chip .q-star-off {
    color: #cbd5e1;
}
.quick-app-chip .q-star:hover {
    transform: scale(1.2);
    color: #d97706;
}
.service-card {
    position: relative;
}
.app-fav-star {
    position: absolute;
    top: 7px;
    right: 9px;
    font-size: 0.9rem;
    line-height: 1;
    color: #cbd5e1;
    cursor: pointer;
    z-index: 3;
    padding: 2px 4px;
    border-radius: 999px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s ease;
}
.app-fav-star:hover {
    transform: scale(1.25);
    color: #f59e0b;
}
.app-fav-star.is-fav {
    color: #f59e0b;
    text-shadow: 0 1px 4px rgba(245, 158, 11, 0.35);
}
mark.app-search-hl {
    background: #fef08a;
    color: #854d0e;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 800;
}
.service-room-tag {
    font-size: 0.64rem;
    font-weight: 700;
    color: #0f766e;
    background: #ccfbf1;
    padding: 1px 7px;
    border-radius: 999px;
    margin-top: 2px;
}
@keyframes appCardStaggerIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.service-card.app-card-stagger {
    animation: appCardStaggerIn 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (max-width: 768px) {
    body.me-assign-fullscreen {
        --nav-h: 0px;
        overflow: hidden;
        height: 100dvh;
    }
    body.me-assign-fullscreen .me-tab-bar,
    body.me-assign-fullscreen .me-home-embed-bar,
    body.me-assign-fullscreen .me-checkin-wrap,
    body.me-assign-fullscreen .pftb,
    body.me-assign-fullscreen .bt-return-app,
    body.me-assign-fullscreen .bottom-nav,
    body.me-assign-fullscreen #topNav,
    body.me-assign-fullscreen #sideNavLeft,
    body.me-assign-fullscreen #sideNavRight,
    body.me-assign-fullscreen #appImpersonateBanner,
    body.me-assign-fullscreen #__debug-bar {
        display: none !important;
    }
    body.me-assign-fullscreen .app-shell,
    body.me-assign-fullscreen .body-wrap,
    body.me-assign-fullscreen .main-content,
    body.me-assign-fullscreen #panel-me,
    body.me-assign-fullscreen #panel-me.panel.active,
    body.me-assign-fullscreen #panel-me .me-frame-slot:not([hidden]) {
        height: 100dvh !important;
        max-height: 100dvh !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

@media (min-width: 768px) {
    body.panel-me-hub-active .main-content,
    body.panel-me-embed-active .main-content {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: calc(100dvh - var(--header-h));
        padding-bottom: 12px;
    }

    body.panel-me-hub-active #panel-me.panel.active,
    body.panel-me-embed-active #panel-me.panel.active {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    body.panel-me-hub-active .me-tab-bar,
    body.panel-me-hub-active .me-pu-sub-bar,
    body.panel-me-embed-active .me-home-embed-bar {
        flex-shrink: 0;
    }

    body.panel-me-hub-active .me-frame-slot:not([hidden]),
    body.panel-me-embed-active .me-frame-slot:not([hidden]) {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        overflow: hidden;
    }

    body.panel-me-hub-active .me-iframe,
    body.panel-me-embed-active .me-iframe {
        height: 100%;
    }
}

/* ปุ่มกลับแอปเดิม — แถบบนสุดของ .app-shell (สไตล์เดียวกับ common2/theme.css) */
.bt-return-app {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    background: linear-gradient(180deg, #F0FDF4 0%, #ECFDF5 100%);
    border-bottom: 1px solid rgba(46, 139, 87, 0.18);
    z-index: 40;
}

.bt-return-app[hidden] {
    display: none !important;
}

body.has-bt-return-app {
    --bt-return-h: 42px;
}

.bt-return-app-btn {
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #F0FDF4 0%, #DCFCE7 100%);
    color: var(--bt-green-dark);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 8px 14px;
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(27, 94, 59, 0.12);
}

.bt-return-app-btn:hover,
.bt-return-app-btn:focus-visible {
    background: linear-gradient(180deg, #DCFCE7 0%, #BBF7D0 100%);
    outline: none;
}

/* Settings — ปรับขนาดตัวอักษรสมูท + ปุ่มล้างแคชและโหลดใหม่ */
html {
    transition: font-size 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.fontsize-seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 16px 14px;
}
.fontsize-btn {
    padding: 10px 8px;
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.18s ease;
}
.fontsize-btn:hover {
    border-color: var(--bt-green);
    background: #f0fdf4;
    transform: translateY(-1px);
}
.fontsize-btn.active {
    background: linear-gradient(180deg, #2E8B57 0%, #1B5E3B 100%);
    border-color: #14532d;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(27, 94, 59, 0.28);
}
.settings-group-cache {
    padding-bottom: 14px;
}
.btn-clear-cache {
    margin: 8px 16px 0;
    width: calc(100% - 32px);
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}
.btn-clear-cache:hover {
    background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
}

.fire-kind-row {
    display: flex;
    gap: 16px;
    margin: 4px 0 8px;
    font-weight: 700;
}
.fire-send-btn {
    margin-top: 8px;
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.28);
}
.fire-clear-btn {
    margin-top: 8px;
    background: linear-gradient(180deg, #22c55e 0%, #166534 100%);
}
.fire-send-msg {
    min-height: 1.2em;
    margin: 8px 0 0;
    font-size: 13px;
    font-weight: 700;
}
.fire-push-banner {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.45);
}
.fire-push-banner[hidden] { display: none !important; }
.fire-push-card {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
    padding: 22px 18px;
    border-radius: 20px;
    background: #7f1d1d;
    color: #fff;
    text-align: center;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.fire-push-banner p {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.45;
}
.fire-push-banner button,
#firePushAllow {
    min-height: 76px;
    border: 0;
    border-radius: 16px;
    background: #fff;
    color: #7f1d1d;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 800;
    padding: 16px 20px;
    cursor: pointer;
    touch-action: manipulation;
}
.fire-screen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(127, 29, 29, 0.94);
    animation: fire-pulse 1s ease-in-out infinite;
}
.fire-screen[hidden] { display: none !important; }
.fire-screen.is-drill { background: rgba(154, 52, 18, 0.94); }
.fire-screen-card {
    width: min(420px, 100%);
    background: #fff;
    color: #7f1d1d;
    border-radius: 20px;
    padding: 22px 18px;
    text-align: center;
}
.fire-screen-kicker {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.08em;
}
.fire-screen h2 {
    margin: 6px 0 8px;
    font-size: 1.6rem;
}
#fireScreenPlace {
    margin: 0 0 6px;
    font-size: 1.25rem;
    font-weight: 800;
}
#fireScreenMeta {
    margin: 0;
    color: #64748b;
    font-size: 0.9rem;
}
.fire-screen button {
    display: block;
    width: 100%;
    margin-top: 10px;
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
}
.fire-screen button[hidden] { display: none !important; }
#fireScreenAck {
    min-height: 72px;
    margin-top: 18px;
    border-radius: 16px;
    background: #111827;
    color: #fff;
    font-size: 1.45rem;
    touch-action: manipulation;
}
#fireScreenSound,
#fireScreenClear { background: #f59e0b; color: #111827; }
@keyframes fire-pulse {
    0%, 100% { background-color: rgba(127, 29, 29, 0.94); }
    50% { background-color: rgba(185, 28, 28, 0.98); }
}
.fire-screen.is-drill {
    animation-name: fire-pulse-drill;
}
@keyframes fire-pulse-drill {
    0%, 100% { background-color: rgba(154, 52, 18, 0.94); }
    50% { background-color: rgba(234, 88, 12, 0.98); }
}


/* Announcements: new fire controls; Settings controls stay in place. */
#announceFireTools { flex: 0 0 auto; max-height: 44dvh; overflow: auto; padding: 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
#announceFireTools [hidden] { display: none !important; }
#announceFireTools p { font-size: 13px; margin: 6px 0; }
#announceFireTools small { display: block; color: #64748b; font-size: 12px; margin-top: 6px; }
#announceFireTools button { border: 0; border-radius: 9px; padding: 10px 14px; background: #0f766e; color: white; cursor: pointer; font: inherit; }
#announceFireTools button:disabled { opacity: .55; cursor: wait; }
#announceFireSender { margin-top: 10px; padding: 12px; border: 1px solid #fecaca; border-radius: 12px; background: #fff7f7; }
#announceFireSender summary { color: #b91c1c; font-weight: 700; cursor: pointer; }
#announceFireForm { display: grid; gap: 8px; margin-top: 10px; }
#announceFireForm input, #announceFireForm select { box-sizing: border-box; width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
#announceFireTools #announceFireSend { background: #dc2626; }

/* PO notifications: settings for this device, separate from fire alerts. */
#poPushSettings [hidden] { display: none !important; }
#poPushSettings .po-push-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
#poPushSettings .btn-save { width: auto; margin: 0; }
#poPushSettings button:disabled { opacity: .55; cursor: wait; }
#poPushSettings p { font-size: 13px; margin: 8px 0; }
#poPushSettings small { display: block; color: #64748b; font-size: 12px; }
#poPushDisable { background: #64748b; }
