
/* ── Tailwind preflight cancellation: keep Hub's own resets unaffected ──
   Tailwind CDN injects a global reset that conflicts with Hub. We restrict
   most of T-Emp's utility usage to inside #temp-main. */

/* ── T-Emp design tokens (only used inside #temp-main) ── */
#temp-main{
  --tone-50:#FBF8F3;
  --tone-100:#F4ECDD;
  --tone-200:#E6D4B0;
  --tone-300:#D2B58A;
  --tone-400:#B89163;
  --tone-500:#A16435;
  --tone-600:#81502C;
  --tone-700:#62391F;
  --tone-800:#3E2516;
  --tone-900:#241309;
  --te-bg:#F9F5EE;
  --te-card:#FFFFFF;
  --te-border:#E9E0CF;
  --te-text:#2A1F12;
  --te-muted:#7A6A52;
  --te-success:#16A34A;
  --te-warning:#F59E0B;
  --te-danger:#DC2626;
  --te-info:#2563EB;
  background:var(--te-bg);
  color:var(--te-text);
  font-family:'Sarabun','Noto Sans Thai',sans-serif;
  min-height:600px;
}
#temp-main *{box-sizing:border-box}
#temp-main .font-display{font-family:'Inter','Sarabun',sans-serif;letter-spacing:-0.01em}

/* ── Sub-shell layout (sidebar + main inside #temp-main) ──
   Hub already provides outer scroll + topbar. T-Emp lays out inline:
   sidebar = full-height column (no sticky — Hub controls scroll),
   main = grows to fit content. */
#temp-main .te-shell{display:flex;align-items:stretch;min-height:600px}
#temp-main .te-sidebar{
  background:#FFFFFF;border-right:1px solid var(--te-border);width:220px;flex-shrink:0;
  display:flex;flex-direction:column;
}
#temp-main .te-sidebar.collapsed{width:64px}
#temp-main .te-logo{padding:16px 18px;border-bottom:1px solid var(--te-border);display:flex;align-items:center;gap:10px}
#temp-main .te-logo-icon{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,#8B6F47,#6B4F2A);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:14px;
  box-shadow:0 4px 12px rgba(139,111,71,.3);flex-shrink:0}
#temp-main .te-nav-wrap{flex:1;padding:6px 0}
#temp-main .te-nav-item{display:flex;align-items:center;gap:10px;padding:9px 16px;color:#6B5840;cursor:pointer;
  font-size:13px;font-weight:500;border-left:3px solid transparent;transition:all .15s;text-decoration:none}
#temp-main .te-nav-item:hover{background:var(--tone-50);color:var(--tone-700)}
#temp-main .te-nav-item.active{background:var(--tone-50);color:var(--tone-700);border-left-color:var(--tone-500);font-weight:600}
#temp-main .te-nav-item svg{width:16px;height:16px;flex-shrink:0}
#temp-main .te-nav-section{padding:10px 16px 4px;font-size:10.5px;font-weight:700;color:#A89578;
  text-transform:uppercase;letter-spacing:.06em}

#temp-main .te-main{flex:1;min-width:0;display:flex;flex-direction:column}
#temp-main .te-content{padding:22px;flex:1}

/* ── Cards / KPI ── */
#temp-main .te-card{background:#fff;border:1px solid var(--te-border);border-radius:12px;padding:20px;
  box-shadow:0 1px 2px rgba(40,30,15,.04)}
#temp-main .te-kpi{background:#fff;border:1px solid var(--te-border);border-radius:12px;padding:18px;
  display:flex;justify-content:space-between;align-items:flex-start;
  box-shadow:0 1px 2px rgba(40,30,15,.04)}
#temp-main .te-kpi-label{font-size:12.5px;color:var(--te-muted);font-weight:500}
#temp-main .te-kpi-value{font-size:32px;font-weight:800;color:var(--tone-800);margin-top:5px;
  font-family:'Inter',sans-serif;letter-spacing:-0.02em;line-height:1.1}
#temp-main .te-kpi-sub{font-size:11.5px;color:var(--te-muted);margin-top:4px}
#temp-main .te-kpi-icon{width:38px;height:38px;border-radius:9px;background:var(--tone-50);
  display:flex;align-items:center;justify-content:center;color:var(--tone-600)}

