/* ==========================================================================
   VARA BUSINESS MANAGEMENT SYSTEMS TOP NAV -- identical copy in every app (see topnav.php's
   header for the rules). Everything is scoped under .tn-bar with its own
   tn- classes and hard resets, so no app's own global button/input/link/
   header styles can reach in and change how the bar looks.
   ========================================================================== */

.tn-bar {
  /* Theme colors: an organization's theme overrides --tn-bg / --tn-accent
     here and --nav-bg / --accent on :root (topnav.php, v10). */
  --tn-bg: #0f2747;
  --tn-accent: #5b8dff;
  --tn-text: #1f2430;
  --tn-muted: #6b7280;
  --tn-border: #dfe3e8;
  --tn-hover: #f1f4f8;
  --tn-error: #b42318;
  box-sizing: border-box;
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 28px;
  width: 100%;
  min-height: 60px;
  margin: 0;
  padding: 0 24px;
  background: var(--tn-bg);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.3;
  text-align: left;
  box-shadow: 0 2px 10px rgba(15, 39, 71, 0.25);
}
.tn-bar *, .tn-bar *::before, .tn-bar *::after { box-sizing: border-box; }
.tn-bar [hidden] { display: none !important; }
.tn-bar a { text-decoration: none; }
.tn-bar button {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  min-height: 0;
  min-width: 0;
  width: auto;
  height: auto;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.tn-ico { width: 18px; height: 18px; flex-shrink: 0; }

.tn-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 19px; font-weight: 700; white-space: nowrap; }
.tn-brand:hover { color: #fff; }
.tn-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--tn-accent) 0 50%, color-mix(in srgb, var(--tn-accent) 52%, #fff) 50% 100%);
  transform: rotate(45deg) scale(0.82);
}
.tn-brand-text { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
/* v10: the organization's logo in place of the mark. */
.tn-logo { display: block; height: 36px; width: auto; max-width: 200px; object-fit: contain; flex-shrink: 0; }
/* v11: today's season, holiday or event decoration beside the name. */
.tn-deco { display: inline-flex; align-items: center; margin-left: -18px; width: 26px; height: 26px; flex-shrink: 0; animation: tn-deco-in 0.6s ease-out; }
.tn-deco svg { width: 22px; height: 22px; }
@keyframes tn-deco-in { from { opacity: 0; transform: translateY(-4px) rotate(-8deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tn-deco { animation: none; } }
@media (max-width: 860px) { .tn-deco { margin-left: -8px; } }
.tn-bar .tn-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.tn-nav { display: flex; align-items: stretch; align-self: stretch; gap: 4px; }
.tn-bar .tn-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14.5px;
  font-weight: 400;
  white-space: nowrap;
}
.tn-bar .tn-link:hover { color: #fff; background: none; }
.tn-bar .tn-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #e5322d; box-shadow: 0 0 0 2px var(--tn-bg, #0f2747); }
.tn-bar .tn-link.tn-active { color: #fff; font-weight: 600; border-bottom-color: var(--tn-accent); }
.tn-toggle { display: none !important; }

.tn-spacer { flex: 1; }

.tn-actions { display: flex; align-items: center; gap: 14px; }
.tn-pop { position: relative; }
.tn-bar .tn-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent, #3b6ef6) 90%, #000);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
}
.tn-bar .tn-avatar:hover { background: var(--accent, #3b6ef6); }
/* Profile picture over the initials; removed (initials show) if missing. */
.tn-bar .tn-avatar { position: relative; overflow: hidden; }
.tn-bar .tn-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
/* A round icon button for an app's own actions_html (e.g. a bell). */
.tn-bar .tn-icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
}
.tn-bar .tn-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.tn-bar .tn-icon-btn svg { width: 22px; height: 22px; }

.tn-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 230px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  color: var(--tn-text);
  border: 1px solid var(--tn-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 39, 71, 0.18);
}
.tn-bar .tn-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}
.tn-bar .tn-menu-item:hover { background: var(--tn-hover); color: #334155; }
.tn-menu-item .tn-ico { color: var(--tn-muted); }
.tn-bar .tn-logout, .tn-bar .tn-logout .tn-ico { color: var(--tn-error); }
.tn-menu-head { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid #edf0f4; font-size: 14px; font-weight: 700; }
.tn-menu-head small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--tn-muted); overflow-wrap: anywhere; }
.tn-badge { margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #e5322d; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

@media (max-width: 860px) {
  .tn-bar { flex-wrap: wrap; gap: 0 12px; padding: 8px 16px; }
  .tn-brand { flex: 1; font-size: 17px; min-width: 0; }
  .tn-logo { height: 30px; max-width: 140px; }
  .tn-bar .tn-toggle {
    display: grid !important;
    place-items: center;
    order: 3;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  .tn-spacer { display: none; }
  .tn-actions { order: 2; }
  .tn-nav { order: 4; display: none; flex-basis: 100%; flex-direction: column; padding: 6px 0 4px; }
  .tn-nav.tn-open { display: flex; }
  .tn-bar .tn-link { padding: 10px 6px; border: none; }
  .tn-bar .tn-link.tn-active { color: color-mix(in srgb, var(--tn-accent) 55%, #fff); }
}
@media (max-width: 480px) {
  .tn-bar .tn-dropdown { position: fixed; top: 64px; left: 12px; right: 12px; min-width: 0; }
}

/* v7: "sign out and back in" notice (new access since sign-in). */
.tn-access { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 20px; background: #fff7e6; border-bottom: 1px solid #f3d9a4; color: #7a4b00; font: 500 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.tn-access[hidden] { display: none; }
.tn-access-text { flex: 1 1 260px; }
.tn-access .tn-access-btn { padding: 6px 14px; border: 0; border-radius: 6px; background: #b45309; color: #fff; font: 600 13px/1.2 inherit; font-family: inherit; cursor: pointer; }
.tn-access .tn-access-btn:hover { background: #92400e; }
.tn-access .tn-access-later { padding: 6px 8px; border: 0; background: none; color: #7a4b00; font: 13px/1.2 inherit; font-family: inherit; text-decoration: underline; cursor: pointer; }

/* Log Out is a small POST form (CSRF-protected); its button looks like the other menu items. */
.tn-logout-form { margin: 0; }
.tn-bar button.tn-menu-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }

/* Arrange menu dialog (v16) */
.tn-arr-back { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .45); }
.tn-arr { width: 100%; max-width: 380px; max-height: 100%; overflow: auto; padding: 18px; border-radius: 10px; background: #fff; color: var(--tn-text); box-shadow: 0 12px 32px rgba(0, 0, 0, .25); font: 14px/1.4 system-ui, sans-serif; }
.tn-arr-title { margin: 0 0 6px; font-size: 17px; }
.tn-arr-help { margin: 0 0 12px; color: var(--tn-muted); }
.tn-arr-list { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--tn-border); border-radius: 8px; }
.tn-arr-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--tn-border); }
.tn-arr-row:first-child { border-top: 0; }
.tn-arr-label { flex: 1; font-weight: 600; }
.tn-arr-move { width: 32px; height: 32px; border: 1px solid var(--tn-border); border-radius: 6px; background: #fff; color: var(--tn-text); font: inherit; cursor: pointer; }
.tn-arr-move:hover:not(:disabled) { background: var(--tn-hover); }
.tn-arr-move:disabled { opacity: .35; cursor: default; }
.tn-arr-msg { min-height: 20px; margin: 0 0 8px; color: var(--tn-error); }
.tn-arr-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.tn-arr-btn { padding: 8px 14px; border: 1px solid var(--tn-border); border-radius: 6px; background: #fff; color: var(--tn-text); font: inherit; cursor: pointer; }
.tn-arr-btn:hover:not(:disabled) { background: var(--tn-hover); }
.tn-arr-btn:disabled { opacity: .5; cursor: default; }
.tn-arr-primary { border-color: var(--tn-bg); background: var(--tn-bg); color: #fff; }
.tn-arr-primary:hover:not(:disabled) { background: var(--tn-bg); filter: brightness(1.15); }
