/* ===== Worker House — Light theme ===== */
:root {
    color-scheme: light;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-softer: #f5f6ff;
    --secondary: #0f172a;
    --base-bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --border: #e5e7eb;
    --border-strong: #d4d7df;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
    --shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.12), 0 2px 6px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 24px 48px -24px rgba(15, 23, 42, 0.25);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* overflow-x: clip prevents horizontal scroll WITHOUT creating a scroll container
   (hidden would break position:sticky on descendants like .topbar) */
html, body { overflow-x: clip; }
body {
    font-family: "Plus Jakarta Sans", "IBM Plex Sans Thai", "Inter", "Segoe UI", "SF Pro Display", system-ui, -apple-system, Arial, sans-serif;
    background: var(--base-bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss01", "ss03";
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, button, select, textarea { font: inherit; color: inherit; }

/* ===== Layout ===== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 22px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform .35s var(--ease);
    z-index: 60;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 2px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, #7c6df1 100%);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55);
}
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; position: relative; }
.nav {
    flex: 1 1 auto;
    min-height: 0;
}
.nav-indicator {
    position: absolute; left: 0; right: 0;
    height: var(--ni-h, 40px);
    transform: translateY(var(--ni-y, 0px));
    background: var(--primary-soft);
    border-radius: var(--radius-sm);
    transition: transform .4s cubic-bezier(.6,.05,.2,1), height .3s var(--ease);
    z-index: 0;
    pointer-events: none;
}
.nav-indicator::before {
    content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px;
    background: var(--primary); border-radius: 3px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px; font-weight: 500;
    transition: color .25s var(--ease), transform .25s var(--ease);
    position: relative;
    z-index: 1;
}
.nav-item:hover { color: var(--text); }
.nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

.sidebar-foot {
    margin-top: auto;
    flex-shrink: 0;
}
.foot-card {
    background: linear-gradient(135deg, var(--primary) 0%, #6d65ec 100%);
    color: #fff;
    padding: 14px 16px; border-radius: 14px;
    box-shadow: 0 10px 24px -12px rgba(79, 70, 229, .55);
}
.foot-label { font-size: 12px; opacity: .85; }
.foot-value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; overflow-x: clip; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 24px;
    background: rgba(246, 247, 251, .85);
    backdrop-filter: saturate(150%) blur(10px);
    -webkit-backdrop-filter: saturate(150%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.chip {
    padding: 6px 12px; border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12.5px; font-weight: 600;
}

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    transition: background .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.96); }

.content {
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    animation: fadeUp .45s var(--ease) both;
    will-change: transform, opacity;
}
.content.slide-right { animation: slideInRight .38s var(--ease) both; }
.content.slide-left { animation: slideInLeft .38s var(--ease) both; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translate3d(28px, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translate3d(-28px, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* ===== Cards / blocks ===== */
.page-head {
    display: flex; flex-wrap: wrap; gap: 12px;
    justify-content: space-between; align-items: flex-end;
    margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
.page-sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s var(--ease);
}
.card-pad { padding: 18px; }
.card:hover { box-shadow: var(--shadow); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat {
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-icon {
    position: absolute; right: 14px; top: 14px;
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary); color: #fff;
    font-weight: 600; font-size: 14px;
    transition: transform .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
    box-shadow: 0 6px 14px -8px rgba(79, 70, 229, .55);
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn-ghost {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-soft {
    background: var(--primary-soft); color: var(--primary); box-shadow: none;
}
.btn-soft:hover { background: #e4e7ff; }

.btn-danger {
    background: var(--danger); color: #fff;
    box-shadow: 0 6px 14px -8px rgba(220, 38, 38, .5);
}
.btn-danger:hover { background: #b91c1c; }

.btn-danger-soft {
    background: var(--danger-soft); color: var(--danger); box-shadow: none;
}
.btn-danger-soft:hover { background: #fde2e2; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.input, .select, .textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
    font-size: 14px;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
    background: #fff;
}
.textarea { resize: vertical; min-height: 72px; }

.form-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* ===== Tables / rows ===== */
.row-list { display: flex; flex-direction: column; gap: 10px; }
.row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s var(--ease);
    animation: rowIn .35s var(--ease) both;
}
.row:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
@keyframes rowIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.row-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
    font-weight: 700; font-size: 15px;
    flex-shrink: 0;
}
.row-name { font-weight: 600; font-size: 15px; }
.row-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.balance-pill {
    padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 13px;
    background: var(--success-soft); color: var(--success);
    white-space: nowrap;
}
.balance-pill.zero { background: var(--surface-2); color: var(--text-2); }
.balance-pill.neg { background: var(--danger-soft); color: var(--danger); }

/* Empty state */
.empty {
    padding: 48px 20px; text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-2);
}
.empty-icon {
    width: 52px; height: 52px; border-radius: 14px;
    background: var(--primary-soft); color: var(--primary);
    display: grid; place-items: center; margin: 0 auto 12px;
}
.empty-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ===== Sections ===== */
.section-title {
    font-size: 15px; font-weight: 700; margin: 18px 0 10px;
    display: flex; align-items: center; gap: 8px;
}

/* Work tick bar */
.work-card { padding: 16px; }
.work-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.work-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.tick-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 12px; border-radius: 10px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border);
    font-weight: 600; font-size: 13.5px;
    transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), color .2s var(--ease);
}
.tick-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.tick-btn:active { transform: scale(.98); }
.tick-btn svg { width: 16px; height: 16px; }
.tick-btn.is-active {
    background: var(--success-soft);
    border-color: #86efac;
    color: var(--success);
}
.tick-btn.success-flash {
    background: var(--success-soft) !important;
    border-color: #bbf7d0 !important;
    color: var(--success) !important;
}

.log-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.log-item {
    display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
    padding: 8px 10px; border-radius: 8px;
    background: var(--surface-2);
    font-size: 13px;
    align-items: center;
    animation: rowIn .3s var(--ease) both;
}
.log-item .log-del {
    width: 26px; height: 26px; border-radius: 7px;
    background: transparent; border: 1px solid transparent; color: var(--text-3);
    display: grid; place-items: center;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.log-item .log-del:hover { background: var(--danger-soft); color: var(--danger); }
.log-amount { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif; }
.log-amount.neg { color: var(--danger); }

.badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
}
.badge.half { background: #fff7ed; color: #c2410c; }
.badge.full { background: var(--success-soft); color: var(--success); }
.badge.custom { background: #ecfeff; color: #0e7490; }
.badge.bonus { background: #fef3c7; color: #92400e; }

/* ===== Modal ===== */
.modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .35);
    opacity: 0; transition: opacity .25s var(--ease);
    pointer-events: auto;
}
.modal-backdrop.show { opacity: 1; }
.modal {
    position: fixed; left: 50%; top: 50%;
    transform: translate(-50%, -46%) scale(.98);
    width: min(460px, calc(100vw - 32px));
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 20px;
    opacity: 0;
    transition: transform .3s var(--ease), opacity .3s var(--ease);
    pointer-events: auto;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}
.modal.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 14px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px;
}
.confirm-warn {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px;
    background: #fff4ed;
    border: 1px solid #fcd9b6;
    color: #9a3412;
    border-radius: 12px;
}
.confirm-warn svg { flex-shrink: 0; margin-top: 2px; color: #c2410c; }
.confirm-warn-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.confirm-warn-sub { font-size: 12.5px; color: #9a3412; opacity: .85; line-height: 1.5; }
.modal-body .field label b { color: var(--text); font-weight: 700; }

/* ===== Toasts ===== */
.toasts {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 90;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 12px 14px; padding-right: 32px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 240px;
    font-size: 14px; font-weight: 500;
    position: relative;
    animation: toastIn .35s var(--ease) both;
    display: flex; gap: 10px; align-items: center;
}
.toast::before { content: ""; width: 4px; align-self: stretch; border-radius: 3px; background: var(--primary); }
.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateX(16px); }
}

/* ===== Loader ===== */
.loader { display: grid; place-items: center; padding: 60px 0; }
.spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Scrim + Bottom nav ===== */
.scrim {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .4);
    opacity: 0; pointer-events: none;
    transition: opacity .3s var(--ease);
    z-index: 55;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.bottom-nav { display: none; }

.mobile-only { display: none; }

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0;
        width: 280px; height: 100vh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        z-index: 120;
    }
    .sidebar.open { transform: translateX(0); }
    .scrim { z-index: 110; }
    .mobile-only { display: inline-flex; }
    .content { padding: 18px 16px 100px; }
    .topbar { padding: 12px 16px; }
    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(var(--bn-count, 5), 1fr);
        gap: 2px;
        position: fixed; left: 0; right: 0; bottom: 0;
        background: rgba(255, 255, 255, .96);
        backdrop-filter: saturate(150%) blur(12px);
        -webkit-backdrop-filter: saturate(150%) blur(12px);
        border-top: 1px solid var(--border);
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        z-index: 50;
    }
    .bn-indicator {
        position: absolute;
        top: 6px; bottom: calc(6px + env(safe-area-inset-bottom));
        left: 6px;
        width: calc((100% - 12px) / var(--bn-count, 5));
        background: var(--primary-soft);
        border-radius: 12px;
        transform: translateX(calc(var(--bn-index, 0) * 100%));
        transition: transform .45s cubic-bezier(.6,.05,.2,1);
        pointer-events: none;
        z-index: 0;
    }
    .bn-item {
        position: relative; z-index: 1;
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 6px 4px;
        color: var(--text-3);
        font-size: 11px; font-weight: 500;
        border-radius: 10px;
        transition: color .25s var(--ease), transform .25s var(--ease);
    }
    .bn-item.active { color: var(--primary); }
    .bn-item.active svg { transform: scale(1.08); transition: transform .3s var(--ease); }
    .row { grid-template-columns: 1fr; }
    .row-actions { justify-content: flex-start; }
    .toasts { left: 16px; right: 16px; bottom: 88px; }
}

