/* ---------- Ambient light (static: decorative motion does not belong on working screens) ---------- */
.ambient { position: fixed; inset: 0 0 auto 0; height: 560px; overflow: hidden; pointer-events: none; z-index: 0; }
.ambient span { position: absolute; border-radius: 50%; filter: blur(90px); }
.ambient .a { width: 620px; height: 620px; left: -160px; top: -340px; background: var(--light-a); }
.ambient .b { width: 520px; height: 520px; left: 34%; top: -380px; background: var(--light-c); }
.ambient .c { width: 560px; height: 560px; right: -140px; top: -320px; background: var(--light-d); }
.ambient .d { width: 420px; height: 420px; left: 58%; top: -300px; background: var(--light-b); opacity: 0.7; }

/* ---------- Floating glass bar (navigation layer) ----------
   A capsule that floats 12px below the top edge, aligned to the content column. Content scrolls under it and is
   refracted through its rim; a soft scroll-edge fade replaces a hard divider once the page moves. */
.bar {
  position: sticky; top: 0; z-index: 40;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  pointer-events: none; /* the gap around the capsule stays clickable */
}
.bar::before { /* only the gap above the capsule: text never peeks in sharply at the top edge */
  content: ""; position: absolute; inset: 0 0 auto 0; height: calc(20px + env(safe-area-inset-top, 0px)); pointer-events: none;
  background: linear-gradient(180deg, var(--edge-fade), transparent);
  opacity: 0; transition: opacity 240ms var(--ease-out);
}
.bar[data-scrolled="true"]::before { opacity: 1; }
.bar-inner {
  width: min(1440px, 100% - 48px); margin: 0 auto;
  height: 60px; padding: 0 10px 0 22px; border-radius: 30px;
  display: flex; align-items: center; gap: 20px;
  pointer-events: auto;
}
.bar-inner > .lg-mat { transition: box-shadow 240ms var(--ease-out); }
.brand { display: inline-flex; align-items: center; gap: 12px; flex: none; border-radius: 10px; }
.brand img { height: 24px; width: auto; display: block; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
.brand-rule, .brand-partner-rule { width: 1px; height: 18px; background: var(--hairline-strong); }
/* The Tempus wordmark is heavier than the TEAMPL one, so it sits a little shorter to match its visual weight. */
.brand img.logo-partner { height: 20px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.012em; white-space: nowrap; }

.tabs { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.tab {
  height: 34px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center;
  font-size: 14px; font-weight: 520; color: var(--text-2); white-space: nowrap;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out);
}
.tab:active { transform: scale(0.97); }
.tab.active, .tab[aria-current="page"] { color: var(--ink); background: var(--lens-fill); box-shadow: var(--lens-shadow); }

.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 999px;
  display: grid; place-items: center; color: var(--text-2);
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-expanded="true"] { background: var(--hover-strong); color: var(--ink); }
.count-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 650; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}
.menu-btn { display: none; }

.user-trigger {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 4px 10px 4px 4px; border-radius: 999px;
  transition: background-color 150ms var(--ease-out), transform 120ms var(--ease-out);
}
.user-trigger:active { transform: scale(0.98); }
.user-trigger[aria-expanded="true"] { background: var(--hover-strong); }
.user-meta { display: grid; text-align: left; line-height: 1.2; }
.user-name { font-size: 14px; font-weight: 560; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.user-trigger .chev { color: var(--text-3); transition: transform 200ms var(--ease-out); }
.user-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

.avatar {
  --av: 32px; --h: 215;
  width: var(--av); height: var(--av); flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: max(9px, calc(var(--av) * 0.38)); font-weight: 620; letter-spacing: 0.01em;
  color: hsl(var(--h) 42% 30%); background: hsl(var(--h) 52% 91%);
}
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 70% 84%); background: hsl(var(--h) 26% 24%); }
.avatar-empty { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--thread); color: var(--text-3) !important; }

