/* ═══════════════════════════════════════════════════════════════
   RESET & VARIABLES
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
    --font: 'Kanit', -apple-system, 'Segoe UI', system-ui, sans-serif;

    /* Brand */
    --primary: #d0320e;
    --primary-d: #a82509;
    --primary-l: #fdf0ec;
    --primary-grad: linear-gradient(135deg, #e8573a 0%, #d0320e 55%, #a82509 100%);
    --primary-shadow: 0 7px 18px -6px rgba(208,50,14,0.55);

    /* Surfaces */
    --bg: #f7f5f4;
    --card: #ffffff;
    --border: #ece9e7;
    --border-2: #e6e2df;
    --shadow: 0 1px 2px rgba(16,24,40,0.03), 0 2px 7px rgba(16,24,40,0.04);
    --shadow-hover: 0 9px 25px -8px rgba(16,24,40,0.12);

    /* Text */
    --text: #14213d;
    --text-2: #3d4a63;
    --text-3: #6b778c;
    --text-4: #a0a9ba;

    /* Accents */
    --green: #10b981;
    --red: #ef4444;
    --amber: #f59e0b;
    --blue: #3b82f6;
    --violet: #8b5cf6;
    --teal: #14b8a6;
    --rose: #f43f5e;

    /* Layout */
    --sb-w: 272px;
    --sb-w-mini: 67px;
    --tb-h: 60px;
    --radius: 12px;

    --ease: cubic-bezier(0.4,0,0.2,1);
    --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
}

html, body {
    height:100%; width:100%;
    font-family: var(--font);
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(208,50,14,0.18); }
button { font-family: var(--font); }

/* Material Symbols */
.ms {
    font-family: 'Material Symbols Rounded';
    font-weight: normal; font-style: normal;
    font-size: 18px; line-height: 1;
    letter-spacing: normal; text-transform: none;
    display: inline-block; white-space: nowrap;
    word-wrap: normal; direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

.app { display:flex; height:calc(100vh / var(--z, 1)); width:calc(100vw / var(--z, 1)); }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sb-w); min-width: var(--sb-w);
    height: calc(100vh / var(--z, 1));
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: width 0.3s var(--ease), min-width 0.3s var(--ease);
    overflow: hidden;
    z-index: 100;
}
.sidebar.mini { width: var(--sb-w-mini); min-width: var(--sb-w-mini); }

