/* ================================================================
   CTG.EMP — SHELL (sidebar · topbar · breadcrumb · layout)
   ================================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  transition: grid-template-columns .25s ease;
}
.app.sb-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ================================================================
   SIDEBAR (luôn dark, giữ command-center feel ở cả light theme)
   ================================================================ */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg-a) 0%, var(--sidebar-bg-b) 100%);
  border-right: 1px solid #101a2b;
  color: #C6D0E0;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  border-bottom: 1px solid #101a2b;
  margin-bottom: 10px;
}
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #065F46, #022C22);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(52,211,153,.25);
}
.brand-name {
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: #FFFFFF;
  line-height: 1.15;
}
.brand-sub {
  font-size: 10px;
  color: #6F819C;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-top: 2px;
}
.app.sb-collapsed .brand-name,
.app.sb-collapsed .brand-sub { display: none; }
.app.sb-collapsed .brand { justify-content: center; padding: 6px 0 14px; }

.nav-group {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: #4C5D77;
  padding: 12px 12px 6px;
  font-weight: 600;
}
.app.sb-collapsed .nav-group {
  padding: 12px 0 6px;
  text-align: center;
  color: transparent;
  border-top: 1px solid #101a2b;
  margin-top: 8px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #A6B5CC;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
}
.nav-btn svg { flex-shrink: 0; opacity: .85; }
.nav-btn:hover {
  background: rgba(52,211,153,.06);
  color: #E7EEF7;
}
.nav-btn.active {
  background: linear-gradient(90deg, rgba(16,185,129,.16), rgba(16,185,129,.03));
  color: #FFFFFF;
  box-shadow: inset 2px 0 0 var(--teal-glow);
}
.nav-btn.active svg { opacity: 1; color: var(--teal-glow); }
.nav-btn.nav-locked {
  opacity: .35;
  cursor: not-allowed;
}
.nav-btn.nav-locked::after {
  content: '🔒';
  position: absolute;
  right: 10px;
  font-size: 10px;
  opacity: .6;
}
.nav-btn.nav-locked:hover {
  background: transparent;
  color: inherit;
}
.bt-item.bt-locked { opacity: .3; }

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #0A0F17;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--mono);
}

.app.sb-collapsed .nav-btn {
  justify-content: center;
  padding: 10px 0;
}
.app.sb-collapsed .nav-btn .lbl,
.app.sb-collapsed .nav-btn .nav-badge { display: none; }

/* Tooltip for collapsed sidebar */
.nav-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-4);
  color: var(--ink);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}
.app.sb-collapsed .nav-btn[data-tip]:hover::after { display: block; }

.sb-toggle {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid #101a2b;
  border-radius: 8px;
  color: #6F819C;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.sb-toggle:hover { color: #E7EEF7; border-color: var(--line-2); }
.sb-toggle-icon { transition: transform .25s ease; }
.app.sb-collapsed .sb-toggle-icon { transform: rotate(180deg); }
.app.sb-collapsed .sb-toggle-lbl { display: none; }
.app.sb-collapsed .sb-toggle { justify-content: center; padding: 8px 0; }

.sidebar-foot {
  padding: 12px 10px 4px;
  font-size: 10.5px;
  color: #4C5D77;
  line-height: 1.5;
  border-top: 1px solid #101a2b;
  margin-top: 8px;
}
.app.sb-collapsed .sidebar-foot { display: none; }

/* ================================================================
   MAIN
   ================================================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.top-title h1 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink-heading);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-title .sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}

.top-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 6px 10px 6px 12px;
  border-radius: 8px;
  color: var(--ink-3);
  cursor: pointer;
  transition: all .15s;
  font-size: 12.5px;
}
.top-search:hover { border-color: var(--line-2); color: var(--ink-2); }
.top-search .kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-4);
  border: 1px solid var(--line-2);
  color: var(--ink-3);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.role-sw {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.role-sw:hover { border-color: var(--teal); background: var(--bg-4); }
.role-sw .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--teal-glow);
  box-shadow: 0 0 8px var(--teal-glow);
}
.role-sw .role-name { font-weight: 600; }
.role-sw .role-tag { color: var(--ink-3); font-size: 10.5px; margin-left: 2px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.icon-btn:hover { background: var(--bg-3); color: var(--ink); border-color: var(--line); }

.icon-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 14px; height: 14px;
  border-radius: 8px;
  background: var(--crit);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  display: grid; place-items: center;
  padding: 0 3px;
  border: 2px solid var(--bg-1);
}

.device-sw {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.device-sw button {
  width: 28px; height: 26px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--ink-3);
  cursor: pointer;
  transition: all .15s;
}
.device-sw button:hover { color: var(--ink); }
.device-sw button.on {
  background: var(--bg-1);
  color: var(--teal-glow);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line-2);
}

/* ================================================================
   ORG-LEVEL INDICATOR BAR — vị trí thực trong cơ cấu tổ chức
   Tập đoàn › Khối › Phòng › Nhân viên (khác breadcrumb menu điều hướng)
   ================================================================ */
.org-level-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 7px 20px;
  background: linear-gradient(90deg, var(--teal-deep) 0%, var(--bg-2) 55%);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--topbar-h);
  z-index: 16;
}
.org-level-bar .olb-crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.org-level-bar .olb-crumb .olb-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  opacity: .75;
}
.org-level-bar .olb-sep {
  color: var(--ink-4);
  margin: 0 2px;
  font-size: 12px;
}
.org-level-bar .olb-corp { background: rgba(52,211,153,.16); color: var(--teal-glow); border: 1px solid rgba(52,211,153,.4); }
.org-level-bar .olb-block { border: 1px solid var(--olb-block-line, var(--line-2)); background: var(--olb-block-bg, var(--bg-3)); color: var(--olb-block-color, var(--ink)); }
.org-level-bar .olb-dept { border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink-2); }
.org-level-bar .olb-user {
  margin-left: auto;
  color: var(--ink-3);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}
