/* ==========================================================================
   Header (white, 70px) + horizontal blue navigation (52px)
   ========================================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1002;
  height: var(--header-h); background: var(--header-bg);
  box-shadow: 0 1px 0 var(--border), 0 .5rem 1rem rgba(18, 38, 63, .03);
}
.topbar .container { height: 100%; display: flex; align-items: center; gap: 12px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 700; font-size: 17px; letter-spacing: .06em; margin-right: 18px; white-space: nowrap; }
.brand:hover { color: var(--heading); }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand small { display: block; font-size: 9.5px; letter-spacing: .14em; color: var(--text-muted); font-weight: 500; margin-top: -2px; }

.app-search { position: relative; width: 260px; }
.app-search input {
  width: 100%; height: 38px; border: 0; border-radius: 30px; background: var(--soft-bg);
  padding: 0 14px 0 38px; font-size: var(--fs-base); outline: none; color: var(--text);
}
.app-search input:focus { box-shadow: 0 0 0 2px var(--primary-soft); }
.app-search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; width: 380px; max-height: 420px; overflow: auto; }

.topbar-btn {
  height: var(--header-h); min-width: 42px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: transparent; color: #555b6d; position: relative; font-size: var(--fs-base);
}
.topbar-btn:hover { color: var(--primary); }
.topbar-btn .badge-dot {
  position: absolute; top: 18px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; font-weight: 600; text-align: center;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.lang-flag { width: 22px; height: 15px; border-radius: 2px; overflow: hidden; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.05); }
.user-btn { gap: 8px; padding: 0 12px; }
.user-btn .avatar { width: 34px; height: 34px; font-size: 12px; }
.user-btn .user-name { font-weight: var(--fw-medium); }
.menu-toggle { display: none; }

/* Horizontal nav */
.topnav {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 1001; height: var(--nav-h);
  background: var(--primary);
  box-shadow: 0 .5rem 1rem rgba(52, 69, 165, .15);
}
.topnav .container { height: 100%; }
.nav-list { display: flex; align-items: stretch; height: 100%; margin: 0; padding: 0; list-style: none; gap: 2px; }
.nav-item { position: relative; display: flex; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 0; background: transparent;
  color: rgba(255, 255, 255, .78); font-size: var(--fs-base); font-weight: var(--fw-medium); white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-link svg { opacity: .9; }
.nav-link .chev { opacity: .7; margin-left: -2px; transition: transform var(--t-fast); }
.nav-link:hover, .nav-item.open > .nav-link { color: #fff; background: rgba(255, 255, 255, .08); }
.nav-item.active > .nav-link { color: #fff; }
.nav-item.active > .nav-link::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: #fff;
}
.nav-dropdown {
  position: absolute; top: 100%; left: 0; min-width: 220px; padding: 8px 0; margin: 0; list-style: none;
  background: #fff; border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-drop);
  opacity: 0; visibility: hidden; transform: translateY(6px); transition: all var(--t-fast) var(--ease);
}
.nav-item.open > .nav-dropdown { opacity: 1; visibility: visible; transform: none; }
.nav-dropdown a, .nav-dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 20px; border: 0; background: none; text-align: left;
  color: var(--text-2); font-size: var(--fs-base);
}
.nav-dropdown a:hover, .nav-dropdown button:hover, .nav-dropdown .active { color: var(--primary); background: var(--primary-softer); }
.nav-dropdown .ext { margin-left: auto; color: var(--text-light); }
.nav-tag { font-size: 9.5px; padding: 1px 6px; border-radius: 8px; background: var(--success); color: #fff; font-weight: 600; margin-left: auto; }

/* Generic dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 1100; min-width: 180px; padding: 6px 0;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-drop);
  display: none; text-align: left;
}
.dropdown-menu.left { right: auto; left: 0; }
.dropdown.open > .dropdown-menu { display: block; animation: dd-in var(--t-fast) var(--ease); }
.topbar .dropdown-menu { top: calc(100% - 6px); }
@keyframes dd-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 18px; border: 0; background: none;
  color: var(--text-2); font-size: var(--fs-base); text-align: left; white-space: nowrap;
}
.dropdown-item:hover { background: var(--hover-bg); color: var(--heading); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item[disabled] { opacity: .5; cursor: not-allowed; }
.dropdown-header { padding: 8px 18px 4px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.dropdown-divider { height: 1px; margin: 6px 0; background: var(--border); }

/* Notification dropdown */
.notif-menu { width: 340px; padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-head h6 { margin: 0; font-size: 14px; }
.notif-list { max-height: 330px; overflow: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; width: 100%; text-align: left; }
.notif-item:hover { background: var(--hover-bg); }
.notif-item.unread { background: var(--primary-softer); }
.notif-item .avatar { width: 32px; height: 32px; flex: none; }
.notif-item h6 { margin: 0 0 2px; font-size: 13px; font-weight: 500; }
.notif-item p { margin: 0; font-size: 12px; color: var(--text-muted); }

/* Apps (quick access) grid */
.apps-menu { width: 300px; padding: 10px; }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.apps-grid a, .apps-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--radius); color: var(--text-2); font-size: 12px; border: 0; background: none; }
.apps-grid a:hover, .apps-grid button:hover { background: var(--soft-bg); color: var(--primary); }
.apps-grid .ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

/* Mega menu */
.mega-menu { width: 640px; padding: 20px; left: 0; right: auto; }
.mega-menu .grid-3 h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 8px; }
.mega-menu ul { list-style: none; margin: 0; padding: 0; }
.mega-menu li a { display: block; padding: 5px 0; color: var(--text-2); }
.mega-menu li a:hover { color: var(--primary); }

/* Mobile nav drawer */
.mobile-backdrop { position: fixed; inset: 0; background: rgba(33, 37, 41, .45); z-index: 1000; opacity: 0; visibility: hidden; transition: opacity var(--t); }
body.nav-open .mobile-backdrop { opacity: 1; visibility: visible; }
