/* Account controls share the workspace palette; report layouts stay untouched. */
body.workspace-view .sidebar > .profile-menu-root {
  position: relative;
  display: block;
  margin: 0 0 16px;
  padding: 0;
  min-width: 0;
  z-index: 6;
  text-align: left;
}

.profile-menu-root .profile-trigger {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 0 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.profile-menu-root .profile-trigger:hover,
.profile-menu-root .profile-trigger[aria-expanded="true"] {
  background: var(--surface-active);
}

.profile-menu-root .profile-identity { min-width: 0; }
body.workspace-view .profile-menu-root .profile-identity strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-menu-root .profile-caption {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 300;
  line-height: 1.4;
}
.profile-menu-root .profile-trigger > svg {
  width: 12px;
  height: 12px;
  color: var(--muted);
}
.profile-menu-root .profile-trigger[aria-expanded="true"] > svg { transform: rotate(180deg); }

.profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 10;
  width: 300px;
  max-width: calc(100vw - 40px);
  padding: 10px;
  border: .5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow);
  text-align: left;
}
/* A pointer can cross the gap from the avatar into the open menu. */
.profile-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -11px;
  height: 11px;
}
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
}
.profile-menu-item > svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.profile-menu-item:hover,
.profile-menu-item:focus-visible { background: var(--accent-soft); }
.profile-menu-item:hover > svg,
.profile-menu-item:focus-visible > svg { color: var(--ink); }
.profile-menu :is(hr, .profile-menu-divider, .profile-menu-separator) {
  height: 0;
  margin: 10px 0;
  border: 0;
  border-top: .5px solid var(--line);
}

.personal-cabinet { width: 100%; min-width: 0; }
.personal-heading { margin-bottom: 25px; }
.personal-heading h1 {
  margin: 0 0 10px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
}
.personal-heading p { color: var(--muted); font-size: 13px; font-weight: 300; line-height: 1.6; }
.personal-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  padding: 0 0 10px;
  border-bottom: .5px solid var(--paper);
}
.personal-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 20px;
  border: .5px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
}
.personal-tabs button:hover { color: var(--ink); background: var(--paper); }
.personal-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.personal-tabs svg { width: 18px; height: 18px; flex: 0 0 18px; }
.personal-panel {
  min-width: 0;
  margin-bottom: 25px;
  padding: 20px;
  border: .5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--panel-shadow);
}
.personal-panel h2 { font-size: 18px; font-weight: 700; line-height: 1.35; letter-spacing: 0; }
.personal-panel > p { margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 300; }
.personal-panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.personal-panel-heading .button { flex-shrink: 0; }
.personal-details { display: grid; margin: 25px 0 0; }
.personal-details > div {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(0, 3fr);
  align-items: baseline;
  gap: 10px 25px;
  padding: 20px 0;
  border-top: .5px solid var(--paper);
}
.personal-details > div:last-child { padding-bottom: 0; }
.personal-details dt { color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.5; }
.personal-details dd { margin: 0; color: var(--ink); font-size: 16px; font-weight: 300; line-height: 1.5; overflow-wrap: anywhere; }
.connections-list { display: grid; gap: 25px; margin-top: 25px; }
.connection-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 20px 25px;
  min-width: 0;
  padding: 20px;
  border: .5px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}
.connection-card-main { display: flex; align-items: flex-start; gap: 20px; min-width: 0; }
.connection-card-main > div { min-width: 0; }
.connection-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}
.connection-card h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.connection-card .connection-meta { margin-top: 10px; color: var(--muted); font-size: 11px; font-weight: 300; line-height: 1.6; overflow-wrap: anywhere; }
.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
}
.connection-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: var(--muted); }
.connection-state.is-connected { color: var(--ink); background: var(--accent-soft); }
.connection-state.is-connected::before { background: var(--accent); box-shadow: 0 0 4px 2px var(--accent-soft); }
.connection-state.is-demo { color: var(--ink); }
.connection-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; grid-column: 1 / -1; }
.personal-cabinet .connection-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 37px;
  padding: 9px 14px;
  border: .5px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
}
.personal-cabinet .connection-remove:hover:not(:disabled) { background: var(--surface); color: var(--ink); border-color: var(--line); }
.connections-list .empty-state { padding: 20px; border: .5px dashed var(--line); border-radius: 12px; }
.connections-list .empty-state p { font-size: 13px; }
.connections-empty { padding: 20px 0; color: var(--muted); font-size: 13px; }
.personal-panel > .personal-connections-note { margin-top: 25px; font-size: 11px; }
.connection-confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
#disconnect-dialog p + p { margin-top: 10px; }

@media (max-width: 1000px) {
  .profile-menu-root .profile-trigger { grid-template-columns: 41px minmax(0, 1fr) 12px; gap: 8px; }
  body.workspace-view .profile-menu-root .profile-trigger .avatar { width: 41px; height: 41px; font-size: 18px; }
  body.workspace-view .profile-menu-root .profile-identity strong { font-size: 11px; }
}
@media (max-width: 900px) {
  .profile-menu-root .profile-trigger { grid-template-columns: 38px minmax(0, 1fr) 12px; padding: 0; }
  body.workspace-view .profile-menu-root .profile-trigger .avatar { width: 38px; height: 38px; }
  .connection-card { grid-template-columns: minmax(0, 1fr); }
  .connection-state { justify-self: start; }
}
@media (max-width: 640px) {
  body.workspace-view .sidebar > .profile-menu-root { position: absolute; top: 10px; right: 15px; width: auto; margin: 0; padding: 0; }
  .profile-menu-root .profile-trigger { display: flex; gap: 8px; min-height: 44px; padding: 2px; }
  body.workspace-view .profile-menu-root .profile-trigger .avatar { display: grid; width: 40px; height: 40px; font-size: 18px; }
  .profile-menu-root .profile-identity { display: none; }
  .profile-menu { left: auto; right: 0; width: 300px; max-width: calc(100vw - 30px); }
  .personal-tabs button { flex: 1; padding: 10px; }
  .personal-details > div { grid-template-columns: minmax(0, 1fr); }
  .personal-panel-heading { align-items: flex-start; }
  .personal-panel-heading .button { white-space: normal; }
  .connection-card-main { flex-direction: column; gap: 10px; }
  .connection-card-actions { align-items: stretch; flex-direction: column; }
  .connection-card-actions .button, .personal-cabinet .connection-remove { width: 100%; white-space: normal; }
}
