/* ===== Design tokens ===== */
:root {
    --bg:            #E8EEF7;
    --surface:       #FFFFFF;
    --surface-soft:  #F5F8FC;
    --ink:           #16233F;
    --ink-soft:      #5B6B86;
    --ink-faint:     #8B98AD;
    --border:        #DCE5F0;
    --border-strong: #C9D6E6;

    --primary:       #17469B;
    --primary-hover: #113A83;
    --primary-tint:  #E4ECF8;
    --primary-ring:  rgba(23,70,155,.16);

    --brand-red:      #C8102E;
    --brand-red-tint: #FBEAEC;

    --warn:      #C4841A;
    --warn-tint: #FFF6E8;
    --ok:        #2F8A5B;
    --ok-tint:   #E7F6EE;
    --bad:       #C0564C;
    --bad-tint:  #FCEDEB;
    --info:      #3D7AB8;
    --info-tint: #E8F1FA;
    --violet:      #6B5BA8;
    --violet-tint: #F1EDF9;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    --shadow-sm: 0 1px 2px rgba(22,35,63,.04);
    --shadow:    0 1px 2px rgba(22,35,63,.04), 0 10px 28px rgba(23,70,155,.07);
    --shadow-lg: 0 24px 60px rgba(22,35,63,.16);

    --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; max-width: 100%; overflow-x: hidden; }

body {
    margin: 0;
    font-family: 'Prompt', 'Sarabun', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    background:
        radial-gradient(1100px 520px at -8% -18%, #D5E3F7 0%, transparent 58%),
        radial-gradient(820px 460px at 108% -8%, #FADDE2 0%, transparent 52%),
        radial-gradient(700px 380px at 88% 108%, #DDE9F8 0%, transparent 55%),
        var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
body:has(.app-shell) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
::selection { background: var(--primary-tint); color: var(--primary); }

a { color: var(--primary); }

.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ===== App shell ===== */
.app-shell {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}
.app-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFD 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    z-index: 40;
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(180deg, #EEF4FC 0%, transparent 100%);
    flex-shrink: 0;
}
.sb-logo {
    width: 46px; height: 46px;
    margin: -6px 0;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sb-logo img { width: 100%; height: 100%; object-fit: contain; }
.sb-brand-text { min-width: 0; }
.sb-brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -.01em;
    line-height: 1.2;
    color: var(--primary);
}
.sb-brand-sub {
    font-size: 11.5px;
    line-height: 1.3;
    color: var(--ink-faint);
}

.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px 12px; }

.sb-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding: 16px 10px 7px;
}

.sb-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    margin-bottom: 2px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
    position: relative;
    transition: background .14s, color .14s, box-shadow .14s;
}
.sb-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .88; }
.sb-link:hover { background: var(--primary-tint); color: var(--primary); }
.sb-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(23,70,155,.22);
}
.sb-link.active svg { opacity: 1; }
.sb-link.active::before { display: none; }
.sb-count {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 20px;
    background: var(--brand-red-tint);
    color: var(--brand-red);
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
}
.sb-link.active .sb-count {
    background: rgba(255,255,255,.22);
    color: #fff;
}

