:root {
  --pm-radius: 18px;
  /* Light theme (premium glass) */
  --pm-glass: rgba(255, 255, 255, 0.78);
  --pm-glass-2: rgba(255, 255, 255, 0.62);
  --pm-border: rgba(99, 102, 241, 0.22);
  --pm-shadow: 0 18px 60px rgba(2, 6, 23, 0.18);
  --pm-text: rgba(15, 23, 42, 0.92);
  --pm-muted: rgba(15, 23, 42, 0.68);
}

body.dark {
  --pm-glass: rgba(2, 6, 23, 0.88);
  --pm-glass-2: rgba(2, 6, 23, 0.72);
  --pm-border: rgba(99, 102, 241, 0.28);
  --pm-shadow: 0 18px 70px rgba(0, 0, 0, 0.48);
  --pm-text: rgba(226, 232, 240, 0.94);
  --pm-muted: rgba(226, 232, 240, 0.72);
}

.profile {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.70);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease, background 160ms ease;
}
body.dark .profile-chip { background: rgba(30, 41, 59, 0.35); }
.profile-chip:hover { transform: translateY(-1px); filter: brightness(1.02); }
.profile-chip:active { transform: translateY(0); }
.profile-chip:focus-visible { outline: none; box-shadow: var(--ring); }

.profile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--grad-2);
  position: relative;
}

.profile-avatar::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.85);
}
body.dark .profile-avatar::after { border-color: rgba(2, 6, 23, 0.82); }

.profile-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  line-height: 1.12;
}
.profile-meta strong {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-user, inherit);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.profile-sub {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-role { font-weight: 800; color: var(--text); opacity: 0.9; }
.profile-hotel { opacity: 0.85; }
.profile-sep { opacity: 0.65; }
.profile-caret { opacity: 0.72; font-size: 12px; }

.session-badge {
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-clock, inherit);
  font-weight: 500;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
  border: 1px solid rgba(99, 102, 241, 0.22);
  background:
    radial-gradient(140% 160% at 12% 10%, rgba(99, 102, 241, 0.30), transparent 60%),
    radial-gradient(140% 160% at 88% 18%, rgba(236, 72, 153, 0.22), transparent 58%),
    radial-gradient(140% 180% at 50% 120%, rgba(6, 182, 212, 0.20), transparent 62%),
    rgba(255, 255, 255, 0.58);
  box-shadow:
    0 14px 46px rgba(99, 102, 241, 0.12),
    0 10px 28px rgba(2, 6, 23, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.55) inset;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
body.dark .session-badge {
  color: var(--text);
  border-color: rgba(99, 102, 241, 0.28);
  background:
    radial-gradient(140% 160% at 12% 10%, rgba(99, 102, 241, 0.28), transparent 60%),
    radial-gradient(140% 160% at 88% 18%, rgba(236, 72, 153, 0.18), transparent 58%),
    radial-gradient(140% 180% at 50% 120%, rgba(6, 182, 212, 0.18), transparent 62%),
    rgba(2, 6, 23, 0.42);
  box-shadow:
    0 18px 58px rgba(0, 0, 0, 0.52),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.topbar-clock {
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
}

@media (max-width: 640px) {
  /* Mobile: keep topbar single-row by compacting profile + hiding clock */
  .topbar-clock { display: none; }
  .profile-chip { padding: 8px; gap: 8px; }
  .profile-meta, .profile-caret { display: none; }
}

.profile-dropdown {
  position: fixed;
  z-index: 80;
  width: 320px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  border-radius: var(--pm-radius);
  border: 1px solid var(--pm-border);
  background: linear-gradient(180deg, var(--pm-glass), var(--pm-glass-2));
  box-shadow: var(--pm-shadow), 0 2px 0 rgba(255, 255, 255, 0.22) inset;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 10px;
  color: var(--pm-text);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-10px) scale(0.985);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
}
body.dark .profile-dropdown {
  box-shadow: var(--pm-shadow), 0 2px 0 rgba(255, 255, 255, 0.06) inset;
}
.profile-dropdown.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s;
}