/* ── Buttons (T-Emp local; do NOT leak to Hub) ── */
#temp-main .btn{display:inline-flex;align-items:center;gap:8px;padding:8px 14px;border-radius:8px;font-size:13px;
  font-weight:600;cursor:pointer;transition:all .15s;border:1px solid transparent;white-space:nowrap;
  font-family:inherit;line-height:1.2}
#temp-main .btn-primary{background:linear-gradient(135deg,#8B6F47,#6B4F2A);color:#fff;
  box-shadow:0 2px 6px rgba(107,79,42,.25)}
#temp-main .btn-primary:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(107,79,42,.35)}
#temp-main .btn-soft{background:var(--tone-50);color:var(--tone-700);border-color:var(--tone-200)}
#temp-main .btn-soft:hover{background:var(--tone-100)}
#temp-main .btn-ghost{background:transparent;color:#6B5840;border-color:transparent}
#temp-main .btn-ghost:hover{background:#F4ECDD}
#temp-main .btn-danger{background:#FEF2F2;color:#B91C1C;border-color:#FCA5A5}
#temp-main .btn-danger:hover{background:#FEE2E2}
#temp-main .btn-sm{padding:5px 10px;font-size:12px;border-radius:6px}

/* ── Form ── */
#temp-main .te-input,#temp-main .te-select,#temp-main .te-textarea{width:100%;padding:8px 11px;
  border:1px solid var(--te-border);border-radius:7px;font-size:13.5px;background:#fff;color:var(--te-text);
  transition:all .15s;font-family:inherit}
#temp-main .te-input:focus,#temp-main .te-select:focus,#temp-main .te-textarea:focus{
  outline:none;border-color:var(--tone-500);box-shadow:0 0 0 3px rgba(139,111,71,.12)}
#temp-main .te-label{display:block;font-size:12px;font-weight:600;color:#6B5840;margin-bottom:5px}

/* ── Tables ── */
#temp-main .te-table{width:100%;border-collapse:separate;border-spacing:0}
#temp-main .te-table thead th{background:#FAF6EE;color:#6B5840;font-size:11.5px;font-weight:700;
  padding:10px 13px;text-align:left;text-transform:uppercase;letter-spacing:.04em;
  border-bottom:1px solid var(--te-border)}
#temp-main .te-table tbody td{padding:11px 13px;font-size:13px;border-bottom:1px solid #F2EBDD;color:var(--te-text)}
#temp-main .te-table tbody tr:hover td{background:#FBF8F3}
#temp-main .te-table tbody tr:last-child td{border-bottom:none}

/* ── Badges (scoped) ── */
#temp-main .badge{display:inline-flex;align-items:center;padding:3px 9px;border-radius:999px;
  font-size:11px;font-weight:600;line-height:1.4}
#temp-main .badge-success{background:#DCFCE7;color:#166534}
#temp-main .badge-warning{background:#FEF3C7;color:#92400E}
#temp-main .badge-danger{background:#FEE2E2;color:#991B1B}
#temp-main .badge-info{background:#DBEAFE;color:#1E40AF}
#temp-main .badge-muted{background:#F3F0E8;color:#6B5840}

/* ── Avatar (scoped) ── */
#temp-main .avatar{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,#D2B58A,#A16435);
  color:#fff;font-weight:700;font-size:12.5px;display:inline-flex;align-items:center;justify-content:center;
  flex-shrink:0;text-transform:uppercase}
#temp-main .avatar-lg{width:60px;height:60px;font-size:21px}
#temp-main .avatar-sm{width:26px;height:26px;font-size:10.5px}

/* ── Tabs ── */
#temp-main .tabs{display:flex;gap:4px;border-bottom:1px solid var(--te-border);margin-bottom:16px}
#temp-main .tab{padding:9px 14px;font-size:13px;font-weight:600;color:var(--te-muted);cursor:pointer;
  border-bottom:2px solid transparent;transition:all .15s}