.org-level-bar .olb-user b { color: var(--ink); font-weight: 700; }
.org-level-bar .olb-scopepill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.org-level-bar .olb-scopepill.scope-group { background: rgba(52,211,153,.16); color: var(--teal-glow); }
.org-level-bar .olb-scopepill.scope-block { background: rgba(56,189,248,.16); color: var(--info); }
.org-level-bar .olb-scopepill.scope-dept  { background: rgba(245,158,11,.16); color: var(--warn); }
.org-level-bar .olb-scopepill.scope-self  { background: rgba(168,85,247,.16); color: var(--purple); }
.org-level-bar .olb-scopepill.scope-none  { background: rgba(239,68,68,.16); color: var(--crit); }
.app.device-mobile .org-level-bar { padding: 6px 12px; overflow-x: auto; white-space: nowrap; top: var(--topbar-h); }
@media (max-width: 860px) {
  .org-level-bar { padding: 6px 12px; overflow-x: auto; white-space: nowrap; }
  .org-level-bar .olb-user { display: none; }
}

/* ================================================================
   BREADCRUMB
   ================================================================ */
.breadcrumb {
  height: var(--breadcrumb-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--ink-3);
  font-size: 12px;
  position: sticky;
  top: calc(var(--topbar-h) + var(--orglevelbar-h));
  z-index: 15;
}
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--teal-glow); text-decoration: none; }
.breadcrumb .sep { color: var(--ink-4); font-size: 10px; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

.bc-tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
}
.bc-tabs button {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.bc-tabs button:hover { color: var(--ink); }
.bc-tabs button.on {
  color: var(--teal-glow);
  border-bottom-color: var(--teal-glow);
  font-weight: 600;
}

/* ================================================================
   CONTENT
   ================================================================ */
.content {
  flex: 1;
  padding: 18px 22px 60px;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
  font-weight: 600;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title:first-child { margin-top: 0; }
.section-title::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--teal-glow);
  border-radius: 2px;
}

/* ================================================================
   MOBILE / MENU BUTTON / DRAWER CLOSE
   ================================================================ */
.menu-btn { display: none; }
.drawer-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: #E7EEF7;
  cursor: pointer;
  place-items: center;
  z-index: 5;
}
body.drawer-on .drawer-close { display: grid; }
@media (max-width: 900px) {
  .drawer-close { display: none; }
  body.drawer-on .drawer-close { display: grid; }
}
.app.device-mobile .drawer-close { display: none; }
.app.device-mobile body.drawer-on .drawer-close,
body.drawer-on .app.device-mobile .drawer-close { display: grid; }

/* ================================================================
   MOBILE DRAWER BACKDROP
   ================================================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
body.drawer-on .drawer-backdrop { opacity: 1; pointer-events: auto; }

/* ================================================================
   BOTTOM TAB (mobile only)
   ================================================================ */
.bottom-tab {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: 60px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  z-index: 40;
  padding: 4px 6px;
  gap: 2px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.35);
}
.bottom-tab .bt-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 2px;
  transition: color .12s;
}
.bottom-tab .bt-item:hover { color: var(--ink); }
.bottom-tab .bt-item.on { color: var(--teal-glow); }
.bottom-tab .bt-item.bt-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--teal-glow), var(--teal));
  box-shadow: 0 4px 12px rgba(16,185,129,.35);
  min-width: 60px;
  flex: 0 0 auto;
  padding: 6px 10px;
  color: #052e21;
  font-weight: 700;
}

/* ================================================================
   DEVICE FRAMES (topbar preview)
   ================================================================ */