.profile-dropdown.is-measuring {
  visibility: hidden;
  opacity: 0;
  transform: none;
  pointer-events: none;
  transition: none !important;
}

.profile-dd-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.16);
  background: rgba(255, 255, 255, 0.42);
}
.profile-dd-head .pm-name { font-size: 14px; font-weight: 600; color: var(--pm-text); font-family: var(--font-user, inherit); }
.profile-dd-head .pm-sub { font-size: 11px; color: var(--pm-muted); }

.profile-dd-actions { margin-top: 10px; display: grid; gap: 6px; }
.profile-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid rgba(99, 102, 241, 0.10);
  background: rgba(255, 255, 255, 0.35);
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease, border-color 140ms ease;
  user-select: none;
}
.profile-dd-item { border-color: rgba(99, 102, 241, 0.14); }
body.dark .profile-dd-item { background: rgba(255, 255, 255, 0.04); border-color: rgba(99, 102, 241, 0.14); }
.profile-dd-item:hover { transform: translateY(-1px); filter: brightness(1.04); border-color: rgba(99, 102, 241, 0.18); }
.profile-dd-item:active { transform: translateY(0); }
.profile-dd-icon {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.16);
}
.profile-dd-label { font-size: 13px; font-weight: 500; font-family: var(--font-user, inherit); color: var(--pm-text); }
.profile-dd-desc { font-size: 11px; font-weight: 400; font-family: var(--font-user, inherit); color: var(--pm-muted); }
.profile-dd-meta { display: grid; }

.profile-dd-item.is-danger {
  border-color: rgba(239, 68, 68, 0.20);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.10), rgba(249, 115, 22, 0.10));
}
.profile-dd-item.is-danger .profile-dd-icon {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.18);
}

.pm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 6, 23, 0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 0s linear 180ms;
}
.pm-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease, visibility 0s;
}

.pm-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%) scale(0.98);
  width: min(560px, calc(100vw - 26px));
  z-index: 91;
  border-radius: 22px;
  border: 1px solid var(--pm-border);
  background: linear-gradient(180deg, var(--pm-glass), var(--pm-glass-2));
  box-shadow: var(--pm-shadow);
  color: var(--pm-text);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
  overflow: hidden;
}
.pm-modal.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s;
}

.pm-modal__head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.16);
}
.pm-modal__title { font-size: 14px; font-weight: 600; font-family: var(--font-user, inherit); }
.pm-modal__close {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  background: rgba(255, 255, 255, 0.30);
  color: var(--pm-text);
  cursor: pointer;
}
.pm-modal__close:hover { filter: brightness(1.04); }
body.dark .pm-modal__close { background: rgba(255, 255, 255, 0.05); }

.pm-modal__body { padding: 14px 16px 16px; }
.pm-kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.12);
  background: rgba(255, 255, 255, 0.28);
}
.pm-kv + .pm-kv { margin-top: 10px; }
.pm-k { color: var(--pm-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.pm-v { color: var(--pm-text); font-weight: 600; overflow-wrap: anywhere; }
.pm-v--name { font-family: var(--font-user, inherit); font-weight: 600; }
body.dark .pm-kv { background: rgba(255, 255, 255, 0.04); }

.pm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(99, 102, 241, 0.14);
}
.pm-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.50);
  color: var(--pm-text);
  border-radius: 16px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease, border-color 140ms ease;
  font-weight: 600;
}
body.dark .pm-btn { background: rgba(255, 255, 255, 0.06); }
.pm-btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.pm-btn:active { transform: translateY(0); }
.pm-btn--primary { background: var(--grad); color: #fff; border-color: rgba(99, 102, 241, 0.22); }
.pm-btn--danger { background: linear-gradient(135deg, #ef4444, #f97316); color: #fff; border-color: rgba(239, 68, 68, 0.22); }

@media (max-width: 560px) {
  .profile-meta strong { max-width: 140px; }
  .profile-dropdown { width: min(92vw, 340px); }
  .pm-kv { grid-template-columns: 1fr; }
}
.profile-dd-head { color: var(--pm-text); }
body.dark .profile-dd-head { background: rgba(255, 255, 255, 0.05); }