#temp-main .tab:hover{color:var(--tone-700)}
#temp-main .tab.active{color:var(--tone-700);border-bottom-color:var(--tone-500)}

/* ── Org chart ── */
#temp-main .org-tree{display:flex;flex-direction:column;align-items:center;gap:0;padding:18px}
#temp-main .org-node{background:#fff;border:2px solid var(--tone-200);border-radius:11px;padding:11px 16px;
  display:flex;align-items:center;gap:10px;min-width:170px;
  box-shadow:0 2px 8px rgba(40,30,15,.06);position:relative}
#temp-main .org-node.ceo{border-color:var(--tone-500);background:linear-gradient(135deg,#FBF8F3,#F4ECDD)}
#temp-main .org-row{display:flex;gap:22px;align-items:flex-start;flex-wrap:wrap;justify-content:center;
  position:relative;padding-top:28px}
#temp-main .org-row::before{content:"";position:absolute;top:0;left:50%;width:1px;height:28px;background:var(--tone-300)}
#temp-main .org-children{display:flex;gap:16px;flex-wrap:wrap;justify-content:center}

/* ── Status dot ── */
#temp-main .dot{width:8px;height:8px;border-radius:50%;display:inline-block}
#temp-main .dot-success{background:var(--te-success)}
#temp-main .dot-warning{background:var(--te-warning)}
#temp-main .dot-danger{background:var(--te-danger)}
#temp-main .dot-info{background:var(--te-info)}
#temp-main .dot-muted{background:#9CA3AF}

/* ── Utility (scoped) ── */
#temp-main .hide{display:none!important}

/* ── T-Emp Modal (own modal stack so doesn't conflict with Hub modals) ── */
.temp-modal-overlay{position:fixed;inset:0;background:rgba(40,30,15,.45);z-index:9000;
  display:flex;align-items:center;justify-content:center;padding:20px;backdrop-filter:blur(2px);
  font-family:'Sarabun','Noto Sans Thai',sans-serif}
.temp-modal-overlay *{box-sizing:border-box}
.temp-modal-card{background:#fff;border-radius:14px;width:100%;max-width:640px;
  max-height:92vh;overflow-y:auto;box-shadow:0 20px 60px rgba(40,30,15,.25)}