.sb-online {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 10px 12px 8px;
}
.sb-online-h {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-soft);
    letter-spacing: .02em;
    margin-bottom: 8px;
}
.sb-online-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #2F8A5B;
    box-shadow: 0 0 0 0 rgba(47,138,91,.45);
    animation: sb-pulse 1.8s ease-out infinite;
    flex-shrink: 0;
}
@keyframes sb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(47,138,91,.45); }
    70% { box-shadow: 0 0 0 6px rgba(47,138,91,0); }
    100% { box-shadow: 0 0 0 0 rgba(47,138,91,0); }
}
.sb-online-n {
    margin-left: auto;
    min-width: 18px;
    padding: 0 6px;
    height: 18px;
    border-radius: 99px;
    background: var(--ok-tint);
    color: var(--ok);
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sb-online-list {
    max-height: 168px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sb-online-empty {
    font-size: 12px;
    color: var(--ink-faint);
    padding: 4px 2px 6px;
}
.sb-online-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 10px;
}
.sb-online-row.is-me { background: var(--ok-tint); }
.avatar.av-sm { width: 26px; height: 26px; font-size: 11px; }
.sb-online-who {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.sb-online-who b {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-online-who em {
    font-style: normal;
    font-weight: 700;
    color: var(--ok);
    font-size: 11px;
}
.sb-online-who small {
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-foot {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
}
.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2A62BE, #17469B);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.avatar.has-photo, .id-avatar.has-photo {
    padding: 0;
    overflow: hidden;
    background: var(--surface-soft);
    color: transparent;
    font-size: 0;
}
.avatar.has-photo img, .id-avatar.has-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sb-foot-info { min-width: 0; flex: 1; }
.sb-foot-name {
    font-size: 13.5px; font-weight: 600; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-foot-role { font-size: 11.5px; color: var(--ink-faint); }
.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border: 0; background: transparent;
    border-radius: var(--r-sm);
    color: var(--ink-faint);
    text-decoration: none;
    cursor: pointer;
    transition: background .14s, color .14s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--bad-tint); color: var(--bad); }

/* ===== Topbar (mobile) ===== */
.topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar .sb-brand-name { font-size: 15px; }
.burger {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--r-md);
    color: var(--ink);
    cursor: pointer;
}
.burger svg { width: 19px; height: 19px; }
.scrim { display: none; }

/* ===== Page ===== */
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 30px 30px 72px; min-width: 0; overflow-x: hidden; }
.page-wide { max-width: 1360px; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head-text { flex: 1; min-width: 0; }
.page-title {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0 0 4px;
    line-height: 1.25;
    color: var(--primary);
}
.page-title::after {
    content: '';
    display: block;
    width: 42px; height: 4px; border-radius: 99px;
    margin-top: 10px;
    background: linear-gradient(90deg, var(--primary), var(--brand-red));
}
.page-sub { color: var(--ink-soft); margin: 0; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section { margin-bottom: 30px; }
.section-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.section-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0;
}
.section-note { font-size: 13px; color: var(--ink-faint); margin: 0; }
.section-link { margin-left: auto; font-size: 13.5px; font-weight: 500; text-decoration: none; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    min-width: 0;
}
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #FAFCFF 0%, #fff 100%);
}
.card-head .section-title { margin: 0; }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 22px; }
.card-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
}

