/* Passwordless front door and account chrome. is-auth keeps product content
   hidden until the licensed session or the honest sign-in state is ready. */

/* ------------------------------------------------- shell visibility switch */
html.is-auth .topbar,
html.is-auth .tabbar,
html.is-auth .more-scrim,
html.is-auth .more-sheet,
html.is-auth #view,
html.is-auth .foot { display: none !important; }

/* Licensed-only, identity-free first paint. */
.auth-boot { display: none; }
.auth-boot:not([hidden]) + .skip-link { display: none; }
html[data-refera-licensed="true"].is-auth .auth-boot {
  position:fixed;inset:0;z-index:160;display:flex;color:var(--ink);background:var(--paper)
}
.auth-boot-mark {
  display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;flex:none;
  color:#fff;background:var(--teal);border-radius:9px;font:600 21px/1 var(--font)
}
.auth-boot .login-brand { margin-bottom: 28px; }
.auth-boot-copy { margin: 10px 0 24px; }
.auth-boot-track {display:block;width:100%;height:3px;overflow:hidden;background:var(--hair)}
.auth-boot-track > span {
  display:block;width:58%;height:100%;background:var(--teal)
}
.auth-boot-actions:not([hidden]) { display: flex; gap: 8px; margin-top: 20px; }
.auth-boot-actions .btn { flex: 1; min-width: 0; }

/* ------------------------------------------------------------- the screen */
.login-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px var(--gutter) calc(32px + var(--safe-bottom));
}
.login-card-wrap { width: min(400px, 100%); }

/* the sign-in card — a plain elevated surface, no window chrome */
.login-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sheet);
  overflow: hidden;
  box-shadow: var(--overlay-shadow);
}
@media (prefers-reduced-motion: no-preference) {
  .login-card { animation: rise-in var(--dur-slow) var(--ease-out) both; }
  .login-foot { animation: login-foot-in var(--dur-slow) var(--ease-out) both; animation-delay: 90ms; }
}
@keyframes login-foot-in {
  from { opacity: 0; transform: translateY(12px); }
}

/* ------------------------------------------------------------------- body */
.login-body { padding: 32px 30px 26px; }

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-mark { display: flex; flex: none; }
.login-mark svg { border-radius: 8px; }
.login-wordmark {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  letter-spacing:0; line-height: 1;
}

.login-eyebrow {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--ink3); margin-bottom: 8px;
}
.login-title {
  font-size: 23px; font-weight: 500; letter-spacing:0; line-height: 1.2;
  margin-bottom: 22px;
}

/* ------------------------------------------------------------------ fields */
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.005em;
  color: var(--ink2);
}
.login-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  font: 400 14px/1.4 var(--font); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair-dark); border-radius: var(--r-input);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.login-input::placeholder { color: var(--ink3-decor); }
.login-input:hover { border-color: var(--ink3); }
.login-input:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 14%, transparent);
}

.login-submit { width: 100%; margin-top: 6px; min-height: 44px; }
.login-passkey { width: 100%; min-height: 44px; margin-top: 10px; }

/* quiet "or" divider between the two paths */
.login-or {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.01em; color: var(--ink3);
}
.login-or::before, .login-or::after {
  content: ''; flex: 1; height: 1px; background: var(--hair);
}

/* the one-click demo path — prominent ghost pill with a travelling arrow */
.login-demo { width: 100%; min-height: 44px; gap: 8px; }
.login-demo-arrow { display: flex; }
.login-demo-arrow svg { transition: transform var(--dur-fast) var(--ease-out); }
.login-demo:hover .login-demo-arrow svg { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
  .login-demo:hover .login-demo-arrow svg { transform: none; }
}

/* neutral guidance + request status: calm ink, never the attention colour.
   Attention amber is reserved for the honest demo declaration below. */
.login-note {
  margin-top: 18px; text-align: center;
  font-size: 12.5px; line-height: 1.5; color: var(--ink2);
}

/* demonstration posture, in as many words (amber — the demo-chip voice).
   NO text-transform: the line must render exactly as written. */
.login-demo-note {
  margin-top: 18px; text-align: center;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--amber);
}

/* quiet footer under the card */
.login-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0 4px; margin-top: 20px; text-align: center;
  font-size: 12px; letter-spacing: 0.005em;
}
.login-foot a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 8px; color: var(--ink3);
}
.login-foot a:hover { color: var(--teal); }
.login-foot a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  border-radius: var(--r-input);
}

/* ------------------------------------------------------------------- 390px */
@media (max-width: 719px) {
  .login-screen { padding: 20px 16px calc(24px + var(--safe-bottom)); }
  .login-body { padding: 26px 22px 22px; }
}

/* ==================================================== WORKSPACE SWITCHER */
/* Top-left: the Refera R mark + current practice name + chevron, opening a
   menu to switch/add a practice (js/workspace.js). This is the primary
   identity in the console (Attio-style), so the account chip on the right
   carries the PERSON, not a duplicate practice name. */