/* Brand */
.sb-brand {
    height: var(--tb-h);
    display: flex; align-items: center; gap: 10.5px;
    padding: 0 18px;
    flex-shrink: 0;
}
.sb-logo {
    width: 35px; height: 35px;
    border-radius: 50%;
    background: var(--primary-grad);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--primary-shadow), inset 0 0 0 3px rgba(255,255,255,0.25);
}
.sb-logo .ms { color: #fff; font-size: 18px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

.sb-brand-text { white-space: nowrap; transition: opacity 0.2s; }
.sb-brand-name { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.1; letter-spacing: -0.01em; }
.sb-brand-name span { color: var(--primary); }
.sb-brand-sub { font-size: 9.5px; color: var(--text-3); font-weight: 400; }
.sidebar.mini .sb-brand-text { opacity: 0; pointer-events: none; }

/* Menu */
.sb-menu {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    padding: 4px 0 10.5px;
}
.sb-menu::-webkit-scrollbar { width: 4px; }
.sb-menu::-webkit-scrollbar-thumb { background: transparent; border-radius: 9px; }
.sb-menu:hover::-webkit-scrollbar-thumb { background: #e2e5ec; }

.sb-section {
    padding: 16px 19px 5.5px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-4);
    white-space: nowrap;
    transition: opacity 0.2s;
}
.sidebar.mini .sb-section { opacity: 0; height: 10.5px; padding: 0; overflow: hidden; }

.m-head {
    display: flex; align-items: center;
    height: 39px;
    margin: 2px 10.5px;
    padding: 0 10.5px;
    border-radius: 9.5px;
    cursor: pointer;
    color: var(--text-2);
    transition: background 0.18s var(--ease), color 0.18s var(--ease), box-shadow 0.25s var(--ease);
    user-select: none;
    gap: 10.5px;
}
.m-head:hover { background: #f6f4f3; color: var(--text); }
.m-head:hover .m-icon { color: var(--primary); }

.m-head.active {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: var(--primary-shadow);
}
.m-head.active .m-icon { color: #fff; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
/* Parent of an active sub item: soft highlight only */
.m-head.parent-active { background: var(--primary-l); color: var(--primary-d); box-shadow: none; }
.m-head.parent-active .m-icon { color: var(--primary); }

.m-icon {
    font-size: 19px;
    width: 21px;
    flex-shrink: 0;
    color: var(--text-3);
    transition: color 0.18s;
}
.m-label {
    flex: 1;
    font-size: 12.5px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-badge {
    font-size: 10.5px; font-weight: 500;
    min-width: 19px; height: 18px;
    padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 18px;
    background: #f2efed;
    color: var(--text-3);
}
.m-head.active .m-badge { background: rgba(255,255,255,0.25); color: #fff; }
.m-head.parent-active .m-badge { background: #fbd9cf; color: var(--primary-d); }

.m-arrow { font-size: 16px; color: var(--text-4); transition: transform 0.28s var(--ease-spring); }
.m-arrow.open { transform: rotate(90deg); }
.m-head.active .m-arrow { color: #fff; }

.sidebar.mini .m-head { justify-content: center; padding: 0; gap: 0; }
.sidebar.mini .m-label,
.sidebar.mini .m-badge,
.sidebar.mini .m-arrow { display: none; }

/* Submenu */
.m-sub {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s var(--ease);
    position: relative;
}
.m-sub.open { max-height: 1400px; }
.sidebar.mini .m-sub { max-height: 0 !important; }
.m-sub::before {
    content: '';
    position: absolute;
    left: 31px; top: 4px; bottom: 5.5px;
    width: 1.5px;
    background: var(--border-2);
    border-radius: 2px;
}

.m-sub-item {
    display: flex; align-items: center; gap: 9px;
    height: 33px;
    margin: 1px 10.5px 1px 42px;
    padding: 0 9px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-3);
    font-size: 11.5px;
    transition: all 0.16s var(--ease);
    position: relative;
}
.m-sub-item .ms { font-size: 16px; flex-shrink: 0; }
.m-sub-item > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub-item:hover { background: #f6f4f3; color: var(--text); }
.m-sub-item.active { background: var(--primary-l); color: var(--primary-d); font-weight: 500; }
.m-sub-item.active::before {
    content: '';
    position: absolute;
    left: -14px; top: 50%;
    width: 7px; height: 7px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px #f6bfb0;
}
/* เมนูย่อยชั้นที่ 2 (เช่น เอกสารคลังวัสดุ → ใบรับวัสดุ) */
.m-sub-parent .m-sub-arrow { margin-left: auto; font-size: 15px; transition: transform 0.25s var(--ease); }
.m-sub-parent.open .m-sub-arrow { transform: rotate(90deg); }
.m-sub2 { overflow: hidden; max-height: 0; transition: max-height 0.3s var(--ease); }
.m-sub2.open { max-height: 160px; }
.m-sub2 .m-sub-item { margin-left: 50px; height: 30px; font-size: 11px; }
.sidebar.mini .m-sub2 { max-height: 0 !important; }
.m-sub-divider { height: 1px; margin: 5.5px 18px 5.5px 51px; background: var(--border); }

/* Footer */
.sb-foot { padding: 10.5px 12px 14px; flex-shrink: 0; transition: opacity 0.2s; }
.sb-org {
    border: 1px solid var(--border);
    background: #faf9f8;
    border-radius: 10.5px;
    padding: 9px 10.5px;
    margin-bottom: 10.5px;
}
.sb-org-name { display: flex; align-items: center; gap: 5.5px; font-size: 11px; font-weight: 600; color: var(--text); }
.sb-org-name .ms { font-size: 15px; color: var(--primary); }
.sb-org-sub { font-size: 9.5px; color: var(--text-3); margin-top: 2px; }
.sb-ver { font-size: 9.5px; color: var(--text-4); line-height: 1.5; padding: 0 4px; }
.sidebar.mini .sb-foot { opacity: 0; pointer-events: none; }

/* Tooltip (mini mode) */
.sb-tip {
    position: fixed;
    left: calc(var(--sb-w-mini) + 7px);
    background: var(--text);
    color: #fff;
    padding: 5.5px 10.5px;
    border-radius: 7px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.15s var(--ease);
    z-index: 9999;
    box-shadow: 0 7px 21px rgba(16,24,40,0.2);
}
.sb-tip.show { opacity: 1; transform: translateX(0); }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.main { flex:1; display:flex; flex-direction:column; overflow:hidden; min-width:0; }

.topbar {
    height: var(--tb-h); min-height: var(--tb-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 21px 0 16px;
    z-index: 50;
}

.tb-btn {
    width: 35px; height: 35px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9.5px;
    border: 1px solid var(--border-2);
    background: var(--card);
    color: var(--text-3);
    cursor: pointer;
    position: relative;
    transition: all 0.16s var(--ease);
    flex-shrink: 0;
}
.tb-btn:hover { color: var(--primary); border-color: #f7cdc2; background: var(--primary-l); }
.tb-btn .ms { font-size: 18px; }
.tb-collapse .ms { transition: transform 0.3s var(--ease); }
.sidebar.mini ~ .main .tb-collapse .ms { transform: scaleX(-1); }

.tb-count {
    position: absolute; top: -6px; right: -6px;
    min-width: 17px; height: 17px;
    padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10.5px; font-weight: 600;
    background: var(--red); color: #fff;
    border: 2px solid #fff;
    border-radius: 18px;
}

.tb-search {
    flex: 1; max-width: 458px;
    display: flex; align-items: center; gap: 9px;
    height: 37px;
    padding: 0 12px;
    background: var(--card);
    border: 1px solid var(--border-2);
    border-radius: 9.5px;
    color: var(--text-4);
    transition: all 0.18s var(--ease);
}
.tb-search:focus-within { border-color: #ee9a85; box-shadow: 0 0 0 4px rgba(208,50,14,0.12); color: var(--primary); }
.tb-search input {
    flex:1; min-width:0;
    border:none; outline:none; background:transparent;
    font-family: var(--font); font-size: 12px; font-weight: 300; color: var(--text);
}
.tb-search input::placeholder { color: var(--text-4); }

.tb-right { display:flex; align-items:center; gap:9px; margin-left: auto; }

.tb-user {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 7px 4px 4px;
    margin-left: 5.5px;
    border-radius: 10.5px;
    cursor: pointer;
    transition: background 0.16s;
}
.tb-user:hover { background: #f6f4f3; }
.tb-avatar {
    width: 35px; height: 35px;
    border-radius: 50%;
    background: var(--primary-grad);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13.5px; font-weight: 600;
    box-shadow: var(--primary-shadow);
}
.tb-user-info { line-height: 1.25; }
.tb-user-name { font-size: 12px; font-weight: 500; color: var(--text); }
.tb-user-role { font-size: 9.5px; color: var(--text-3); }
.tb-caret { font-size: 16px; color: var(--text-4); }

/* ═══════════════════════════════════════════════════════════════
   CONTENT
   ═══════════════════════════════════════════════════════════════ */
.content { flex:1; overflow-y:auto; padding: 23px 21px 28px; }
.content::-webkit-scrollbar { width: 7px; }
.content::-webkit-scrollbar-thumb { background: #d9dde5; border-radius: 9px; border: 2px solid var(--bg); }

/* Page header */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
    margin-bottom: 19px;
}
.page-title { font-size: 23px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; line-height: 1.25; }
.page-desc { font-size: 12px; color: var(--text-3); font-weight: 300; margin-top: 4px; }
.page-meta { text-align: right; font-size: 11px; color: var(--text-3); line-height: 1.6; flex-shrink: 0; }
.page-meta b { font-weight: 500; color: var(--text-2); }
.demo-chip {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 4px;
    font-size: 10.5px; font-weight: 500;
    color: var(--primary-d);
    background: var(--primary-l);
    border: 1px solid #fad3c8;
    padding: 1px 8px;
    border-radius: 18px;
}
.demo-chip .ms { font-size: 12px; }

/* ── Stat cards ── */
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    display: flex; align-items: center; gap: 14px;
    cursor: pointer;
    transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: transparent; }

.stat-ic {
    width: 46px; height: 46px;
    border-radius: 11.5px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s var(--ease-spring);
}
.stat-ic .ms { font-size: 23px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.stat:hover .stat-ic { transform: scale(1.07) rotate(-3deg); }

.t-brand  { background: #fde6df; color: var(--primary); }
.t-blue   { background: #eaf2ff; color: var(--blue); }
.t-green  { background: #e7f8f1; color: var(--green); }
.t-violet, .t-purple { background: #f1ecff; color: var(--violet); }
.t-amber  { background: #fff6e0; color: #e29100; }
.t-red    { background: #fdecec; color: var(--red); }
.t-teal   { background: #e3f7f5; color: var(--teal); }
.t-rose   { background: #ffebef; color: var(--rose); }
.t-gray   { background: #f2efed; color: var(--text-3); }

.stat-body { min-width: 0; flex: 1; }
.stat-lbl { font-size: 11px; color: var(--text-2); font-weight: 400; }
.stat-val { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.25; letter-spacing: -0.01em; white-space: nowrap; }
.stat-val small { font-size: 15px; font-weight: 600; margin-left: 2px; }
.stat-sub { font-size: 10px; color: var(--text-3); font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub.up   { color: var(--green); font-weight: 500; }
.stat-sub.down { color: var(--red); font-weight: 500; }
.stat-sub.link { color: var(--text-3); }
.stat-bar { height: 5.5px; background: #f2efed; border-radius: 9px; margin: 5.5px 0 4px; overflow: hidden; }
.stat-bar > i { display: block; height: 100%; background: var(--primary-grad); border-radius: 9px; }

/* ── Cards / panels ── */
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
    min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10.5px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-count {
    font-size: 10.5px; font-weight: 600;
    background: #fdecec; color: var(--red);
    padding: 1px 8px;
    border-radius: 18px;
}
.card-count.brand { background: var(--primary-l); color: var(--primary-d); }
.card-link {
    margin-left: auto;
    font-size: 11px; font-weight: 400;
    color: var(--primary);
    cursor: pointer;
    background: none; border: none;
    display: inline-flex; align-items: center; gap: 2px;
}
.card-link:hover { color: var(--primary-d); text-decoration: underline; }
.card-link .ms { font-size: 14px; }

.chart-box { position: relative; height: 202px; }
.chart-box.sm { height: 176px; }
.chart-foot { text-align: center; font-size: 10.5px; color: var(--text-3); margin-top: 5.5px; }

/* Custom legend */
.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 9px; font-size: 10.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5.5px; }
.legend i { width: 10.5px; height: 10.5px; border-radius: 50%; display: inline-block; }

/* List rows */
.list { display: flex; flex-direction: column; }
.row {
    display: flex; align-items: center; gap: 10.5px;
    padding: 9px 2px;
    border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: none; }
.row-ic {
    width: 32px; height: 32px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.row-ic .ms { font-size: 17px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 10px; color: var(--text-3); font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { font-size: 10px; color: var(--text-4); white-space: nowrap; text-align: right; }

.pill {
    display: inline-block;
    font-size: 10.5px; font-weight: 500;
    padding: 2px 8px;
    border-radius: 18px;
    white-space: nowrap;
}
.pill.brand { background: var(--primary-l); color: var(--primary-d); }
.pill.red    { background: #fdecec; color: var(--red); }
.pill.green  { background: #e7f8f1; color: #0b9467; }
.pill.blue   { background: #eaf2ff; color: #2563eb; }
.pill.gray   { background: #f2efed; color: var(--text-3); }

.mini-bar { width: 62px; height: 5.5px; background: #f2efed; border-radius: 9px; overflow: hidden; margin-top: 4px; margin-left: auto; }
.mini-bar > i { display: block; height: 100%; border-radius: 9px; background: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   PLACEHOLDER PAGE
   ═══════════════════════════════════════════════════════════════ */
.crumb { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.crumb a { color: var(--text-3); cursor: pointer; }
.crumb a:hover { color: var(--primary); }
.crumb .ms { font-size: 14px; color: var(--text-4); }

.pg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-height: calc(calc(100vh / var(--z, 1)) - var(--tb-h) - 141px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    padding: 53px 18px;
}
.pg-empty-ic {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: var(--primary-l);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 19px;
    position: relative;
}
.pg-empty-ic::before {
    content: '';
    position: absolute; inset: -10px;
    border-radius: 50%;
    border: 1.5px dashed #f3b5a5;
    animation: spin 30s linear infinite;
}
.pg-empty-ic .ms { font-size: 39px; color: var(--primary); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48; }
.pg-empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.pg-empty-desc { font-size: 12px; color: var(--text-3); font-weight: 300; line-height: 1.6; margin-bottom: 21px; }

.btn {
    display: inline-flex; align-items: center; gap: 5.5px;
    height: 37px; padding: 0 19px;
    border: none; border-radius: 9.5px;
    font-size: 12.5px; font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.btn .ms { font-size: 16px; }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: var(--primary-shadow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10.5px 21px -8px rgba(208,50,14,0.6); }
.btn-primary:active { transform: translateY(0); }
.btn-danger { background: #dc2626; color: #fff; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }
.btn-danger:hover { transform: translateY(-1px); background: #b91c1c; box-shadow: 0 6px 16px rgba(220, 38, 38, 0.45); }
.btn-danger:active { transform: translateY(0); }

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS & RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@keyframes fadeUp { from { opacity:0; transform:translateY(10.5px); } to { opacity:1; transform:none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.anim { animation: fadeUp 0.45s var(--ease) both; }
.d1 { animation-delay: 0.03s; } .d2 { animation-delay: 0.08s; }
.d3 { animation-delay: 0.13s; } .d4 { animation-delay: 0.18s; }
.d5 { animation-delay: 0.23s; }

@media (max-width: 1360px) {
    .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tb-user-info, .tb-caret { display: none; }
}
@media (max-width: 1080px) {
    .g-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   DATABASE SETUP OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.setup[hidden] { display: none; }
.setup {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(792px 440px at 15% 10%, rgba(208,50,14,0.18), transparent 60%),
        radial-gradient(704px 440px at 90% 95%, rgba(232,87,58,0.16), transparent 60%),
        var(--bg);
    animation: fadeUp 0.35s var(--ease) both;
}
.setup-card {
    width: min(422px, calc(calc(100vw / var(--z, 1)) - 35px));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 21px 53px -20px rgba(70,22,10,0.28);
    padding: 32px 32px 25px;
    text-align: center;
}
.setup-ic {
    width: 67px; height: 67px; margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--primary-l);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.setup-ic::before {
    content: ''; position: absolute; inset: -8px;
    border-radius: 50%; border: 1.5px dashed #f3b5a5;
    animation: spin 30s linear infinite;
}
.setup-ic .ms { font-size: 32px; color: var(--primary); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48; }
.setup-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 5.5px; }
.setup-desc { font-size: 12px; font-weight: 300; color: var(--text-3); line-height: 1.7; }
.setup-err {
    margin-top: 14px; padding: 9px 12px;
    font-size: 11px; text-align: left; line-height: 1.55;
    color: #b42318; background: #fdecec;
    border: 1px solid #f9c9c9; border-radius: 9px;
    word-break: break-all;
}
.setup-err[hidden] { display: none; }
.setup-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 21px; }
.setup-actions .btn { justify-content: center; width: 100%; }
.setup-actions .btn[disabled] { opacity: 0.6; cursor: wait; transform: none; }
.btn-ghost { background: var(--card); color: var(--primary-d); border: 1px solid var(--border-2); }
.btn-ghost:hover { background: var(--primary-l); border-color: #f3b5a5; }
.setup-note { margin-top: 16px; font-size: 10px; color: var(--text-4); }

/* Database badge in sidebar */
.sb-org { cursor: pointer; transition: border-color 0.16s, background 0.16s; }
.sb-org:hover { border-color: #f3b5a5; background: var(--primary-l); }
.sb-org-name > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-org-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════════════════ */
.login[hidden] { display: none; }
.login {
    position: fixed; inset: 0; z-index: 9000;
    display: flex; align-items: center; justify-content: center;
    padding: 18px;
    background:
        radial-gradient(792px 440px at 12% 8%, rgba(208,50,14,0.20), transparent 60%),
        radial-gradient(704px 440px at 92% 96%, rgba(232,87,58,0.18), transparent 60%),
        var(--bg);
    animation: fadeUp 0.35s var(--ease) both;
}
.login-card {
    width: min(370px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 19px;
    padding: 32px 28px 25px;
    box-shadow: 0 21px 53px -15px rgba(60, 22, 12, 0.22), 0 0 0 1px rgba(0,0,0,0.03);
    overflow: hidden;
    animation: scaleIn 0.25s var(--ease) both;
}

.login-card .login-logo {
    width: 49px; height: 49px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), #e8573a);
    color: #fff;
    box-shadow: 0 9px 19px -6px rgba(208,50,14,0.45);
    margin-bottom: 14px;
}
.login-card .login-logo .ms { font-size: 26px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 28; }

/* Form panel */
.login-form {
    width: 100%;
    display: flex; flex-direction: column;
    padding: 0;
}
.login-title { font-size: 19px; font-weight: 600; color: var(--text); text-align: center; }
.login-desc { font-size: 11.5px; font-weight: 300; color: var(--text-3); margin: 4px 0 18px; line-height: 1.5; text-align: center; }

.field[hidden] { display: none; }
.field { display: block; margin-bottom: 12px; }
.field-lbl { display: block; font-size: 11px; font-weight: 500; color: var(--text-2); margin-bottom: 5.5px; }
.field-box {
    display: flex; align-items: center; gap: 9px;
    height: 40px; padding: 0 10.5px;
    background: #faf9f8;
    border: 1px solid var(--border-2);
    border-radius: 10.5px;
    color: var(--text-4);
    transition: all 0.16s var(--ease);
}
.field-box:focus-within { background: #fff; border-color: #ee9a85; box-shadow: 0 0 0 4px rgba(208,50,14,0.12); color: var(--primary); }
.field-box.invalid { border-color: #f1a5a5; box-shadow: 0 0 0 4px rgba(239,68,68,0.08); }
.field-box .ms { font-size: 18px; }
.field-box input {
    flex: 1; min-width: 0; height: 100%;
    border: none; outline: none; background: transparent;
    font-family: var(--font); font-size: 12px; color: var(--text);
}
.field-box input::placeholder { color: var(--text-4); font-weight: 300; }
.field-eye {
    border: none; background: none; cursor: pointer; color: var(--text-4);
    width: 26px; height: 26px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
}
.field-eye:hover { background: #f2efed; color: var(--primary); }

.login-err {
    margin: 2px 0 12px; padding: 9px 10.5px;
    font-size: 11px; line-height: 1.55;
    color: #b42318; background: #fdecec;
    border: 1px solid #f9c9c9; border-radius: 9px;
}
.login-err[hidden] { display: none; }
.login-err.shake { animation: shake 0.35s; }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

.login-btn { width: 100%; justify-content: center; height: 40px; margin-top: 4px; font-size: 13px; }
.login-btn[disabled] { opacity: 0.7; cursor: wait; transform: none; }
.login-btn .spin { animation: spin 0.8s linear infinite; }

.login-db {
    display: flex; align-items: center; gap: 5.5px;
    margin-top: 19px; padding-top: 14px;
    border-top: 1px dashed var(--border);
    font-size: 11px; color: var(--text-4);
}
.login-db .ms { font-size: 14px; }
.login-db-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-db-change {
    margin-left: auto; border: none; background: none; cursor: pointer;
    font-size: 11px; color: var(--primary); font-family: var(--font);
}
.login-db-change:hover { text-decoration: underline; }
.login-db-change[hidden] { display: none; }




/* ═══════════════════════════════════════════════════════════════
   USER MENU & TOAST
   ═══════════════════════════════════════════════════════════════ */
.tb-user-wrap { position: relative; }
.user-menu[hidden] { display: none; }
.user-menu {
    position: absolute; right: 0; top: calc(100% + 7px);
    width: 204px; z-index: 200;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 35px -12px rgba(45,20,12,0.25);
    padding: 5.5px;
    animation: fadeUp 0.18s var(--ease) both;
}
.user-menu-head { padding: 9px 10.5px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.user-menu-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-sub { font-size: 10px; color: var(--text-3); }
.user-menu-item {
    width: 100%; display: flex; align-items: center; gap: 9px;
    height: 35px; padding: 0 10.5px;
    border: none; background: none; border-radius: 8px;
    font-size: 11.5px; color: var(--text-2); cursor: pointer; text-align: left;
    transition: background 0.14s;
}
.user-menu-item .ms { font-size: 17px; color: var(--text-3); }
.user-menu-item:hover { background: #f6f4f3; }
.user-menu-item.danger { color: #c2362b; }
.user-menu-item.danger .ms { color: #c2362b; }
.user-menu-item.danger:hover { background: #fdecec; }
.user-menu-item[hidden] { display: none; }

.toast {
    position: fixed; left: 50%; bottom: 25px; z-index: 20000;
    transform: translate(-50%, 14px);
    max-width: min(458px, calc(calc(100vw / var(--z, 1)) - 35px));
    padding: 9.5px 16px;
    font-size: 11.5px; color: #fff;
    background: #2d1a15;
    border-radius: 10.5px;
    box-shadow: 0 12px 28px -10px rgba(20,10,50,0.5);
    opacity: 0; pointer-events: none;
    transition: all 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ═══════════════════════════════════════════════════════════════
   LOCK STATE & SPLASH — ซ่อนตัวแอปจนกว่าจะล็อกอินสำเร็จ
   ═══════════════════════════════════════════════════════════════ */
body.locked .app { visibility: hidden; }
.splash[hidden] { display: none; }
.splash {
    position: fixed; inset: 0; z-index: 8000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: var(--bg);
}
.splash-logo {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary-grad);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--primary-shadow);
    animation: splashPulse 1.4s ease-in-out infinite;
}
.splash-logo .ms { color: #fff; font-size: 26px; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.splash-msg { font-size: 11.5px; color: var(--text-3); text-align: center; max-width: 422px; line-height: 1.6; }
.splash.error .splash-msg { color: #b42318; }
.splash.error .splash-logo { animation: none; background: #c2362b; box-shadow: none; }
@keyframes splashPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ═══════════════════════════════════════════════════════════════
   CONFIRM PASSWORD MODAL
   ═══════════════════════════════════════════════════════════════ */
.confirm[hidden] { display: none; }
.confirm {
    position: fixed; inset: 0; z-index: 9500;
    display: flex; align-items: center; justify-content: center; padding: 18px;
    background: rgba(45,20,12,0.45);
    backdrop-filter: blur(3px);
    animation: fadeUp 0.2s var(--ease) both;
}
.confirm-card {
    width: min(352px, 100%);
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 26px 62px -20px rgba(45,20,12,0.5);
    padding: 25px 25px 19px;
    text-align: center;
}
.confirm-ic {
    width: 49px; height: 49px; margin: 0 auto 10.5px; border-radius: 50%;
    background: var(--primary-l); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.confirm-ic .ms { font-size: 25px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.confirm-title { font-size: 15px; font-weight: 600; color: var(--text); }
.confirm-desc { font-size: 11.5px; font-weight: 300; color: var(--text-3); margin: 4px 0 14px; }
.confirm-card .field-box { text-align: left; }
.confirm-card .login-err { text-align: left; margin-top: 10.5px; }
.confirm-actions { display: flex; gap: 9px; margin-top: 16px; }
.confirm-actions .btn { flex: 1; justify-content: center; height: 37px; }
.confirm-actions .btn[disabled] { opacity: 0.7; cursor: wait; }

/* ═══════════════════════════════════════════════════════════════
   POLISH — Tomato Red theme
   ═══════════════════════════════════════════════════════════════ */
html, body {
    background:
        radial-gradient(820px 380px at 100% -6%, rgba(208,50,14,0.055), transparent 62%),
        radial-gradient(640px 360px at 0% 108%, rgba(232,87,58,0.045), transparent 62%),
        var(--bg);
}
:root { --shadow: 0 1px 2px rgba(60,28,16,0.04), 0 2px 8px rgba(60,28,16,0.05); --shadow-hover: 0 10px 26px -8px rgba(90,32,14,0.18); }
.sb-logo, .tb-avatar { box-shadow: var(--primary-shadow), inset 0 0 0 2px rgba(255,255,255,0.28); }
.content::-webkit-scrollbar-thumb { background: #ddd6d2; }
.content::-webkit-scrollbar-thumb:hover { background: #cbc2bd; }

/* ═══════════════════════════════════════════════════════════════
   DATA TABLES & ADMIN PROFILE (Compact)
   ═══════════════════════════════════════════════════════════════ */
.data-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 14px;
}
.data-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.data-card-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 6px;
}
.data-card-title .ms { font-size: 18px; color: var(--primary); }

.data-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(calc(100vh / var(--z, 1)) - 355px);
    min-height: 280px;
}
.data-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.data-table-wrap::-webkit-scrollbar-thumb { background: #d9dde5; border-radius: 9px; }
.data-table-wrap::-webkit-scrollbar-thumb:hover { background: #cbc2bd; }
.data-table-wrap::-webkit-scrollbar-track { background: transparent; }

.data-table {
    width: 100%; border-collapse: collapse; text-align: left;
    font-size: 12.5px;
}
.data-table th {
    padding: 8px 12px; font-size: 11px; font-weight: 600;
    color: var(--text-3); letter-spacing: 0.02em;
    background: #fafbfc;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: inset 0 -1px 0 var(--border), 0 1px 0 var(--border);
}
.data-table td {
    padding: 9px 12px; color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: #fafbfc; }
.data-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 500;
}
.badge .ms { font-size: 14px; }
.badge-brand { background: var(--primary-l); color: var(--primary-d); border: 1px solid #fad3c8; }
.badge-green { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-gray  { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.user-cell-name { font-weight: 500; font-size: 12.5px; color: var(--text); }
.user-cell-sub { font-size: 11px; color: var(--text-3); }

.admin-hero {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(208,50,14,0.05), rgba(232,87,58,0.015));
    border: 1px solid #fbd9cf; border-radius: 12px;
    padding: 12px 16px; margin-bottom: 14px;
}
.admin-hero-left { display: flex; align-items: center; gap: 14px; }
.admin-hero-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 600;
    box-shadow: 0 4px 12px -3px rgba(208,50,14,0.35);
}
.admin-hero-info h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.admin-hero-info p { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
.admin-hero-badges { display: flex; gap: 6px; align-items: center; }

/* ═══════════════════════════════════════════════════════════════
   USER MODAL (เพิ่ม/แก้ไขผู้ใช้)
   ═══════════════════════════════════════════════════════════════ */
.user-modal-backdrop[hidden] { display: none; }
.user-modal-backdrop {
    position: fixed; inset: 0; z-index: 9500;
    display: flex; align-items: center; justify-content: center;
    background: rgba(45, 20, 12, 0.45);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s var(--ease) both;
}
.user-modal-card {
    width: min(420px, calc(calc(100vw / var(--z, 1)) - 32px));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 60px -15px rgba(60, 22, 12, 0.25);
    padding: 24px 26px 20px;
    animation: scaleIn 0.22s var(--ease) both;
}
.user-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.user-modal-title {
    font-size: 16px; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.user-modal-title .ms { font-size: 22px; color: var(--primary); }
.user-modal-close {
    border: none; background: none; cursor: pointer; color: var(--text-4);
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.user-modal-close:hover { background: #f1f2f6; color: var(--text); }
.user-modal-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 18px; padding-top: 14px;
    border-top: 1px solid var(--border);
}
.select-box select {
    flex: 1; border: none; outline: none; background: transparent;
    font-family: var(--font); font-size: 13.5px; color: var(--text);
    cursor: pointer;
}
.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    vertical-align: middle;
}
.table-btn {
    border: none; background: transparent; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-3); transition: all 0.16s;
    flex-shrink: 0;
}
.table-btn:hover { background: var(--primary-l); color: var(--primary); }
.table-btn.delete:hover,
.table-btn.text-red:hover { background: #fee2e2; color: #dc2626; }
.table-btn .ms { font-size: 17px; }

.data-table th.col-actions,
.data-table td.col-actions {
    text-align: center;
    white-space: nowrap;
    width: 110px;
    min-width: 104px;
}




/* ═══════════════════════════════════════════════════════════════
   ADMIN MANAGEMENT (ดู / เพิ่ม / แก้ไข)
   ═══════════════════════════════════════════════════════════════ */
.badge-red { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.count-pill { font-size: 10.5px; font-weight: 500; color: var(--text-3); background: #f2efed; padding: 1px 8px; border-radius: 20px; }
.data-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-search {
    display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; min-width: 210px;
    background: var(--card); border: 1px solid var(--border-2); border-radius: 8px; color: var(--text-4);
    transition: all 0.16s var(--ease);
}
.tool-search:focus-within { border-color: #ee9a85; box-shadow: 0 0 0 3px rgba(208,50,14,0.1); color: var(--primary); }
.tool-search .ms { font-size: 16px; }
.tool-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-family: var(--font); font-size: 12px; color: var(--text); }
.tool-select {
    height: 30px; padding: 0 8px; border: 1px solid var(--border-2); border-radius: 8px;
    background: var(--card); font-family: var(--font); font-size: 12px; color: var(--text-2); cursor: pointer; outline: none;
}
.tool-select:focus { border-color: #ee9a85; }
.tbl-msg { text-align: center; color: var(--text-3); padding: 22px; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.me-tag { font-size: 10px; color: var(--primary); font-weight: 600; }
.code-tag { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11.5px; color: var(--text-2); background: #f6f4f3; padding: 1px 6px; border-radius: 5px; }

/* modal กว้างขึ้น + ฟอร์มสองคอลัมน์ */
.user-modal-card.wide { width: min(560px, calc(calc(100vw / var(--z, 1)) - 32px)); max-height: calc(calc(100vh / var(--z, 1)) - 32px); overflow-y: auto; }
.user-modal-card.wide::-webkit-scrollbar { width: 6px; }
.user-modal-card.wide::-webkit-scrollbar-thumb { background: #ddd6d2; border-radius: 10px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.fgrid[hidden] { display: none; }
.fgrid > .field[hidden] { display: none; }
.field-hint { display: block; font-size: 10.5px; color: var(--text-4); margin-top: 3px; }
.area-box { height: auto; align-items: flex-start; padding: 7px 10px; }
.area-box textarea { flex: 1; min-width: 0; border: none; outline: none; resize: vertical; background: transparent; font-family: var(--font); font-size: 12.5px; color: var(--text); min-height: 44px; }
.field-box input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.field-box input:disabled { color: var(--text-3); cursor: not-allowed; }

/* view modal */
.view-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.view-avatar {
    width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-grad); color: #fff; font-size: 19px; font-weight: 600;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--primary-shadow);
}
.view-name { font-size: 15px; font-weight: 600; color: var(--text); }
.view-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.view-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; margin: 0; }
.view-grid > div { padding: 8px 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.view-grid .span2 { grid-column: 1 / -1; }
.view-grid dt { font-size: 10.5px; color: var(--text-4); margin-bottom: 1px; }
.view-grid dd { margin: 0; font-size: 12.5px; color: var(--text); word-break: break-word; white-space: pre-wrap; }
@media (max-width: 560px) { .fgrid, .view-grid { grid-template-columns: minmax(0, 1fr); } }


/* ═══════════════════════════════════════════════════════════════
   PROJECTS (ข้อมูลโครงการ)
   ═══════════════════════════════════════════════════════════════ */
.badge-blue { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mini-stat, .m-card {
    display: flex; align-items: center; gap: 11px;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
    padding: 12px 14px; min-width: 0;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}
.mini-stat:hover, .m-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.mini-ic, .m-card-ic { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.mini-ic .ms, .m-card-ic .ms { font-size: 20px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.mini-lbl, .m-card-lbl { font-size: 11px; color: var(--text-3); }
.mini-val, .m-card-val { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.25; letter-spacing: -0.01em; white-space: nowrap; }
.mini-sub, .m-card-sub { font-size: 10.5px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.money-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-3); }
.money-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pbar { height: 5px; background: #f1ebe8; border-radius: 10px; overflow: hidden; margin: 4px 0 3px; }
.pbar > i { display: block; height: 100%; border-radius: 10px; background: var(--primary-grad); }
.pbar.over > i { background: #dc2626; }
.neg { color: #dc2626; font-weight: 600; }

.money-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.money-box { background: #faf9f8; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.money-box span { display: block; font-size: 10.5px; color: var(--text-4); }
.money-box b { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.money-box.neg { background: #fef2f2; border-color: #fecaca; }
.money-box.neg b { color: #b91c1c; }
.money-row .span3 { grid-column: 1 / -1; }

.fgrid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.readonly-box { background: #f6f4f3; }
.readonly-box input { color: var(--text-2); font-variant-numeric: tabular-nums; }
.field-box.neg-box input { color: #dc2626; font-weight: 600; }
.field-box input[type=date] { font-family: var(--font); color: var(--text); }
@media (max-width: 560px) { .fgrid3 { grid-template-columns: minmax(0, 1fr); } .money-row { grid-template-columns: minmax(0, 1fr); } }

/* ═══════════════════════════════════════════════════════════════
   MODERN FORM DESIGN SYSTEM (หน้าเพิ่ม/แก้ไขพนักงาน และฟอร์มระบบ)
   ═══════════════════════════════════════════════════════════════ */
.emp-form-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 980px) {
    .emp-form-grid { grid-template-columns: 1fr; }
}

.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 14px;
}
.form-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.form-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}
.form-card-title .ms {
    font-size: 19px;
    color: var(--primary);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 11px;
}
.form-group.no-mb { margin-bottom: 0; }
.form-lbl {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 4px;
}
.form-lbl .req {
    color: var(--red);
    font-weight: 700;
}
.form-hint {
    font-size: 10.5px;
    color: var(--text-4);
    line-height: 1.3;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    height: 36px;
    padding: 0 11px;
    font-family: var(--font);
    font-size: 12.5px;
    color: var(--text);
    background: #faf9f8;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    outline: none;
    transition: all 0.16s var(--ease);
}
.form-textarea {
    height: auto;
    min-height: 56px;
    padding: 8px 11px;
    resize: vertical;
    line-height: 1.45;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    background: #fff;
    border-color: #ee9a85;
    box-shadow: 0 0 0 3.5px rgba(208,50,14,0.12);
    color: var(--text);
}
.form-input[readonly] {
    background: #f2efed;
    color: var(--text-2);
    cursor: not-allowed;
    border-color: var(--border);
}
.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-4);
    font-weight: 300;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
}
.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 12px;
}
@media (max-width: 640px) {
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
}

/* Active Toggle Box & Switch Component */
.active-toggle-box {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 12px;
    background: #faf9f8;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.16s;
}
.active-toggle-box:hover {
    background: #f4f1ee;
}
.active-toggle-box input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
}
.active-toggle-box span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

/* ── Modern Switch Toggle Component ── */
.emp-switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
    padding: 3px 6px;
    border-radius: 20px;
    transition: background 0.16s ease;
}
.emp-switch:not(.disabled):hover {
    background: rgba(0, 0, 0, 0.04);
}
.emp-switch.disabled {
    cursor: default;
    opacity: 0.8;
}
.emp-switch-track {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    background-color: #cbd5e1;
    border-radius: 18px;
    transition: background-color 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}
.emp-switch-track.active {
    background-color: #10b981;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 6px rgba(16, 185, 129, 0.35);
}
.emp-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}
.emp-switch-track.active .emp-switch-thumb {
    transform: translateX(14px);
}
.emp-switch-text {
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transition: color 0.18s;
}
.emp-switch-text.active {
    color: #047857;
}
.emp-switch-text.inactive {
    color: #64748b;
}

/* Form switch box */
.emp-form-switch-box {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 38px;
    padding: 0 12px;
    background: #faf9f8;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.18s;
}
.emp-form-switch-box:hover {
    background: #f4f1ee;
    border-color: #e2ddd8;
}
.emp-form-switch-box input[type="checkbox"] {
    display: none;
}
.emp-form-switch-box .emp-switch-track {
    width: 36px;
    height: 20px;
    border-radius: 20px;
}
.emp-form-switch-box .emp-switch-thumb {
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
}
.emp-form-switch-box .emp-switch-track.active .emp-switch-thumb {
    transform: translateX(16px);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL ดูข้อมูลพนักงาน (Wide & Categorized View - Original Beautiful Layout)
   ═══════════════════════════════════════════════════════════════ */
.emp-view-modal-card {
    max-width: 1100px !important;
    width: 95% !important;
    max-height: 90vh !important;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 16px !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.08) !important;
}

.emp-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.emp-view-body {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 22px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none !important; /* ซ่อน scrollbar Firefox */
    -ms-overflow-style: none !important; /* ซ่อน scrollbar IE/Edge */
}

.emp-view-body::-webkit-scrollbar,
.emp-view-modal-card::-webkit-scrollbar,
#empViewModal *::-webkit-scrollbar {
    display: none !important; /* ซ่อน scrollbar Chrome/Safari/WebView2 */
    width: 0 !important;
    height: 0 !important;
}

.emp-view-hero-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
}

.emp-view-photo-box {
    width: 88px;
    height: 88px;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emp-view-hero-main {
    flex: 1;
    min-width: 0;
}

.emp-view-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.emp-view-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
}

.emp-view-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.emp-view-card-head .ms {
    font-size: 18px;
    color: var(--primary);
}

.emp-view-card-body {
    padding: 14px 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
}

.emp-view-field {
    min-width: 0;
}

.emp-view-field.span2 {
    grid-column: 1 / -1;
}

.emp-view-field-lbl {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.emp-view-field-val {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
    line-height: 1.4;
}

.emp-view-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    background: #ffffff;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .emp-view-grid-2col {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MATERIAL INVENTORY STYLES
   ═══════════════════════════════════════════════════════════════ */
.mat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: transform 0.18s ease;
}
.mat-avatar:hover {
    transform: scale(1.08);
}
.mini-stat.highlight-warn {
    border-color: #fde68a !important;
    background: #fffbeb !important;
}
.mini-stat.highlight-alert {
    border-color: #fecaca !important;
    background: #fef2f2 !important;
}




/* ═══════════════════════════════════════════════════════════════
   DB MANAGER (จัดการฐานข้อมูล SQLite)
   ═══════════════════════════════════════════════════════════════ */
.m-sub-item[hidden] { display: none; }
.dbm-tabs { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.dbm-tab {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text-2);
    font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all 0.15s ease;
}
.dbm-tab .ms { font-size: 17px; }
.dbm-tab:hover { background: #fafbfc; }
.dbm-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dbm-split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; align-items: start; }
.dbm-tbl-list { max-height: calc(calc(100vh / var(--z, 1)) - 380px); min-height: 200px; overflow-y: auto; padding: 6px; }
.dbm-tbl-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.dbm-tbl-item .ms { font-size: 17px; color: var(--text-4); }
.dbm-tbl-item:hover { background: #f4f6f9; }
.dbm-tbl-item.active { background: #eef2ff; color: var(--text); font-weight: 600; }
.dbm-tbl-item.active .ms { color: var(--primary); }
.dbm-tbl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbm-tbl-cnt { font-size: 11px; color: var(--text-3); background: #f1f5f9; border-radius: 10px; padding: 1px 8px; }
.dbm-wrap { max-height: calc(calc(100vh / var(--z, 1)) - 430px); min-height: 120px; }
.dbm-table td, .dbm-table th { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.dbm-null { color: var(--text-4); font-style: italic; font-size: 11px; }
.dbm-blob { color: #7c3aed; font-size: 11.5px; }
.dbm-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.dbm-seg button { border: 0; background: #fff; padding: 0 12px; height: 30px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text-2); }
.dbm-seg button.active { background: var(--primary); color: #fff; }
.dbm-pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.dbm-pager .btn { height: 28px; padding: 0 10px; font-size: 12px; border: 1px solid var(--border); }
.dbm-schema { padding: 4px 16px 16px; }
.dbm-schema h4 { margin: 14px 0 6px; font-size: 12.5px; color: var(--text); }
.dbm-schema .dbm-wrap { max-height: 260px; border: 1px solid var(--border); border-radius: 8px; }
.dbm-sql { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 12px 14px; font-size: 12px; line-height: 1.5; overflow-x: auto; white-space: pre-wrap; margin: 8px 0 0; font-family: Consolas, 'Courier New', monospace; }
.dbm-sql-in { font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; width: 100%; resize: vertical; }
.dbm-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.dbm-mcard { padding: 18px; }
.dbm-mcard h3 { margin: 10px 0 4px; font-size: 14px; }
.dbm-mcard p { font-size: 12px; color: var(--text-3); line-height: 1.55; margin: 0 0 12px; }
.dbm-mic { width: 38px; height: 38px; border-radius: 10px; background: #eef2ff; color: var(--primary); display: flex; align-items: center; justify-content: center; }
.dbm-out { margin-top: 12px; font-size: 12px; }
@media (max-width: 900px) { .dbm-split { grid-template-columns: 1fr; } }


/* ── ตารางวัสดุแบบกะทัดรัด ── */
.mat-table { font-size: 12px; }
.mat-table th { padding: 6px 10px; }
.mat-table td { padding: 4px 10px; }
.mat-code { font-family: Consolas, 'Courier New', monospace; font-size: 11.5px; font-weight: 600; color: var(--primary); cursor: pointer; white-space: nowrap; }
.mat-code:hover { text-decoration: underline; }
.mat-name { font-weight: 600; font-size: 12.5px; line-height: 1.3; cursor: pointer; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-name:hover { color: var(--primary); }
.mat-sub { font-size: 10.5px; color: var(--text-3); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-ellipsis { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 11.5px; }
.mat-table .badge { font-size: 10px; padding: 1px 6px; }
.mat-table .table-btn { width: 26px; height: 26px; }

/* ไอคอนสำคัญ / ควบคุม ในลิสต์วัสดุ (คอลัมน์ซ้ายสุด) */
.mat-flag { font-size: 18px; vertical-align: middle; margin-right: 2px; cursor: help; }
.mat-flag-imp { color: #f59e0b; font-variation-settings: 'FILL' 1; }
.mat-flag-ctl { color: #dc2626; }

/* ลิสต์พนักงานแบบกระชับ */
.emp-table { font-size: 12px; }
.emp-table th { padding: 6px 10px; }
.emp-table td { padding: 4px 10px; }
.emp-code { font-family: monospace; font-size: 12px; font-weight: 700; color: var(--primary); }
.emp-name { font-weight: 600; font-size: 12.5px; cursor: pointer; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp-name:hover { color: var(--primary); }
.emp-ell { display: inline-block; vertical-align: middle; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp-table .badge { font-size: 10.5px; padding: 1px 6px; }
.emp-table .table-btn { width: 26px; height: 26px; }
.emp-table .emp-switch-text { display: none; }

/* เมนู 3 จุด */
.row-menu-btn.open { background: var(--primary-l); color: var(--primary); }
.row-menu { position: fixed; z-index: 9999; min-width: 150px; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px -6px rgba(16,24,40,0.22); }
.row-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-family: var(--font); font-size: 12.5px; color: var(--text); text-align: left; white-space: nowrap; }
.row-menu-item .ms { font-size: 17px; color: var(--text-3); }
.row-menu-item:hover { background: var(--primary-l); }
.row-menu-item:hover .ms { color: var(--primary); }
.row-menu-item.danger { color: #dc2626; }
.row-menu-item.danger .ms { color: #dc2626; }
.row-menu-item.danger:hover { background: #fee2e2; }
.row-menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }
.mat-table td.col-actions, .emp-table td.col-actions { width: 48px; min-width: 48px; }
.mat-table th.col-actions, .emp-table th.col-actions { width: 48px; min-width: 48px; }

.badge-yellow { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* รูปโปรไฟล์ผู้ดูแลระบบ */
.has-pic { background-size: cover !important; background-position: center !important; color: transparent !important; font-size: 0 !important; }
.um-pic { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.um-pic-prev { width: 64px; height: 64px; border-radius: 50%; flex: none; background: var(--primary-grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 600; }
.um-pic-info { display: flex; flex-direction: column; gap: 5px; } .um-pic-info small { font-size: 11px; color: var(--text-3); }
.um-pic-btns { display: flex; gap: 8px; }
.admin-hero-avatar { overflow: hidden; }

/* จัดการโครงการ (สิทธิ์เห็นโครงการ) */
.pa-grid { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .pa-grid { grid-template-columns: 1fr; } }
.pa-list { max-height: calc(calc(100vh / var(--z, 1)) - 290px); overflow-y: auto; padding-bottom: 8px; }
.pa-user { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; } .pa-user:hover { background: #faf8f7; } .pa-user.on { background: var(--primary-l); }
.pa-av { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-grad); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.pa-un { flex: 1; min-width: 0; display: flex; flex-direction: column; } .pa-un b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pa-un small { font-size: 11px; color: var(--text-3); }
.pa-proj { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; font-size: 13px; } .pa-proj:hover { background: #faf8f7; } .pa-proj.off { opacity: .6; }
.pa-pid { font-weight: 600; min-width: 52px; color: var(--primary); } .pa-pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pa-mainline { color: var(--primary) !important; }
.pa-tag { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 2px 10px; font: inherit; font-size: 11px; color: var(--text-3); cursor: pointer; flex: none; white-space: nowrap; }
.pa-tag:hover { border-color: var(--primary); color: var(--primary); } .pa-tag.main { background: var(--primary-l); border-color: #f1c6bb; color: var(--primary); font-weight: 600; cursor: default; }

/* หน้ารายการ: กรอบตารางยืดลงถึงขอบล่าง */
.content:has(> .data-card.d2 > .data-table-wrap) { display: flex; flex-direction: column; padding-bottom: 16px; }
.content:has(> .data-card.d2 > .data-table-wrap) > .page-head { flex: none; }
.content:has(> .data-card.d2 > .data-table-wrap) > .data-card.d2 { flex: 1 1 auto; min-height: 0; margin-bottom: 0; display: flex; flex-direction: column; }
.content:has(> .data-card.d2 > .data-table-wrap) > .data-card.d2 > .data-table-wrap { flex: 1 1 auto; min-height: 120px; max-height: none; }
.content:has(> .data-card.d2 > .data-table-wrap) > .data-card.d2 > :not(.data-table-wrap) { flex: none; }

/* เอกสารที่มีไฟล์แนบแล้ว */
.mat-code.has-file { color: #15803d; background: rgba(22,163,74,.12); display: inline-flex; align-items: center; gap: 3px; }
.mat-code.has-file .ms { font-size: 14px; }
tr.row-has-file td { background: rgba(22,163,74,.07); }
.btn-has-file { color: #15803d !important; border-color: rgba(22,163,74,.5) !important; background: rgba(22,163,74,.1) !important; }

/* ตารางกว้าง (เช่น รายการเติมน้ำมัน): ให้คอลัมน์สุดท้าย (ปุ่มจัดการ) ติดขอบขวาเสมอ ไม่ต้องเลื่อนไปหา */
.data-table.sticky-act th:last-child, .data-table.sticky-act td:last-child {
    position: sticky; right: 0; z-index: 2; background: var(--card, #fff);
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .18);
}
.data-table.sticky-act thead th:last-child { z-index: 3; }
.data-table.sticky-act tbody tr:hover td:last-child { background: var(--row-hover, #f6f7fb); }