/* ---------- Page ---------- */
.page { position: relative; z-index: 1; width: min(1440px, 100% - 48px); margin: 0 auto; padding: 32px 0 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-title { font-size: 28px; line-height: 34px; font-weight: 620; letter-spacing: -0.022em; font-variation-settings: "opsz" 28; }
.page-sub { margin-top: 6px; font-size: 15px; color: var(--text-2); text-wrap: pretty; }
/* Back link above the page title (detail, profile, settings). */
.page-back { display: flex; width: fit-content; align-items: center; gap: 6px; margin: 0 0 18px -8px; }
.page-back .ic { width: 18px; height: 18px; }
/* The dark ambient haze lifts the ground behind the page head above the accent's 4.5:1 floor (D12). */
:root[data-theme="dark"] .page-head .btn-text { color: var(--text-2); }
.credit {
  position: relative; z-index: 1; width: min(1440px, 100% - 48px); margin: 0 auto;
  padding: 20px 0 calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 13px; color: var(--text-3); border-top: 1px solid var(--hairline);
}

/* ---------- Hover lives behind a fine pointer (no sticky hover on touch) ---------- */
@media (hover: hover) and (pointer: fine) {
  .tab:not(.active):not([aria-current="page"]):hover { color: var(--ink); background: var(--hover); }
  .icon-btn:hover { background: var(--hover); color: var(--ink); }
  .user-trigger:hover { background: var(--hover); }
  .menu-item:hover { background: var(--hover-strong); }
  .btn-primary:hover { background: var(--button-hover); box-shadow: 0 12px 26px -12px rgba(11, 13, 18, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
  .btn-secondary:hover { background: var(--surface-2); }
  .btn-text:hover { background: var(--accent-soft); color: var(--ink); }
  .input:hover:not(:focus), .select:hover:not(:focus) { border-color: color-mix(in srgb, var(--hairline-strong) 50%, var(--accent)); }
  .segmented button:not([aria-pressed="true"]):hover, .track-items > button:not([aria-pressed="true"]):hover { color: var(--ink); background: var(--hover); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .tabs { display: none; }
  .menu-btn { display: grid; }
}
@media (max-width: 720px) {
  .bar-inner, .page, .credit { width: calc(100% - 32px); }
  .bar { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .bar-inner { gap: 12px; height: 56px; padding: 0 6px 0 16px; border-radius: 28px; }
  html { scroll-padding-top: 76px; }
  .brand { gap: 10px; }
  .brand img { height: 22px; }
  .brand img.logo-partner { height: 18px; }
  .brand-name { font-size: 14px; }
  .user-trigger .chev { display: none; }
  /* Keep the name and role as the button's accessible name when the text is no longer drawn. */
  .user-meta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .user-trigger { padding: 4px; }
  /* Narrow viewports stack all four ambient lights over the page head; keep one so text holds 4.5:1 (D12). */
  .ambient .b, .ambient .c, .ambient .d { display: none; }
  .page { padding-top: 20px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .page-title { font-size: 24px; line-height: 30px; }
  .notif { width: min(372px, calc(100vw - 32px)); right: -48px; }
  .credit { flex-direction: column; gap: 4px; }
}
@media (max-width: 379px) {
  .brand-rule, .brand-name:not(.brand-org-name) { display: none; }
}
/* Two logos use the width the product name had; the link keeps its accessible name. */
@media (max-width: 720px) {
  .brand.has-partner .brand-rule, .brand.has-partner .brand-name:not(.brand-org-name) { display: none; }
}
/* The technician bar also carries the availability pill and the Sections menu. On a phone the product name and the pill's
   chevron give way so the bell and the user menu stay on screen; the brand link keeps its accessible name. */
@media (max-width: 720px) {
  body[data-portal="technician"] .bar-inner { gap: 8px; }
  body[data-portal="technician"] .brand-rule, body[data-portal="technician"] .brand-name:not(.brand-org-name) { display: none; }
  body[data-portal="technician"] .availability-trigger { padding: 0 10px; gap: 6px; }
  body[data-portal="technician"] .availability-trigger .ic { display: none; }
}
/* The technician bar has no room for a second logo on a phone: the pill, Sections menu, bell and avatar already fill it.
   !important because the dark-theme logo swap above is more specific than these hides. */
@media (max-width: 480px) {
  body[data-portal="technician"] .brand-partner-rule, body[data-portal="technician"] .brand .logo-partner { display: none !important; }
}
@media (max-width: 359px) {
  .brand-partner-rule, .brand .logo-partner { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .tab, .icon-btn, .user-trigger, .user-trigger .chev, .bar::before { transition-duration: 0ms; }
  .tab:active, .icon-btn:active, .user-trigger:active { transform: none; }
}
@media (pointer: coarse) { .icon-btn { width: 42px; height: 42px; } }