/* ===== Stat / balance cards ===== */
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .16s, transform .16s;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
a.stat { text-decoration: none; color: inherit; cursor: pointer; display: block; }
a.stat:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stat-top { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.stat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.stat-name {
    font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value {
    display: flex; align-items: baseline; gap: 6px;
    margin-bottom: 12px;
}
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.stat-unit { font-size: 13px; color: var(--ink-faint); }
.bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-bottom: 9px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }
.stat-foot { font-size: 12.5px; color: var(--ink-faint); }

.kpi {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .16s, transform .16s, border-color .16s;
}
a.kpi:hover, .kpi:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: #C5D4EA;
}
.kpi-icon {
    width: 44px; height: 44px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-num { font-size: 22px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi-label { font-size: 13px; color: var(--ink-soft); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 9px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(180deg, #2156B3 0%, var(--primary) 100%); color: #fff; box-shadow: 0 4px 12px rgba(23,70,155,.26); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-soft { background: var(--primary-tint); color: var(--primary); }
.btn-soft:hover { background: #DBE5F5; }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-outline:hover { background: var(--surface-soft); border-color: var(--ink-faint); }
.btn-danger { background: var(--bad-tint); color: var(--bad); }
.btn-danger:hover { background: #F8DFDC; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px 4px 9px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-plain { padding: 4px 11px; }
.badge-plain::before { display: none; }
.badge-pending   { background: var(--warn-tint);   color: var(--warn); }
.badge-approved  { background: var(--ok-tint);     color: var(--ok); }
.badge-rejected  { background: var(--bad-tint);    color: var(--bad); }
.badge-cancelled { background: var(--surface-soft); color: var(--ink-soft); }
.badge-skipped   { background: var(--violet-tint); color: var(--violet); }
.badge-info      { background: var(--info-tint);   color: var(--info); }

/* ===== Alerts ===== */
.alert {
    display: flex; gap: 12px;
    padding: 14px 16px;
    border-radius: var(--r-lg);
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert svg { width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px; }
.alert-body { min-width: 0; }
.alert-title { font-weight: 600; margin-bottom: 3px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert li { margin-bottom: 3px; }
.alert-success { background: var(--ok-tint);   color: #2F6F4C; border-color: #CFE8DA; }
.alert-error   { background: var(--bad-tint);  color: #9E463D; border-color: #F3D7D3; }
.alert-warn    { background: var(--warn-tint); color: #8E651F; border-color: #F0E0C2; }
.alert-info    { background: var(--info-tint); color: #3B6A98; border-color: #D5E3F2; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}
.req { color: var(--bad); }
.input, .field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: border-color .14s, box-shadow .14s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field select[size] { padding: 6px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.field input:disabled, .field select:disabled {
    background: var(--surface-soft);
    color: var(--ink-soft);
    cursor: not-allowed;
}
.be-cal { position: relative; min-width: 0; }
.be-cal-trigger {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 42px; padding: 8px 12px 8px 13px;
    border: 1px solid var(--border-strong); border-radius: var(--r-md);
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 14px; text-align: left; cursor: pointer;
    transition: border-color .14s, box-shadow .14s;
}
.be-cal-trigger:hover { border-color: var(--primary); }
.be-cal.open .be-cal-trigger,
.be-cal-trigger:focus-visible {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.be-cal-text { flex: 1; min-width: 0; font-weight: 600; }
.be-cal-text.is-empty { font-weight: 500; color: var(--ink-faint); }
.be-cal-ico { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-faint); }
.be-cal-pop {
    padding: 12px 12px 10px;
    border: 1px solid var(--border); border-radius: 16px;
    background: #fff; box-shadow: var(--shadow-lg);
}
.be-cal-nav {
    display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
.be-cal-nav-btn {
    width: 32px; height: 32px; flex-shrink: 0; padding: 0;
    border: 0; border-radius: 10px; background: var(--surface-soft);
    color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
}
.be-cal-nav-btn:hover { background: var(--primary-tint); color: var(--primary); }
.be-cal-title {
    flex: 1; min-width: 0; height: 32px; padding: 0 8px;
    border: 0; border-radius: 10px; background: transparent;
    font: inherit; font-size: 14px; font-weight: 750; color: var(--ink);
    cursor: pointer;
}
.be-cal-title:hover { background: var(--primary-tint); color: var(--primary); }
.be-cal-weeks, .be-cal-grid, .be-cal-years {
    display: grid; gap: 2px;
}
.be-cal-weeks, .be-cal-grid { grid-template-columns: repeat(7, 1fr); }
.be-cal-years { grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 8px; }
.be-cal-weeks span {
    height: 26px; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--ink-faint);
}
.be-cal-blank { min-height: 34px; }
.be-cal-day, .be-cal-year {
    min-height: 34px; padding: 0; border: 0; border-radius: 10px;
    background: transparent; color: var(--ink);
    font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
}
.be-cal-day:hover, .be-cal-year:hover { background: var(--primary-tint); color: var(--primary); }
.be-cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.be-cal-day.on, .be-cal-year.on {
    background: var(--primary); color: #fff;
}
.be-cal-day.on:hover, .be-cal-year.on:hover { background: var(--primary-hover); color: #fff; }
.be-cal-foot {
    display: flex; justify-content: space-between; gap: 8px;
    margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.be-cal-foot button {
    height: 30px; padding: 0 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--primary);
    font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.be-cal-foot button:hover { background: var(--primary-tint); }
.auth-panel .be-cal-trigger { height: 46px; border-radius: 12px; background: var(--surface-soft); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
    background: transparent; color: var(--ink-faint); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { color: var(--primary); background: var(--primary-tint); }
.pw-toggle svg { display: block; }
.pw-ico-hide { display: none; }
.pw-wrap.is-on .pw-ico-show { display: none; }
.pw-wrap.is-on .pw-ico-hide { display: block; }
.hint { font-size: 12.5px; color: var(--ink-faint); }
.check {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-soft);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
}
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.check-text { min-width: 0; }
.check-sub { font-weight: 400; color: var(--ink-faint); font-size: 12.5px; }

.filters {
    display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end;
}
.filters .field { flex: 1 1 165px; }
.filters .btn { margin-bottom: 1px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }
table.data {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}
table.data th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-faint);
    background: linear-gradient(180deg, #F4F8FD 0%, var(--surface-soft) 100%);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.data td {
    padding: 12px 14px;
    font-size: 14px;
    border-bottom: 1px solid #EEF3F9;
    vertical-align: middle;
    overflow: hidden;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-soft); }
.td-num { text-align: right; font-variant-numeric: tabular-nums; width: 5.2rem; }
.td-id { color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 13px; width: 4.8rem; }
.td-actions { text-align: right; width: 7.4rem; white-space: normal; overflow: visible; }
.td-actions .btn { width: 100%; }
.td-actions form { display: block; margin-top: 6px; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 12.5px; color: var(--ink-faint); }
.cell-clamp, .td-nowrap {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-status { min-width: 9rem; }
.td-status .cell-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.leave-type {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
}
.leave-type .stat-dot { margin: 0; flex-shrink: 0; }

/* ===== Empty state ===== */
.empty { padding: 56px 24px; text-align: center; }
.empty-icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: var(--primary-tint);
    border: 1px solid transparent;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
}
.empty-icon svg { width: 23px; height: 23px; }
.empty-title { font-weight: 600; margin-bottom: 4px; }
.empty-text { font-size: 13.5px; color: var(--ink-faint); }

.alert {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    background: var(--surface);
}
.alert > svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.alert-body { min-width: 0; flex: 1; font-size: 14px; line-height: 1.5; }
.alert-title { font-weight: 750; margin-bottom: 2px; }
.alert-warn { background: var(--warn-tint); border-color: #F0E0C2; color: #8A5A10; }
.alert-warn > svg { color: var(--warn); }
.alert-error { background: var(--bad-tint); border-color: #F0C9C3; color: #8E3B34; }
.alert-error > svg { color: var(--bad); }
.alert-info { background: var(--info-tint); border-color: #D3E4F5; color: #2C5F8A; }
.alert-info > svg { color: var(--info); }
.alert-success { background: var(--ok-tint); border-color: #CFE8DA; color: #1F6B44; }
.alert-success > svg { color: var(--ok); }

.stat.is-over { border-color: #F0C9C3; background: var(--bad-tint); }
.stat.is-over .stat-unit { color: var(--bad); font-weight: 700; }
.lb-row.is-over { background: var(--bad-tint); }
.lb-row.is-over .lb-left { color: var(--bad); }
.lt-item.is-over .lt-item-meta,
.lt-face-meta.is-over { color: var(--bad); }
.summary-val.is-over { color: var(--bad); }

/* ===== Approval chain ===== */
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chain-step {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 99px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--ink-soft);
}
.chain-step.is-current { background: var(--warn-tint); border-color: #F0E0C2; color: var(--warn); font-weight: 600; }
.chain-step.is-done { background: var(--ok-tint); border-color: #CFE8DA; color: var(--ok); }
.chain-step.is-skip { background: var(--violet-tint); border-color: #E2DCF1; color: var(--violet); }
.chain-arrow { color: var(--ink-faint); font-size: 12px; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(22,35,63,.42);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 90;
    animation: fade .16s ease;
}
.modal {
    background: var(--surface);
    border-radius: var(--r-xl);
    width: min(460px, 100%);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: pop .2s cubic-bezier(.2,.9,.3,1.1);
}
.modal-head { padding: 24px 24px 0; text-align: center; }
.modal-icon {
    width: 52px; height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--ok-tint);
    color: var(--ok);
    display: flex; align-items: center; justify-content: center;
}
.modal-icon svg { width: 26px; height: 26px; }
.modal-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.modal-sub { font-size: 13.5px; color: var(--ink-soft); margin: 0; }
.modal-body { padding: 20px 24px; }
.summary { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.summary-row {
    display: flex; align-items: baseline; gap: 14px;
    padding: 11px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.summary-row:last-child { border-bottom: 0; }
.summary-key { font-size: 13px; color: var(--ink-soft); width: 106px; flex-shrink: 0; }
.summary-val { font-weight: 600; text-align: right; margin-left: auto; min-width: 0; overflow-wrap: anywhere; }
.modal-foot { padding: 0 24px 24px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }

/* ===== Login / Register ===== */
.auth {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 28px 18px;
    background:
        radial-gradient(900px 460px at 8% -14%, #C9DBF5 0%, transparent 62%),
        radial-gradient(760px 420px at 94% 4%, #F8D4D9 0%, transparent 58%),
        radial-gradient(620px 360px at 50% 112%, #D7E6F8 0%, transparent 50%),
        var(--bg);
}
.auth-card {
    width: min(400px, 100%);
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 24px;
    padding: 34px 32px;
    box-shadow: 0 24px 60px rgba(23,70,155,.14);
}
.auth-card-wide { width: min(520px, 100%); }
.auth-card.shake, .auth-shell.shake { animation: shake .35s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0) }
    25% { transform: translateX(-7px) }
    75% { transform: translateX(7px) }
}
.auth-logo {
    width: 132px; height: 132px;
    display: flex; align-items: center; justify-content: center;
    margin: -14px auto 4px;
}
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-title { font-size: 22px; font-weight: 750; margin: 0 0 6px; letter-spacing: -.02em; line-height: 1.3; color: var(--ink); }
.auth-sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 22px; }
.auth-forgot {
    display: inline-block; margin-top: 8px;
    font-size: 13px; font-weight: 650; color: var(--primary); text-decoration: none;
}
.auth-forgot:hover { text-decoration: underline; }
.auth-foot { text-align: center; font-size: 13.5px; color: var(--ink-faint); margin: 20px 0 0; }
.auth-foot a { color: var(--primary); font-weight: 700; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.auth-shell {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: .92fr 1.08fr;
    background: #fff;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.9);
    box-shadow: 0 28px 80px rgba(23,70,155,.16);
}
.auth-shell-wide {
    width: min(1040px, 100%);
    grid-template-columns: .68fr 1.32fr;
}
.auth-brand {
    position: relative;
    display: flex; flex-direction: column; justify-content: center;
    gap: 28px;
    padding: 40px 36px 32px;
    color: var(--primary);
    background: #fff;
    border-right: 1px solid #E8EEF5;
    box-shadow: inset 0 4px 0 var(--primary);
    overflow: hidden;
}
.auth-brand::before {
    content: '';
    position: absolute; inset: auto -40px -50px auto;
    width: 220px; height: 220px; border-radius: 50%;
    border: 18px solid rgba(23,70,155,.06);
    pointer-events: none;
}
.auth-brand-top { position: relative; z-index: 1; }
.auth-brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-tint);
    color: var(--primary);
}
.auth-brand-mark svg { width: 20px; height: 20px; }
.auth-brand-logo {
    width: 188px;
    margin: 16px auto 12px;
    background: none;
}
.auth-brand-logo img {
    width: 100%; height: auto; display: block; object-fit: contain;
}
.auth-brand h1 {
    margin: 0 0 8px; font-size: 22px; font-weight: 750;
    line-height: 1.35; letter-spacing: -.02em; text-align: center;
    color: var(--ink);
    word-break: keep-all;
    overflow-wrap: normal;
}
.auth-shell-wide .auth-brand h1 {
    font-size: 19px;
}
.auth-brand p {
    margin: 0; text-align: center; font-size: 13.5px;
    color: var(--ink-soft); line-height: 1.55;
}
.auth-brand-foot {
    position: relative; z-index: 1;
    padding-top: 16px;
    border-top: 1px solid #DCE5F0;
    font-size: 12.5px; color: var(--ink-faint); text-align: center;
}
.auth-panel { padding: 40px 42px 34px; background: #fff; }
.auth-kicker {
    margin: 0 0 4px;
    font-size: 11.5px; font-weight: 750; letter-spacing: .1em;
    text-transform: uppercase; color: var(--primary);
}
.auth-panel .auth-title { text-align: left; }
.auth-panel .auth-sub { text-align: left; }
.auth-panel .field { margin-bottom: 14px; }
.auth-panel .field input,
.auth-panel .field select {
    height: 46px; border-radius: 12px; background: var(--surface-soft);
}
.auth-panel .btn-primary {
    height: 48px; border-radius: 14px; font-size: 15.5px; font-weight: 750;
    margin-top: 6px;
}
.auth-hint {
    font-weight: 500; color: var(--ink-faint); font-size: 12.5px;
}
.auth-sec {
    margin: 0 0 14px; padding: 14px 16px 6px;
    border-radius: 16px; background: #F6F9FD;
    border: 1px solid #E4EBF5;
}
.auth-sec-head {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 12px; color: var(--primary);
    font-size: 13.5px; font-weight: 750;
}
.auth-sec-head svg { width: 16px; height: 16px; }
.auth-sec .form-grid { gap: 12px 14px; }
.auth-sec .field { margin-bottom: 10px; }
@media (max-width: 860px) {
    .auth-shell, .auth-shell-wide { grid-template-columns: 1fr; }
    .auth-brand { padding: 26px 24px 20px; }
    .auth-brand-logo { width: 128px; margin: 8px auto 6px; }
    .auth-brand h1 { font-size: 18px; }
    .auth-brand-foot { display: none; }
    .auth-panel { padding: 26px 22px 24px; }
}

/* ===== Leave form (ยื่นใบลา / แก้ไขใบลา) ===== */
.entry-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 20px; align-items: start; }
.lt-picker { margin: 0; position: relative; }
.lt-native {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.lt-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 11px 12px 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: border-color .14s, box-shadow .14s, background .14s;
}
.lt-btn:hover { border-color: var(--primary); }
.lt-picker.open .lt-btn,
.lt-btn:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.lt-picker.is-invalid .lt-btn { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(192,86,76,.16); }
.lt-btn.has-value {
    background: var(--lt-tint);
    border-color: var(--lt);
}
.lt-btn-face {
    display: flex; align-items: center; gap: 12px;
    min-width: 0; flex: 1;
}
.lt-btn-placeholder { color: var(--ink-faint); font-size: 14.5px; }
.lt-face-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lt-face-name { font-size: 15px; font-weight: 700; line-height: 1.25; }
.lt-face-meta { font-size: 12.5px; color: var(--lt); font-weight: 600; }
.lt-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-faint); transition: transform .16s; }
.lt-picker.open .lt-chev { transform: rotate(180deg); color: var(--primary); }

.lt-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--lt-tint); color: var(--lt); flex-shrink: 0;
}
.lt-btn.has-value .lt-icon,
.lt-item.is-on .lt-icon { background: var(--lt); color: #fff; }
.lt-icon svg { width: 16px; height: 16px; display: block; }

.lt-menu {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.lt-menu-label {
    padding: 10px 14px 6px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--ink-faint);
}
.lt-item {
    display: grid;
    grid-template-columns: 34px minmax(0,1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
}
.lt-item:hover { background: var(--surface-soft); }
.lt-item.is-on {
    background: var(--lt-tint);
    border-left-color: var(--lt);
}
.lt-item.is-empty { opacity: .72; }
.lt-item.is-locked {
    opacity: .55;
    cursor: not-allowed;
}
.lt-item.is-locked:hover { background: transparent; }
.lt-item.is-locked .lt-item-meta { color: var(--bad); }
.lt-item-main { min-width: 0; }
.lt-item-name { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.lt-item-blurb { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; line-height: 1.4; }
.lt-item-meta {
    font-size: 12.5px; font-weight: 700; color: var(--lt);
    white-space: nowrap; text-align: right;
}
.lt-item.is-empty .lt-item-meta { color: var(--bad); }
.lt-select-hint { margin: 8px 0 0; }

.presets { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--border-strong); background: var(--surface);
    border-radius: 99px; padding: 5px 13px; font-size: 12.5px; font-weight: 500;
    font-family: inherit; color: var(--ink-soft); cursor: pointer; transition: all .14s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }
.chip.on { border-color: var(--primary); color: #fff; background: var(--primary); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--surface);
    font-size: 13.5px; font-weight: 500; color: var(--ink-soft); text-decoration: none;
    transition: all .14s;
}
.tab:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }
.tab.on {
    background: linear-gradient(180deg, #2156B3 0%, var(--primary) 100%);
    border-color: var(--primary); color: #fff; font-weight: 600;
    box-shadow: 0 4px 10px rgba(23,70,155,.2);
}
.tab-n {
    font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
    background: var(--bg); color: var(--ink-soft);
}
.tab.on .tab-n { background: rgba(255,255,255,.22); color: #fff; }

.side { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 16px; }

.lb-body { padding: 8px 12px 12px; }
.lb-year-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-faint);
    padding: 6px 8px 4px;
}
.lb-year + .lb-year { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--border); }
.lb-span-note { margin: 10px 0 0; }
.lb-list { display: flex; flex-direction: column; }
.lb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 10px;
}
.lb-row + .lb-row { margin-top: 2px; }
.lb-row.on { background: var(--primary-tint); }
.lb-info { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.lb-info .stat-dot { margin-top: 6px; flex-shrink: 0; }
.lb-copy { min-width: 0; }
.lb-name { font-size: 13.5px; font-weight: 650; line-height: 1.3; }
.lb-meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 1px; }
.lb-left {
    font-size: 13px;
    font-weight: 750;
    color: var(--primary);
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
}
.lb-row.is-empty .lb-left { color: var(--bad); }
.lb-row.is-empty .lb-name { color: var(--ink-soft); }
.calc-num { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.calc-sub { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.calc-warn { color: var(--bad); font-weight: 600; }

.chain-list { display: flex; flex-direction: column; gap: 0; }
.chain-item { display: flex; gap: 11px; padding: 9px 0; }
.chain-mark {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; font-weight: 700;
    background: var(--surface-soft); border: 1px solid var(--border); color: var(--ink-faint);
}
.chain-item.now .chain-mark { background: var(--warn-tint); border-color: #F0E0C2; color: var(--warn); }
.chain-item.skip .chain-mark { background: var(--violet-tint); border-color: #E2DCF1; color: var(--violet); }
.chain-role { font-size: 13px; font-weight: 600; }
.chain-who { font-size: 12.5px; color: var(--ink-faint); }

.drop {
    display: block;
    border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
    padding: 26px 20px; text-align: center; cursor: pointer;
    background: var(--surface-soft); transition: border-color .14s, background .14s;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-tint); }
.drop-icon { color: var(--ink-faint); margin-bottom: 8px; }
.drop-icon svg { width: 26px; height: 26px; }
.drop-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.drop-sub { font-size: 12.5px; color: var(--ink-faint); }

.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.file-row {
    display: flex; align-items: center; gap: 11px;
    border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 9px 12px; background: var(--surface);
}
.file-badge {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.file-info { min-width: 0; flex: 1; }
.file-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: var(--ink-faint); }
.file-del {
    border: 0; background: transparent; color: var(--ink-faint);
    cursor: pointer; padding: 5px; border-radius: 7px; display: flex;
}
.file-del svg { width: 15px; height: 15px; }
.file-del:hover { background: var(--bad-tint); color: var(--bad); }
.file-row.bad { border-color: #F0C9C3; background: var(--bad-tint); }
.file-row.bad .file-size { color: var(--bad); font-weight: 600; }

/* ไฟล์เดิมที่ถูกกาไว้ว่าจะลบ */
.file-row.removing { border-color: #F0C9C3; background: var(--bad-tint); }
.file-row.removing .file-name { text-decoration: line-through; color: var(--ink-faint); }
.file-keep { display: none; }
.file-toggle {
    border: 1px solid var(--border-strong); background: var(--surface);
    border-radius: 8px; padding: 5px 11px; font-size: 12.5px; font-family: inherit;
    color: var(--ink-soft); cursor: pointer; white-space: nowrap; transition: all .14s;
}
.file-toggle:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-tint); }
.file-row.removing .file-toggle { border-color: var(--border-strong); color: var(--ink-soft); background: var(--surface); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
    .entry-layout { grid-template-columns: 1fr; }
    .side { position: static; }
}

@media (max-width: 900px) {
    .page-head-text { min-width: 0; width: 100%; }
    .topbar { display: flex; flex-shrink: 0; }
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim {
        display: block;
        position: fixed; inset: 0;
        background: rgba(22,35,63,.4);
        z-index: 35;
    }
    .page { padding: 22px 16px 60px; }
    .page-title { font-size: 21px; }
    .page-head { gap: 12px; margin-bottom: 16px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; justify-content: center; min-height: 40px; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .summary-key { width: 92px; }
    table.data th, table.data td { padding: 11px 14px; }
    .card-head, .card-body, .card-foot { padding-left: 16px; padding-right: 16px; }
    .btn { -webkit-tap-highlight-color: transparent; }
}

@media (max-width: 760px) {
    .table-wrap {
        overflow: visible;
        margin: 0;
        max-width: 100%;
    }
    table.data thead { display: none; }
    table.data,
    table.data tbody {
        display: block;
        width: 100%;
        max-width: 100%;
    }
    table.data tbody tr {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
        margin: 0 0 10px;
        padding: 12px 14px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
        box-sizing: border-box;
    }
    table.data tbody tr:last-child { margin-bottom: 0; }
    table.data tbody tr:hover { background: var(--surface); }
    table.data td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        width: 100% !important;
        max-width: none;
        padding: 0;
        border: 0;
        overflow: visible;
        white-space: normal;
        text-align: right;
    }
    table.data td.cell-main,
    table.data td.td-nowrap,
    table.data td.cell-clamp,
    table.data .td-nowrap,
    table.data .cell-clamp,
    table.data .leave-type {
        max-width: none;
        overflow: visible;
        text-overflow: unset;
        white-space: normal;
    }
    table.data td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 42%;
        color: var(--ink-faint);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0;
        text-transform: none;
        text-align: left;
        white-space: nowrap;
    }
    table.data td:not([data-label])::before,
    table.data td[data-label=""]::before {
        content: none;
        display: none;
    }
    table.data td.td-actions {
        justify-content: stretch;
        padding-top: 4px;
        white-space: normal;
        overflow: visible;
    }
    table.data td.td-actions .btn { width: auto; flex: 1; justify-content: center; }
    table.data td.org-hide-sm,
    table.data th.org-hide-sm,
    table.data .org-hide-sm,
    table.data td.hide-sm {
        display: none !important;
    }
    table.data td > * { min-width: 0; }
    .table-wrap,
    .pe-table-wrap,
    .org-table-wrap {
        overflow: visible;
        max-width: 100%;
    }
    table.data.org-table {
        table-layout: auto;
    }
    table.data.org-table td,
    table.data.org-table th {
        white-space: normal;
        width: auto !important;
    }
    .org-who-n,
    .org-staff {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
    .person-name,
    .req-name,
    .ld-item-name,
    .cell-main,
    .owner-card-name,
    .m-summary-name,
    .ps-name {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        word-break: break-word;
    }
    .req-meta,
    .req-reason,
    .ld-item-meta,
    .req-type-cell,
    .leave-type {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
}

@media (max-width: 640px) {
    .page { padding: 14px 12px 72px; }
    .page-title { font-size: 18px; }
    .page-title::after { width: 32px; height: 3px; margin-top: 8px; }
    .page-sub { font-size: 13px; }
    .card { border-radius: 14px; }
    .card-head { padding: 12px 14px; }
    .card-body { padding: 14px; }
    .card-foot { padding: 12px 14px; }
    .summary-row {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }
    .summary-key { width: auto; }
    .summary-val { text-align: left; margin-left: 0; }
    .filters { gap: 8px; }
    .table-wrap { margin: 0; }
}

.pager {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-soft);
}
.pager-info { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.pager-per {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-soft); margin-left: auto;
}
.pager-per select {
    height: 36px; padding: 0 28px 0 10px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pager-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 12px;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); text-decoration: none;
    font-size: 13.5px; font-weight: 600; line-height: 1;
}
.pager-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-tint); }
.pager-btn.on {
    background: linear-gradient(180deg, #2156B3 0%, var(--primary) 100%);
    border-color: var(--primary); color: #fff;
    box-shadow: 0 4px 10px rgba(23,70,155,.22);
}
.pager-btn.is-off { opacity: .38; cursor: default; }
.pager-gap { color: var(--ink-faint); padding: 0 4px; font-weight: 600; }

/* Searchable staff picker (proxy leave) */
.staff-combo { position: relative; min-width: 0; }
.staff-combo-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.staff-combo-input {
    width: 100%;
    padding: 10px 36px 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2364726F' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3Cpath d='M12.5 12.5L16 16'/%3E%3C/svg%3E") no-repeat right 12px center;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: border-color .14s, box-shadow .14s;
}
.staff-combo-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.staff-combo.is-open .staff-combo-input,
.staff-combo-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}
.staff-combo-list {
    position: fixed;
    z-index: 1200;
    max-height: min(320px, 50vh);
    overflow: auto;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: 0 12px 28px rgba(23, 70, 155, .18);
    box-sizing: border-box;
}
.staff-combo-option {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 9px 11px;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
}
.staff-combo-option:hover,
.staff-combo-option.is-active { background: var(--primary-tint); color: var(--primary); }
.staff-combo-option.is-selected { font-weight: 600; color: var(--primary); }
.staff-combo-empty {
    padding: 12px 11px;
    font-size: 13px;
    color: var(--ink-faint);
}

@media print {
    .sidebar, .topbar, .page-actions, .filters, .pager { display: none !important; }
    .page { padding: 0; max-width: none; overflow: visible; }
    .card { box-shadow: none; border-color: #ccc; }
    table.data,
    table.data thead,
    table.data tbody,
    table.data tr,
    table.data th,
    table.data td {
        display: revert;
        width: auto !important;
        max-width: none;
        white-space: normal;
    }
}