.temp-modal-card.modal-lg{max-width:880px}
.temp-modal-header{padding:18px 22px;border-bottom:1px solid #E9E0CF;
  display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff;z-index:1;
  font-weight:700;color:#3E2516}
.temp-modal-body{padding:22px}
.temp-modal-footer{padding:14px 22px;border-top:1px solid #E9E0CF;
  display:flex;gap:9px;justify-content:flex-end;position:sticky;bottom:0;background:#fff}
.temp-modal-card .te-input,.temp-modal-card .te-select,.temp-modal-card .te-textarea{
  width:100%;padding:8px 11px;border:1px solid #E9E0CF;border-radius:7px;font-size:13.5px;
  background:#fff;color:#2A1F12;font-family:inherit}
.temp-modal-card .te-label{display:block;font-size:12px;font-weight:600;color:#6B5840;margin-bottom:5px}
.temp-modal-card .btn{display:inline-flex;align-items:center;gap:8px;padding:8px 14px;border-radius:8px;
  font-size:13px;font-weight:600;cursor:pointer;border:1px solid transparent;font-family:inherit}
.temp-modal-card .btn-primary{background:linear-gradient(135deg,#8B6F47,#6B4F2A);color:#fff}
.temp-modal-card .btn-soft{background:#FBF8F3;color:#62391F;border-color:#E6D4B0}
.temp-modal-card .btn-ghost{background:transparent;color:#6B5840}
.temp-modal-card .btn-danger{background:#FEF2F2;color:#B91C1C;border-color:#FCA5A5}

/* ── T-Emp Toast (own stack — Hub already has #toast singleton) ── */
.temp-toast-root{position:fixed;bottom:24px;right:24px;z-index:9100;display:flex;flex-direction:column;gap:8px}
.temp-toast{background:#241309;color:#fff;padding:11px 16px;border-radius:9px;font-size:13.5px;font-weight:500;
  box-shadow:0 8px 24px rgba(0,0,0,.2);animation:tempSlideUp .2s ease;max-width:380px;
  font-family:'Sarabun','Noto Sans Thai',sans-serif}
.temp-toast.toast-success{background:#166534}
.temp-toast.toast-error{background:#991B1B}
@keyframes tempSlideUp{from{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}

/* ── body.temp-theme — Hub topbar accent (matches T-Emp brown palette) ── */
body.temp-theme .topbar{
  background:linear-gradient(90deg,#62391F 0%,#81502C 50%,#A16435 100%)!important;
  border-bottom:1px solid #62391F!important;
}
body.temp-theme .topbar-title{color:#fff!important;font-weight:700;}
body.temp-theme .topbar-search-input{background:rgba(255,255,255,.95)!important;color:#2A1F12!important;
  border:1px solid rgba(255,255,255,.4)!important;border-radius:8px;}
body.temp-theme .topbar-btn,body.temp-theme .user-pill{color:#fff!important;}
body.temp-theme .user-avatar{background:#3E2516!important;color:#fff!important;}

/* ── Responsive ── */
@media(max-width:900px){
  #temp-main .te-shell{flex-direction:column}
  #temp-main .te-sidebar{position:relative;top:0;width:100%;height:auto;max-height:none;border-right:none;
    border-bottom:1px solid var(--te-border)}
  #temp-main .te-nav-wrap{display:flex;overflow-x:auto;padding:6px}
  #temp-main .te-nav-section{display:none}
  #temp-main .te-nav-item{flex-shrink:0;border-left:none;border-bottom:3px solid transparent}
  #temp-main .te-nav-item.active{border-left-color:transparent;border-bottom-color:var(--tone-500)}
  #temp-main .te-content{padding:14px}
}

/* ── Org chart: Drag & Drop ── */
#temp-main .org-node[draggable="true"]{cursor:grab;transition:transform .12s ease,box-shadow .12s ease,opacity .15s ease,border-color .12s ease}
#temp-main .org-node[draggable="true"]:hover{transform:translateY(-1px);box-shadow:0 6px 14px rgba(40,30,15,.12)}
#temp-main .org-node[draggable="true"]:active{cursor:grabbing}
#temp-main .org-node.org-dragging{opacity:.4;transform:scale(.96)}
/* node ที่ลากเข้ามา (potential drop target) */
#temp-main .org-drop-active .org-node[draggable="true"]{border-style:dashed}
#temp-main .org-node.org-drop-target{
  border-color:var(--tone-500) !important;
  background:linear-gradient(135deg,#FFF8E7,#FCEBC4) !important;
  box-shadow:0 0 0 3px rgba(161,100,53,.18),0 6px 14px rgba(40,30,15,.14);
  transform:scale(1.04)
}
/* Drop zone บนสุด (ทำให้เป็น root) */
#temp-main .org-root-drop{
  border:2px dashed var(--tone-300);background:#FBF8F3;color:var(--muted);
  border-radius:11px;padding:14px 18px;text-align:center;font-size:13px;
  margin-bottom:14px;transition:all .15s ease;display:none
}
#temp-main .org-drop-active .org-root-drop{display:block}
#temp-main .org-root-drop.over{
  border-color:var(--tone-500);background:#FCEBC4;color:var(--tone-800);
  box-shadow:0 0 0 3px rgba(161,100,53,.18)
}


/* v1.0.2i: aliases for legacy T-Emp modal markup */
.temp-modal-card .modal-header{padding:18px 22px;border-bottom:1px solid #E9E0CF;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff;z-index:1;font-weight:700;color:#3E2516}
.temp-modal-card .modal-body{padding:22px}
.temp-modal-card .modal-footer{padding:14px 22px;border-top:1px solid #E9E0CF;display:flex;gap:9px;justify-content:flex-end;position:sticky;bottom:0;background:#fff}

/* T-Emp V1.28 mobile additions are injected by js/05-temp-module.js to keep isolated patch. */


/* V1.30 T-Emp: TA/TT unified people page, org chart, photos, warnings */
.emp-company-summary{display:flex;gap:10px;align-items:stretch;flex-wrap:wrap;margin:0 0 14px}
.emp-company-pill{background:#fff;border:1px solid var(--te-border,#E8E1D4);border-radius:14px;padding:10px 14px;min-width:140px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
.emp-company-pill b{display:block;font-size:22px;color:var(--tone-800,#3D2C1C);line-height:1}
.emp-company-pill span{font-size:12px;color:var(--muted,#7A6A52)}
.emp-company-note{font-size:12px;color:var(--muted,#7A6A52);align-self:center;background:#FAF6EC;border:1px dashed #E5D5BD;border-radius:999px;padding:8px 12px}
.emp-photo-avatar{overflow:hidden;background:#F6EFE3}
.emp-photo-avatar img,.emp-photo-preview img{width:100%;height:100%;object-fit:cover;display:block}
.emp-photo-field{display:flex;gap:14px;align-items:center;background:#FAF6EC;border:1px solid #EFE1CC;border-radius:14px;padding:12px}
.emp-photo-preview{width:76px;height:76px;border-radius:16px;background:#fff;border:1px solid #E8E1D4;display:flex;align-items:center;justify-content:center;overflow:hidden;font-size:12px;color:var(--muted,#7A6A52)}
.emp-profile-head{display:flex;align-items:center;gap:12px;background:#FAF6EC;border:1px solid #EFE1CC;border-radius:14px;padding:12px;margin-bottom:10px}
.emp-warning-policy{background:#FFF7ED;border:1px solid #FED7AA;color:#7C2D12;border-radius:12px;padding:10px 12px;font-size:12px;line-height:1.55;margin-bottom:12px}
.org-modern-board{background:linear-gradient(180deg,#fff 0%,#FAF6EC 100%);border:1px solid #EFE1CC;border-radius:18px;padding:22px;min-width:max-content;box-shadow:inset 0 1px 0 rgba(255,255,255,.7)}
.org-node{min-width:210px;border:1px solid #E7D8C3!important;border-radius:16px!important;background:#fff!important;box-shadow:0 8px 20px rgba(89,60,30,.08);transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;gap:10px!important}
.org-node:hover{transform:translateY(-2px);box-shadow:0 12px 26px rgba(89,60,30,.13)}
.org-node.ceo{border-color:#B6743A!important;background:linear-gradient(180deg,#FFF7ED,#fff)!important}
.org-node.org-drop-target{border-color:#2563EB!important;box-shadow:0 0 0 4px rgba(37,99,235,.12),0 12px 26px rgba(89,60,30,.13)}
.org-root-drop{border:1px dashed #B6743A;background:#FFF7ED;color:#92400E;border-radius:14px;padding:12px;text-align:center;margin-bottom:14px;font-weight:700}
.org-root-drop.over{background:#FED7AA;border-color:#92400E}
@media(max-width:720px){.emp-photo-field{grid-column:span 1!important;align-items:flex-start}.emp-company-note{width:100%;border-radius:12px}.org-node{min-width:190px}}

/* V1.37 T-Emp production forms: full-page panels, no accidental outside-click close */
.temp-modal-overlay.modal-fullpage{align-items:stretch;justify-content:center;padding:0;background:rgba(15,23,42,.32)}
.temp-modal-overlay.modal-fullpage .temp-modal-card{max-width:none;width:min(1180px,100vw);height:100vh;max-height:100vh;border-radius:0;display:flex;flex-direction:column;overflow:hidden}
.temp-modal-overlay.modal-fullpage .temp-modal-card.modal-lg{max-width:none;width:min(1180px,100vw)}
.temp-modal-overlay.modal-fullpage .modal-body,.temp-modal-overlay.modal-fullpage .temp-modal-body{flex:1;overflow:auto}
.temp-modal-overlay.modal-fullpage .modal-header,.temp-modal-overlay.modal-fullpage .modal-footer{flex:0 0 auto}
@media(max-width:720px){.temp-modal-overlay.modal-fullpage .temp-modal-card{width:100vw}.temp-modal-overlay.modal-fullpage .grid.grid-cols-2{grid-template-columns:1fr}.temp-modal-overlay.modal-fullpage .col-span-2{grid-column:span 1 / span 1}}
