/* Starts to the right of the rail, which now occupies the top-left corner.
   --sb-w is inherited from body, so this follows the collapse automatically. */
#dt-topbar {
  position: fixed; top: 0; left: var(--sb-w, 220px); right: 0; height: 56px;
  background: rgba(11,20,16,.98);
  border-bottom: 1px solid rgba(44,221,127,.2);
  backdrop-filter: blur(24px);
  /* brand now lives in the sidebar, so the bar's contents sit right */
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 24px 0 20px;
  z-index: 1500;
  box-shadow: 0 2px 20px rgba(0,0,0,.4);
}
#dt-topbar-brand { display: flex; align-items: center; gap: 12px; }
#dt-topbar-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #2cdd7f 0%, #2cdd7f 50%, #77e9d6 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 14px rgba(44,221,127,.5);
  position: relative; overflow: hidden; flex-shrink: 0;
}
#dt-topbar-icon::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.2) 0%, transparent 60%);
}
#dt-topbar-brand-text { display: flex; flex-direction: column; gap: 1px; }
/* The brand lockup now lives in the sidebar rail (#sb-brand); these rules
   remain only for the login screen's own title styling. */
#dt-topbar-title {
  font-size: 14px; font-weight: 800; letter-spacing: 1.2px;
  color: #ecf3f0; text-transform: uppercase; line-height: 1;
}
#dt-topbar-sub {
  font-size: 9px; font-weight: 600; letter-spacing: 1.5px;
  color: rgba(44,221,127,.75); text-transform: uppercase;
}
#dt-topbar-user { position: relative; }
#dt-topbar-user-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 8px;
  background: rgba(44,221,127,.07);
  border: 1px solid rgba(44,221,127,.18);
  border-radius: 10px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
#dt-topbar-user-btn:hover {
  background: rgba(44,221,127,.14); border-color: rgba(44,221,127,.35);
}
#dt-topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #2cdd7f, #77e9d6);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: #0a130f;
  box-shadow: 0 0 8px rgba(44,221,127,.35); flex-shrink: 0;
}
#dt-topbar-username { font-size: 13px; font-weight: 600; color: #ecf3f0; white-space: nowrap; }
#dt-topbar-chevron { font-size: 11px; color: rgba(44,221,127,.7); transition: transform .2s; }
#dt-topbar-user.open #dt-topbar-chevron { transform: rotate(180deg); }
#dt-topbar-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 10px);
  background: rgba(12,22,18,.98);
  border: 1px solid rgba(44,221,127,.2);
  border-radius: 14px; min-width: 260px;
  box-shadow: 0 12px 40px rgba(0,0,0,.65), 0 0 0 1px rgba(44,221,127,.05);
  padding: 14px; z-index: 400;
  backdrop-filter: blur(20px);
  animation: ddFadeIn .18s ease;
}
@keyframes ddFadeIn { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:none} }
#dt-topbar-user.open #dt-topbar-dropdown { display: block; }
#dt-topbar-user:not(.open) #dt-topbar-dropdown { display: none; }
#ctx-branch, #ctx-floor { color-scheme: dark; }
#ctx-branch option, #ctx-floor option { background: #12201a; color: #cee2d8; }
#ctx-branch option:checked, #ctx-floor option:checked { background: #1e3129; color: #2cdd7f; }
.dt-dd-header { padding: 0 0 8px; }
.dt-dd-name { font-size: 13px; font-weight: 700; color: #ecf3f0; }
.dt-dd-role { font-size: 11px; color: rgba(44,221,127,.7); margin-top: 2px; }
.dt-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; font-size: .8rem; color: rgba(211,229,220,.75);
  cursor: pointer; transition: background .15s, color .15s;
  border-radius: 8px; margin: 1px 0;
}
.dt-dd-item:hover { background: rgba(44,221,127,.08); color: #ecf3f0; }
.dt-dd-item.danger { color: rgba(255,77,109,.8); }
.dt-dd-item.danger:hover { background: rgba(255,77,109,.1); color: #ff4d6d; }

/* Context selector (branch + floor) — inline in topbar */
#context-selector {
  display: flex; flex-direction: row; align-items: center;
  gap: 0; flex: 1; justify-content: center;
  position: static; background: none; border: none;
  border-radius: 0; padding: 0; box-shadow: none; min-width: 0;
}
#context-selector .ctx-row { display: flex; align-items: center; gap: 8px; padding: 0 20px; }
#context-selector label {
  font-size: 9px; font-weight: 700; color: rgba(44,221,127,.65);
  text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
}
#context-selector select {
  padding: 5px 28px 5px 10px;
  background: rgba(44,221,127,.07); border: 1px solid rgba(44,221,127,.22);
  border-radius: 8px; color: #ecf3f0; font-size: 12px; font-weight: 500;
  outline: none; cursor: pointer; min-width: 150px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%232cdd7f' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color .15s, background .15s;
}
#context-selector select:focus,
#context-selector select:hover { border-color: rgba(44,221,127,.5); background-color: rgba(44,221,127,.12); }
#context-selector select:disabled { opacity: .45; cursor: not-allowed; }
.ctx-divider { width: 1px; height: 28px; background: rgba(44,221,127,.18); flex-shrink: 0; }
.ctx-add-btn {
  background: rgba(0,204,170,.15); border: 1px solid rgba(0,204,170,.4);
  color: #00ccaa; width: 28px; height: 28px;
  border-radius: 7px; cursor: pointer; font-size: 1.1rem; line-height: 1;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ctx-add-btn:hover { background: rgba(0,204,170,.3); }
.dt-view-only .ctx-add-btn { display: none; }

.user-badge {
  position: fixed; top: 12px; right: 16px; z-index: 10000;
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 0.3rem 0.8rem 0.3rem 0.5rem;
  font-size: 0.8rem; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.user-badge .user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-badge .logout-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.75rem; margin-left: 0.3rem; }
.user-badge .user-role { font-size: 0.65rem; color: var(--muted); margin-right: 0.3rem; }
.user-badge .logout-btn:hover { color: var(--warn); }