.app.device-tablet, .app.device-mobile {
  border: 12px solid #0a0f17;
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(0,0,0,.5);
  overflow: hidden;
  margin: 20px auto;
}
.app.device-tablet {
  max-width: 1024px;
  grid-template-columns: 220px 1fr;
}
.app.device-tablet .top-search { max-width: 200px; }
.app.device-tablet .top-search .kbd { display: none; }
.app.device-tablet .role-sw .role-tag { display: none; }
.app.device-tablet .device-sw { display: none; }
.app.device-tablet .top-title h1 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.app.device-tablet .top-title .sub { display: none; }
.app.device-mobile {
  max-width: 390px;
  grid-template-columns: 1fr;
}
.app.device-mobile .sidebar {
  position: fixed;
  top: 0;
  left: -260px;
  width: 260px;
  height: 100vh;
  z-index: 46;
  transition: left .28s ease;
}
body.drawer-on .app.device-mobile .sidebar,
body.drawer-on .sidebar {
  left: 0 !important;
}
.app.device-mobile .menu-btn { display: grid; }
.app.device-mobile .top-search { display: none; }
.app.device-mobile .role-sw .role-tag { display: none; }
.app.device-mobile .device-sw { display: none; }
.app.device-mobile .top-title h1 { font-size: 14px; }
.app.device-mobile .top-title .sub { display: none; }
.app.device-mobile .content { padding: 12px 12px 80px; }
/* Device-mobile preview: dùng bottom-tab absolute trong frame */
.app.device-mobile { position: relative; overflow: hidden; }
.app.device-mobile .bottom-tab {
  display: flex;
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  height: 60px;
  z-index: 40;
  border-radius: 0 0 8px 8px;
  grid-column: 1 / -1;
}
.app.device-mobile .main { padding-bottom: 60px; }
.app.device-mobile .breadcrumb { padding: 0 12px; overflow-x: auto; white-space: nowrap; font-size: 11px; }
.app.device-mobile .breadcrumb .bc-tabs { display: none; }
.app.device-mobile .fab-stack { bottom: 76px; }

/* Force 1-col grid inside device-mobile */
.app.device-mobile .grid.g-2,
.app.device-mobile .grid.g-3,
.app.device-mobile .grid.g-4,
.app.device-mobile .grid.g-5,
.app.device-mobile .grid.g-6,
.app.device-mobile .grid.g-2c,
.app.device-mobile .grid.g-3c,
.app.device-mobile .grid.g-c2 {
  grid-template-columns: 1fr !important;
}
.app.device-mobile .hero-banner {
  grid-template-columns: 1fr !important;
}
.app.device-mobile .hero-banner .hb-cta { justify-self: flex-start; }
.app.device-mobile .hero-banner h2 { font-size: 20px; }
.app.device-mobile .hero-banner .hb-desc { font-size: 12px; }
.app.device-mobile .card-h h3 { font-size: 12.5px; }
.app.device-mobile .stat-value { font-size: 22px; }
.app.device-mobile .stat { padding: 10px 12px; }
.app.device-mobile .section-title { margin: 16px 0 8px; font-size: 11px; }
.app.device-mobile .avatar { display: none; }
.app.device-mobile .topbar { padding: 0 10px; gap: 6px; }
.app.device-mobile .top-meta { gap: 4px; }
.app.device-mobile .icon-btn { width: 30px; height: 30px; }
.app.device-mobile .role-sw { padding: 3px 6px; font-size: 10.5px; max-width: 90px; overflow: hidden; }
.app.device-mobile .role-sw .role-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
.app.device-mobile .task-meta { font-size: 10.5px; }
.app.device-mobile .approval-row { grid-template-columns: 1fr; gap: 6px; }
.app.device-mobile .meeting-item { flex-direction: column; }
.app.device-mobile .meeting-date { width: 100%; }

/* ================================================================
   REAL RESPONSIVE (không dùng device preview, browser thực sự nhỏ)
   ================================================================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 46;
    transition: left .28s ease;
  }
  body.drawer-on .sidebar { left: 0; }
  .menu-btn { display: grid; }
  .top-search { display: none; }
  .role-sw .role-tag { display: none; }
  .device-sw { display: none; }
  .top-title h1 { font-size: 14px; }
  .top-title .sub { display: none; }
  .content { padding: 12px 12px 80px; }
  .bottom-tab { display: flex; }
  .fab-stack { bottom: 76px; }
  .breadcrumb { padding: 0 12px; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 640px) {
  .grid.g-2, .grid.g-3, .grid.g-4, .grid.g-5, .grid.g-6, .grid.g-2c, .grid.g-3c, .grid.g-c2 {
    grid-template-columns: 1fr !important;
  }
  .hero-banner {
    grid-template-columns: 1fr !important;
  }
  .hero-banner .hb-cta { justify-self: flex-start; }
  .top-meta { gap: 4px; }
  .top-meta .role-sw { padding: 4px 8px; font-size: 11px; }
  .top-meta .role-sw .role-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
