/* PHF Cơ cấu tổ chức V1 (Batch 02) — VISUAL MASTER PORT (18/09/2026): faithful
   port of the Admin-APPROVED PHF_OrgChart_Admin_Modern_V6_BALANCED.html.
   Class names mirror that file's own classes (.org-shell/.org-head/.brand/
   .viewport/.canvas/.wires/.card/.director/.branch/.unit/.store/.foot),
   see phf-org-chart-view.js header comment for the geometry engine that
   computes each node's inline left/top/width/height from live tree data.
   One shared font stack everywhere — no per-node override. Desktop
   (>900px, matching the master's own breakpoint) = this absolute-canvas
   layout. Mobile = a completely separate stacked/accordion markup below
   (.org-mobile), never a scaled-down canvas. */

.phf-org-wrap{font-family:Arial,"Helvetica Neue",Helvetica,system-ui,-apple-system,sans-serif;color:#17231d}
.org-shell{width:min(1500px,100%);margin:0 auto;background:#fff;border:1px solid #e1e7e3;border-radius:16px;box-shadow:0 18px 50px rgba(31,61,46,.10);overflow:hidden}

/* User Org Chart home breadcrumb (LOCAL polish, 18/09/2026) — additive
   strip above .org-head, never rendered for Admin's Preview (see
   renderTree()'s opts.showHomeBreadcrumb). Does not touch .org-head itself
   or anything below it. */
.org-breadcrumb{display:flex;align-items:center;gap:8px;padding:10px 34px 0;font-size:12.5px;color:#6d7771}
.org-breadcrumb-home{border:0;background:none;padding:0;margin:0;font:inherit;color:#07643d;font-weight:700;cursor:pointer}
.org-breadcrumb-home:hover{text-decoration:underline}
.org-breadcrumb-sep{color:#b7c0bb}
.org-breadcrumb-current{color:#6d7771}

.org-head{min-height:96px;padding:0 34px;display:flex;align-items:center;gap:22px;border-bottom:1px solid #e6ebe8;background:linear-gradient(180deg,#fff,#fdfefd)}
.brand{display:flex;align-items:center;min-width:150px}
.brand-logo{width:150px;height:50px;object-fit:contain;display:block}
.head-rule{width:1px;height:44px;background:#dfe5e1;flex:0 0 auto}
.head-title b{display:block;font-size:24px;letter-spacing:-.35px}
.head-title span{display:block;margin-top:6px;font-size:12px;color:#6d7771}
/* ▶ Trình chiếu — entry to the CURRENT organization presentation (User view
   header only; Admin Preview never renders it). */
.org-present-btn{margin-left:auto;flex:0 0 auto;border:1px solid #07643d;background:#07643d;color:#fff;border-radius:8px;padding:9px 16px;font:inherit;font-size:13px;font-weight:700;cursor:pointer;white-space:nowrap}
.org-present-btn:hover{background:#054f30;border-color:#054f30}
.org-present-btn:focus-visible{outline:2px solid #f58220;outline-offset:2px}

.viewport{overflow:auto;background:radial-gradient(circle at 85% 5%,#fff5ed 0,transparent 19%),linear-gradient(#fff,#fefefe);padding:0 0 8px}
.canvas{position:relative;margin:0 auto}
.wires{position:absolute;inset:0;z-index:0}
.wires path{fill:none;stroke:#ef7a2b;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vector-effect:non-scaling-stroke}

.org-card{position:absolute;z-index:2;background:#fff;border:1px solid #e7a06f;box-shadow:0 7px 18px rgba(80,55,37,.055);border-radius:10px;text-align:center;font-family:inherit}
.org-card .icon{display:grid;place-items:center}
.org-card .icon svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

.org-card.director{border:0;color:#fff;background:linear-gradient(135deg,#e95600 0%,#ff7b18 100%);box-shadow:0 12px 25px rgba(210,76,0,.20);display:flex;align-items:center;justify-content:center}
.org-card.director .icon{position:absolute;left:20px;width:44px;height:44px;border-radius:10px;background:rgba(255,255,255,.16);box-shadow:inset 0 1px 0 rgba(255,255,255,.35)}
.org-card.director .copy{width:100%;padding:0 65px}
.org-card.director .eyebrow{font-size:10px;font-weight:800;letter-spacing:1px;text-transform:uppercase}
.org-card.director strong{display:block;margin-top:5px;font-size:21px;line-height:1.1}

.org-card.branch{display:flex;align-items:center;justify-content:center;padding:18px 58px}
.org-card.branch .icon{position:absolute;left:18px;top:18px;width:42px;height:42px;border-radius:10px;color:#f5660a;background:linear-gradient(145deg,#fffaf6,#ffe2cd);box-shadow:0 5px 12px rgba(177,82,23,.10),inset 0 1px 0 #fff}
.org-card.branch .role{min-height:13px;font-size:9.5px;line-height:1.25;font-weight:700;letter-spacing:.3px;text-transform:uppercase;color:#775f51}
.org-card.branch h2{margin:6px 0 5px;color:#07643d;font-size:19px;line-height:1.1;letter-spacing:-.15px;font-weight:700}
.org-card.branch .person{font-size:14px;font-weight:700;line-height:1.2}
.org-card.branch .badge{display:inline-block;margin-top:7px;padding:3px 7px;border-radius:999px;background:#fff5eb;border:1px solid #f1bd95;color:#9b4b14;font-size:8.5px;font-weight:700}

.org-card.unit{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:9px 8px;font-size:13px;line-height:1.2;font-weight:700}
.org-card.unit .icon{width:36px;height:36px;margin-bottom:8px;border-radius:9px;color:#f5660a;background:linear-gradient(145deg,#fffaf6,#ffe2cc);box-shadow:0 5px 10px rgba(146,69,24,.09),inset 0 1px 0 #fff}
.org-card.unit .icon svg{width:18px;height:18px}

/* Chi nhánh bán hàng trực tiếp — deliberate GREEN treatment (these 3 branches
   are the primary revenue-generating units; the visual master gives them
   distinct weight on purpose, kept exactly as approved). */
.org-card.store{border-color:#75b996;background:linear-gradient(145deg,#f7fdf9,#e7f7ee);box-shadow:0 8px 18px rgba(8,119,71,.08);display:flex;align-items:center;justify-content:center;padding:10px 12px 10px 48px}
.org-card.store .icon{position:absolute;left:12px;width:36px;height:36px;border-radius:9px;color:#087747;background:linear-gradient(145deg,#fff,#d5f1e1);box-shadow:0 5px 10px rgba(8,119,71,.10),inset 0 1px 0 #fff}
.org-card.store .icon svg{width:18px;height:18px}
.org-card.store small{display:block;color:#527463;font-size:8.5px;letter-spacing:.7px;font-weight:800}
.org-card.store strong{display:block;margin-top:4px;color:#07643d;font-size:14px;white-space:nowrap}

/* Footer inset matches the canvas's own centered inset ((1500px shell -
   1440px CANVAS_W) / 2 = 30px), not the header's 34px — the header bar has
   no geometry below it to align to, but the footer legend sits directly
   under the chart's right edge and must line up with it exactly. */
.foot{height:42px;border-top:1px solid #e6ebe8;display:flex;align-items:center;justify-content:space-between;padding:0 30px;font-size:10px;color:#89918d;background:#fff}
.foot b{color:#69736d;font-weight:700}
.legend{display:flex;align-items:center;gap:7px}
.dot{width:7px;height:7px;border-radius:50%;background:#087747}

.org-mobile{display:none}

@media (max-width:900px){
  .org-shell{border-radius:0;border-left:0;border-right:0}
  .org-breadcrumb{padding:10px 20px 0}
  .org-head{min-height:0;padding:16px 20px}
  .head-title b{font-size:20px}
  .head-title span{font-size:11px}
  .viewport{display:none}
  .foot{padding:0 20px}

  .org-mobile{display:block;padding:16px 18px 24px}
  .org-m-director{text-align:center;background:linear-gradient(135deg,#e95600 0%,#ff7b18 100%);color:#fff;border-radius:14px;padding:14px 20px;margin-bottom:16px}
  .org-m-eyebrow{display:block;font-size:10px;font-weight:800;letter-spacing:1px;text-transform:uppercase}
  .org-m-director strong{display:block;margin-top:4px;font-size:19px}

  .org-m-branch{border:1px solid #e7a06f;border-radius:14px;margin-bottom:12px;overflow:hidden}
  .org-m-branch-head{width:100%;text-align:left;background:linear-gradient(180deg,#fff7ef,#fffaf6);border:0;padding:14px 40px 14px 16px;cursor:pointer;position:relative;display:block;font-family:inherit}
  .org-m-role{display:block;font-size:9.5px;font-weight:800;letter-spacing:.45px;text-transform:uppercase;color:#775f51}
  .org-m-branch-head h2{margin:6px 0 4px;color:#d95200;font-size:17px;font-weight:800}
  .org-m-person{display:block;font-size:13.5px;font-weight:800;color:#17231d}
  .org-m-branch .badge{display:inline-block;margin-top:6px;padding:3px 7px;border-radius:999px;background:#fff5eb;border:1px solid #f1bd95;color:#9b4b14;font-size:9px;font-weight:700}
  .org-m-chevron{position:absolute;top:50%;right:14px;margin-top:-8px;width:16px;height:16px;stroke:#c9895a;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .15s ease}
  .org-m-branch.is-expanded .org-m-chevron{transform:rotate(180deg)}
  .org-m-body{display:none;padding:12px 16px 16px;background:#fff}
  .org-m-branch.is-expanded .org-m-body{display:block}
  .org-m-units{list-style:none;margin:0;padding:0;font-size:13px;font-weight:700;color:#17231d}
  .org-m-units>li{padding:8px 0;border-bottom:1px solid #f2ece5}
  .org-m-units>li:last-child{border-bottom:0}
  .org-m-stores{list-style:none;margin:6px 0 0;padding:8px 0 0 14px;border-left:2px solid #75b996;font-size:12px;font-weight:600;color:#07643d}
  .org-m-stores>li{padding:4px 0}
}

/* ---- Realtime People Master hover/tap (LOCAL polish, 18/09/2026;
   Phase C member-UX unification pass). Additive only: idle state is zero
   footprint on .org-card/.org-m-units (no badge/count/icon added to the
   locked visual above). Preview/sheet are detached elements appended to
   <body>, position:fixed, so opening/closing them never shifts chart
   layout or the idle visual. ONE interaction for every department: desktop
   hover -> lightweight preview only; click/tap (any size, any device) ->
   right side sheet with the full vertical member list. */
.org-card.unit[data-org-unit]{cursor:pointer}
[data-org-unit-mobile]{cursor:pointer}

/* Lightweight hover preview — name + count + hint only, never a member list */
.org-member-pop{position:fixed;z-index:100200;min-width:200px;max-width:260px;background:#fff;border:1px solid #e1e7e3;border-radius:14px;box-shadow:0 16px 40px rgba(20,40,30,.18);padding:12px 14px;font-family:Arial,Helvetica,system-ui,sans-serif;opacity:0;transform:translateY(4px);transition:opacity .12s ease,transform .12s ease;pointer-events:none}
.org-member-pop.is-open{opacity:1;transform:translateY(0)}
.org-member-pop-title{font-size:12.5px;font-weight:800;color:#07643d;margin-bottom:4px}
.org-member-pop-body{font-size:12px;color:#17231d}
.org-member-pop-count{color:#3c4844}
.org-member-pop-cta{margin-top:4px;font-weight:700;color:#07643d}
.org-member-loading,.org-member-empty{color:#6d7771;font-size:12px}

/* Shared member row markup — reused inside the side sheet's vertical list */
.org-member-row{display:flex;flex-direction:column;gap:1px;padding:10px 0;border-bottom:1px solid #f2f5f3}
.org-member-row:last-child{border-bottom:0}
.org-member-name{font-weight:700;font-size:13.5px;color:#17231d}
.org-member-title{color:#6d7771;font-size:12px}

/* Right side sheet — the ONE detail surface for small and large departments
   alike (no separate center-modal path anymore). Chart stays visible behind
   a subtle backdrop; sheet slides in from the right. */
.org-member-sheet{position:fixed;inset:0;z-index:100300}
.org-member-sheet-backdrop{position:absolute;inset:0;background:rgba(10,30,20,.28);opacity:0;transition:opacity .18s ease}
.org-member-sheet-panel{position:absolute;top:0;right:0;bottom:0;width:min(420px,92vw);max-width:440px;min-width:380px;background:#fff;box-shadow:-18px 0 44px rgba(10,30,20,.20);display:flex;flex-direction:column;overflow:hidden;font-family:Arial,Helvetica,system-ui,sans-serif;transform:translateX(100%);transition:transform .22s ease}
.org-member-sheet.is-open .org-member-sheet-backdrop{opacity:1}
.org-member-sheet.is-open .org-member-sheet-panel{transform:translateX(0)}
.org-member-sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:18px 18px 12px;border-bottom:1px solid #edf0ee}
.org-member-sheet-head-copy strong{display:block;font-size:16px;color:#07643d;line-height:1.25}
.org-member-sheet-count{margin-top:4px;font-size:12.5px;color:#3c4844}
.org-member-sheet-close{border:1px solid #dfe4e1;background:#fff;color:#626b66;width:32px;height:32px;border-radius:50%;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}
.org-member-sheet-source{padding:10px 18px;font-size:11px;color:#89918d;border-bottom:1px solid #f2f5f3}
.org-member-sheet-list{list-style:none;margin:0;padding:4px 18px 18px;overflow-y:auto;overflow-x:hidden;flex:1 1 auto}

body.org-member-sheet-lock{overflow:hidden}

@media (max-width:900px){
  .org-member-sheet-panel{width:100vw;max-width:100vw;min-width:0}
}

/* ---- Admin: Cơ cấu tổ chức (tree editor) ---- */
.phf-orgadm{max-width:1080px;margin:0 auto;padding:0 0 60px;font-family:Arial,Helvetica,system-ui,sans-serif;color:#17382d}
.phf-orgadm-banner{background:#fff3e0;border:1px solid #f0c38f;border-radius:12px;padding:10px 14px;font-size:13px;font-weight:600;color:#a1560a;margin-bottom:14px}
.phf-orgadm-toolbar{display:flex;justify-content:flex-end;gap:8px;margin-bottom:12px}
.phf-orgadm-btn{border:1px solid #d6e9e1;background:#fff;color:#17382d;border-radius:10px;padding:8px 14px;font-size:13px;cursor:pointer}
.phf-orgadm-btn.primary{background:#0b5a43;border-color:#0b5a43;color:#fff;font-weight:700}
.phf-orgadm-btn.primary:disabled{opacity:.5;cursor:not-allowed}
.phf-orgadm-tree{background:#fff;border:1px solid #dfeee7;border-radius:16px;padding:10px}
.phf-orgadm-row{display:flex;align-items:center;gap:8px;padding:8px 6px;border-bottom:1px solid #f0f5f3;flex-wrap:wrap}
.phf-orgadm-row:last-child{border-bottom:0}
.phf-orgadm-row.is-hidden{opacity:.45}
.phf-orgadm-label{font-size:13.5px;flex:1 1 220px;min-width:180px}
.phf-orgadm-type{font-size:10.5px;color:#5f746c;background:#f4f9f7;border-radius:999px;padding:2px 8px;margin-left:6px}
.phf-orgadm-actions{display:flex;gap:4px;flex-wrap:wrap}
.phf-orgadm-actions button{border:1px solid #d6e9e1;background:#fff;border-radius:8px;padding:4px 8px;font-size:11.5px;cursor:pointer}
.phf-orgadm-actions select{border:1px solid #d6e9e1;border-radius:8px;font-size:11.5px;padding:3px 4px}
.phf-orgadm-inline-form{display:flex;gap:6px;flex-wrap:wrap;padding:8px 6px;background:#f7fbf9;border-radius:10px;margin:4px 0}
.phf-orgadm-inline-form input,.phf-orgadm-inline-form select{border:1px solid #d6e9e1;border-radius:8px;padding:6px 8px;font-size:12.5px}
.phf-orgadm-modal{position:fixed;inset:0;z-index:99999;background:rgba(6,24,18,.5);display:flex;align-items:center;justify-content:center;padding:18px}
.phf-orgadm-modal-card{width:min(1440px,95vw);max-height:90vh;overflow:auto;background:#fff;border-radius:18px;padding:18px}
.phf-orgadm-modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