@media (max-width: 520px) {
    .page-title { font-size: 20px; }
    .stat-value { font-size: 22px; }
}

/* Focus-visible accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Scrollbar polish */
.log-list::-webkit-scrollbar { width: 6px; }
.log-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }


/* ===== Status dots / tags (employee grading) ===== */
.status-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(15,23,42,0.05);
    margin-right: 10px;
    vertical-align: middle;
}
.status-dot.s-green   { background: #16a34a; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(22,163,74,0.25); }
.status-dot.s-yellow  { background: #f59e0b; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(245,158,11,0.25); }
.status-dot.s-red     { background: #dc2626; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(220,38,38,0.25); }
.status-dot.s-neutral { background: #94a3b8; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(148,163,184,0.25); }

.status-tag {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .01em;
    margin-left: 4px;
}
.status-tag.s-green   { background: #dcfce7; color: #15803d; }
.status-tag.s-yellow  { background: #fef3c7; color: #b45309; }
.status-tag.s-red     { background: #fee2e2; color: #b91c1c; }
.status-tag.s-neutral { background: #f1f5f9; color: #475569; }

/* Left color stripe by status on rows/cards */
.row.status-green,   .work-card.status-green   { box-shadow: inset 4px 0 0 #16a34a, var(--shadow-sm); }
.row.status-yellow,  .work-card.status-yellow  { box-shadow: inset 4px 0 0 #f59e0b, var(--shadow-sm); }
.row.status-red,     .work-card.status-red     { box-shadow: inset 4px 0 0 #dc2626, var(--shadow-sm); }
.row.status-neutral, .work-card.status-neutral { box-shadow: inset 4px 0 0 #cbd5e1, var(--shadow-sm); }

/* ===== Analytics ===== */
.legend-row { display: flex; flex-wrap: wrap; gap: 14px 18px; margin: -4px 0 14px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.legend .status-dot { margin-right: 2px; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr auto;
    align-items: center; gap: 12px;
}
.bar-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track {
    position: relative;
    height: 22px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
    display: flex;
}
.bar-seg { height: 100%; transition: width .45s var(--ease); }
.bar-seg.bar-work   { background: linear-gradient(90deg, #22c55e, #16a34a); }
.bar-seg.bar-absent { background: linear-gradient(90deg, #fca5a5, #ef4444); }
.bar-meta { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bar-num-w { color: #15803d; font-weight: 700; }
.bar-num-a { color: #b91c1c; font-weight: 700; }
.bar-sep { color: var(--text-3); margin: 0 2px; }
.bar-legend { display: flex; gap: 16px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.bar-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.bar-legend .dot.bar-work   { background: #16a34a; }
.bar-legend .dot.bar-absent { background: #ef4444; }

/* Calendar */
.cal-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.cal-title { font-size: 18px; font-weight: 700; }
.cal-summary { display: inline-flex; gap: 8px; }
.cal-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.cal-chip.w { background: #dcfce7; color: #15803d; }
.cal-chip.a { background: #fee2e2; color: #b91c1c; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { margin-bottom: 4px; }
.cal-dow-cell { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 0; }
.cal-cell {
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    padding: 6px;
    display: flex; flex-direction: column; justify-content: space-between;
    font-size: 12px;
    border: 1px solid transparent;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
    min-height: 56px;
}
.cal-cell.blank { background: transparent; }
.cal-cell.future { background: #f8fafc; color: var(--text-3); }
.cal-cell.before { background: #f1f5f9; color: #94a3b8; font-style: italic; }
.cal-cell.worked { background: #dcfce7; color: #14532d; border-color: #86efac; }
.cal-cell.bonus  { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }
.cal-cell.absent { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.cal-cell.today  { outline: 2px solid var(--primary); outline-offset: 1px; }
.cal-cell:hover:not(.blank) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cal-num { font-weight: 700; font-size: 13px; }
.cal-label { font-size: 10px; line-height: 1.2; opacity: .85; }

/* Analytics table */
.analytics-table-wrap { overflow-x: auto; }
.analytics-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.analytics-table thead th {
    text-align: left; padding: 10px 10px;
    font-size: 12px; font-weight: 600; color: var(--text-3);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: .04em;
}
.analytics-table tbody td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
.analytics-table tbody tr:last-child td { border-bottom: none; }
.analytics-table td.nm { font-weight: 600; }
.analytics-table tbody tr:hover { background: var(--surface-2); }

@media (max-width: 720px) {
    .bar-row { grid-template-columns: minmax(100px, 130px) 1fr auto; gap: 8px; }
    .cal-cell { padding: 4px; min-height: 48px; }
    .cal-label { display: none; }
    .cal-controls { grid-template-columns: 1fr; }
}

/* ============================================================
   PREMIUM OVERHAUL — high-end, editorial, "อลังการ" polish
   ============================================================ */
:root {
    --primary: #4f46e5;
    --primary-2: #7c6df1;
    --primary-3: #a78bfa;
    --accent: #06b6d4;
    --accent-2: #22d3ee;
    --base-bg: #eef1f9;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --border: #e6e8f0;
    --border-strong: #d6dae6;
    --text: #0b1224;
    --text-2: #4a5468;
    --text-3: #8791a6;
    --ring: 0 0 0 4px rgba(79, 70, 229, .14);
    --shadow-xs: 0 1px 2px rgba(11, 18, 36, .04);
    --shadow-sm: 0 2px 6px rgba(11, 18, 36, .04), 0 1px 2px rgba(11, 18, 36, .03);
    --shadow:   0 14px 40px -20px rgba(11, 18, 36, .22), 0 4px 10px -4px rgba(11, 18, 36, .08);
    --shadow-lg: 0 32px 80px -32px rgba(11, 18, 36, .35), 0 10px 24px -12px rgba(11, 18, 36, .15);
    --shadow-glow: 0 20px 50px -20px rgba(79, 70, 229, .45);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-lg: 22px;
}

/* Ambient gradient mesh background */
html, body { background: #eef1f9; }
body {
    position: relative;
    background:
        radial-gradient(1200px 800px at -10% -10%, rgba(124, 109, 241, .18), transparent 60%),
        radial-gradient(1000px 700px at 110% 10%, rgba(6, 182, 212, .14), transparent 55%),
        radial-gradient(900px 600px at 50% 110%, rgba(167, 139, 250, .12), transparent 55%),
        #eef1f9;
    background-attachment: fixed;
}

/* Premium typography: Plus Jakarta Sans (Latin) + IBM Plex Sans Thai (Thai) */
body {
    font-family: "Plus Jakarta Sans", "IBM Plex Sans Thai", "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    letter-spacing: 0;
    font-weight: 400;
}
/* Thai-optimized weight calibration — IBM Plex Sans Thai reads heavier than Latin at same weight */
:lang(th), body {
    font-feature-settings: "kern", "liga";
}
body::before {
    content: "";
    position: fixed; inset: 0;
    background-image:
        radial-gradient(rgba(11,18,36,0.035) 1px, transparent 1px);
    background-size: 22px 22px;
    pointer-events: none;
    z-index: 0;
    mask-image: radial-gradient(ellipse at top, #000 20%, transparent 75%);
}
.app { position: relative; z-index: 1; }

/* Sidebar glass */
.sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,.85) 0%, rgba(255,255,255,.72) 100%);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-right: 1px solid rgba(230, 232, 240, .7);
    padding: 20px 14px 18px;
}

/* Brand mark — premium gradient + glow */
.brand-mark {
    width: 42px; height: 42px; border-radius: 13px;
    background:
        radial-gradient(120% 120% at 0% 0%, #8b7bff 0%, transparent 55%),
        linear-gradient(135deg, #4f46e5 0%, #6d65ec 55%, #06b6d4 130%);
    box-shadow:
        0 10px 24px -8px rgba(79, 70, 229, .55),
        inset 0 1px 0 rgba(255, 255, 255, .35),
        inset 0 -12px 20px rgba(11, 18, 36, .12);
    position: relative; overflow: hidden;
}
.brand-mark::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,.35) 0%, transparent 50%);
    pointer-events: none;
}
.brand-title {
    background: linear-gradient(120deg, #0b1224 0%, #4f46e5 60%, #06b6d4 120%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: -.015em;
    font-weight: 700;
    font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}

/* Nav indicator — premium glow */
.nav-indicator {
    background: linear-gradient(120deg, rgba(79,70,229,.14) 0%, rgba(124,109,241,.12) 50%, rgba(6,182,212,.10) 100%);
    border: 1px solid rgba(79, 70, 229, .18);
    box-shadow:
        0 8px 22px -10px rgba(79, 70, 229, .45),
        inset 0 1px 0 rgba(255, 255, 255, .6);
}
.nav-indicator::before {
    left: 6px; width: 3px; border-radius: 3px;
    background: linear-gradient(180deg, #4f46e5 0%, #06b6d4 100%);
    box-shadow: 0 0 10px rgba(79, 70, 229, .6);
}
.nav-item { padding: 11px 14px; font-size: 14px; letter-spacing: -.005em; }
.nav-item svg { transition: transform .3s var(--ease); }
.nav-item:hover svg { transform: translateX(2px); }
.nav-item.active { color: var(--primary); font-weight: 700; }

/* Sidebar foot card — premium */
.foot-card {
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(255,255,255,.22) 0%, transparent 60%),
        linear-gradient(135deg, #4f46e5 0%, #6d65ec 55%, #06b6d4 140%);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow:
        0 20px 40px -18px rgba(79, 70, 229, .55),
        inset 0 1px 0 rgba(255, 255, 255, .3);
    position: relative; overflow: hidden;
}
.foot-card::before {
    content: ""; position: absolute; right: -30px; bottom: -30px;
    width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(255,255,255,.25), transparent 70%);
    pointer-events: none;
}
.foot-value { font-size: 22px; letter-spacing: -.018em; font-weight: 700; font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; }

/* Topbar — refined glass */
.topbar {
    background: linear-gradient(180deg, rgba(246,247,251,.85) 0%, rgba(246,247,251,.55) 100%);
    backdrop-filter: saturate(170%) blur(14px);
    -webkit-backdrop-filter: saturate(170%) blur(14px);
    border-bottom: 1px solid rgba(230, 232, 240, .7);
    padding: 14px 28px;
}
.topbar-title { font-size: 16px; letter-spacing: -.01em; font-weight: 600; }

.chip {
    padding: 6px 13px;
    background: linear-gradient(135deg, rgba(79,70,229,.10), rgba(6,182,212,.10));
    border: 1px solid rgba(79,70,229,.18);
    color: var(--primary);
    font-weight: 600; font-size: 12px; letter-spacing: .005em;
    backdrop-filter: blur(8px);
}

.icon-btn {
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(230,232,240,.8);
    box-shadow: var(--shadow-xs);
    transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.icon-btn:hover {
    background: rgba(255,255,255,.95);
    border-color: rgba(79,70,229,.25);
    box-shadow: 0 6px 14px -6px rgba(79,70,229,.25);
}

/* Page head */
.page-title {
    font-size: 24px; font-weight: 700; letter-spacing: -.018em;
    line-height: 1.25;
    background: linear-gradient(120deg, #0b1224 0%, #27324a 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-sub { color: var(--text-2); font-size: 13.5px; margin-top: 6px; font-weight: 400; }

/* Cards — premium depth */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: box-shadow .35s var(--ease), transform .35s var(--ease), border-color .35s var(--ease);
}
.card:hover {
    box-shadow: var(--shadow);
    border-color: rgba(79,70,229,.18);
    transform: translateY(-1px);
}

/* Stat cards — premium with colored accents */
.stats-grid { gap: 16px; margin-bottom: 24px; }
.stat {
    padding: 20px 22px 18px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.9) 0%, rgba(255,255,255,.7) 100%),
        var(--surface);
    border: 1px solid rgba(230, 232, 240, .85);
    border-radius: 18px;
    box-shadow: 0 4px 16px -10px rgba(11, 18, 36, .12);
    position: relative; overflow: hidden;
    backdrop-filter: blur(8px);
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #4f46e5 0%, #7c6df1 35%, #06b6d4 100%);
    opacity: .9;
    border-radius: 18px 18px 0 0;
}
.stat::after {
    content: ""; position: absolute; right: -40px; top: -40px;
    width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(closest-side, rgba(79,70,229,.10), transparent 70%);
    pointer-events: none;
}
.stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px -20px rgba(11, 18, 36, .22), 0 6px 14px -8px rgba(79, 70, 229, .18);
    border-color: rgba(79, 70, 229, .22);
}
.stat-label { font-size: 11.5px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.stat-value {
    font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.02em;
    line-height: 1.15;
    background: linear-gradient(120deg, #0b1224 0%, #2a3456 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    font-variant-numeric: tabular-nums;
    font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 500; }
.stat-icon {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, rgba(79,70,229,.14), rgba(6,182,212,.10));
    color: var(--primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 4px 12px -6px rgba(79,70,229,.3);
}

/* Buttons — premium gradient with shine */
.btn {
    padding: 11px 18px;
    border-radius: 12px;
    font-weight: 600; letter-spacing: 0;
    font-size: 13.5px;
    background: linear-gradient(135deg, #4f46e5 0%, #6d65ec 55%, #7c6df1 100%);
    box-shadow:
        0 10px 22px -10px rgba(79, 70, 229, .55),
        inset 0 1px 0 rgba(255, 255, 255, .25);
    position: relative; overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .25s var(--ease), filter .2s var(--ease);
}
.btn::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,.25) 50%, transparent 80%);
    transform: translateX(-120%);
    transition: transform .7s var(--ease);
    pointer-events: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(79, 70, 229, .6), inset 0 1px 0 rgba(255,255,255,.3); filter: brightness(1.04); }
.btn:hover::after { transform: translateX(120%); }
.btn:active { transform: translateY(0) scale(.98); }

.btn-ghost {
    background: rgba(255,255,255,.75);
    border: 1px solid rgba(214, 218, 230, .9);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    backdrop-filter: blur(10px);
}
.btn-ghost:hover { background: #fff; border-color: rgba(79,70,229,.25); box-shadow: 0 6px 14px -8px rgba(79,70,229,.22); filter: none; }
.btn-ghost::after { display: none; }

.btn-soft {
    background: linear-gradient(135deg, rgba(79,70,229,.12), rgba(6,182,212,.10));
    border: 1px solid rgba(79,70,229,.18);
    color: var(--primary);
    box-shadow: none;
}
.btn-soft:hover { background: linear-gradient(135deg, rgba(79,70,229,.18), rgba(6,182,212,.14)); filter: none; }
.btn-soft::after { display: none; }

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 55%, #b91c1c 100%);
    box-shadow: 0 10px 22px -10px rgba(220, 38, 38, .55), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-danger-soft {
    background: linear-gradient(135deg, rgba(220,38,38,.10), rgba(239,68,68,.06));
    border: 1px solid rgba(220,38,38,.18);
    color: var(--danger);
}
.btn-danger-soft::after { display: none; }

.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* Forms — premium */
.input, .select, .textarea {
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid rgba(214, 218, 230, .9);
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 2px rgba(11,18,36,.02);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .14), 0 4px 10px -6px rgba(79,70,229,.25);
}

.label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: .005em; }

/* Rows — premium list cards */
.row-list { gap: 12px; }
.row {
    padding: 16px 18px;
    background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(255,255,255,.82) 100%);
    border: 1px solid rgba(230, 232, 240, .85);
    border-radius: 16px;
    box-shadow: 0 2px 8px -4px rgba(11,18,36,.06);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.row:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 34px -18px rgba(11,18,36,.22), 0 4px 10px -6px rgba(79,70,229,.18);
    border-color: rgba(79,70,229,.22);
}

/* Avatar — premium gradient ring */
.avatar {
    width: 44px; height: 44px;
    border-radius: 13px;
    background:
        linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: var(--primary);
    font-weight: 800; font-size: 15px;
    box-shadow:
        inset 0 0 0 1px rgba(79, 70, 229, .15),
        0 4px 12px -6px rgba(79, 70, 229, .22);
    position: relative;
}
.avatar::before {
    content: ""; position: absolute; inset: -2px; border-radius: 15px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(79,70,229,.35), rgba(6,182,212,.25));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0; transition: opacity .3s var(--ease);
}
.row:hover .avatar::before { opacity: 1; }
.row-name { font-weight: 600; font-size: 14.5px; letter-spacing: 0; }
.row-sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; font-weight: 400; }

/* Balance pill — premium */
.balance-pill {
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(34,197,94,.12), rgba(34,197,94,.06));
    border: 1px solid rgba(34,197,94,.22);
    color: #166534;
    font-weight: 600;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}
.balance-pill.zero {
    background: linear-gradient(135deg, rgba(148,163,184,.14), rgba(148,163,184,.06));
    border-color: rgba(148,163,184,.22); color: var(--text-2);
}
.balance-pill.neg {
    background: linear-gradient(135deg, rgba(220,38,38,.12), rgba(220,38,38,.06));
    border-color: rgba(220,38,38,.22); color: #991b1b;
}

/* Work card — premium */
.work-card {
    padding: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(255,255,255,.82) 100%);
    border: 1px solid rgba(230, 232, 240, .85);
    border-radius: 18px;
    box-shadow: 0 4px 14px -8px rgba(11,18,36,.08);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.work-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -20px rgba(11,18,36,.22), 0 6px 14px -8px rgba(79,70,229,.16);
}

.tick-btn {
    padding: 12px 14px;
    background: rgba(246, 248, 252, .7);
    border: 1px solid rgba(230, 232, 240, .9);
    border-radius: 12px;
    font-weight: 600; font-size: 13px;
    backdrop-filter: blur(6px);
    transition: all .25s var(--ease);
}
.tick-btn:hover {
    background: linear-gradient(135deg, rgba(79,70,229,.10), rgba(6,182,212,.08));
    color: var(--primary);
    border-color: rgba(79, 70, 229, .28);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px -10px rgba(79, 70, 229, .35);
}
.tick-btn.is-active,
.tick-btn.is-active:hover {
    background: var(--success-soft);
    border-color: #86efac;
    color: var(--success);
    box-shadow: 0 8px 16px -12px rgba(21, 128, 61, .35);
}

/* Badges — premium */
.badge {
    font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
    letter-spacing: .02em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.badge.full { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #14532d; }
.badge.half { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #9a3412; }
.badge.bonus { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #854d0e; }
.badge.custom { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #155e75; }

/* Log items */
.log-item {
    background: rgba(246, 248, 252, .7);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 12px;
    transition: background .2s var(--ease), border-color .2s var(--ease);
}
.log-item:hover {
    background: #fff;
    border-color: rgba(230, 232, 240, .9);
    box-shadow: var(--shadow-xs);
}

/* Modal — premium */
.modal-backdrop {
    background: radial-gradient(ellipse at center, rgba(11,18,36,.45) 0%, rgba(11,18,36,.65) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal {
    border-radius: 22px;
    padding: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(250,251,254,.96) 100%);
    border: 1px solid rgba(230, 232, 240, .85);
    box-shadow:
        0 40px 80px -20px rgba(11,18,36,.45),
        0 0 0 1px rgba(255,255,255,.4) inset,
        0 -1px 0 rgba(11,18,36,.06) inset;
}
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-sub { color: var(--text-2); font-size: 13.5px; font-weight: 400; }

/* Toasts — premium */
.toast {
    padding: 14px 16px; padding-right: 36px;
    background: linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(250,251,254,.92) 100%);
    border: 1px solid rgba(230, 232, 240, .9);
    border-radius: 14px;
    box-shadow: 0 20px 40px -20px rgba(11,18,36,.3), 0 4px 10px -6px rgba(11,18,36,.1);
    backdrop-filter: blur(12px);
    font-weight: 600;
}

/* Bottom nav — floating premium pill */
@media (max-width: 960px) {
    .bottom-nav {
        left: 12px; right: 12px; bottom: 12px;
        padding: 8px;
        background: rgba(255, 255, 255, .72);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border: 1px solid rgba(230, 232, 240, .85);
        border-top: 1px solid rgba(230, 232, 240, .85);
        border-radius: 22px;
        box-shadow:
            0 20px 40px -15px rgba(11, 18, 36, .25),
            0 4px 12px -4px rgba(11, 18, 36, .08),
            inset 0 1px 0 rgba(255, 255, 255, .7);
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    .bn-indicator {
        top: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
        left: 8px;
        width: calc((100% - 16px) / var(--bn-count, 5));
        background: linear-gradient(135deg, rgba(79, 70, 229, .14) 0%, rgba(6, 182, 212, .10) 100%);
        border: 1px solid rgba(79, 70, 229, .18);
        border-radius: 16px;
        box-shadow:
            0 6px 16px -8px rgba(79, 70, 229, .4),
            inset 0 1px 0 rgba(255, 255, 255, .6);
    }
    .bn-item {
        font-size: 10.5px; font-weight: 500;
        padding: 8px 4px;
        letter-spacing: 0;
    }
    .bn-item svg { transition: transform .3s var(--ease), filter .3s var(--ease); }
    .bn-item.active {
        color: var(--primary);
        font-weight: 600;
    }
    .bn-item.active svg {
        transform: translateY(-1px) scale(1.08);
        filter: drop-shadow(0 3px 6px rgba(79, 70, 229, .45));
    }
    .content { padding: 18px 16px 110px; }
}

/* Status dot — premium glow */
.status-dot {
    width: 11px; height: 11px;
    box-shadow:
        0 0 0 3px var(--surface),
        0 0 0 4px rgba(11,18,36,0.05),
        0 2px 4px rgba(11,18,36,0.1);
}
.status-dot.s-green {
    background: radial-gradient(circle at 30% 30%, #4ade80, #15803d);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(22,163,74,0.3), 0 0 12px rgba(22,163,74,0.45);
}
.status-dot.s-yellow {
    background: radial-gradient(circle at 30% 30%, #fbbf24, #b45309);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(245,158,11,0.3), 0 0 12px rgba(245,158,11,0.45);
}
.status-dot.s-red {
    background: radial-gradient(circle at 30% 30%, #f87171, #b91c1c);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px rgba(220,38,38,0.3), 0 0 12px rgba(220,38,38,0.45);
}
.status-dot.s-neutral {
    background: radial-gradient(circle at 30% 30%, #cbd5e1, #64748b);
}

/* Status tag */
.status-tag {
    padding: 2px 9px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.status-tag.s-green { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #14532d; }
.status-tag.s-yellow { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.status-tag.s-red { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }
.status-tag.s-neutral { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); color: #475569; }

/* Left color stripe stronger with glow */
.row.status-green,   .work-card.status-green   { box-shadow: inset 4px 0 0 #16a34a, 0 2px 8px -4px rgba(22,163,74,0.25); }
.row.status-yellow,  .work-card.status-yellow  { box-shadow: inset 4px 0 0 #f59e0b, 0 2px 8px -4px rgba(245,158,11,0.25); }
.row.status-red,     .work-card.status-red     { box-shadow: inset 4px 0 0 #dc2626, 0 2px 8px -4px rgba(220,38,38,0.25); }
.row.status-neutral, .work-card.status-neutral { box-shadow: inset 4px 0 0 #cbd5e1, 0 2px 8px -4px rgba(148,163,184,0.2); }
.row.status-green:hover   { box-shadow: inset 4px 0 0 #16a34a, 0 18px 34px -18px rgba(22,163,74,0.35); }
.row.status-yellow:hover  { box-shadow: inset 4px 0 0 #f59e0b, 0 18px 34px -18px rgba(245,158,11,0.35); }
.row.status-red:hover     { box-shadow: inset 4px 0 0 #dc2626, 0 18px 34px -18px rgba(220,38,38,0.35); }

/* Analytics — premium bar chart */
.bar-track {
    height: 24px;
    background: linear-gradient(180deg, #eef1f7 0%, #e4e8f2 100%);
    box-shadow: inset 0 1px 2px rgba(11,18,36,0.06), inset 0 0 0 1px rgba(214,218,230,0.5);
}
.bar-seg.bar-work {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 70%, #15803d 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 12px rgba(22,163,74,0.25);
}
.bar-seg.bar-absent {
    background: linear-gradient(90deg, #fda4af 0%, #ef4444 70%, #dc2626 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 0 12px rgba(220,38,38,0.25);
}

/* Calendar cells — premium */
.cal-cell {
    border-radius: 12px;
    font-weight: 600;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.cal-cell.worked {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #14532d;
    border-color: rgba(22,163,74,.35);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 6px -3px rgba(22,163,74,.25);
}
.cal-cell.absent {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #7f1d1d;
    border-color: rgba(220,38,38,.35);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 6px -3px rgba(220,38,38,.25);
}
.cal-cell.bonus {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #3730a3;
    border-color: rgba(79,70,229,.35);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 6px -3px rgba(79,70,229,.25);
}
.cal-cell.today {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(79,70,229,.12), 0 6px 16px -8px rgba(79,70,229,.4);
}
.cal-cell:hover:not(.blank):not(.before):not(.future) {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 20px -10px rgba(11,18,36,.25);
}

/* Analytics table */
.analytics-table thead th {
    color: var(--text-3); letter-spacing: .08em; font-size: 11px;
    padding: 12px 12px;
}
.analytics-table tbody td { padding: 14px 12px; }
.analytics-table tbody tr { transition: background .2s var(--ease); }
.analytics-table tbody tr:hover { background: linear-gradient(90deg, rgba(79,70,229,.05), rgba(6,182,212,.03)); }

/* Cal chips (summary) */
.cal-chip {
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 6px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.cal-chip.w { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #14532d; }
.cal-chip.a { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }

/* Empty state refine */
.empty {
    padding: 56px 24px;
    background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(246,248,252,.7));
    border: 1px dashed rgba(214,218,230,.9);
    border-radius: 20px;
}
.empty-icon {
    width: 60px; height: 60px; border-radius: 18px;
    background: linear-gradient(135deg, rgba(79,70,229,.14), rgba(6,182,212,.08));
    color: var(--primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 24px -12px rgba(79,70,229,.35);
}

/* Loader spinner premium */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(230,232,240,.7);
    border-top: 3px solid transparent;
    background:
        conic-gradient(from 0deg, rgba(79,70,229,0), #4f46e5 30%, #06b6d4 60%, rgba(79,70,229,0) 100%)
        border-box;
    -webkit-mask:
        radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    mask:
        radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    border: none;
    border-radius: 50%;
}

/* Section titles refined */
.section-title {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    text-transform: uppercase; letter-spacing: .1em;
    margin: 22px 0 12px;
    font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.section-title::before {
    content: ""; display: inline-block; width: 3px; height: 14px;
    border-radius: 2px; margin-right: 4px;
    background: linear-gradient(180deg, #4f46e5, #06b6d4);
}

/* Scrollbar premium */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(148,163,184,.35), rgba(148,163,184,.2));
    border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(79,70,229,.4), rgba(6,182,212,.3)); background-clip: padding-box; border: 2px solid transparent; }

/* Selection */
::selection { background: rgba(79, 70, 229, .22); color: var(--text); }

/* Confirm warn — premium */
.confirm-warn {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid rgba(251, 146, 60, .3);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}

/* Responsive polish */
@media (max-width: 520px) {
    .page-title { font-size: 22px; }
    .stat { padding: 16px 18px 14px; }
    .stat-value { font-size: 24px; }
}


/* Numeric/currency globally uses Plus Jakarta for crisp digits while Thai text uses IBM Plex Sans Thai */
.stat-value, .foot-value, .balance-pill, .log-amount,
.bar-meta, .bar-num-w, .bar-num-a, .cal-num,
.analytics-table td:nth-child(3),
.analytics-table td:nth-child(4),
.analytics-table td:nth-child(5),
.analytics-table td:nth-child(6) {
    font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* Heading hierarchy tuned for Thai � avoid making Thai text feel too heavy */
.brand-sub { font-size: 11.5px; letter-spacing: 0; font-weight: 400; }
.label { font-weight: 500; }

/* Thai line-height boost for cleaner descenders (sara-u / vowel marks) */
.row-name, .page-title, .modal-title, .brand-title { line-height: 1.35; }


/* Keep Thai baht sign rendered by IBM Plex Sans Thai so it doesn't look broken in Latin fonts */
.stat-value, .foot-value, .balance-pill, .log-amount {
    font-family: "IBM Plex Sans Thai", "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}


/* ===== Hide scrollbars globally (keep scroll behavior) ===== */
html, body, * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
    background: transparent !important;
}

/* ===== Stat card — light premium (soft fintech) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat {
    position: relative;
    padding: 20px 22px 22px;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(99, 102, 241, .05), transparent 55%),
        linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border: 1px solid rgba(226, 230, 242, .9);
    border-radius: 20px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .9) inset,
        0 1px 2px rgba(11, 18, 36, .04),
        0 14px 32px -20px rgba(11, 18, 36, .18),
        0 4px 10px -6px rgba(11, 18, 36, .06);
    overflow: hidden;
    backdrop-filter: none;
    min-height: 148px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr auto;
    column-gap: 14px;
    row-gap: 6px;
    transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
    isolation: isolate;
}

/* Decorative soft tint blob in the background — airy, light version */
.stat::before {
    content: "";
    position: absolute;
    inset: auto -50px -70px auto;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--stat-glow, rgba(99, 102, 241, .18)) 0%, transparent 65%);
    filter: blur(24px);
    opacity: .85;
    z-index: 0;
    pointer-events: none;
    transition: opacity .5s var(--ease), transform .5s var(--ease);
    display: block !important;
}

/* Subtle dotted texture — very faint on light bg */
.stat::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(15, 23, 42, .045) 1px, transparent 1px);
    background-size: 18px 18px;
    background-position: 0 0;
    opacity: .6;
    z-index: 0;
    pointer-events: none;
    display: block !important;
}

.stat > * { position: relative; z-index: 1; }

.stat:hover {
    transform: translateY(-3px);
    border-color: rgba(210, 216, 232, .95);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .95) inset,
        0 1px 2px rgba(11, 18, 36, .05),
        0 24px 48px -18px rgba(11, 18, 36, .22),
        0 8px 18px -10px rgba(11, 18, 36, .1);
}
.stat:hover::before {
    opacity: 1;
    transform: scale(1.1);
}

.stat-label {
    grid-column: 1;
    grid-row: 1;
    font-size: 12.5px;
    color: #64748b;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status pill next to label */
.stat-label::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--stat-accent, #6366f1);
    box-shadow: 0 0 0 3px var(--stat-halo, rgba(99, 102, 241, .18));
    flex-shrink: 0;
}

.stat-icon {
    position: static;
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--stat-icon-bg, linear-gradient(135deg, #eef2ff, #e0e7ff));
    border: 1px solid var(--stat-icon-border, rgba(165, 180, 252, .5));
    color: var(--stat-accent, #6366f1);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, .6) inset,
        0 2px 6px -2px rgba(11, 18, 36, .08);
    display: grid;
    place-items: center;
    margin-top: 0;
}
.stat-icon svg { width: 17px; height: 17px; stroke-width: 2; }

.stat-value {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 32px;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: -.03em;
    line-height: 1.05;
    color: #0b1224;
    background: none !important;
    -webkit-text-fill-color: #0b1224 !important;
    font-variant-numeric: tabular-nums;
    font-family: "IBM Plex Sans Thai", "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    align-self: end;
    text-shadow: none;
}

.stat-sub {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: 11.5px;
    color: #8791a6;
    margin-top: 14px;
    font-weight: 500;
    padding-top: 12px;
    border-top: 1px solid rgba(226, 230, 242, .85);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: .01em;
}
.stat-sub::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 2px;
    background: var(--stat-accent, #6366f1);
    box-shadow: none;
    flex-shrink: 0;
}

/* Per-card accent color set (light-tuned tints) */
.stats-grid > .stat:nth-child(1) {
    --stat-accent: #d97706;
    --stat-glow: rgba(251, 191, 36, .22);
    --stat-halo: rgba(251, 191, 36, .22);
    --stat-icon-bg: linear-gradient(135deg, #fef3c7, #fde68a);
    --stat-icon-border: rgba(251, 191, 36, .5);
}
.stats-grid > .stat:nth-child(2) {
    --stat-accent: #2563eb;
    --stat-glow: rgba(96, 165, 250, .22);
    --stat-halo: rgba(96, 165, 250, .22);
    --stat-icon-bg: linear-gradient(135deg, #dbeafe, #bfdbfe);
    --stat-icon-border: rgba(96, 165, 250, .5);
}
.stats-grid > .stat:nth-child(3) {
    --stat-accent: #059669;
    --stat-glow: rgba(52, 211, 153, .2);
    --stat-halo: rgba(52, 211, 153, .22);
    --stat-icon-bg: linear-gradient(135deg, #dcfce7, #bbf7d0);
    --stat-icon-border: rgba(52, 211, 153, .5);
}
.stats-grid > .stat:nth-child(4) {
    --stat-accent: #7c3aed;
    --stat-glow: rgba(192, 132, 252, .22);
    --stat-halo: rgba(192, 132, 252, .22);
    --stat-icon-bg: linear-gradient(135deg, #ede9fe, #ddd6fe);
    --stat-icon-border: rgba(192, 132, 252, .5);
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat { min-height: 132px; padding: 16px 16px 16px; border-radius: 18px; }
    .stat-value { font-size: 24px; margin-top: 6px; }
    .stat-icon { width: 32px; height: 32px; border-radius: 10px; }
    .stat-icon svg { width: 15px; height: 15px; }
    .stat-label { font-size: 11.5px; }
    .stat-sub { font-size: 11px; margin-top: 10px; padding-top: 10px; }
}


/* ===== Sticky topbar reinforcement =====
   Ensure the top nav truly sticks to the viewport edge and sits above all content */
.main > .topbar,
.topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
}

/* ===== Mobile overflow hardening ===== */
.app,
.main,
.content,
.card,
.card-pad,
.row,
.work-card,
.bar-chart,
.analytics-table-wrap,
.cal-controls,
.cal-grid {
    min-width: 0;
    max-width: 100%;
}

.page-sub,
.row-sub,
.legend,
.stat-label,
.stat-sub,
.cal-title,
.cal-chip,
.cal-label {
    overflow-wrap: anywhere;
}

.cal-controls > *,
.cal-controls .field,
.cal-controls .input,
.cal-controls .select {
    min-width: 0;
}

.cal-grid {
    width: 100%;
}

.cal-cell {
    min-width: 0;
    overflow: hidden;
}

.cal-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.analytics-table {
    min-width: 620px;
}

@media (max-width: 520px) {
    .content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .card-pad {
        padding: 12px;
    }

    .legend-row {
        gap: 8px 10px;
    }

    .bar-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .bar-track {
        width: 100%;
    }

    .bar-meta {
        justify-self: start;
    }

    .cal-head {
        align-items: flex-start;
    }

    .cal-summary {
        flex-wrap: wrap;
    }

    .cal-grid {
        gap: 2px;
    }

    .cal-dow-cell {
        font-size: 10px;
        padding: 4px 0;
    }

    .cal-cell {
        min-height: 38px;
        padding: 3px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
    }

    .cal-num {
        font-size: 12px;
    }

    .cal-label {
        display: none;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topbar-title {
        max-width: 45vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

#print-root {
    display: none;
}

.cutoff-history-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.cutoff-snapshot {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

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

.cutoff-snapshot-card span,
.cutoff-detail-sub,
.period-note,
.cutoff-worker-total span {
    color: var(--text-3);
}

.cutoff-snapshot-card b {
    display: block;
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.1;
}

.cutoff-history-row.is-selected {
    border-color: var(--primary);
    background: var(--primary-softer);
}

.cutoff-detail {
    display: grid;
    gap: 16px;
}

.cutoff-detail-head,
.cutoff-worker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.cutoff-detail-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.cutoff-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.cutoff-metrics > div {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--surface-2);
}

.cutoff-metrics span {
    display: block;
    color: var(--text-3);
    font-size: 12px;
}

.cutoff-metrics b {
    display: block;
    margin-top: 3px;
    font-size: 18px;
}

.cutoff-worker {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    background: var(--surface);
}

.cutoff-worker + .cutoff-worker {
    margin-top: 2px;
}

.cutoff-worker-total {
    text-align: right;
    white-space: nowrap;
}

.cutoff-worker-total b {
    display: block;
    font-size: 20px;
}

.period-timeline {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.period-event {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    background: var(--surface-2);
}

.period-event.withdraw {
    background: var(--danger-soft);
}

.period-date b,
.period-date span {
    display: block;
}

.period-date span {
    margin-top: 2px;
    color: var(--text-3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.period-title {
    font-weight: 700;
}

.period-money {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.period-money.in {
    color: var(--success);
}

.period-money.out {
    color: var(--danger);
}

@media (max-width: 520px) {
    .cutoff-snapshot,
    .cutoff-metrics {
        grid-template-columns: 1fr;
    }

    .cutoff-detail-head,
    .cutoff-worker-head {
        flex-direction: column;
    }

    .period-event {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .period-money,
    .cutoff-worker-total {
        text-align: left;
    }

    .cutoff-history-row {
        grid-template-columns: 1fr !important;
    }

    .cutoff-history-actions {
        justify-content: space-between;
        width: 100%;
    }
}

@media print {
    @page {
        size: A4;
        margin: 6mm;
    }

    html,
    body {
        width: auto;
        height: auto;
        overflow: visible !important;
        background: #fff !important;
        color: #111827 !important;
    }

    body.printing-cutoff .app,
    body.printing-cutoff [data-toasts],
    body.printing-cutoff [data-modal-root] {
        display: none !important;
    }

    body.printing-cutoff #print-root {
        display: block !important;
        font-family: "IBM Plex Sans Thai", "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
        color: #111827;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-page {
        break-after: page;
        page-break-after: always;
        position: relative;
        padding: 5mm;
        min-height: calc(297mm - 12mm);
        height: calc(297mm - 12mm);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        font-size: 9.4px;
        line-height: 1.22;
        background: #ffffff;
        border: .45mm solid #111827;
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-page::before {
        content: none;
    }

    .print-page > * {
        position: relative;
        z-index: 1;
    }

    .print-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .print-header {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        border: 1px solid #111827;
        border-left: 3px solid #4f46e5;
        border-radius: 0;
        background: #ffffff;
        color: #111827;
        padding: 5px 7px;
        margin-bottom: 6px;
        flex: 0 0 auto;
    }

    .print-kicker,
    .print-sub,
    .print-meta,
    .print-empty,
    .print-table .muted {
        color: #4b5563;
    }

    .print-header .print-kicker,
    .print-header .print-sub,
    .print-header .print-meta {
        color: #4b5563;
    }

    .print-kicker {
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
    }

    .print-header h1 {
        margin: 2px 0 2px;
        font-size: 18px;
        line-height: 1.1;
        color: #111827;
    }

    .print-meta {
        text-align: right;
        font-size: 10px;
        white-space: nowrap;
    }

    .print-summary {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
        margin-bottom: 6px;
        flex: 0 0 auto;
    }

    .print-summary > div {
        border: 1px solid #d1d5db;
        background: #fff;
        padding: 4px 5px;
    }

    .print-summary span {
        display: block;
        color: #4b5563;
        font-size: 9.5px;
    }

    .print-summary b {
        display: block;
        margin-top: 1px;
        font-size: 11px;
    }

    .print-summary .total {
        border-color: #4f46e5;
        background: #ffffff;
        color: #111827;
        border-width: 2px;
    }

    .print-summary .total span {
        color: #4f46e5;
    }

    .print-columns {
        display: grid;
        grid-template-columns: minmax(0, 1.3fr) minmax(0, .85fr);
        gap: 8px;
        align-items: start;
    }

    .print-columns h2 {
        margin: 0 0 4px;
        font-size: 12px;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #d1d5db;
        padding: 2px 3px;
        vertical-align: top;
        overflow-wrap: anywhere;
    }

    .print-table th {
        background: #ffffff;
        font-size: 8.6px;
        text-align: left;
        color: #4b5563;
    }

    .print-table th:first-child,
    .print-table td:first-child {
        width: 22px;
        text-align: center;
    }

    .print-table .num {
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    .print-note {
        max-width: 58mm;
    }

    .print-timeline-title {
        margin: 0 0 3px;
        font-size: 10px;
        font-weight: 800;
        flex: 0 0 auto;
        color: #111827;
    }

    .print-timeline {
        flex: 1 1 auto;
    }

    .print-timeline th:nth-child(1),
    .print-timeline td:nth-child(1) {
        width: 7mm;
    }

    .print-timeline th:nth-child(2),
    .print-timeline td:nth-child(2) {
        width: 25mm;
    }

    .print-timeline th:nth-child(3),
    .print-timeline td:nth-child(3) {
        width: 30mm;
    }

    .print-timeline th:nth-child(5),
    .print-timeline td:nth-child(5),
    .print-timeline th:nth-child(6),
    .print-timeline td:nth-child(6) {
        width: 24mm;
    }

    .print-timeline tr.work td {
        background: #ffffff;
    }

    .print-timeline tr.work td:first-child {
        border-left-color: #16a34a;
    }

    .print-timeline tr.withdraw td {
        background: #ffffff;
    }

    .print-timeline tr.withdraw td:first-child {
        border-left-color: #dc2626;
    }

    .print-time {
        display: block;
        margin-top: 1px;
        color: #6b7280;
        font-size: 8.2px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }

    .print-table .in {
        color: #166534;
    }

    .print-table .out {
        color: #991b1b;
    }

    .print-page.dense {
        font-size: 8.2px;
        line-height: 1.12;
    }

    .print-page.dense .print-table th,
    .print-page.dense .print-table td {
        padding: 1px 2px;
    }

    .print-page.dense .print-header h1 {
        font-size: 15px;
    }

    .print-sign { display: none !important; }
}

/* Hard lock the application UI to light mode. Keep this at the end so it wins
   over older premium/dark overrides that may still be cached by browsers. */
@media screen {
    :root {
        color-scheme: light !important;
        --base-bg: #eef1f9 !important;
        --surface: #ffffff !important;
        --surface-2: #f6f8fc !important;
        --surface-glass: rgba(255, 255, 255, .86) !important;
        --text: #0b1224 !important;
        --text-2: #4a5468 !important;
        --text-3: #8791a6 !important;
        --border: #e6e8f0 !important;
        --border-strong: #d6dae6 !important;
    }

    html,
    body {
        background: #eef1f9 !important;
        color: #0b1224 !important;
    }

    body {
        background:
            radial-gradient(1200px 800px at -10% -10%, rgba(124, 109, 241, .12), transparent 60%),
            radial-gradient(1000px 700px at 110% 10%, rgba(6, 182, 212, .10), transparent 55%),
            #eef1f9 !important;
    }

    .app,
    .main,
    .content {
        background: transparent !important;
        color: #0b1224 !important;
    }

    .sidebar,
    .bottom-nav,
    .card,
    .row,
    .work-card,
    .stat,
    .modal,
    .toast,
    .input,
    .select,
    .textarea,
    .empty,
    .cutoff-worker,
    .cutoff-snapshot-card,
    .cutoff-metrics > div {
        background: #ffffff !important;
        color: #0b1224 !important;
        border-color: #e6e8f0 !important;
    }

    .topbar {
        background: rgba(238, 241, 249, .88) !important;
        color: #0b1224 !important;
        border-color: #e6e8f0 !important;
    }

    .nav-item,
    .row-sub,
    .page-sub,
    .stat-label,
    .label,
    .modal-sub {
        color: #4a5468 !important;
    }

    .brand-sub,
    .stat-sub,
    .empty,
    .period-note,
    .cutoff-detail-sub,
    .period-date span {
        color: #8791a6 !important;
    }

    .nav-item.active {
        background: #eef2ff !important;
        color: #4f46e5 !important;
    }

    .foot-card,
    .brand-mark {
        color: #ffffff !important;
    }

    .btn {
        color: #ffffff;
    }

    .btn-soft,
    .btn-ghost {
        background: #eef2ff !important;
        color: #4f46e5 !important;
        border-color: #dfe3ff !important;
    }

    .period-event {
        background: #f6f8fc !important;
    }

    .period-event.withdraw {
        background: #fff1f2 !important;
    }
}