.ws-switch {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 38px; max-width: min(44vw, 340px);
  margin-left: -3px; padding: 4px 8px 4px 5px;
  background: none; color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.ws-switch:hover { background: var(--surface); border-color: var(--hair); }
.ws-switch[aria-expanded="true"] { background: var(--surface); border-color: var(--hair-dark); }
.ws-switch .brand-mark { flex: none; border-radius: 8px; }
.ws-clinic-mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; overflow: hidden; border-radius: 7px;
  border: 1px solid var(--tenant-brand-edge, var(--hair));
  background: var(--surface); color: var(--tenant-brand, var(--teal));
  font-family: var(--mono); font-size: 9px; font-weight: 700;
}
.ws-clinic-mark img, .ws-item-avatar img {
  width: 100%; height: 100%; display: block; object-fit: contain;
}
.ws-brand-cross {
  flex: none; color: var(--ink3); font-size: 12px; line-height: 1;
}
.ws-name {
  font-family: var(--display); font-size: 16px; font-weight: 600;
  letter-spacing:0; line-height: 1; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.ws-chev {
  flex: none; color: var(--ink3);
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ws-switch:hover .ws-chev { color: var(--ink2); }
.ws-switch[aria-expanded="true"] .ws-chev { transform: rotate(180deg); color: var(--ink2); }

.ws-menu {
  position: fixed; z-index: 80;
  top: calc(var(--safe-top) + var(--topbar-h) + 8px);
  left: var(--gutter);
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-card); box-shadow: var(--overlay-shadow);
  padding: 8px;
}
.ws-menu:not([hidden]) { animation: account-pop var(--dur) var(--spring-in); }
.ws-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 12px; border-bottom: 1px solid var(--hair);
}
.ws-head-mark, .ws-item-avatar {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--teal); color: #fff;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}
.ws-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-head-name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-head-sub {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em; color: var(--ink3);
}
.ws-group-label {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.01em; color: var(--ink3);
  margin: 10px 10px 4px;
}
.ws-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-input);
  background: none; text-align: left; color: var(--ink); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.ws-item:hover { background: var(--paper); text-decoration: none; }
.ws-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ws-item-name {
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-sub {
  font-size: 11.5px; color: var(--ink2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-tick { flex: none; color: var(--teal); display: flex; }
.ws-ico {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--paper); color: var(--ink2); border: 1px solid var(--hair);
}
.ws-item-action:hover .ws-ico { color: var(--teal); border-color: var(--tone-teal-border); }
.ws-div { height: 1px; background: var(--hair); margin: 6px 4px; }

/* =========================================================== ACCOUNT CHIP */
/* Signed-in state on the topbar (right): initials avatar + the person,
   sentence-case sans (mono is reserved for seals and hashes). */
.account-slot { display: contents; }

.account-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 4px 12px 4px 5px;
  background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--r-pill);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.account-chip:hover { border-color: var(--hair-dark); background: var(--bar); }
.account-chip[aria-expanded="true"] { border-color: var(--ink); }
.account-avatar {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--pill-bg); color: var(--pill-fg);
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.06em;
}
.account-name {
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.005em; color: var(--ink2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

/* the small account menu (fixed under the topbar's right edge) */
.account-menu {
  position: fixed; z-index: 80;
  top: calc(var(--safe-top) + var(--topbar-h) + 8px);
  right: var(--gutter);
  width: min(280px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--r-card);
  box-shadow: var(--overlay-shadow);
  padding: 8px;
}
.account-menu:not([hidden]) { animation: account-pop var(--dur) var(--spring-in); }
@keyframes account-pop { from { transform: translateY(-8px); opacity: 0; } }
.account-who {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--hair);
}
.account-who-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.01em; color: var(--ink3);
}
.account-who-name { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.account-who-practice {
  font-size: 11.5px; letter-spacing: 0.005em;
  color: var(--ink2); margin-top: 1px;
}
.account-signout {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; text-align: left;
  font: 500 13.5px/1.2 var(--font); color: var(--ink);
  background: none; border: 0; border-radius: var(--r-input); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.account-signout:hover { background: var(--paper); }

@media (max-width: 719px) {
  .account-name { display: none; }
  .account-chip {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 4px;
    border-color: transparent;
    background: none;
  }
  .account-menu { right: 12px; top: calc(var(--safe-top) + var(--topbar-h) + 6px); }
  /* mobile: the switcher shrinks to the mark + chevron (tap target); the
     practice name lives in the menu and the Today header where there is room */
  .ws-name { display: none; }
  .ws-switch { gap: 5px; min-height: 44px; padding: 4px 6px; }
  .ws-menu { left: 12px; top: calc(var(--safe-top) + var(--topbar-h) + 6px); }
}
